1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/build_bug.h>
11 * 32 bit KVM's emulated SMM layout. Based on Intel P6 layout
12 * (https://www.sandpile.org/x86/smm.htm).
15 struct kvm_smm_seg_state_32
{
21 struct kvm_smram_state_32
{
33 /* A20M#, CPL, shutdown and other reserved/undocumented fields */
35 u8 int_shadow
; /* KVM extension */
38 struct kvm_smm_seg_state_32 ds
;
39 struct kvm_smm_seg_state_32 fs
;
40 struct kvm_smm_seg_state_32 gs
;
41 struct kvm_smm_seg_state_32 idtr
; /* IDTR has only base and limit */
42 struct kvm_smm_seg_state_32 tr
;
44 struct kvm_smm_seg_state_32 gdtr
; /* GDTR has only base and limit */
45 struct kvm_smm_seg_state_32 ldtr
;
46 struct kvm_smm_seg_state_32 es
;
47 struct kvm_smm_seg_state_32 cs
;
48 struct kvm_smm_seg_state_32 ss
;
61 u32 gprs
[8]; /* GPRS in the "natural" X86 order (EAX/ECX/EDX.../EDI) */
69 /* 64 bit KVM's emulated SMM layout. Based on AMD64 layout */
71 struct kvm_smm_seg_state_64
{
78 struct kvm_smram_state_64
{
80 struct kvm_smm_seg_state_64 es
;
81 struct kvm_smm_seg_state_64 cs
;
82 struct kvm_smm_seg_state_64 ss
;
83 struct kvm_smm_seg_state_64 ds
;
84 struct kvm_smm_seg_state_64 fs
;
85 struct kvm_smm_seg_state_64 gs
;
86 struct kvm_smm_seg_state_64 gdtr
; /* GDTR has only base and limit*/
87 struct kvm_smm_seg_state_64 ldtr
;
88 struct kvm_smm_seg_state_64 idtr
; /* IDTR has only base and limit*/
89 struct kvm_smm_seg_state_64 tr
;
91 /* I/O restart and auto halt restart are not implemented by KVM */
100 u8 amd_nmi_mask
; /* Documented in AMD BKDG as NMI mask, not used by KVM */
107 * Two fields below are implemented on AMD only, to store
108 * SVM guest vmcb address if the #SMI was received while in the guest mode.
111 u64 svm_guest_vmcb_gpa
;
112 u64 svm_guest_virtual_int
; /* unknown purpose, not implemented */
119 /* ssp and svm_* fields below are not implemented by KVM */
134 u64 gprs
[16]; /* GPRS in a reversed "natural" X86 order (R15/R14/../RCX/RAX.) */
138 struct kvm_smram_state_64 smram64
;
139 struct kvm_smram_state_32 smram32
;
143 static inline int kvm_inject_smi(struct kvm_vcpu
*vcpu
)
145 kvm_make_request(KVM_REQ_SMI
, vcpu
);
149 static inline bool is_smm(struct kvm_vcpu
*vcpu
)
151 return vcpu
->arch
.hflags
& HF_SMM_MASK
;
154 void kvm_smm_changed(struct kvm_vcpu
*vcpu
, bool in_smm
);
155 void enter_smm(struct kvm_vcpu
*vcpu
);
156 int emulator_leave_smm(struct x86_emulate_ctxt
*ctxt
);
157 void process_smi(struct kvm_vcpu
*vcpu
);
159 static inline int kvm_inject_smi(struct kvm_vcpu
*vcpu
) { return -ENOTTY
; }
160 static inline bool is_smm(struct kvm_vcpu
*vcpu
) { return false; }
163 * emulator_leave_smm is used as a function pointer, so the
164 * stub is defined in x86.c.