Re: [PATCH v3 1/2] KVM: X86: Fix warning caused by stale emulation context

From: Sean Christopherson
Date: Thu May 27 2021 - 19:47:10 EST


On Fri, May 28, 2021, Wanpeng Li wrote:
> How about this?

Yep, perfect! Sorry about the squash confusion.

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index bbc4e04..dba8077 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7226,6 +7226,11 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
> BUILD_BUG_ON(HF_SMM_MASK != X86EMUL_SMM_MASK);
> BUILD_BUG_ON(HF_SMM_INSIDE_NMI_MASK != X86EMUL_SMM_INSIDE_NMI_MASK);
>
> + ctxt->interruptibility = 0;
> + ctxt->have_exception = false;
> + ctxt->exception.vector = -1;
> + ctxt->perm_ok = false;
> +
> init_decode_cache(ctxt);
> vcpu->arch.emulate_regs_need_sync_from_vcpu = false;
> }
> @@ -7561,11 +7566,6 @@ int x86_decode_emulated_instruction(struct
> kvm_vcpu *vcpu, int emulation_type,
> kvm_vcpu_check_breakpoint(vcpu, &r))
> return r;
>
> - ctxt->interruptibility = 0;
> - ctxt->have_exception = false;
> - ctxt->exception.vector = -1;
> - ctxt->perm_ok = false;
> -
> ctxt->ud = emulation_type & EMULTYPE_TRAP_UD;
>
> r = x86_decode_insn(ctxt, insn, insn_len);