On Wed, 04 Nov 2026 20:20:30 PST (-0800), [email protected] wrote:
This series adds a way to fix errata for specific cores, and adds the
first erratum.
Patch 1 adds the framework, with no errata yet:
- riscv-errata.def lists the errata. Each one has a -mfix-NAME option.
- RISCV_CORE_ERRATUM in riscv-cores.def lists the errata of a core.
- --with-errata=LIST turns on workarounds by default.
Patch 2 adds -mfix-sifive-mal-9174, which is on by default for
sifive-p870-d. It keeps the destination of a vector indexed load from
overlapping its index. The code does not change when it is off.
I plan to backport this series to GCC 16.
Tested with QEMU and our p870 bigsky board.
So you're planning on shipping the chips with the errata on boards that
make it outside SiFive? If that's the case we probably want workarounds
for this all over the place: at least something to plumb it through the
Linux errata frameworks so userspace can see they're running on one of
these systems, which we should probably hook into something like
-march=native so that keeps working. We could probably also detect this
case during trap handling in Linux and show some sort of warning, which
would help users find bugs more quickly.
I don't think we need to block this on the rest of that support, though.
Having the codegen in is the hard part, the rest is just cosmetic.
Kito Cheng (2):
RISC-V: Add per-CPU errata framework
RISC-V: Work around SiFive erratum MAL-9174
gcc/config.gcc | 19 +++++
gcc/config/riscv/riscv-cores.def | 15 +++-
gcc/config/riscv/riscv-errata.def | 35 +++++++++
gcc/config/riscv/riscv-opts.h | 13 ++++
gcc/config/riscv/riscv.cc | 71 +++++++++++++++++++
gcc/config/riscv/riscv.h | 1 +
gcc/config/riscv/riscv.md | 9 +++
gcc/config/riscv/riscv.opt | 4 ++
gcc/config/riscv/vector.md | 34 +++++----
gcc/doc/install.texi | 12 ++++
gcc/doc/invoke.texi | 20 ++++++
.../riscv/rvv/base/sifive-mal-9174-1.c | 46 ++++++++++++
.../riscv/rvv/base/sifive-mal-9174-2.c | 46 ++++++++++++
.../riscv/rvv/base/sifive-mal-9174-3.c | 46 ++++++++++++
.../riscv/rvv/base/sifive-mal-9174-4.c | 46 ++++++++++++
15 files changed, 402 insertions(+), 15 deletions(-)
create mode 100644 gcc/config/riscv/riscv-errata.def
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/sifive-mal-9174-1.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/sifive-mal-9174-2.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/sifive-mal-9174-3.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/sifive-mal-9174-4.c
base-commit: 08f84a62a4cf141bbe391ff8c670ac16c99b1f42