lkml.org 
[lkml]   [2022]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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 :-/

\
 
 \ /
  Last update: 2022-07-21 16:25    [W:0.066 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site