[PATCH v5 16/20] KVM: x86: Add APX in supported XCR0

From: Chang S. Bae

Date: Mon Jul 20 2026 - 13:51:53 EST


Set kvm_caps.supported_xcr0[APX] when the host has enabled the APX state
along with CONFIG_KVM_APX=y.

Signed-off-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
---
V4 -> V5: Separate out from userspace exposure (Sean)
---
arch/x86/kvm/x86.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 266d7a02855b..48f8a2d69987 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7082,6 +7082,8 @@ int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops)
if (boot_cpu_has(X86_FEATURE_XSAVE)) {
kvm_host.xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
kvm_caps.supported_xcr0 = kvm_host.xcr0 & KVM_SUPPORTED_XCR0;
+ if (IS_ENABLED(CONFIG_KVM_APX))
+ kvm_caps.supported_xcr0 |= kvm_host.xcr0 & XFEATURE_MASK_APX;
}

if (boot_cpu_has(X86_FEATURE_XSAVES)) {
--
2.53.0