From: Bo Gan <ganboing@gmail.com>
To: linux-riscv@lists.infradead.org, samuel.holland@sifive.com,
david@redhat.com, palmer@dabbelt.com, pjw@kernel.org,
gaohan@iscas.ac.cn, me@ziyao.cc
Cc: lizhi2@eswincomputing.com, hal.feng@starfivetech.com,
marcel@ziswiler.com, conor@kernel.org, kernel@esmil.dk,
devicetree@vger.kernel.org
Subject: [RFC PATCH v2 2/3] riscv: errata: sifive: support auipc/load pair in patched alternatives
Date: Sun, 15 Mar 2026 23:03:27 -0700 [thread overview]
Message-ID: <20260316060328.1173634-3-ganboing@gmail.com> (raw)
In-Reply-To: <20260316060328.1173634-1-ganboing@gmail.com>
Enhance the errata/sifive patching function to support auipc/load
insn pair by fixing the offsets in immediate, just like in function
`riscv_cpufeature_patch_func`. Refer to commit 27c653c06505
("RISC-V: fix auipc-jalr addresses in patched alternatives")
Signed-off-by: Bo Gan <ganboing@gmail.com>
---
arch/riscv/errata/sifive/errata.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/errata/sifive/errata.c b/arch/riscv/errata/sifive/errata.c
index d0c61f86cba33..f26c997e04e59 100644
--- a/arch/riscv/errata/sifive/errata.c
+++ b/arch/riscv/errata/sifive/errata.c
@@ -80,6 +80,7 @@ void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
unsigned int stage)
{
struct alt_entry *alt;
+ void *oldptr, *altptr;
u32 cpu_req_errata;
u32 tmp;
@@ -100,9 +101,12 @@ void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
tmp = (1U << alt->patch_id);
if (cpu_req_errata & tmp) {
+ oldptr = ALT_OLD_PTR(alt);
+ altptr = ALT_ALT_PTR(alt);
+
mutex_lock(&text_mutex);
- patch_text_nosync(ALT_OLD_PTR(alt), ALT_ALT_PTR(alt),
- alt->alt_len);
+ patch_text_nosync(oldptr, altptr, alt->alt_len);
+ riscv_alternative_fix_offsets(oldptr, alt->alt_len, oldptr - altptr);
mutex_unlock(&text_mutex);
}
}
--
2.34.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-03-16 6:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 6:03 [RFC PATCH v2 0/3] riscv: support EIC770X/JH7110 noncoherent devices with XPbmtUC Bo Gan
2026-03-16 6:03 ` [RFC PATCH v2 1/3] riscv: alternatives: support auipc+load pair Bo Gan
2026-03-16 6:03 ` Bo Gan [this message]
2026-03-16 6:03 ` [RFC PATCH v2 3/3] riscv: errata: sifive: Add an "errata" to simulate Svpbmt on cores without Bo Gan
2026-03-23 23:08 ` [RFC PATCH v2 0/3] riscv: support EIC770X/JH7110 noncoherent devices with XPbmtUC Bo Gan
2026-03-24 17:49 ` Conor Dooley
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=20260316060328.1173634-3-ganboing@gmail.com \
--to=ganboing@gmail.com \
--cc=conor@kernel.org \
--cc=david@redhat.com \
--cc=devicetree@vger.kernel.org \
--cc=gaohan@iscas.ac.cn \
--cc=hal.feng@starfivetech.com \
--cc=kernel@esmil.dk \
--cc=linux-riscv@lists.infradead.org \
--cc=lizhi2@eswincomputing.com \
--cc=marcel@ziswiler.com \
--cc=me@ziyao.cc \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.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