On Fri, May 31, 2024, Chao Gao wrote: > On Thu, May 30, 2024 at 06:49:56PM +0530, Manali Shukla wrote: > >>> + /* Check the extension for binary stats */ > >>> + TEST_REQUIRE(this_cpu_has(X86_FEATURE_IDLE_HLT)); > >> > >> IIUC, this test assumes that the IDLE_HLT feature is enabled for guests if it > >> is supported by the CPU. But this isn't true in some cases: > >> > >I understand you are intending to create a capability for IDLE HLT intercept > >feature, but in my opinion, the IDLE Halt intercept feature doesn't require > >user space to do anything for the feature itself. > > Yes, I agree. Actually, I was thinking about: > > 1. make the feature bit visible from /proc/cpuinfo by removing the leading "" > from the comment following the bit definition in patch 1 > > 2. parse /proc/cpuinfo to determine if this IDLE_HLT feature is supported by the > kernel Neither of these is sufficient/correct. E.g. they'll get false positives if run on a kernel that recognizes IDLE_HLT, but that doesn't have KVM support for enabling the feature. The canonical way to check for features in KVM selftests is kvm_cpu_has(), which looks at KVM_GET_SUPPORTED_CPUID (by default, selftests VMs enable all features, i.e. reflect the result of KVM_GET_SUPPORTED_CPUID into KVM_SET_CPUID2). > But I am not sure if it's worth it. I'll defer to maintainers.