On Tue, 24 Jan 2023 at 00:02, Richard Henderson
<[email protected]> wrote:
>
> Handle GPC Fault types in arm_deliver_fault, reporting as
> either a GPC exception at EL3, or falling through to insn
> or data aborts at various exception levels.
>
> Signed-off-by: Richard Henderson <[email protected]>
> +static unsigned encode_gpcsc(ARMMMUFaultInfo *fi)
> +{
> + static uint8_t const gpcsc[] = {
> + [GPCF_AddressSize] = 0b00000,
> + [GPCF_Walk] = 0b00010,
> + [GPCF_Fail] = 0b00110,
> + [GPCF_EABT] = 0b01010,
> + };
> +
> + /* Note that we've validated fi->gpcf and fi->level above. */
> + return gpcsc[fi->gpcf] | fi->level;
GPCSC is 6 bits, and you've only put the top 5 bits in the
gpcsc[] array here, so you either need to shift that right
by 1, or else have the array entries all have an extra 0
on the least-significant end.
The comment says gpcf and level have been validated, but
the code assumes that GPCF_AddressSize implies level 0,
which isn't validated.
Otherwise
Reviewed-by: Peter Maydell <[email protected]>
thanks
-- PMM