Skip to content

Commit 23cf13d

Browse files
author
Marc Zyngier
committed
KVM: arm64: Account for 52bit when computing maximum OA
Adjust the computation of the max OA to account for 52bit PAs. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 0090c0a commit 23cf13d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

arch/arm64/include/asm/kvm_nested.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,18 @@ static inline u64 decode_range_tlbi(u64 val, u64 *range, u16 *asid)
265265
return base;
266266
}
267267

268-
static inline unsigned int ps_to_output_size(unsigned int ps)
268+
static inline unsigned int ps_to_output_size(unsigned int ps, bool pa52bit)
269269
{
270270
switch (ps) {
271271
case 0: return 32;
272272
case 1: return 36;
273273
case 2: return 40;
274274
case 3: return 42;
275275
case 4: return 44;
276-
case 5:
276+
case 5: return 48;
277+
case 6: if (pa52bit)
278+
return 52;
279+
fallthrough;
277280
default:
278281
return 48;
279282
}

arch/arm64/kvm/at.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
295295
ps = (wi->regime == TR_EL2 ?
296296
FIELD_GET(TCR_EL2_PS_MASK, tcr) : FIELD_GET(TCR_IPS_MASK, tcr));
297297

298-
wi->max_oa_bits = min(get_kvm_ipa_limit(), ps_to_output_size(ps));
298+
wi->max_oa_bits = min(get_kvm_ipa_limit(), ps_to_output_size(ps, wi->pa52bit));
299299

300300
/* Compute minimal alignment */
301301
x = 3 + ia_bits - ((3 - wi->sl) * stride + wi->pgshift);

arch/arm64/kvm/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static void vtcr_to_walk_info(u64 vtcr, struct s2_walk_info *wi)
349349
wi->sl = FIELD_GET(VTCR_EL2_SL0_MASK, vtcr);
350350
/* Global limit for now, should eventually be per-VM */
351351
wi->max_oa_bits = min(get_kvm_ipa_limit(),
352-
ps_to_output_size(FIELD_GET(VTCR_EL2_PS_MASK, vtcr)));
352+
ps_to_output_size(FIELD_GET(VTCR_EL2_PS_MASK, vtcr), false));
353353
}
354354

355355
int kvm_walk_nested_s2(struct kvm_vcpu *vcpu, phys_addr_t gipa,

0 commit comments

Comments
 (0)