Signed-off-by: Mohamed Mediouni <[email protected]>
---
target/i386/emulate/x86.h | 1 +
target/i386/emulate/x86_helpers.c | 8 ++++++++
target/i386/emulate/x86_mmu.c | 3 +++
target/i386/hvf/x86.c | 5 +++++
4 files changed, 17 insertions(+)
diff --git a/target/i386/emulate/x86.h b/target/i386/emulate/x86.h
index 73edccfba0..caf0e3be50 100644
--- a/target/i386/emulate/x86.h
+++ b/target/i386/emulate/x86.h
@@ -263,6 +263,7 @@ bool x86_is_protected(CPUState *cpu);
bool x86_is_real(CPUState *cpu);
bool x86_is_v8086(CPUState *cpu);
bool x86_is_long_mode(CPUState *cpu);
+bool x86_is_la57(CPUState *cpu);
bool x86_is_long64_mode(CPUState *cpu);
bool x86_is_paging_mode(CPUState *cpu);
bool x86_is_pae_enabled(CPUState *cpu);
diff --git a/target/i386/emulate/x86_helpers.c
b/target/i386/emulate/x86_helpers.c
index 0700cc05ef..7bdd7e4c2a 100644
--- a/target/i386/emulate/x86_helpers.c
+++ b/target/i386/emulate/x86_helpers.c
@@ -236,6 +236,14 @@ bool x86_is_long_mode(CPUState *cpu)
return ((efer & lme_lma) == lme_lma);
}
+bool x86_is_la57(CPUState *cpu)
+{
+ X86CPU *x86_cpu = X86_CPU(cpu);
+ CPUX86State *env = &x86_cpu->env;
+ uint64_t is_la57 = env->cr[4] & CR4_LA57_MASK;
+ return is_la57;
+}
+
bool x86_is_long64_mode(CPUState *cpu)
{
error_report("unimplemented: is_long64_mode()");
diff --git a/target/i386/emulate/x86_mmu.c b/target/i386/emulate/x86_mmu.c
index b82a55a3da..35987a897a 100644
--- a/target/i386/emulate/x86_mmu.c
+++ b/target/i386/emulate/x86_mmu.c
@@ -56,6 +56,9 @@ static int gpt_top_level(CPUState *cpu, bool pae)
return 2;
}
if (x86_is_long_mode(cpu)) {
+ if (x86_is_la57(cpu)) {
+ return 5;
+ }
return 4;
}
diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c
index 2fa210ff60..e98f480f41 100644
--- a/target/i386/hvf/x86.c
+++ b/target/i386/hvf/x86.c
@@ -138,6 +138,11 @@ bool x86_is_long_mode(CPUState *cpu)
return rvmcs(cpu->accel->fd, VMCS_GUEST_IA32_EFER) & MSR_EFER_LMA;
}
+bool x86_is_la57(CPUState *cpu)
+{
+ return false;
+}
+
bool x86_is_long64_mode(CPUState *cpu)
{
struct vmx_segment desc;
--
2.50.1 (Apple Git-155)