From: Jim Mattson Subject: [kvm-unit-tests PATCH 1/2] Fix vmptrst result type Date: Mon, 17 Jul 2017 11:58:36 -0700 Message-ID: <20170717185837.30336-1-jmattson@google.com> Cc: Jim Mattson To: kvm@vger.kernel.org Return-path: Received: from mail-pg0-f48.google.com ([74.125.83.48]:36762 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbdGQS7P (ORCPT ); Mon, 17 Jul 2017 14:59:15 -0400 Received: by mail-pg0-f48.google.com with SMTP id u5so21862852pgq.3 for ; Mon, 17 Jul 2017 11:59:14 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: vmptrst stores a 64-bit physical address to memory (or -1 if there is no current VMCS). Signed-off-by: Jim Mattson --- x86/vmx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x86/vmx.h b/x86/vmx.h index 392979ba8ae8..a368f31b159d 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -5,6 +5,7 @@ #include "processor.h" #include "bitops.h" #include "asm/page.h" +#include "asm/io.h" struct vmcs { u32 revision_id; /* vmcs revision identifier */ @@ -646,10 +647,12 @@ static inline int vmcs_write(enum Encoding enc, u64 val) static inline int vmcs_save(struct vmcs **vmcs) { bool ret; + unsigned long pa; u64 rflags = read_rflags() | X86_EFLAGS_CF | X86_EFLAGS_ZF; - asm volatile ("push %1; popf; vmptrst %2; setbe %0" - : "=q" (ret) : "q" (rflags), "m" (*vmcs) : "cc"); + asm volatile ("push %2; popf; vmptrst %1; setbe %0" + : "=q" (ret), "=m" (pa) : "r" (rflags) : "cc"); + *vmcs = (pa == -1ull) ? NULL : phys_to_virt(pa); return ret; } -- 2.13.2.932.g7449e964c-goog