Skip to content

Commit 4f27fe8

Browse files
author
Marc Zyngier
committed
KVM: arm64: Kill KVM_PGTABLE_S2_NOFWB
Nobody is using this flag anymore, so remove it. This allows some cleanup by removing stage2_has_fwb(), which is can be replaced by a direct check on the capability. 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-5-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent a373930 commit 4f27fe8

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

arch/arm64/include/asm/kvm_pgtable.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,12 @@ struct kvm_pgtable_mm_ops {
229229

230230
/**
231231
* enum kvm_pgtable_stage2_flags - Stage-2 page-table flags.
232-
* @KVM_PGTABLE_S2_NOFWB: Don't enforce Normal-WB even if the CPUs have
233-
* ARM64_HAS_STAGE2_FWB.
234232
* @KVM_PGTABLE_S2_IDMAP: Only use identity mappings.
235233
* @KVM_PGTABLE_S2_AS_S1: Final memory attributes are that of Stage-1.
236234
*/
237235
enum kvm_pgtable_stage2_flags {
238-
KVM_PGTABLE_S2_NOFWB = BIT(0),
239-
KVM_PGTABLE_S2_IDMAP = BIT(1),
240-
KVM_PGTABLE_S2_AS_S1 = BIT(2),
236+
KVM_PGTABLE_S2_IDMAP = BIT(0),
237+
KVM_PGTABLE_S2_AS_S1 = BIT(1),
241238
};
242239

243240
/**

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,6 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift)
631631
return vtcr;
632632
}
633633

634-
static bool stage2_has_fwb(struct kvm_pgtable *pgt)
635-
{
636-
if (!cpus_have_final_cap(ARM64_HAS_STAGE2_FWB))
637-
return false;
638-
639-
return !(pgt->flags & KVM_PGTABLE_S2_NOFWB);
640-
}
641-
642634
void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu,
643635
phys_addr_t addr, size_t size)
644636
{
@@ -661,14 +653,13 @@ void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu,
661653

662654
#define KVM_S2_MEMATTR(pgt, attr) \
663655
({ \
656+
bool __fwb = cpus_have_final_cap(ARM64_HAS_STAGE2_FWB); \
664657
kvm_pte_t __attr; \
665658
\
666659
if ((pgt)->flags & KVM_PGTABLE_S2_AS_S1) \
667-
__attr = PAGE_S2_MEMATTR(AS_S1, \
668-
stage2_has_fwb(pgt)); \
660+
__attr = PAGE_S2_MEMATTR(AS_S1, __fwb); \
669661
else \
670-
__attr = PAGE_S2_MEMATTR(attr, \
671-
stage2_has_fwb(pgt)); \
662+
__attr = PAGE_S2_MEMATTR(attr, __fwb); \
672663
\
673664
__attr; \
674665
})
@@ -880,7 +871,7 @@ static bool stage2_unmap_defer_tlb_flush(struct kvm_pgtable *pgt)
880871
* system supporting FWB as the optimization is entirely
881872
* pointless when the unmap walker needs to perform CMOs.
882873
*/
883-
return system_supports_tlb_range() && stage2_has_fwb(pgt);
874+
return system_supports_tlb_range() && cpus_have_final_cap(ARM64_HAS_STAGE2_FWB);
884875
}
885876

886877
static void stage2_unmap_put_pte(const struct kvm_pgtable_visit_ctx *ctx,
@@ -1160,7 +1151,7 @@ static int stage2_unmap_walker(const struct kvm_pgtable_visit_ctx *ctx,
11601151
if (mm_ops->page_count(childp) != 1)
11611152
return 0;
11621153
} else if (stage2_pte_cacheable(pgt, ctx->old)) {
1163-
need_flush = !stage2_has_fwb(pgt);
1154+
need_flush = !cpus_have_final_cap(ARM64_HAS_STAGE2_FWB);
11641155
}
11651156

11661157
/*
@@ -1390,7 +1381,7 @@ int kvm_pgtable_stage2_flush(struct kvm_pgtable *pgt, u64 addr, u64 size)
13901381
.arg = pgt,
13911382
};
13921383

1393-
if (stage2_has_fwb(pgt))
1384+
if (cpus_have_final_cap(ARM64_HAS_STAGE2_FWB))
13941385
return 0;
13951386

13961387
return kvm_pgtable_walk(pgt, addr, size, &walker);

0 commit comments

Comments
 (0)