diff mbox series

kvm/x86 : simplify the handle of invvpid function

Message ID 1533130222-114621-1-git-send-email-peng.hao2@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series kvm/x86 : simplify the handle of invvpid function | expand

Commit Message

Peng Hao Aug. 1, 2018, 1:30 p.m. UTC
When vpids are not supported or disabled, vpid_sync_context is just
a no-op including single-context type or global-context type. we
can just return in vpid_sync_context when vpid==0.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 arch/x86/kvm/vmx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1689f43..b76a18d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1968,10 +1968,7 @@  static void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs)
 
 static inline void vpid_sync_vcpu_single(int vpid)
 {
-	if (vpid == 0)
-		return;
-
-	if (cpu_has_vmx_invvpid_single())
+	if (cpu_has_vmx_invvpid_single())
 		__invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vpid, 0);
 }
 
@@ -1983,6 +1980,9 @@  static inline void vpid_sync_vcpu_global(void)
 
 static inline void vpid_sync_context(int vpid)
 {
+	if (vpid == 0)
+		return;
+
 	if (cpu_has_vmx_invvpid_single())
 		vpid_sync_vcpu_single(vpid);
 	else