]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Optimise away S1POE handling when not supported by host
authorFuad Tabba <tabba@google.com>
Fri, 13 Feb 2026 14:38:13 +0000 (14:38 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 13 Feb 2026 14:54:48 +0000 (14:54 +0000)
Although ID register sanitisation prevents guests from seeing the
feature, adding this check to the helper allows the compiler to entirely
eliminate S1POE-specific code paths (such as context switching POR_EL1)
when the host kernel is compiled without support (CONFIG_ARM64_POE is
disabled).

This aligns with the pattern used for other optional features like SVE
(kvm_has_sve()) and FPMR (kvm_has_fpmr()), ensuring no POE logic if the
host lacks support, regardless of the guest configuration state.

Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260213143815.1732675-3-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h

index 5d5a3bbdb95e4b9b2c40a670bbbad5c8741211d3..2ca264b3db5fa0322cc8dd788284b0a98e995fee 100644 (file)
@@ -1616,7 +1616,8 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val);
        (kvm_has_feat((k), ID_AA64MMFR3_EL1, S1PIE, IMP))
 
 #define kvm_has_s1poe(k)                               \
-       (kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP))
+       (system_supports_poe() &&                       \
+        kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP))
 
 #define kvm_has_ras(k)                                 \
        (kvm_has_feat((k), ID_AA64PFR0_EL1, RAS, IMP))