Re: [PATCH v6 0/3] Add support for the Idle HLT intercept feature

Manali Shukla
2025-02-10T05:06:48Z

On 1/28/2025 6:18 PM, Manali Shukla wrote:
> The upcoming new Idle HLT Intercept feature allows for the HLT
> instruction execution by a vCPU to be intercepted by the hypervisor
> only if there are no pending V_INTR and V_NMI events for the vCPU.
> When the vCPU is expected to service the pending V_INTR and V_NMI
> events, the Idle HLT intercept won’t trigger. The feature allows the
> hypervisor to determine if the vCPU is actually idle and reduces
> wasteful VMEXITs.
>
> The Idle HLT intercept feature is used for enlightened guests who wish
> to securely handle the events. When an enlightened guest does a HLT
> while an interrupt is pending, hypervisor will not have a way to
> figure out whether the guest needs to be re-entered or not. The Idle
> HLT intercept feature allows the HLT execution only if there are no
> pending V_INTR and V_NMI events.
>
> Presence of the Idle HLT Intercept feature is indicated via CPUID
> function Fn8000_000A_EDX[30].
>
> Document for the Idle HLT intercept feature is available at [1].
>
> This series is based on kvm-x86/next (eb723766b103) + [2].
>
> Testing Done:
> - Tested the functionality for the Idle HLT intercept feature
> using selftest ipi_hlt_test.
> - Tested on normal, SEV, SEV-ES, SEV-SNP guest for the Idle HLT intercept
> functionality.
> - Tested the Idle HLT intercept functionality on nested guest.
>
> v5 -> v6
> - Incorporated Neeraj's review comments on selftest.
>
> v4 -> v5
> - Incorporated Sean's review comments on nested Idle HLT intercept support.
> - Make svm_idle_hlt_test independent of the Idle HLT to run on all hardware.
>
> v3 -> v4
> - Drop the patches to add vcpu_get_stat() into a new series [2].
> - Added nested Idle HLT intercept support.
>
> v2 -> v3
> - Incorporated Andrew's suggestion to structure vcpu_stat_types in
> a way that each architecture can share the generic types and also
> provide its own.
>
> v1 -> v2
> - Did changes in svm_idle_hlt_test based on the review comments from Sean.
> - Added an enum based approach to get binary stats in vcpu_get_stat() which
> doesn't use string to get stat data based on the comments from Sean.
> - Added safe_halt() and cli() helpers based on the comments from Sean.
>
> [1]: AMD64 Architecture Programmer's Manual Pub. 24593, April 2024,
> Vol 2, 15.9 Instruction Intercepts (Table 15-7: IDLE_HLT).
> https://bugzilla.kernel.org/attachment.cgi?id=306251
>
> [2]: https://lore.kernel.org/kvm/ee027335-f1b9-4637-bc79-27a610c1ab08@amd.com/T/#u
>
> ---
> V5: https://lore.kernel.org/kvm/20250103081828.7060-1-manali.shukla@amd.com/
> V4: https://lore.kernel.org/kvm/20241022054810.23369-1-manali.shukla@amd.com/
> V3: https://lore.kernel.org/kvm/20240528041926.3989-4-manali.shukla@amd.com/T/
> V2: https://lore.kernel.org/kvm/20240501145433.4070-1-manali.shukla@amd.com/
> V1: https://lore.kernel.org/kvm/20240307054623.13632-1-manali.shukla@amd.com/
>
> Manali Shukla (3):
> x86/cpufeatures: Add CPUID feature bit for Idle HLT intercept
> KVM: SVM: Add Idle HLT intercept support
> KVM: selftests: Add self IPI HLT test
>
> arch/x86/include/asm/cpufeatures.h | 1 +
> arch/x86/include/asm/svm.h | 1 +
> arch/x86/include/uapi/asm/svm.h | 2 +
> arch/x86/kvm/svm/svm.c | 13 ++-
> tools/testing/selftests/kvm/Makefile.kvm | 1 +
> .../selftests/kvm/include/x86/processor.h | 1 +
> tools/testing/selftests/kvm/ipi_hlt_test.c | 81 +++++++++++++++++++
> 7 files changed, 97 insertions(+), 3 deletions(-)
> create mode 100644 tools/testing/selftests/kvm/ipi_hlt_test.c
>
>
> base-commit: eb723766b1030a23c38adf2348b7c3d1409d11f0
> prerequisite-patch-id: cb345fc0d814a351df2b5788b76eee0eef9de549
> prerequisite-patch-id: 71806f400cffe09f47d6231cb072cbdbd540de1b
> prerequisite-patch-id: 9ea0412aab7ecd8555fcee3e9609dbfe8456d47b
> prerequisite-patch-id: 3504df50cdd33958456f2e56139d76867273525c
> prerequisite-patch-id: 674e56729a56cc487cb85be1a64ef561eb7bac8a
> prerequisite-patch-id: 48e87354f9d6e6bd121ca32ab73cd0d7f1dce74f
> prerequisite-patch-id: b32c21df6522a7396baa41d62bcad9479041d97a
> prerequisite-patch-id: 0ff4b504e982db7c1dfa8ec6ac485c92a89f4af8
> prerequisite-patch-id: 509018dc2fc1657debc641544e86f5a92d04bc1a

A gentle reminder for the review.

-Manali