]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates/x86: Initialize jailhouse_use_vmcall
authorValentine Sinitsyn <valentine.sinitsyn@gmail.com>
Thu, 6 Nov 2014 11:54:03 +0000 (16:54 +0500)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 7 Nov 2014 06:43:58 +0000 (07:43 +0100)
Jailhouse relies on the caller to define and initialize jailhouse_use_vmcall
global variable for hypercalls to work properly. As no inmates currently use
hypercalls, the code was stripped from the original patch.

This patch re-introduces jailhouse_use_vmcall initialization, this time with
hypercall_init() function, which should be called during inmate initialization
the same way other *_init() function are called. This way, inmates that don't
need hypercalls (or timers) can skip initializing them.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates/lib/x86/hypercall.c [new file with mode: 0644]
inmates/lib/x86/inmate.h

diff --git a/inmates/lib/x86/hypercall.c b/inmates/lib/x86/hypercall.c
new file mode 100644 (file)
index 0000000..f710376
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Valentine Sinitsyn, 2014
+ *
+ * Authors:
+ *  Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <inmate.h>
+
+#define X86_FEATURE_VMX        (1 << 5)
+
+bool jailhouse_use_vmcall;
+
+void hypercall_init(void)
+{
+       u32 eax = 1, ecx = 0;
+
+       asm volatile(
+               "cpuid"
+               : "=c" (ecx)
+               : "a" (eax), "c" (ecx)
+               : "rbx", "rdx", "memory"
+       );
+
+       if (ecx & X86_FEATURE_VMX)
+               jailhouse_use_vmcall = true;
+}
index 0dcea56df1f389691de2827a9ae091e070fb0ce5..33d7cb4f3c90eb01c688cb1eafa13462d440d179 100644 (file)
@@ -218,6 +218,8 @@ void ioapic_pin_set_vector(unsigned int pin,
 
 void inmate_main(void);
 
+void hypercall_init(void);
+
 void pm_timer_init(void);
 unsigned long pm_timer_read(void);
 void delay_us(unsigned long microsecs);