Skip to contentSkip to conversation

KVM:nVMX: Make setup/unsetup under the same conditions

PATCH Applied Peng Hao 3 participants 3 messages Feb 22, 2022 – Feb 24, 2022

Subsystems (3)
lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH v2 1/1 KVM:nVMX: Make setup/unsetup under the same conditions

From: Peng Hao <[email protected]>

Make sure nested_vmx_hardware_setup/unsetup() are called in pairs under the same conditions. Calling nested_vmx_hardware_unsetup() when nested is false "works" right now because it only calls free_page() on zero- initialized pointers, but it's possible that more code will be added to nested_vmx_hardware_unsetup() in the future.

---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +1 -1
index 75ed7d6f35cc..9fad3c73395a 100644
@@ -7852,7 +7852,7 @@ static __init int hardware_setup(void)
 	vmx_set_cpu_caps();
 
 	r = alloc_kvm_area();
-	if (r)
+	if (r && nested)
 		nested_vmx_hardware_unsetup();
 
 	kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);
Signature · 1 line
2.27.0
#1 lore raw

Needs a space added as fixup.

Quoted 30 lines · Peng Hao

From: Peng Hao <[email protected]>

Make sure nested_vmx_hardware_setup/unsetup() are called in pairs under the same conditions. Calling nested_vmx_hardware_unsetup() when nested is false "works" right now because it only calls free_page() on zero- initialized pointers, but it's possible that more code will be added to nested_vmx_hardware_unsetup() in the future.

---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +1 -1
index 75ed7d6f35cc..9fad3c73395a 100644
@@ -7852,7 +7852,7 @@ static __init int hardware_setup(void)
 	vmx_set_cpu_caps();
 
 	r = alloc_kvm_area();
-	if (r)
+	if (r && nested)
 		nested_vmx_hardware_unsetup();
 
 	kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);
Signature · 1 line
2.27.0
maintainer Applied
#2 lore raw
In reply to Peng Hao
Quoted 19 lines · Peng Hao

From: Peng Hao <[email protected]>

Make sure nested_vmx_hardware_setup/unsetup() are called in pairs under the same conditions. Calling nested_vmx_hardware_unsetup() when nested is false "works" right now because it only calls free_page() on zero- initialized pointers, but it's possible that more code will be added to nested_vmx_hardware_unsetup() in the future.

---
  arch/x86/kvm/vmx/vmx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +0 -0
index 75ed7d6f35cc..9fad3c73395a 100644

arch/x86/kvm/vmx/vmx.c static __init int hardware_setup(void) · line 7858

Quoted 8 lines
arch/x86/kvm/vmx/vmx.c +1 -1
@@ -7852,7 +7852,7 @@ static __init int hardware_setup(void)
  	vmx_set_cpu_caps();
 
  	r = alloc_kvm_area();
-	if (r)
+	if (r && nested)
  		nested_vmx_hardware_unsetup();
 
  	kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);

Queued, thanks.

Paolo