Re: [PATCH v5 15/19] KVM:x86: Optimize CET supervisor SSP save/reload

From: Yang, Weijiang
Date: Wed Aug 09 2023 - 05:01:13 EST


On 8/4/2023 4:43 PM, Chao Gao wrote:
On Thu, Aug 03, 2023 at 12:27:28AM -0400, Yang Weijiang wrote:
Make PL{0,1,2}_SSP as write-intercepted to detect whether
guest is using these MSRs. Disable intercept to the MSRs
if they're written with non-zero values. KVM does save/
reload for the MSRs only if they're used by guest.
What would happen if guest tries to use XRSTORS to load S_CET state from a
xsave area without any writes to the PL0-2_SSP (i.e., at that point, writes to
the MSRs are still intercepted)?
I need to do some experiments to get the details, but now expect some kind
of error in guest is seen.
@@ -2420,6 +2432,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
else
vmx->pt_desc.guest.addr_a[index / 2] = data;
break;
+ case MSR_IA32_PL0_SSP ... MSR_IA32_PL2_SSP:
+ if (kvm_set_msr_common(vcpu, msr_info))
+ return 1;
+ if (data) {
+ vmx_disable_write_intercept_sss_msr(vcpu);
+ wrmsrl(msr_index, data);
Is it necessary to do the wrmsl()?
looks the next kvm_x86_prepare_switch_to_guest() will load PL0-2_SSP from the
caching values.
Oh, yes, it's not necessary after moving the reload logic to kvm_x86_prepare_switch_to_guest().
Thanks!