Skip to content

Commit 17d7b15

Browse files
author
Marc Zyngier
committed
KVM: arm64: Add KVM_PGTABLE_S2_AS_S1 flag
Plumb the MT_S2{,_FWB}_AS_S1 memory types into the KVM_S2_MEMATTR() macro with a new KVM_PGTABLE_S2_AS_S1 flag. Nobody selects it yet. Reviewed-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20260123191637.715429-3-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent d4236f1 commit 17d7b15

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

arch/arm64/include/asm/kvm_pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ struct kvm_pgtable_mm_ops {
232232
* @KVM_PGTABLE_S2_NOFWB: Don't enforce Normal-WB even if the CPUs have
233233
* ARM64_HAS_STAGE2_FWB.
234234
* @KVM_PGTABLE_S2_IDMAP: Only use identity mappings.
235+
* @KVM_PGTABLE_S2_AS_S1: Final memory attributes are that of Stage-1.
235236
*/
236237
enum kvm_pgtable_stage2_flags {
237238
KVM_PGTABLE_S2_NOFWB = BIT(0),
238239
KVM_PGTABLE_S2_IDMAP = BIT(1),
240+
KVM_PGTABLE_S2_AS_S1 = BIT(2),
239241
};
240242

241243
/**

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,19 @@ void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu,
659659
}
660660
}
661661

662-
#define KVM_S2_MEMATTR(pgt, attr) PAGE_S2_MEMATTR(attr, stage2_has_fwb(pgt))
662+
#define KVM_S2_MEMATTR(pgt, attr) \
663+
({ \
664+
kvm_pte_t __attr; \
665+
\
666+
if ((pgt)->flags & KVM_PGTABLE_S2_AS_S1) \
667+
__attr = PAGE_S2_MEMATTR(AS_S1, \
668+
stage2_has_fwb(pgt)); \
669+
else \
670+
__attr = PAGE_S2_MEMATTR(attr, \
671+
stage2_has_fwb(pgt)); \
672+
\
673+
__attr; \
674+
})
663675

664676
static int stage2_set_xn_attr(enum kvm_pgtable_prot prot, kvm_pte_t *attr)
665677
{

0 commit comments

Comments
 (0)