On 02.02.2026 13:57, Oleksii Kurochko wrote:
> @@ -14,6 +15,12 @@ static inline void local_hfence_gvma_all(void)
> asm volatile ( "hfence.gvma zero, zero" ::: "memory" );
> }
>
> +/* Flush VS-stage TLB for current hart. */
> +static inline void flush_tlb_guest_local(void)
> +{
> + HFENCE_VVMA(0, 0);
For this use, ...
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/insn-defs.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef ASM_RISCV_INSN_DEFS_H
> +#define ASM_RISCV_INSN_DEFS_H
> +
> +#define HFENCE_VVMA(vaddr, asid) \
> + asm volatile ("hfence.vvma %0, %1" \
> + :: "r"(vaddr), "r"(asid) : "memory")
... don't you want to use "rJ" as the constraints here?
It's further not quite clear to me whether the memory clobber is really
needed. Pretty certainly not for the use in context switch, but perhaps
for other future uses it's better to be there, even if only to be on the
safe side.
Also, style nit: There are a number of blanks missing in this asm().
Jan