On Thu, 2022-07-21 at 00:40 +0000, Sean Christopherson wrote: > On Tue, Jun 21, 2022, Maxim Levitsky wrote: > > Those structs will be used to read/write the smram state image. > > > > Also document the differences between KVM's SMRAM layout and SMRAM > > layout that is used by real Intel/AMD cpus. > > > > Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx> > > --- > > arch/x86/kvm/kvm_emulate.h | 139 +++++++++++++++++++++++++++++++++++++ > > 1 file changed, 139 insertions(+) > > > > diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h > > index 89246446d6aa9d..7015728da36d5f 100644 > > --- a/arch/x86/kvm/kvm_emulate.h > > +++ b/arch/x86/kvm/kvm_emulate.h > > @@ -503,6 +503,145 @@ enum x86_intercept { > > nr_x86_intercepts > > }; > > > > + > > +/* > > + * 32 bit KVM's emulated SMM layout > > + * Loosely based on Intel's layout > > + */ > > + > > +struct kvm_smm_seg_state_32 { > > + u32 flags; > > + u32 limit; > > + u32 base; > > +} __packed; > > + > > +struct kvm_smram_state_32 { > > + > > + u32 reserved1[62]; /* FE00 - FEF7 */ > > + u32 smbase; /* FEF8 */ > > + u32 smm_revision; /* FEFC */ > > + u32 reserved2[5]; /* FF00-FF13 */ > > + /* CR4 is not present in Intel/AMD SMRAM image*/ > > + u32 cr4; /* FF14 */ > > + u32 reserved3[5]; /* FF18 */ > > Again, I love this approach, but we should have compile-time asserts to verify > the layout, e.g. see vmx_check_vmcs12_offsets(). > No objections, will do. Best regards, Maxim Levitsky