On Fri, Aug 04, 2023 at 11:13:36AM +0800, Yang, Weijiang wrote:Hold on until host_initiated access is finalized.
Why should userspace be allowed to access SHSTK MSRs in this case? L1 may notYes, but userspace should be able to access SHSTK MSRs even only IBT is exposed to guest so@@ -7214,6 +7217,13 @@ static void kvm_probe_msr_to_save(u32 msr_index)shall we consider the case where IBT is supported while SS isn't
if (!kvm_caps.supported_xss)
return;
break;
+ case MSR_IA32_U_CET:
+ case MSR_IA32_S_CET:
+ case MSR_KVM_GUEST_SSP:
+ case MSR_IA32_PL0_SSP ... MSR_IA32_INT_SSP_TAB:
+ if (!kvm_is_cet_supported())
(e.g., in L1 guest)?
far as KVM can support SHSTK MSRs.
even enumerate SHSTK (qemu removes -shstk explicitly but keeps IBT), how KVM in
L1 can allow its userspace to do that?
OK, maybe the helper is not necessary anymore, I will remove it, thank you!When KVM claims a feature is supported, it should ensure all its dependencies areI think using exiting check implies two things:+static inline bool kvm_is_cet_supported(void)why not just check if SHSTK or IBT is supported explicitly, i.e.,
+{
+ return (kvm_caps.supported_xss & CET_XSTATE_MASK) == CET_XSTATE_MASK;
return kvm_cpu_cap_has(X86_FEATURE_SHSTK) ||
kvm_cpu_cap_has(X86_FEATURE_IBT);
this is straightforward. And strictly speaking, the support of a feature and
the support of managing a feature's state via XSAVE(S) are two different things.x
1. Platform/KVM can support CET features.
2. CET user mode MSRs are backed by host thus are guaranteed to be valid.
i.e., the purpose is to check guest CET dependencies instead of features' availability.
met. that's, KVM's support of a feature also imples all dependencies are met.
Function-wise, the two approaches have no difference. I just think checking
KVM's support of SHSTK/IBT is more clear because the function name is
kvm_is_cet_supported() rather than e.g., kvm_is_cet_state_managed_by_xsave().
kvm_cpu_cap_has(X86_FEATURE_SHSTK) || kvm_cpu_cap_has(X86_FEATURE_IBT)
only tells at least one of the CET features is supported by KVM.
then patch 16 has no need to do
+ /*
+ * If SHSTK and IBT are not available in KVM, clear CET user bit in
+ * kvm_caps.supported_xss so that kvm_is_cet__supported() returns
+ * false when called.
+ */
+ if (!kvm_cpu_cap_has(X86_FEATURE_SHSTK) &&
+ !kvm_cpu_cap_has(X86_FEATURE_IBT))
+ kvm_caps.supported_xss &= ~CET_XSTATE_MASK;