public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
From: Luis Gerhorst <luis.gerhorst@fau.de>
To: Samuel Holland <samuel.holland@sifive.com>
Cc: Lukas Gerlach <lukas.gerlach@cispa.de>,
	 ast@kernel.org, bjorn@kernel.org,  bpf@vger.kernel.org,
	 daniel.weber@cispa.de, daniel@iogearbox.net,
	 jo.vanbulck@kuleuven.be, linux-riscv@lists.infradead.org,
	 luke.r.nels@gmail.com, marton.bognar@kuleuven.be,
	 michael.schwarz@cispa.de, palmer@dabbelt.com,  pjw@kernel.org,
	 xi.wang@gmail.com, cleger@rivosinc.com,  palmer@rivosinc.com,
	 conor.dooley@microchip.com, andrew@sifive.com
Subject: Re: [PATCH] riscv, bpf: Emit fence.i for BPF_NOSPEC
Date: Thu, 08 Jan 2026 11:05:06 +0100	[thread overview]
Message-ID: <875x9czagd.fsf@fau.de> (raw)
In-Reply-To: <06ac0b87-d398-4cb0-a614-760bfe41cf7f@sifive.com> (Samuel Holland's message of "Wed, 7 Jan 2026 17:30:02 -0600")

Samuel Holland <samuel.holland@sifive.com> writes:

> The Zifencei extension is no longer a mandatory part of the ISA, but it is
> mandatory for Linux. Linux requires at least "rv32ima or rv64ima, as defined by
> version 2.2 of the user ISA and version 1.10 of the privileged ISA".
>
> Notably, in version 2.2 of the user ISA, the Zifencei extension was still an
> unnamed subset of the I extension, so it is included in the above requirement.
> It was later removed from the I extension and given its own name, which is why
> we have weirdness like the code below. (You can see in arch/riscv/Makefile where
> we unconditionally add either ISA version 2.2 or Zifencei to CFLAGS.)
>
>> RISC-V cpufeature.c had this in [2]:
>> 
>> 		/*
>> 		 * Linux requires the following extensions, so we may as well
>> 		 * always set them.
>> 		 */
>> 		set_bit(RISCV_ISA_EXT_ZICSR, this_isa);
>> 		set_bit(RISCV_ISA_EXT_ZIFENCEI, this_isa);
>> 
>> But as of [1] it was changed to:
>> 
>> 		if (acpi_disabled) {
>> 			set_bit(RISCV_ISA_EXT_ZICSR, source_isa);
>> 			set_bit(RISCV_ISA_EXT_ZIFENCEI, source_isa);
>> 
>> So based on that I would assume fence.i may not always be supported.
>
> This is just a quirk of the parsing code. As mentioned in [1], older devicetrees
> were written while Zifencei was an implicit part of I, so we don't expect it to
> appear in the devicetree. The ACPI table definition was written after Zifencei
> was a separate extension, so we do expect Zifencei to appear on its own in the
> ACPI table. But it is still required. (We don't currently check that all
> extensions required by the kernel are actually present; this will be done as
> part of the RVA23 enablement.)
>
>> But I also found that 921ebd8f2c08 ("RISC-V: Allow userspace to flush
>> the instruction cache") seems to assume that fence.i always works (see
>> local_flush_icache_all() which I assume runs in the kernel).
>
> Yes, the kernel definitely won't run if fence.i is missing, so we don't need to
> worry about such hardware. We could probably document this better.

Thanks for clarifying this! In that case the patch looks good to me.

I assume some testing has been done to ensure the instruction coding
works. (I think the eBPF CI does not have RISC-V yet but [1] previously
worked fine for me.)

Acked-by: Luis Gerhorst <luis.gerhorst@fau.de>

[1] https://github.com/pulehui/riscv-bpf-vmtest

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2026-01-08 10:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-28 17:37 [PATCH] riscv, bpf: Emit fence.i for BPF_NOSPEC Lukas Gerlach
2026-01-05 23:28 ` Paul Walmsley
2026-01-06  8:44   ` [PATCH] riscv, bpf: add a speculation barrier " Lukas Gerlach
2026-01-07  8:26     ` Luis Gerhorst
2026-01-07  9:54       ` [PATCH] riscv, bpf: Emit fence.i " Lukas Gerlach
2026-01-07 17:52         ` Luis Gerhorst
2026-01-07 23:30           ` Samuel Holland
2026-01-08 10:05             ` Luis Gerhorst [this message]
2026-01-09  3:41 ` Bo Gan
2026-01-09  5:36   ` [tech-speculation-barriers] " Stefan O'Rear
2026-01-12 16:19     ` Luis Gerhorst
2026-01-12 18:33 ` Bo Gan
2026-01-13  1:51   ` Paul Walmsley
2026-01-15 13:13     ` Lukas Gerlach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875x9czagd.fsf@fau.de \
    --to=luis.gerhorst@fau.de \
    --cc=andrew@sifive.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=cleger@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=daniel.weber@cispa.de \
    --cc=daniel@iogearbox.net \
    --cc=jo.vanbulck@kuleuven.be \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lukas.gerlach@cispa.de \
    --cc=luke.r.nels@gmail.com \
    --cc=marton.bognar@kuleuven.be \
    --cc=michael.schwarz@cispa.de \
    --cc=palmer@dabbelt.com \
    --cc=palmer@rivosinc.com \
    --cc=pjw@kernel.org \
    --cc=samuel.holland@sifive.com \
    --cc=xi.wang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox