Skip to content

Commit ff19a8d

Browse files
Andrew Jonespalmer-dabbelt
authored andcommitted
riscv: alternatives: Rename errata_id to patch_id
Alternatives are used for both errata and cpufeatures. Use a more generic name, 'patch_id', as in "ID of code patching site", to avoid confusion when alternatives are used for cpufeatures. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Link: https://lore.kernel.org/r/20230224154601.88163-5-ajones@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent ce06b42 commit ff19a8d

6 files changed

Lines changed: 49 additions & 49 deletions

File tree

arch/riscv/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ config RISCV_ALTERNATIVE
378378
depends on !XIP_KERNEL
379379
help
380380
This Kconfig allows the kernel to automatically patch the
381-
errata required by the execution platform at run time. The
382-
code patching overhead is minimal, as it's only done once
383-
at boot and once on each module load.
381+
erratum or cpufeature required by the execution platform at run
382+
time. The code patching overhead is minimal, as it's only done
383+
once at boot and once on each module load.
384384

385385
config RISCV_ALTERNATIVE_EARLY
386386
bool

arch/riscv/errata/sifive/errata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ void __init_or_module sifive_errata_patch_func(struct alt_entry *begin,
101101
for (alt = begin; alt < end; alt++) {
102102
if (alt->vendor_id != SIFIVE_VENDOR_ID)
103103
continue;
104-
if (alt->errata_id >= ERRATA_SIFIVE_NUMBER) {
105-
WARN(1, "This errata id:%d is not in kernel errata list", alt->errata_id);
104+
if (alt->patch_id >= ERRATA_SIFIVE_NUMBER) {
105+
WARN(1, "This errata id:%d is not in kernel errata list", alt->patch_id);
106106
continue;
107107
}
108108

109-
tmp = (1U << alt->errata_id);
109+
tmp = (1U << alt->patch_id);
110110
if (cpu_req_errata & tmp) {
111111
mutex_lock(&text_mutex);
112112
patch_text_nosync(ALT_OLD_PTR(alt), ALT_ALT_PTR(alt),

arch/riscv/errata/thead/errata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al
9393
for (alt = begin; alt < end; alt++) {
9494
if (alt->vendor_id != THEAD_VENDOR_ID)
9595
continue;
96-
if (alt->errata_id >= ERRATA_THEAD_NUMBER)
96+
if (alt->patch_id >= ERRATA_THEAD_NUMBER)
9797
continue;
9898

99-
tmp = (1U << alt->errata_id);
99+
tmp = (1U << alt->patch_id);
100100
if (cpu_req_errata & tmp) {
101101
oldptr = ALT_OLD_PTR(alt);
102102
altptr = ALT_ALT_PTR(alt);

arch/riscv/include/asm/alternative-macros.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
#ifdef __ASSEMBLY__
88

9-
.macro ALT_ENTRY oldptr newptr vendor_id errata_id new_len
9+
.macro ALT_ENTRY oldptr newptr vendor_id patch_id new_len
1010
.4byte \oldptr - .
1111
.4byte \newptr - .
1212
.2byte \vendor_id
1313
.2byte \new_len
14-
.4byte \errata_id
14+
.4byte \patch_id
1515
.endm
1616

17-
.macro ALT_NEW_CONTENT vendor_id, errata_id, enable = 1, new_c : vararg
17+
.macro ALT_NEW_CONTENT vendor_id, patch_id, enable = 1, new_c : vararg
1818
.if \enable
1919
.pushsection .alternative, "a"
20-
ALT_ENTRY 886b, 888f, \vendor_id, \errata_id, 889f - 888f
20+
ALT_ENTRY 886b, 888f, \vendor_id, \patch_id, 889f - 888f
2121
.popsection
2222
.subsection 1
2323
888 :
@@ -33,21 +33,21 @@
3333
.endif
3434
.endm
3535

36-
.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
36+
.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, patch_id, enable
3737
886 :
3838
.option push
3939
.option norvc
4040
.option norelax
4141
\old_c
4242
.option pop
4343
887 :
44-
ALT_NEW_CONTENT \vendor_id, \errata_id, \enable, \new_c
44+
ALT_NEW_CONTENT \vendor_id, \patch_id, \enable, \new_c
4545
.endm
4646

47-
.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
48-
new_c_2, vendor_id_2, errata_id_2, enable_2
49-
ALTERNATIVE_CFG "\old_c", "\new_c_1", \vendor_id_1, \errata_id_1, \enable_1
50-
ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
47+
.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \
48+
new_c_2, vendor_id_2, patch_id_2, enable_2
49+
ALTERNATIVE_CFG "\old_c", "\new_c_1", \vendor_id_1, \patch_id_1, \enable_1
50+
ALT_NEW_CONTENT \vendor_id_2, \patch_id_2, \enable_2, \new_c_2
5151
.endm
5252

5353
#define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__
@@ -58,17 +58,17 @@
5858
#include <asm/asm.h>
5959
#include <linux/stringify.h>
6060

61-
#define ALT_ENTRY(oldptr, newptr, vendor_id, errata_id, newlen) \
61+
#define ALT_ENTRY(oldptr, newptr, vendor_id, patch_id, newlen) \
6262
".4byte ((" oldptr ") - .) \n" \
6363
".4byte ((" newptr ") - .) \n" \
6464
".2byte " vendor_id "\n" \
6565
".2byte " newlen "\n" \
66-
".4byte " errata_id "\n"
66+
".4byte " patch_id "\n"
6767

68-
#define ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) \
68+
#define ALT_NEW_CONTENT(vendor_id, patch_id, enable, new_c) \
6969
".if " __stringify(enable) " == 1\n" \
7070
".pushsection .alternative, \"a\"\n" \
71-
ALT_ENTRY("886b", "888f", __stringify(vendor_id), __stringify(errata_id), "889f - 888f") \
71+
ALT_ENTRY("886b", "888f", __stringify(vendor_id), __stringify(patch_id), "889f - 888f") \
7272
".popsection\n" \
7373
".subsection 1\n" \
7474
"888 :\n" \
@@ -83,30 +83,30 @@
8383
".previous\n" \
8484
".endif\n"
8585

86-
#define __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, enable) \
86+
#define __ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, enable) \
8787
"886 :\n" \
8888
".option push\n" \
8989
".option norvc\n" \
9090
".option norelax\n" \
9191
old_c "\n" \
9292
".option pop\n" \
9393
"887 :\n" \
94-
ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c)
94+
ALT_NEW_CONTENT(vendor_id, patch_id, enable, new_c)
9595

96-
#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
97-
new_c_2, vendor_id_2, errata_id_2, enable_2) \
98-
__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \
99-
ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
96+
#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \
97+
new_c_2, vendor_id_2, patch_id_2, enable_2) \
98+
__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1) \
99+
ALT_NEW_CONTENT(vendor_id_2, patch_id_2, enable_2, new_c_2)
100100

101101
#endif /* __ASSEMBLY__ */
102102

103-
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
104-
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
103+
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, CONFIG_k) \
104+
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, IS_ENABLED(CONFIG_k))
105105

106-
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
107-
new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2) \
108-
__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1), \
109-
new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
106+
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, patch_id_1, CONFIG_k_1, \
107+
new_c_2, vendor_id_2, patch_id_2, CONFIG_k_2) \
108+
__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, patch_id_1, IS_ENABLED(CONFIG_k_1), \
109+
new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2))
110110

111111
#else /* CONFIG_RISCV_ALTERNATIVE */
112112
#ifdef __ASSEMBLY__
@@ -137,19 +137,19 @@
137137

138138
/*
139139
* Usage:
140-
* ALTERNATIVE(old_content, new_content, vendor_id, errata_id, CONFIG_k)
140+
* ALTERNATIVE(old_content, new_content, vendor_id, patch_id, CONFIG_k)
141141
* in the assembly code. Otherwise,
142-
* asm(ALTERNATIVE(old_content, new_content, vendor_id, errata_id, CONFIG_k));
142+
* asm(ALTERNATIVE(old_content, new_content, vendor_id, patch_id, CONFIG_k));
143143
*
144144
* old_content: The old content which is probably replaced with new content.
145145
* new_content: The new content.
146146
* vendor_id: The CPU vendor ID.
147-
* errata_id: The errata ID.
148-
* CONFIG_k: The Kconfig of this errata. When Kconfig is disabled, the old
147+
* patch_id: The patch ID (erratum ID or cpufeature ID).
148+
* CONFIG_k: The Kconfig of this patch ID. When Kconfig is disabled, the old
149149
* content will alwyas be executed.
150150
*/
151-
#define ALTERNATIVE(old_content, new_content, vendor_id, errata_id, CONFIG_k) \
152-
_ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k)
151+
#define ALTERNATIVE(old_content, new_content, vendor_id, patch_id, CONFIG_k) \
152+
_ALTERNATIVE_CFG(old_content, new_content, vendor_id, patch_id, CONFIG_k)
153153

154154
/*
155155
* A vendor wants to replace an old_content, but another vendor has used
@@ -158,9 +158,9 @@
158158
* on the following sample code and then replace ALTERNATIVE() with
159159
* ALTERNATIVE_2() to append its customized content.
160160
*/
161-
#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
162-
new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2) \
163-
_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
164-
new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
161+
#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \
162+
new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2) \
163+
_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \
164+
new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2)
165165

166166
#endif

arch/riscv/include/asm/alternative.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ void riscv_alternative_fix_offsets(void *alt_ptr, unsigned int len,
3636
struct alt_entry {
3737
s32 old_offset; /* offset relative to original instruction or data */
3838
s32 alt_offset; /* offset relative to replacement instruction or data */
39-
u16 vendor_id; /* cpu vendor id */
39+
u16 vendor_id; /* CPU vendor ID */
4040
u16 alt_len; /* The replacement size */
41-
u32 errata_id; /* The errata id */
41+
u32 patch_id; /* The patch ID (erratum ID or cpufeature ID) */
4242
};
4343

4444
void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,

arch/riscv/kernel/cpufeature.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,13 @@ void __init_or_module riscv_cpufeature_patch_func(struct alt_entry *begin,
282282
for (alt = begin; alt < end; alt++) {
283283
if (alt->vendor_id != 0)
284284
continue;
285-
if (alt->errata_id >= RISCV_ISA_EXT_MAX) {
285+
if (alt->patch_id >= RISCV_ISA_EXT_MAX) {
286286
WARN(1, "This extension id:%d is not in ISA extension list",
287-
alt->errata_id);
287+
alt->patch_id);
288288
continue;
289289
}
290290

291-
if (!__riscv_isa_extension_available(NULL, alt->errata_id))
291+
if (!__riscv_isa_extension_available(NULL, alt->patch_id))
292292
continue;
293293

294294
oldptr = ALT_OLD_PTR(alt);

0 commit comments

Comments
 (0)