diff options
author | Oliver Upton <oliver.upton@linux.dev> | 2023-04-21 09:16:06 +0200 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-04-21 11:51:40 +0200 |
commit | 39bc95be3782ba88e55cd72e830f37e74395831b (patch) | |
tree | 45bc8818fbd3f9c092f0db35d18e1c0381c8018c /arch | |
parent | KVM: arm64: Infer the PA offset from IPA in stage-2 map walker (diff) | |
download | linux-39bc95be3782ba88e55cd72e830f37e74395831b.tar.xz linux-39bc95be3782ba88e55cd72e830f37e74395831b.zip |
KVM: arm64: Infer PA offset from VA in hyp map walker
Similar to the recently fixed stage-2 walker, the hyp map walker
increments the PA and VA of a walk separately. Unlike stage-2, there is
no bug here as the map walker has exclusive access to the stage-1 page
tables.
Nonetheless, in the interest of continuity throughout the page table
code, tweak the hyp map walker to avoid incrementing the PA and instead
use the VA as the authoritative source of how far along a table walk has
gotten. Calculate the PA to use for a leaf PTE by adding the offset of
the VA from the start of the walk to the starting PA.
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230421071606.1603916-3-oliver.upton@linux.dev
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/kvm/hyp/pgtable.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 140f82300db5..356a3fd5220c 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -410,13 +410,12 @@ enum kvm_pgtable_prot kvm_pgtable_hyp_pte_prot(kvm_pte_t pte) static bool hyp_map_walker_try_leaf(const struct kvm_pgtable_visit_ctx *ctx, struct hyp_map_data *data) { + u64 phys = data->phys + (ctx->addr - ctx->start); kvm_pte_t new; - u64 granule = kvm_granule_size(ctx->level), phys = data->phys; if (!kvm_block_mapping_supported(ctx, phys)) return false; - data->phys += granule; new = kvm_init_valid_leaf_pte(phys, data->attr, ctx->level); if (ctx->old == new) return true; |