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>
--- /dev/null
+/*
+ * 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;
+}
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);