On 11.04.2018 14:18, Jan Kiszka wrote:
On 2018-04-11 11:35, f...@ozog.com wrote:
inmates cannot use X86_FEATURE_VMX from regular cpuid
as vcpu maks the bit explicitely on non-root cells.

create the equivalent bit (same register, same position)
in the JAILHOUSE_CPUID_FEATURES cpuid leaf

Signed-off-by: Francois-Frederic Ozog <f...@ozog.com>
---
 hypervisor/arch/x86/vcpu.c                 | 13 +++++++++++++
 include/arch/x86/asm/jailhouse_hypercall.h |  5 +++++
 inmates/lib/x86/hypercall.c                |  2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/vcpu.c b/hypervisor/arch/x86/vcpu.c
index 21da0592..2bfbff94 100644
--- a/hypervisor/arch/x86/vcpu.c
+++ b/hypervisor/arch/x86/vcpu.c
@@ -331,6 +331,17 @@ bool vcpu_handle_msr_write(void)
        return true;
 }

+static bool is_vmx(void)
+{
+       u32 eax, ebx, ecx, edx;
+
+       eax=1;
+       ebx = ecx = edx =0;
+       cpuid(&eax, &ebx, &ecx, &edx);
+
+       return ecx & X86_FEATURE_VMX;
+}
+
 void vcpu_handle_cpuid(void)
 {
        static const char signature[12] = "Jailhouse";
@@ -350,6 +361,8 @@ void vcpu_handle_cpuid(void)
                guest_regs->rax = 0;
                guest_regs->rbx = 0;
                guest_regs->rcx = 0;
+               if (is_vmx())
+                       guest_regs->rcx |= X86_FEATURE_VMX;
                guest_regs->rdx = 0;
                break;
        default:
diff --git a/include/arch/x86/asm/jailhouse_hypercall.h
b/include/arch/x86/asm/jailhouse_hypercall.h
index 3a52599f..052b9255 100644
--- a/include/arch/x86/asm/jailhouse_hypercall.h
+++ b/include/arch/x86/asm/jailhouse_hypercall.h
@@ -68,6 +68,11 @@
 #define JAILHOUSE_CPUID_SIGNATURE              0x40000000
 #define JAILHOUSE_CPUID_FEATURES               0x40000001

+/*
+ * ECX
+ * bit 5: 1=VMX
+*/
+#define JAILHOUSE_CPUID_FEATURE_VMX            (1ULL << 0)
 /**
  * @defgroup Hypercalls Hypercall Subsystem
  *
diff --git a/inmates/lib/x86/hypercall.c b/inmates/lib/x86/hypercall.c
index ac99f0c3..4a356390 100644
--- a/inmates/lib/x86/hypercall.c
+++ b/inmates/lib/x86/hypercall.c
@@ -44,7 +44,7 @@ bool jailhouse_use_vmcall;

 void hypercall_init(void)
 {
-       u32 eax = 1, ecx = 0;
+       u32 eax = JAILHOUSE_CPUID_FEATURES, ecx = 0;

        asm volatile(
                "cpuid"
--
2.11.0


That's neither what I meant nor how Linux (as guest) works. Just probe
for an AMD CPU and set jailhouse_use_vmcall to true if it's not found.

Jan
I am proposing another patch then rather than using this mail thread.

--
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to