Skip to content

Commit 6537565

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Adjust EL2 stage-1 leaf AP bits when ARM64_KVM_HVHE is set
El2 stage-1 page-table format is subtly (and annoyingly) different when HCR_EL2.E2H is set. Take the ARM64_KVM_HVHE configuration into account when setting the AP bits. Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230609162200.2024064-13-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent cff3b5c commit 6537565

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
#define KVM_PTE_LEAF_ATTR_LO_S1_ATTRIDX GENMASK(4, 2)
2323
#define KVM_PTE_LEAF_ATTR_LO_S1_AP GENMASK(7, 6)
24-
#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO 3
25-
#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW 1
24+
#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO \
25+
({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 2 : 3; })
26+
#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW \
27+
({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 0 : 1; })
2628
#define KVM_PTE_LEAF_ATTR_LO_S1_SH GENMASK(9, 8)
2729
#define KVM_PTE_LEAF_ATTR_LO_S1_SH_IS 3
2830
#define KVM_PTE_LEAF_ATTR_LO_S1_AF BIT(10)

0 commit comments

Comments
 (0)