Re: [PATCH] riscv: cfi: parse riscv_nousercfi before riscv_fill_hwcap()

From: Radim Krčmář

Date: Wed Nov 18 2026 - 15:21:13 EST


2026-11-08T04:42:01-05:00, Guodong Xu <guodong.xu@xxxxxxxxxxxxxxxx>:
> ISA bitmaps don't honour riscv_nousercfi because the ISA bitmaps are
> composed during setup_arch(), while riscv_nousercfi is a __setup()
> parameter, and those are parsed from start_kernel() after setup_arch()
> has returned.
>
> As a consequence, the riscv_nousercfi test in riscv_cfilp_validate() and
> riscv_cfiss_validate() always sees zero, and Zicfilp and Zicfiss stay in
> the ISA bitmaps even when user CFI is disabled on the kernel command
> line.

(I thought that was the intention.)

riscv_nousercfi definintely should disable the hwprobe reporting of
those features (my series did that), and prevent their enablement in
user-mode.

Why disable Zicfilp and Zicfiss in the ISA bitmaps by setting nousercfi,
though? Aren't the validate functions just misusing riscv_nousercfi
instead of defining a clear detection mechanism?

I think the ISA bitmaps should consider whether Linux has the
extensions, which with standard SBI means a successfuly executed FWFT
set/get.

Linux can then use the ISA bitmap to decide whether to use CFI for
kernel code, allow it in KVM guests, report it as available hardware
feature, or allow it in user mode.

nousercfi seems like it should only restrict use of CFI in user mode.

Thanks.