[PATCH v2 09/16] KVM: arm64: Report faults from S1 walk setup at the expected start level
Dan Carpenter
dan at pereq.eu
Fri Nov 27 00:14:07 PST 2026
Hi Marc,
On Mon, Sep 15, 2025 at 12:44:44PM +0100, Marc Zyngier wrote:
> Translation faults from TTBR must be reported on the start level,
> and not level-0. Enforcing this requires moving quite a lot of
> code around so that the start level can be computed early enough
> that it is usable.
>
[ snip ]
> @@ -351,12 +351,17 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
>
> return 0;
>
> -addrsz: /* Address Size Fault level 0 */
> +addrsz:
> + /*
> + * Address Size Fault level 0 to indicate it comes from TTBR.
> + * yes, this is an oddity.
> + */
> fail_s1_walk(wr, ESR_ELx_FSC_ADDRSZ_L(0), false);
> return -EFAULT;
>
> -transfault_l0: /* Translation Fault level 0 */
> - fail_s1_walk(wr, ESR_ELx_FSC_FAULT_L(0), false);
> +transfault:
> + /* Translation Fault on start level */
> + fail_s1_walk(wr, ESR_ELx_FSC_FAULT_L(wi->sl), false);
^^^^^^
Switching this from 0 to wi->sl was obvoiusly done deliberately but Pereq
is trying to do formal verification based on reading the ARM docs and
matching it with the kernel and the AArch64.AArch64_S1Translate() pseudo
code uses a zero here.
> return -EFAULT;
> }
Part of the issue is that wi->sl can be totally bogus.
274 ia_bits = get_ia_size(wi);
^^
ia_bits is based on wl->txsz
275
276 /* AArch64.S1StartLevel() */
277 stride = wi->pgshift - 3;
278 wi->sl = 3 - (((ia_bits - 1) - wi->pgshift) / stride);
so wi->sl is based on ->txsx and the "- wi->pgshift" subtract can
underflow. We check txsz if is invalid later "if (wi->txsz > 39)" etc
but we still end up using the original "wi->sl" invalid start level.
If we made invalid values of ->txsz use zero that would fix my test
cases but it still wouldn't match the doc.
regards,
dan carpenter
More information about the linux-arm-kernel
mailing list