[PATCH v2 1/9] KVM: x86: nSVM: leave nested mode on vCPU free

Maxim Levitsky posted 9 patches 3 years, 5 months ago
[PATCH v2 1/9] KVM: x86: nSVM: leave nested mode on vCPU free
Posted by Maxim Levitsky 3 years, 5 months ago
If the VM was terminated while nested, we free the nested state
while the vCPU still is in nested mode.

Soon a warning will be added for this condition.

Cc: stable@vger.kernel.org
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 arch/x86/kvm/svm/svm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index d22a809d923339..e9cec1b692051c 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1440,6 +1440,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu)
 	 */
 	svm_clear_current_vmcb(svm->vmcb);
 
+	svm_leave_nested(vcpu);
 	svm_free_nested(svm);
 
 	sev_free_vcpu(vcpu);
-- 
2.34.3
Re: [PATCH v2 1/9] KVM: x86: nSVM: leave nested mode on vCPU free
Posted by Liam Merwick 3 years, 4 months ago
On 03/11/2022 14:13, Maxim Levitsky wrote:
> If the VM was terminated while nested, we free the nested state
> while the vCPU still is in nested mode.
> 
> Soon a warning will be added for this condition.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Liam Merwick <liam.merwick@oracle.com>

> ---
>   arch/x86/kvm/svm/svm.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index d22a809d923339..e9cec1b692051c 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1440,6 +1440,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu)
>   	 */
>   	svm_clear_current_vmcb(svm->vmcb);
>   
> +	svm_leave_nested(vcpu);
>   	svm_free_nested(svm);
>   
>   	sev_free_vcpu(vcpu);