Skip to content

Commit 1a61bd0

Browse files
yang-weijiangsean-jc
authored andcommitted
KVM: x86: Save and reload SSP to/from SMRAM
Save CET SSP to SMRAM on SMI and reload it on RSM. KVM emulates HW arch behavior when guest enters/leaves SMM mode,i.e., save registers to SMRAM at the entry of SMM and reload them at the exit to SMM. Per SDM, SSP is one of such registers on 64-bit Arch, and add the support for SSP. Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Yang Weijiang <[email protected]> Tested-by: Mathias Krause <[email protected]> Tested-by: John Allen <[email protected]> Tested-by: Rick Edgecombe <[email protected]> Signed-off-by: Chao Gao <[email protected]> Reviewed-by: Binbin Wu <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 8b59d02 commit 1a61bd0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

arch/x86/kvm/smm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu,
269269
enter_smm_save_seg_64(vcpu, &smram->gs, VCPU_SREG_GS);
270270

271271
smram->int_shadow = kvm_x86_call(get_interrupt_shadow)(vcpu);
272+
273+
if (guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) &&
274+
kvm_msr_read(vcpu, MSR_KVM_INTERNAL_GUEST_SSP, &smram->ssp))
275+
kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
272276
}
273277
#endif
274278

@@ -558,6 +562,10 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
558562
kvm_x86_call(set_interrupt_shadow)(vcpu, 0);
559563
ctxt->interruptibility = (u8)smstate->int_shadow;
560564

565+
if (guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) &&
566+
kvm_msr_write(vcpu, MSR_KVM_INTERNAL_GUEST_SSP, smstate->ssp))
567+
return X86EMUL_UNHANDLEABLE;
568+
561569
return X86EMUL_CONTINUE;
562570
}
563571
#endif

arch/x86/kvm/smm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ struct kvm_smram_state_64 {
116116
u32 smbase;
117117
u32 reserved4[5];
118118

119-
/* ssp and svm_* fields below are not implemented by KVM */
120119
u64 ssp;
120+
/* svm_* fields below are not implemented by KVM */
121121
u64 svm_guest_pat;
122122
u64 svm_host_efer;
123123
u64 svm_host_cr4;

0 commit comments

Comments
 (0)