Skip to content

Commit 8d8e882

Browse files
Marc ZyngierOliver Upton
authored andcommitted
KVM: arm64: Fix EL2 S1 XN handling for hVHE setups
The current XN implementation is tied to the EL2 translation regime, and fall flat on its face with the EL2&0 one that is used for hVHE, as the permission bit for privileged execution is a different one. Fixes: 6537565 ("KVM: arm64: Adjust EL2 stage-1 leaf AP bits when ARM64_KVM_HVHE is set") Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Fuad Tabba <tabba@google.com> Link: https://msgid.link/20251210173024.561160-2-maz@kernel.org Signed-off-by: Oliver Upton <oupton@kernel.org>
1 parent 5e8b511 commit 8d8e882

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

arch/arm64/include/asm/kvm_pgtable.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ typedef u64 kvm_pte_t;
8787

8888
#define KVM_PTE_LEAF_ATTR_HI_SW GENMASK(58, 55)
8989

90-
#define KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54)
90+
#define __KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54)
91+
#define __KVM_PTE_LEAF_ATTR_HI_S1_UXN BIT(54)
92+
#define __KVM_PTE_LEAF_ATTR_HI_S1_PXN BIT(53)
93+
94+
#define KVM_PTE_LEAF_ATTR_HI_S1_XN \
95+
({ cpus_have_final_cap(ARM64_KVM_HVHE) ? \
96+
(__KVM_PTE_LEAF_ATTR_HI_S1_UXN | \
97+
__KVM_PTE_LEAF_ATTR_HI_S1_PXN) : \
98+
__KVM_PTE_LEAF_ATTR_HI_S1_XN; })
9199

92100
#define KVM_PTE_LEAF_ATTR_HI_S2_XN GENMASK(54, 53)
93101

0 commit comments

Comments
 (0)