public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] riscv: Fix alternatives issues on for-next
@ 2023-02-12  2:15 Samuel Holland
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Samuel Holland @ 2023-02-12  2:15 UTC (permalink / raw)
  To: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv
  Cc: Samuel Holland, Andrew Jones, Christoph Muellner, Conor Dooley,
	Guo Ren, Heiko Stuebner, Nathan Chancellor, linux-kernel

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(-)

-- 
2.37.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] riscv: Fix early alternative patching
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
@ 2023-02-12  2:15 ` Samuel Holland
  2023-02-12 15:48   ` Conor Dooley
                     ` (2 more replies)
  2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 13+ messages in thread
From: Samuel Holland @ 2023-02-12  2:15 UTC (permalink / raw)
  To: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv
  Cc: Samuel Holland, Andrew Jones, Christoph Muellner, Conor Dooley,
	Guo Ren, Heiko Stuebner, Nathan Chancellor, linux-kernel

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 <samuel@sholland.org>
---

 arch/riscv/errata/thead/errata.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c
index c0bea5c94128..1dd90a5f86f0 100644
--- a/arch/riscv/errata/thead/errata.c
+++ b/arch/riscv/errata/thead/errata.c
@@ -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);
 		}
-- 
2.37.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] riscv: Fix Zbb alternative IDs
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
@ 2023-02-12  2:15 ` Samuel Holland
  2023-02-12 15:20   ` Conor Dooley
                     ` (2 more replies)
  2023-02-12 15:09 ` [PATCH 0/2] riscv: Fix alternatives issues on for-next Conor Dooley
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 13+ messages in thread
From: Samuel Holland @ 2023-02-12  2:15 UTC (permalink / raw)
  To: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv
  Cc: Samuel Holland, Andrew Jones, Christoph Muellner, Conor Dooley,
	Guo Ren, Heiko Stuebner, Nathan Chancellor, linux-kernel

Commit 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.

Fixes: 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 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(-)

diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
index e158439029ce..274c6f889602 100644
--- a/arch/riscv/include/asm/errata_list.h
+++ b/arch/riscv/include/asm/errata_list.h
@@ -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)						\
diff --git a/arch/riscv/lib/strcmp.S b/arch/riscv/lib/strcmp.S
index 8148b6418f61..986ab23fe787 100644
--- a/arch/riscv/lib/strcmp.S
+++ b/arch/riscv/lib/strcmp.S
@@ -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
diff --git a/arch/riscv/lib/strlen.S b/arch/riscv/lib/strlen.S
index 0f9dbf93301a..8345ceeee3f6 100644
--- a/arch/riscv/lib/strlen.S
+++ b/arch/riscv/lib/strlen.S
@@ -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
diff --git a/arch/riscv/lib/strncmp.S b/arch/riscv/lib/strncmp.S
index 7940ddab2d48..ee49595075be 100644
--- a/arch/riscv/lib/strncmp.S
+++ b/arch/riscv/lib/strncmp.S
@@ -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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] riscv: Fix alternatives issues on for-next
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
  2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
@ 2023-02-12 15:09 ` Conor Dooley
  2023-02-13  1:23 ` Guo Ren
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Conor Dooley @ 2023-02-12 15:09 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Guo Ren,
	Heiko Stuebner, Nathan Chancellor, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 686 bytes --]

Hey Samuel,

On Sat, Feb 11, 2023 at 08:15:31PM -0600, Samuel Holland 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.

On Icicle, Nezha & VisionFive 2:
Tested-by: Conor Dooley <conor.dooley@microchip.com>

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.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
  2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
@ 2023-02-12 15:20   ` Conor Dooley
  2023-02-12 16:31   ` Andrew Jones
  2023-02-13  1:19   ` Guo Ren
  2 siblings, 0 replies; 13+ messages in thread
From: Conor Dooley @ 2023-02-12 15:20 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Guo Ren,
	Heiko Stuebner, Nathan Chancellor, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3001 bytes --]

On Sat, Feb 11, 2023 at 08:15:33PM -0600, Samuel Holland wrote:
> Commit 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.
> 
> 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/20230128172856.3814-5-jszhang@kernel.org/
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  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(-)
> 
> diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
> index e158439029ce..274c6f889602 100644
> --- a/arch/riscv/include/asm/errata_list.h
> +++ b/arch/riscv/include/asm/errata_list.h
> @@ -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)						\
> diff --git a/arch/riscv/lib/strcmp.S b/arch/riscv/lib/strcmp.S
> index 8148b6418f61..986ab23fe787 100644
> --- a/arch/riscv/lib/strcmp.S
> +++ b/arch/riscv/lib/strcmp.S
> @@ -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
> diff --git a/arch/riscv/lib/strlen.S b/arch/riscv/lib/strlen.S
> index 0f9dbf93301a..8345ceeee3f6 100644
> --- a/arch/riscv/lib/strlen.S
> +++ b/arch/riscv/lib/strlen.S
> @@ -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
> diff --git a/arch/riscv/lib/strncmp.S b/arch/riscv/lib/strncmp.S
> index 7940ddab2d48..ee49595075be 100644
> --- a/arch/riscv/lib/strncmp.S
> +++ b/arch/riscv/lib/strncmp.S
> @@ -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
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] riscv: Fix early alternative patching
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
@ 2023-02-12 15:48   ` Conor Dooley
  2023-02-13  1:22   ` Guo Ren
  2023-02-13 16:46   ` Jisheng Zhang
  2 siblings, 0 replies; 13+ messages in thread
From: Conor Dooley @ 2023-02-12 15:48 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Guo Ren,
	Heiko Stuebner, Nathan Chancellor, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

On Sat, Feb 11, 2023 at 08:15:32PM -0600, Samuel Holland wrote:
> 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")

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  arch/riscv/errata/thead/errata.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c
> index c0bea5c94128..1dd90a5f86f0 100644
> --- a/arch/riscv/errata/thead/errata.c
> +++ b/arch/riscv/errata/thead/errata.c
> @@ -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);
>  		}
> -- 
> 2.37.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
  2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
  2023-02-12 15:20   ` Conor Dooley
@ 2023-02-12 16:31   ` Andrew Jones
  2023-02-13  1:19   ` Guo Ren
  2 siblings, 0 replies; 13+ messages in thread
From: Andrew Jones @ 2023-02-12 16:31 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Christoph Muellner, Conor Dooley, Guo Ren, Heiko Stuebner,
	Nathan Chancellor, linux-kernel

On Sat, Feb 11, 2023 at 08:15:33PM -0600, Samuel Holland wrote:
> Commit 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.
> 
> Fixes: 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  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(-)
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] riscv: Fix Zbb alternative IDs
  2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
  2023-02-12 15:20   ` Conor Dooley
  2023-02-12 16:31   ` Andrew Jones
@ 2023-02-13  1:19   ` Guo Ren
  2 siblings, 0 replies; 13+ messages in thread
From: Guo Ren @ 2023-02-13  1:19 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Heiko Stuebner,
	Nathan Chancellor, linux-kernel

Reviewed-by: Guo Ren <guoren@kernel.org>

On Sun, Feb 12, 2023 at 10:15 AM Samuel Holland <samuel@sholland.org> wrote:
>
> Commit 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.
>
> Fixes: 9daca9a5b9ac ("Merge patch series "riscv: improve boot time isa extensions handling"")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
>  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(-)
>
> diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
> index e158439029ce..274c6f889602 100644
> --- a/arch/riscv/include/asm/errata_list.h
> +++ b/arch/riscv/include/asm/errata_list.h
> @@ -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)                                              \
> diff --git a/arch/riscv/lib/strcmp.S b/arch/riscv/lib/strcmp.S
> index 8148b6418f61..986ab23fe787 100644
> --- a/arch/riscv/lib/strcmp.S
> +++ b/arch/riscv/lib/strcmp.S
> @@ -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
> diff --git a/arch/riscv/lib/strlen.S b/arch/riscv/lib/strlen.S
> index 0f9dbf93301a..8345ceeee3f6 100644
> --- a/arch/riscv/lib/strlen.S
> +++ b/arch/riscv/lib/strlen.S
> @@ -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
> diff --git a/arch/riscv/lib/strncmp.S b/arch/riscv/lib/strncmp.S
> index 7940ddab2d48..ee49595075be 100644
> --- a/arch/riscv/lib/strncmp.S
> +++ b/arch/riscv/lib/strncmp.S
> @@ -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
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] riscv: Fix early alternative patching
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
  2023-02-12 15:48   ` Conor Dooley
@ 2023-02-13  1:22   ` Guo Ren
  2023-02-13 16:46   ` Jisheng Zhang
  2 siblings, 0 replies; 13+ messages in thread
From: Guo Ren @ 2023-02-13  1:22 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Heiko Stuebner,
	Nathan Chancellor, linux-kernel

On Sun, Feb 12, 2023 at 10:15 AM Samuel Holland <samuel@sholland.org> wrote:
>
> 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 <samuel@sholland.org>
> ---
>
>  arch/riscv/errata/thead/errata.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c
> index c0bea5c94128..1dd90a5f86f0 100644
> --- a/arch/riscv/errata/thead/errata.c
> +++ b/arch/riscv/errata/thead/errata.c
> @@ -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);
>                 }
> --
> 2.37.4
>
Reviewed-by: Guo Ren <guoren@kernel.org>

-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] riscv: Fix alternatives issues on for-next
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
                   ` (2 preceding siblings ...)
  2023-02-12 15:09 ` [PATCH 0/2] riscv: Fix alternatives issues on for-next Conor Dooley
@ 2023-02-13  1:23 ` Guo Ren
  2023-02-15 14:56 ` Palmer Dabbelt
  2023-02-15 15:00 ` patchwork-bot+linux-riscv
  5 siblings, 0 replies; 13+ messages in thread
From: Guo Ren @ 2023-02-13  1:23 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Jisheng Zhang, Palmer Dabbelt, linux-riscv,
	Andrew Jones, Christoph Muellner, Conor Dooley, Heiko Stuebner,
	Nathan Chancellor, linux-kernel

On Sun, Feb 12, 2023 at 10:15 AM Samuel Holland <samuel@sholland.org> 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.
Great Job! Thx for fixup.

>
>
> 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(-)
>
> --
> 2.37.4
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] riscv: Fix early alternative patching
  2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
  2023-02-12 15:48   ` Conor Dooley
  2023-02-13  1:22   ` Guo Ren
@ 2023-02-13 16:46   ` Jisheng Zhang
  2 siblings, 0 replies; 13+ messages in thread
From: Jisheng Zhang @ 2023-02-13 16:46 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Heiko Stuebner, Palmer Dabbelt, linux-riscv, Andrew Jones,
	Christoph Muellner, Conor Dooley, Guo Ren, Heiko Stuebner,
	Nathan Chancellor, linux-kernel

On Sat, Feb 11, 2023 at 08:15:32PM -0600, Samuel Holland wrote:
> 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!
> 
> Fixes: 8d23e94a4433 ("riscv: switch to relative alternative entries")
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
> ---
> 
>  arch/riscv/errata/thead/errata.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c
> index c0bea5c94128..1dd90a5f86f0 100644
> --- a/arch/riscv/errata/thead/errata.c
> +++ b/arch/riscv/errata/thead/errata.c
> @@ -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);
>  		}
> -- 
> 2.37.4
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] riscv: Fix alternatives issues on for-next
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
                   ` (3 preceding siblings ...)
  2023-02-13  1:23 ` Guo Ren
@ 2023-02-15 14:56 ` Palmer Dabbelt
  2023-02-15 15:00 ` patchwork-bot+linux-riscv
  5 siblings, 0 replies; 13+ messages in thread
From: Palmer Dabbelt @ 2023-02-15 14:56 UTC (permalink / raw)
  To: Palmer Dabbelt, linux-riscv, Jisheng Zhang, Heiko Stuebner,
	Samuel Holland
  Cc: Guo Ren, Heiko Stuebner, Andrew Jones, Conor Dooley,
	Christoph Muellner, linux-kernel, Nathan Chancellor

On Sat, 11 Feb 2023 20:15:31 -0600, Samuel Holland 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
> 
> [...]

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,
-- 
Palmer Dabbelt <palmer@rivosinc.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] riscv: Fix alternatives issues on for-next
  2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
                   ` (4 preceding siblings ...)
  2023-02-15 14:56 ` Palmer Dabbelt
@ 2023-02-15 15:00 ` patchwork-bot+linux-riscv
  5 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+linux-riscv @ 2023-02-15 15:00 UTC (permalink / raw)
  To: Samuel Holland
  Cc: linux-riscv, heiko, jszhang, palmer, ajones, christoph.muellner,
	conor.dooley, guoren, heiko.stuebner, nathan, linux-kernel

Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-02-15 15:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-12  2:15 [PATCH 0/2] riscv: Fix alternatives issues on for-next Samuel Holland
2023-02-12  2:15 ` [PATCH 1/2] riscv: Fix early alternative patching Samuel Holland
2023-02-12 15:48   ` Conor Dooley
2023-02-13  1:22   ` Guo Ren
2023-02-13 16:46   ` Jisheng Zhang
2023-02-12  2:15 ` [PATCH 2/2] riscv: Fix Zbb alternative IDs Samuel Holland
2023-02-12 15:20   ` Conor Dooley
2023-02-12 16:31   ` Andrew Jones
2023-02-13  1:19   ` Guo Ren
2023-02-12 15:09 ` [PATCH 0/2] riscv: Fix alternatives issues on for-next Conor Dooley
2023-02-13  1:23 ` Guo Ren
2023-02-15 14:56 ` Palmer Dabbelt
2023-02-15 15:00 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox