riscv: Fix alternatives issues on for-next
cover riscv: Fix alternatives issues on for-next
Several people have reported that D1 fails to boot on linux-next. Patch 1 fixes a bug where early alternative patching used the wrong address. Patch 2 fixes a separate issue where the Zbb alternatives are incorrectly applied based on the 'C' extension instead of Zbb.
Samuel Holland (2):
riscv: Fix early alternative patching
riscv: Fix Zbb alternative IDs
arch/riscv/errata/thead/errata.c | 4 +--- arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-)
Signature · 1 line
2.37.4
PATCH 1/2 riscv: Fix early alternative patching
Now that the text to patch is located using a relative offset from the alternative entry, the text address should be computed without applying the kernel mapping offset, both before and after VM setup.
---
arch/riscv/errata/thead/errata.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/riscv/errata/thead/errata.c +1 -3
@@ -102,9 +102,7 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al/* On vm-alternatives, the mmu isn't running yet */ if (stage ==RISCV_ALTERNATIVES_EARLY_BOOT ) -memcpy ((void *)__pa_symbol (oldptr), - (void *)__pa_symbol (altptr), - alt->alt_len); +memcpy (oldptr, altptr, alt->alt_len);else patch_text_nosync (oldptr, altptr, alt->alt_len); }
Signature · 1 line
2.37.4
Re: [PATCH 1/2] riscv: Fix early alternative patching
Quoted 5 lines · Samuel Holland
Now that the text to patch is located using a relative offset from the alternative entry, the text address should be computed without applying the kernel mapping offset, both before and after VM setup.
Fixes 8d23e94a4433 ("riscv: switch to relative alternative entries")
Quoted 24 lines
Signed-off-by Samuel Holland <[email protected]>---
arch/riscv/errata/thead/errata.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/riscv/errata/thead/errata.c +1
-3@@ -102,9 +102,7 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al/* On vm-alternatives, the mmu isn't running yet */ if (stage ==RISCV_ALTERNATIVES_EARLY_BOOT ) -memcpy ((void *)__pa_symbol (oldptr), - (void *)__pa_symbol (altptr), - alt->alt_len); +memcpy (oldptr, altptr, alt->alt_len);else patch_text_nosync (oldptr, altptr, alt->alt_len); }Signature · 1 line
2.37.4
Re: [PATCH 1/2] riscv: Fix early alternative patching
In reply to Samuel HollandQuoted 28 lines · Samuel Holland
Now that the text to patch is located using a relative offset from the alternative entry, the text address should be computed without applying the kernel mapping offset, both before and after VM setup.
Fixes 8d23e94a4433 ("riscv: switch to relative alternative entries")Signed-off-by Samuel Holland <[email protected]>---
arch/riscv/errata/thead/errata.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/riscv/errata/thead/errata.c +1
-4@@ -102,9 +102,7 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al/* On vm-alternatives, the mmu isn't running yet */ if (stage ==RISCV_ALTERNATIVES_EARLY_BOOT ) -memcpy ((void *)__pa_symbol (oldptr), - (void *)__pa_symbol (altptr), - alt->alt_len); +memcpy (oldptr, altptr, alt->alt_len);else patch_text_nosync (oldptr, altptr, alt->alt_len); } --
Quoted 2 lines
2.37.4
Signature · 2 lines
Best Regards Guo Ren
Re: [PATCH 1/2] riscv: Fix early alternative patching
In reply to Samuel HollandQuoted 3 lines · Samuel Holland
Now that the text to patch is located using a relative offset from the alternative entry, the text address should be computed without applying the kernel mapping offset, both before and after VM setup.
Good catch!
Quoted 3 lines
Fixes 8d23e94a4433 ("riscv: switch to relative alternative entries")Signed-off-by Samuel Holland <[email protected]>
Quoted 23 lines
---
arch/riscv/errata/thead/errata.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/riscv/errata/thead/errata.c +1
-3@@ -102,9 +102,7 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al/* On vm-alternatives, the mmu isn't running yet */ if (stage ==RISCV_ALTERNATIVES_EARLY_BOOT ) -memcpy ((void *)__pa_symbol (oldptr), - (void *)__pa_symbol (altptr), - alt->alt_len); +memcpy (oldptr, altptr, alt->alt_len);else patch_text_nosync (oldptr, altptr, alt->alt_len); }Signature · 1 line
2.37.4
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 2/2 riscv: Fix Zbb alternative IDs
In reply to Samuel HollandCommit 4bf8860760d9 ("riscv: cpufeature: extend riscv_cpufeature_patch_func to all ISA extensions") switched ISA extension alternatives to use the RISCV_ISA_EXT_* macros instead of CPUFEATURE_*. This was mismerged when applied on top of the Zbb series, so the Zbb alternatives referenced the wrong errata ID values.
---
arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-)
arch/riscv/include/asm/errata_list.h +0 -5
@@ -23,11 +23,6 @@#define ERRATA_THEAD_NUMBER 3#endif -#define CPUFEATURE_SVPBMT 0 -#define CPUFEATURE_ZICBOM 1 -#define CPUFEATURE_ZBB 2 -#define CPUFEATURE_NUMBER 3 -#ifdef __ASSEMBLY__#define ALT_INSN_FAULT (x) \
arch/riscv/lib/strcmp.S +1 -1
@@ -9,7 +9,7 @@ /* int strcmp(const char *cs, const char *ct) */ SYM_FUNC_START(strcmp) - ALTERNATIVE("nop", "j strcmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strcmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returns
arch/riscv/lib/strlen.S +1 -1
@@ -9,7 +9,7 @@ /* int strlen(const char *s) */ SYM_FUNC_START(strlen) - ALTERNATIVE("nop", "j strlen_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strlen_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returns
arch/riscv/lib/strncmp.S +1 -1
@@ -9,7 +9,7 @@ /* int strncmp(const char *cs, const char *ct, size_t count) */ SYM_FUNC_START(strncmp) - ALTERNATIVE("nop", "j strncmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strncmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returns
Signature · 1 line
2.37.4
Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
Quoted 7 lines · Samuel Holland
Commit
4bf8860760d9("riscv: cpufeature: extendriscv_cpufeature_patch_functo all ISA extensions") switched ISA extension alternatives to use the RISCV_ISA_EXT_* macros instead of CPUFEATURE_*. This was mismerged when applied on top of the Zbb series, so the Zbb alternatives referenced the wrong errata ID values.Fixes 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")
Re: your question on irc, I think you did the right thing here as Jisheng did remove them in his series:
https://lore.kernel.org/linux-riscv/[email protected]/
Quoted 67 lines
Signed-off-by Samuel Holland <[email protected]>---
arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-)arch/riscv/include/asm/errata_list.h +0
-5@@ -23,11 +23,6 @@#define ERRATA_THEAD_NUMBER 3#endif -#define CPUFEATURE_SVPBMT 0 -#define CPUFEATURE_ZICBOM 1 -#define CPUFEATURE_ZBB 2 -#define CPUFEATURE_NUMBER 3 -#ifdef __ASSEMBLY__#define ALT_INSN_FAULT (x) \arch/riscv/lib/strcmp.S +1
-1@@ -9,7 +9,7 @@ /* int strcmp(const char *cs, const char *ct) */ SYM_FUNC_START(strcmp) - ALTERNATIVE("nop", "j strcmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strcmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returnsarch/riscv/lib/strlen.S +1
-1@@ -9,7 +9,7 @@ /* int strlen(const char *s) */ SYM_FUNC_START(strlen) - ALTERNATIVE("nop", "j strlen_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strlen_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returnsarch/riscv/lib/strncmp.S +1
-1@@ -9,7 +9,7 @@ /* int strncmp(const char *cs, const char *ct, size_t count) */ SYM_FUNC_START(strncmp) - ALTERNATIVE("nop", "j strncmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strncmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * ReturnsSignature · 1 line
2.37.4
Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
In reply to Samuel HollandQuoted 8 lines · Samuel Holland
Commit
4bf8860760d9("riscv: cpufeature: extendriscv_cpufeature_patch_functo all ISA extensions") switched ISA extension alternatives to use the RISCV_ISA_EXT_* macros instead of CPUFEATURE_*. This was mismerged when applied on top of the Zbb series, so the Zbb alternatives referenced the wrong errata ID values.Fixes 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")Signed-off-by Samuel Holland <[email protected]>
Quoted 8 lines
---
arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-)
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
In reply to Samuel HollandQuoted 75 lines · Samuel Holland
Commit
4bf8860760d9("riscv: cpufeature: extendriscv_cpufeature_patch_functo all ISA extensions") switched ISA extension alternatives to use the RISCV_ISA_EXT_* macros instead of CPUFEATURE_*. This was mismerged when applied on top of the Zbb series, so the Zbb alternatives referenced the wrong errata ID values.Fixes 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")Signed-off-by Samuel Holland <[email protected]>---
arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-)arch/riscv/include/asm/errata_list.h +0
-5@@ -23,11 +23,6 @@#define ERRATA_THEAD_NUMBER 3#endif -#define CPUFEATURE_SVPBMT 0 -#define CPUFEATURE_ZICBOM 1 -#define CPUFEATURE_ZBB 2 -#define CPUFEATURE_NUMBER 3 -#ifdef __ASSEMBLY__#define ALT_INSN_FAULT (x) \arch/riscv/lib/strcmp.S +1
-1@@ -9,7 +9,7 @@ /* int strcmp(const char *cs, const char *ct) */ SYM_FUNC_START(strcmp) - ALTERNATIVE("nop", "j strcmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strcmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returnsarch/riscv/lib/strlen.S +1
-1@@ -9,7 +9,7 @@ /* int strlen(const char *s) */ SYM_FUNC_START(strlen) - ALTERNATIVE("nop", "j strlen_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strlen_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returnsarch/riscv/lib/strncmp.S +1
-2@@ -9,7 +9,7 @@ /* int strncmp(const char *cs, const char *ct, size_t count) */ SYM_FUNC_START(strncmp) - ALTERNATIVE("nop", "j strncmp_zbb", 0, CPUFEATURE_ZBB, CONFIG_RISCV_ISA_ZBB) + ALTERNATIVE("nop", "j strncmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) /* * Returns --2.37.4
Signature · 2 lines
Best Regards Guo Ren
Hey Samuel,
Quoted 4 lines · Samuel Holland
Several people have reported that D1 fails to boot on linux-next. Patch 1 fixes a bug where early alternative patching used the wrong address. Patch 2 fixes a separate issue where the Zbb alternatives are incorrectly applied based on the 'C' extension instead of Zbb.
On Icicle, Nezha & VisionFive 2:
I was really curious why my CI didn't catch this, but I think boot on Icicle wasn't broken as the toolchains pre-date Zbb and therefore it isn't even compiled in.
And the VisionFive 2 doesn't care as it has Zbb.
Thanks for the fixes :)
Conor.
Quoted 5 lines · Samuel Holland
Several people have reported that D1 fails to boot on linux-next. Patch 1 fixes a bug where early alternative patching used the wrong address. Patch 2 fixes a separate issue where the Zbb alternatives are incorrectly applied based on the 'C' extension instead of Zbb.
Great Job! Thx for fixup.
Quoted 16 lines
Samuel Holland (2):
riscv: Fix early alternative patching
riscv: Fix Zbb alternative IDsarch/riscv/errata/thead/errata.c | 4 +--- arch/riscv/include/asm/errata_list.h | 5 ----- arch/riscv/lib/strcmp.S | 2 +- arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/strncmp.S | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-)--
2.37.4
Signature · 2 lines
Best Regards Guo Ren
Palmer Dabbelt
AppliedQuoted 11 lines · Samuel Holland
Several people have reported that D1 fails to boot on linux-next. Patch 1 fixes a bug where early alternative patching used the wrong address. Patch 2 fixes a separate issue where the Zbb alternatives are incorrectly applied based on the 'C' extension instead of Zbb.
Samuel Holland (2):
riscv: Fix early alternative patching
riscv: Fix Zbb alternative IDs[...]
Applied, thanks!
[1/2] riscv: Fix early alternative patching
https://git.kernel.org/palmer/c/bfd6fc5d8014 [2/2] riscv: Fix Zbb alternative IDs https://git.kernel.org/palmer/c/d5a7fab7859d
Best regards,
Signature · 6 lines
Palmer Dabbelt <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Quoted 11 lines · On Sat, 11 Feb 2023 20:15:31 -0600 you wrote:
Several people have reported that D1 fails to boot on linux-next. Patch 1 fixes a bug where early alternative patching used the wrong address. Patch 2 fixes a separate issue where the Zbb alternatives are incorrectly applied based on the 'C' extension instead of Zbb.
Samuel Holland (2):
riscv: Fix early alternative patching
riscv: Fix Zbb alternative IDs[...]
Here is the summary with links:
- [1/2] riscv: Fix early alternative patching
https://git.kernel.org/riscv/c/bfd6fc5d8014 - [2/2] riscv: Fix Zbb alternative IDs https://git.kernel.org/riscv/c/d5a7fab7859d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html