Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

From: Paolo Bonzini
Date: Tue May 05 2015 - 05:37:24 EST




On 04/05/2015 21:59, Radim KrÄmÃÅ wrote:
> > The big ugly one. This patch adds support for switching in and out of
> > system management mode, respectively upon receiving KVM_REQ_SMI and upon
> > executing a RSM instruction. Both 32- and 64-bit formats are supported
> > for the SMM state save area.
> >
> > Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> > ---
> > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> > +static void rsm_set_desc_flags(struct desc_struct *desc, u16 flags)
> > +{
> > + desc->g = (flags >> 15) & 1;
> > + desc->d = (flags >> 14) & 1;
> > + desc->l = (flags >> 13) & 1;
> > + desc->avl = (flags >> 12) & 1;
> > + desc->p = (flags >> 7) & 1;
> > + desc->dpl = (flags >> 5) & 3;
> > + desc->s = (flags >> 4) & 1;
> > + desc->type = flags & 15;
>
> I can't find a description of this ... can you point me to a place where
> the gap between 'p' and 'avl' is documented?
> (Not that it matters unless the guest reads it, but it's a bit weird.)

It turns out that access rights are stored in the same format as the VMX
access rights. However, they are shifted by 8, which my code above
doesn't do (bug).

The documentation is, of course, QEMU and Bochs :) but you can also find
it in http://www.rcollins.org/ftp/source/include/struc.inc. It is not
exactly for SMM, but it is more or less the same.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/