diff mbox

[18/22] KVM: nVMX: Add util to check if VMCS field supported by CPU

Message ID 1529710522-28315-19-git-send-email-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liran Alon June 22, 2018, 11:35 p.m. UTC
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/vmx.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9a0cf93ce8a7..72bd4b6a90fc 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2167,6 +2167,19 @@  static __always_inline void vmcs_writel(unsigned long field, unsigned long value
 	__vmcs_writel(field, value);
 }
 
+static bool cpu_has_vmcs_field(unsigned long field)
+{
+	unsigned long value;
+	u8 error;
+
+	asm volatile (__ex_clear(ASM_VMX_VMREAD_RDX_RAX, "%0") "; seta %1"
+		      : "=a"(value), "=qm"(error)
+		      : "d"(field)
+		      : "cc");
+
+	return error;
+}
+
 static __always_inline void vmcs_clear_bits(unsigned long field, u32 mask)
 {
         BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x2000,