Skip to content

Commit e645226

Browse files
author
Marc Zyngier
committed
KVM: arm64: Compute 52bit TTBR address and alignment
52bit addresses from TTBR need extra adjustment and alignment checks. Implement the requirements of the architecture. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 23cf13d commit e645226

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm64/kvm/at.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static int get_ia_size(struct s1_walk_info *wi)
2828
/* Return true if the IPA is out of the OA range */
2929
static bool check_output_size(u64 ipa, struct s1_walk_info *wi)
3030
{
31+
if (wi->pa52bit)
32+
return wi->max_oa_bits < 52 && (ipa & GENMASK_ULL(51, wi->max_oa_bits));
3133
return wi->max_oa_bits < 48 && (ipa & GENMASK_ULL(47, wi->max_oa_bits));
3234
}
3335

@@ -301,6 +303,16 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
301303
x = 3 + ia_bits - ((3 - wi->sl) * stride + wi->pgshift);
302304

303305
wi->baddr = ttbr & TTBRx_EL1_BADDR;
306+
if (wi->pa52bit) {
307+
/*
308+
* Force the alignment on 64 bytes for top-level tables
309+
* smaller than 8 entries, since TTBR.BADDR[5:2] are used to
310+
* store bits [51:48] of the first level of lookup.
311+
*/
312+
x = max(x, 6);
313+
314+
wi->baddr |= FIELD_GET(GENMASK_ULL(5, 2), ttbr) << 48;
315+
}
304316

305317
/* R_VPBBF */
306318
if (check_output_size(wi->baddr, wi))

0 commit comments

Comments
 (0)