diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-09-29 19:20:09 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-11-09 18:31:16 +0100 |
commit | b0b42197b5c6f0d9447e5b710d64c671be8deec1 (patch) | |
tree | a65a6ba2b209546c465e0d4e63e5b65aa58f0317 /arch/x86/kvm/smm.c | |
parent | KVM: SVM: Name and check reserved fields with structs offset (diff) | |
download | linux-b0b42197b5c6f0d9447e5b710d64c671be8deec1.tar.xz linux-b0b42197b5c6f0d9447e5b710d64c671be8deec1.zip |
KVM: x86: start moving SMM-related functions to new files
Create a new header and source with code related to system management
mode emulation. Entry and exit will move there too; for now,
opportunistically rename put_smstate to PUT_SMSTATE while moving
it to smm.h, and adjust the SMM state saving code.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220929172016.319443-2-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/smm.c')
-rw-r--r-- | arch/x86/kvm/smm.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/x86/kvm/smm.c b/arch/x86/kvm/smm.c new file mode 100644 index 000000000000..b91c48d91f6e --- /dev/null +++ b/arch/x86/kvm/smm.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <linux/kvm_host.h> +#include "x86.h" +#include "kvm_cache_regs.h" +#include "kvm_emulate.h" +#include "smm.h" +#include "trace.h" + +void kvm_smm_changed(struct kvm_vcpu *vcpu, bool entering_smm) +{ + trace_kvm_smm_transition(vcpu->vcpu_id, vcpu->arch.smbase, entering_smm); + + if (entering_smm) { + vcpu->arch.hflags |= HF_SMM_MASK; + } else { + vcpu->arch.hflags &= ~(HF_SMM_MASK | HF_SMM_INSIDE_NMI_MASK); + + /* Process a latched INIT or SMI, if any. */ + kvm_make_request(KVM_REQ_EVENT, vcpu); + + /* + * Even if KVM_SET_SREGS2 loaded PDPTRs out of band, + * on SMM exit we still need to reload them from + * guest memory + */ + vcpu->arch.pdptrs_from_userspace = false; + } + + kvm_mmu_reset_context(vcpu); +} + +void process_smi(struct kvm_vcpu *vcpu) +{ + vcpu->arch.smi_pending = true; + kvm_make_request(KVM_REQ_EVENT, vcpu); +} |