On 09.02.2026 17:52, Oleksii Kurochko wrote:
> If the Smstateen extension is not implemented, the hstateen0 CSR is
> considered non-existent. Any attempt to access it will raise an
> illegal-instruction exception.
> 
> Guard the hstateen0 dump with a runtime check for Smstateen support to
> avoid triggering traps when dumping CSRs on systems that do not
> implement this extension.
> 
> Fixes: 3babc8d2e546 ("xen/riscv: dump GPRs and CSRs on unexpected traps")
> Signed-off-by: Oleksii Kurochko <[email protected]>

Reviewed-by: Jan Beulich <[email protected]>

It is, aiui, independent of patch 1 and hence can go in right away.

> @@ -144,7 +145,12 @@ static void dump_csrs(const char *ctx)
>        (v & HSTATUS_SPV)  ? " SPV"  : "",
>        (v & HSTATUS_GVA)  ? " GVA"  : "");
>      X(hgatp, CSR_HGATP, "\n");
> -    X(hstateen0, CSR_HSTATEEN0, "\n");
> +
> +    if ( riscv_isa_extension_available(NULL, RISCV_ISA_EXT_smstateen) )
> +    {
> +        X(hstateen0, CSR_HSTATEEN0, "\n");
> +    }

I was going to ask for the braces to be dropped, but I notice they are
required as long as X() isn't properly adjusted. This is why even for
local use macros we should take a little more care when introducing
them, so they can be used without having to pay too close attention to
their actual implementation.

Jan

Reply via email to