Messages in this thread | | | Date | Fri, 19 Apr 2024 15:04:54 +0800 | Subject | Re: [PATCH v19 116/130] KVM: TDX: Silently discard SMI request | From | Binbin Wu <> |
| |
On 2/26/2024 4:26 PM, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata <isaku.yamahata@intel.com> > > TDX doesn't support system-management mode (SMM) and system-management > interrupt (SMI) in guest TDs. Because guest state (vcpu state, memory > state) is protected, it must go through the TDX module APIs to change guest > state, injecting SMI and changing vcpu mode into SMM. The TDX module > doesn't provide a way for VMM to inject SMI into guest TD and a way for VMM ^ or
> to switch guest vcpu mode into SMM. > > We have two options in KVM when handling SMM or SMI in the guest TD or the > device model (e.g. QEMU): 1) silently ignore the request or 2) return a > meaningful error. > > For simplicity, we implemented the option 1). > > Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> > --- [...] > + > +static void vt_enable_smi_window(struct kvm_vcpu *vcpu) > +{ > + if (is_td_vcpu(vcpu)) { > + tdx_enable_smi_window(vcpu); > + return;
Can "return tdx_enable_smi_window(vcpu);" directly. > + } > + > + /* RSM will cause a vmexit anyway. */ > + vmx_enable_smi_window(vcpu); > +} > +#endif > + [...] > > +#if defined(CONFIG_INTEL_TDX_HOST) && defined(CONFIG_KVM_SMM) > +int tdx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection); > +int tdx_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram); > +int tdx_leave_smm(struct kvm_vcpu *vcpu, const union kvm_smram *smram); > +void tdx_enable_smi_window(struct kvm_vcpu *vcpu); > +#else
#elif defined(CONFIG_KVM_SMM)
These functions are only needed when CONFIG_KVM_SMM is defined.
> +static inline int tdx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection) { return false; } > +static inline int tdx_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram) { return 0; } > +static inline int tdx_leave_smm(struct kvm_vcpu *vcpu, const union kvm_smram *smram) { return 0; } > +static inline void tdx_enable_smi_window(struct kvm_vcpu *vcpu) {} > +#endif > + > #endif /* __KVM_X86_VMX_X86_OPS_H */
| |