Re: [PATCH v3 4/5] riscv: compat_vdso: Build with zacas if available

From: Vivian Wang

Date: Fri Jul 17 2026 - 08:41:27 EST


Hi Nam,

On 7/17/26 16:06, Nam Cao wrote:

> The compat vdso Makefile does not enable zacas, disallowing source
> files from using zacas instructions. This is an obstacle to adding
> robust __vdso_futex_robust_list32_try_unlock() in a follow-up commit.
>
> Build with zacas, if compiler supports it.
>
> Signed-off-by: Nam Cao <namcao@xxxxxxxxxxxxx>
> ---
> arch/riscv/kernel/compat_vdso/Makefile | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/compat_vdso/Makefile
> index 63580b33e3ce..ffbf84aeb081 100644
> --- a/arch/riscv/kernel/compat_vdso/Makefile
> +++ b/arch/riscv/kernel/compat_vdso/Makefile
> @@ -18,6 +18,10 @@ else
> COMPAT_MARCH := rv32imafd
> endif
>
> +ifneq ($(call cc-option,-mabi=ilp32 -march=rv32ima_zacas),)
> +COMPAT_MARCH := $(COMPAT_MARCH)_zacas
> +endif
> +

I'm wondering if you would be interested in using .option arch, +zacas
for this, instead of enabling it for everything. 

I recently found out that we add and *only* add Zacas and Zabha to the
global -march for kernel code, just for use in assembly code in
arch/riscv/include/asm/cmpxchg.h.

So this is *probably* not a correctness problem, since compilers
probably don't do atomics on their own accord. However, I personally
think it would be a good idea to make everything consistently use
.option arch. This makes it so there's no question on what to do to get
extension instructions in assembly code - you always do. I have a patch
WIP that would make cmpxchg.h use .option arch as well that I will send
shortly.

You would need to write some more boilerplate:

.option push
.option arch, +zacas
amocas.w.rl ...
.option pop

Compilation of this code needs to be guarded behind something like if
(IS_ENABLED(CONFIG_RISCV_ISA_ZABHA)), which AFAICT your code does.

But in exchange for this boilerplate, it would be consistent with stuff
like Zbb, and there would be no more need to be plumbing -march around
in Makefiles.

What do you think?

Vivian "dramforever" Wang