[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YtlhWzUA/oPis8iI@google.com>
Date: Thu, 21 Jul 2022 14:23:23 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Maxim Levitsky <mlevitsk@...hat.com>
Cc: kvm@...r.kernel.org, x86@...nel.org,
Kees Cook <keescook@...omium.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>,
Borislav Petkov <bp@...en8.de>, Joerg Roedel <joro@...tes.org>,
Ingo Molnar <mingo@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>
Subject: Re: [PATCH v2 02/11] KVM: x86: emulator: introduce
update_emulation_mode
On Thu, Jul 21, 2022, Maxim Levitsky wrote:
> On Wed, 2022-07-20 at 23:44 +0000, Sean Christopherson wrote:
> > On Tue, Jun 21, 2022, Maxim Levitsky wrote:
> > > + if (!ctxt->ops->get_cr(ctxt, 0) & X86_CR0_PE) {
> > > + /* Real mode. cpu must not have long mode active */
> > > + if (efer & EFER_LMA)
> > > + return X86EMUL_UNHANDLEABLE;
> >
> > If we hit this, is there any hope of X86EMUL_UNHANDLEABLE doing the right thing?
> > Ah, SMM and the ability to swizzle SMRAM state. Bummer. I was hoping we could
> > just bug the VM.
>
> I just tried to be a good citizen here, it is probably impossible to hit this case.
> (RSM ignores LMA bit in the EFER in the SMRAM).
The reason I asked is because if all of the X86EMUL_UNHANDLEABLE paths are impossible
then my preference would be to refactor this slightly to:
static int emulator_calc_cpu_mode(const struct x86_emulate_ctxt *ctxt)
and return the mode instead of success/failure, and turn those checks into:
KVM_EMULATOR_BUG_ON(efer & EFER_LMA);
with the callers being:
ctxt->mode = emulator_calc_cpu_mode(ctxt);
But I think this one:
if (!ctxt->ops->get_segment(ctxt, &selector, &cs, &base3, VCPU_SREG_CS))
return X86EMUL_UNHANDLEABLE;
is reachable in the em_rsm() case :-/
Powered by blists - more mailing lists