* [PATCH] kvm/vmx: Make setup/unsetup under the same conditions
@ 2022-02-18 11:11 Peng Hao
2022-02-18 16:17 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Peng Hao @ 2022-02-18 11:11 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel
Make sure nested_vmx_hardware_setup/unsetup are called in pairs under
the same conditions.
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
arch/x86/kvm/vmx/vmx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0ffcfe54eea5..5392def71093 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -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);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kvm/vmx: Make setup/unsetup under the same conditions
2022-02-18 11:11 [PATCH] kvm/vmx: Make setup/unsetup under the same conditions Peng Hao
@ 2022-02-18 16:17 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2022-02-18 16:17 UTC (permalink / raw)
To: Peng Hao; +Cc: pbonzini, kvm, linux-kernel
"KVM: VMX" for the scope, or maybe even "KVM: nVMX:" despite this not touching
vmx/nested.c. Either way (but not "kvm/vmx:").
On Fri, Feb 18, 2022, Peng Hao wrote:
> Make sure nested_vmx_hardware_setup/unsetup are called in pairs under
> the same conditions.
Probably worth adding a sentence to clarify that the existing code isn't buggy
only because free_page() plays nice with getting passed '0' and vmx_bitmap is
initialized to zero. Something like:
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.
Reviewed-by: Sean Christopherson <seanjc@google.com>
>
> Signed-off-by: Peng Hao <flyingpeng@tencent.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 0ffcfe54eea5..5392def71093 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -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);
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-18 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 11:11 [PATCH] kvm/vmx: Make setup/unsetup under the same conditions Peng Hao
2022-02-18 16:17 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox