[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <689f5883-54aa-51f8-a06b-69d18d6a3c82@redhat.com>
Date: Wed, 6 Oct 2021 13:22:10 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sasha Levin <sashal@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Maxim Levitsky <mlevitsk@...hat.com>,
Sean Christopherson <seanjc@...gle.com>, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, x86@...nel.org, kvm@...r.kernel.org
Subject: Re: [PATCH MANUALSEL 5.10 4/7] KVM: x86: VMX: synthesize invalid VM
exit when emulating invalid guest state
On 06/10/21 13:12, Sasha Levin wrote:
> From: Maxim Levitsky <mlevitsk@...hat.com>
>
> [ Upstream commit c42dec148b3e1a88835e275b675e5155f99abd43 ]
>
> Since no actual VM entry happened, the VM exit information is stale.
> To avoid this, synthesize an invalid VM guest state VM exit.
>
> Suggested-by: Sean Christopherson <seanjc@...gle.com>
> Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
> Message-Id: <20210913140954.165665-6-mlevitsk@...hat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
> Signed-off-by: Sasha Levin <sashal@...nel.org>
> ---
> arch/x86/kvm/vmx/vmx.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index fcd8bcb7e0ea..e3af56f05a37 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6670,10 +6670,21 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
> vmx->loaded_vmcs->soft_vnmi_blocked))
> vmx->loaded_vmcs->entry_time = ktime_get();
>
> - /* Don't enter VMX if guest state is invalid, let the exit handler
> - start emulation until we arrive back to a valid state */
> - if (vmx->emulation_required)
> + /*
> + * Don't enter VMX if guest state is invalid, let the exit handler
> + * start emulation until we arrive back to a valid state. Synthesize a
> + * consistency check VM-Exit due to invalid guest state and bail.
> + */
> + if (unlikely(vmx->emulation_required)) {
> + vmx->fail = 0;
> + vmx->exit_reason.full = EXIT_REASON_INVALID_STATE;
> + vmx->exit_reason.failed_vmentry = 1;
> + kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_1);
> + vmx->exit_qualification = ENTRY_FAIL_DEFAULT;
> + kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_2);
> + vmx->exit_intr_info = 0;
> return EXIT_FASTPATH_NONE;
> + }
>
> if (vmx->ple_window_dirty) {
> vmx->ple_window_dirty = false;
>
NACK for this one.
The others are good, I'll ack them individually though. Thanks for
setting this up!
Paolo
Powered by blists - more mailing lists