All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2021-07-20 14:44 ` Ben Dooks
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2021-07-20 14:44 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: paul.walmsley, palmer, aou, Ben Dooks, Bin Meng

When trying to load modules built for RISC-V which include assembly files
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

The R_RISCV_ALIGN relocations can be removed at the expense of code space
by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
("RISC-V: Fixes to module loading") -mno-relax is added to the build
variable KBUILD_CFLAGS_MODULE. See [1] for more info.

The issue is that when kbuild builds a .S file, it invokes gcc with
the -mno-relax flag, but this is not being passed through to the
assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
the assembler is invoked correctly. This may have now been fixed in
gcc[2] and this addition should not stop newer gcc and as from working.

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Notes:

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 1f5c03082976..fca40511a8c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.30.2


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

* [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2021-07-20 14:44 ` Ben Dooks
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2021-07-20 14:44 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: paul.walmsley, palmer, aou, Ben Dooks, Bin Meng

When trying to load modules built for RISC-V which include assembly files
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

The R_RISCV_ALIGN relocations can be removed at the expense of code space
by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
("RISC-V: Fixes to module loading") -mno-relax is added to the build
variable KBUILD_CFLAGS_MODULE. See [1] for more info.

The issue is that when kbuild builds a .S file, it invokes gcc with
the -mno-relax flag, but this is not being passed through to the
assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
the assembler is invoked correctly. This may have now been fixed in
gcc[2] and this addition should not stop newer gcc and as from working.

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Notes:

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 1f5c03082976..fca40511a8c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.30.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
  2021-07-20 14:44 ` Ben Dooks
@ 2021-08-10  8:49   ` Ben Dooks
  -1 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2021-08-10  8:49 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: paul.walmsley, palmer, aou, Bin Meng

On 20/07/2021 15:44, Ben Dooks wrote:
> When trying to load modules built for RISC-V which include assembly files
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
> 
> The R_RISCV_ALIGN relocations can be removed at the expense of code space
> by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
> ("RISC-V: Fixes to module loading") -mno-relax is added to the build
> variable KBUILD_CFLAGS_MODULE. See [1] for more info.
> 
> The issue is that when kbuild builds a .S file, it invokes gcc with
> the -mno-relax flag, but this is not being passed through to the
> assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
> the assembler is invoked correctly. This may have now been fixed in
> gcc[2] and this addition should not stop newer gcc and as from working.
> 
> [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
> [2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Just wanted to check v2 is fine for merging, and if so when is that
likely to be?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2021-08-10  8:49   ` Ben Dooks
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2021-08-10  8:49 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: paul.walmsley, palmer, aou, Bin Meng

On 20/07/2021 15:44, Ben Dooks wrote:
> When trying to load modules built for RISC-V which include assembly files
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
> 
> The R_RISCV_ALIGN relocations can be removed at the expense of code space
> by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
> ("RISC-V: Fixes to module loading") -mno-relax is added to the build
> variable KBUILD_CFLAGS_MODULE. See [1] for more info.
> 
> The issue is that when kbuild builds a .S file, it invokes gcc with
> the -mno-relax flag, but this is not being passed through to the
> assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
> the assembler is invoked correctly. This may have now been fixed in
> gcc[2] and this addition should not stop newer gcc and as from working.
> 
> [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
> [2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Just wanted to check v2 is fine for merging, and if so when is that
likely to be?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
  2022-07-25 11:38   ` Ben Dooks
@ 2022-07-25 11:42     ` Conor.Dooley
  0 siblings, 0 replies; 10+ messages in thread
From: Conor.Dooley @ 2022-07-25 11:42 UTC (permalink / raw)
  To: ben.dooks, palmer; +Cc: linux-kernel, linux-riscv

On 25/07/2022 12:38, Ben Dooks wrote:
> On 21/07/2022 20:53, Palmer Dabbelt wrote:
>> On Sun, 29 May 2022 08:22:00 PDT (-0700), ben.dooks@codethink.co.uk wrote:
> 
> [nip
> 
>>>  # GCC versions that support the "-mstrict-align" option default to allowing
>>>  # unaligned accesses.  While unaligned accesses are explicitly allowed in the
>>
>> Sorry for being so slow here, I've gotten pretty buried and it wasn't clear this was a fix.  I put it in fixes with some tags.
> 
> Is it time for linux-riscv list to have a patch tracker on? This might
> help with tracking patches for everyone.

https://patchwork.kernel.org/project/linux-riscv/list/

Just isn't used at all from what I can see.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
  2022-07-21 19:53   ` Palmer Dabbelt
  (?)
@ 2022-07-25 11:38   ` Ben Dooks
  2022-07-25 11:42     ` Conor.Dooley
  -1 siblings, 1 reply; 10+ messages in thread
From: Ben Dooks @ 2022-07-25 11:38 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: linux-kernel, linux-riscv

On 21/07/2022 20:53, Palmer Dabbelt wrote:
> On Sun, 29 May 2022 08:22:00 PDT (-0700), ben.dooks@codethink.co.uk wrote:

[nip

>>  # GCC versions that support the "-mstrict-align" option default to 
>> allowing
>>  # unaligned accesses.  While unaligned accesses are explicitly 
>> allowed in the
> 
> Sorry for being so slow here, I've gotten pretty buried and it wasn't 
> clear this was a fix.  I put it in fixes with some tags.

Is it time for linux-riscv list to have a patch tracker on? This might
help with tracking patches for everyone.


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
  2022-05-29 15:22 ` Ben Dooks
@ 2022-07-21 19:53   ` Palmer Dabbelt
  -1 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-07-21 19:53 UTC (permalink / raw)
  To: ben.dooks
  Cc: linux-kernel, linux-riscv, aou, linux-kernel, ben.dooks, Bin Meng

On Sun, 29 May 2022 08:22:00 PDT (-0700), ben.dooks@codethink.co.uk wrote:
> When trying to load modules built for RISC-V which include assembly files
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
>
> The R_RISCV_ALIGN relocations can be removed at the expense of code space
> by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
> ("RISC-V: Fixes to module loading") -mno-relax is added to the build
> variable KBUILD_CFLAGS_MODULE. See [1] for more info.
>
> The issue is that when kbuild builds a .S file, it invokes gcc with
> the -mno-relax flag, but this is not being passed through to the
> assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
> the assembler is invoked correctly. This may have now been fixed in
> gcc[2] and this addition should not stop newer gcc and as from working.
>
> [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
> [2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857
>
> Notes:
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>  arch/riscv/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 1f5c03082976..fca40511a8c6 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
>  endif
>
>  KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
> +KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
>
>  # GCC versions that support the "-mstrict-align" option default to allowing
>  # unaligned accesses.  While unaligned accesses are explicitly allowed in the

Sorry for being so slow here, I've gotten pretty buried and it wasn't 
clear this was a fix.  I put it in fixes with some tags.

Thanks!

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

* Re: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2022-07-21 19:53   ` Palmer Dabbelt
  0 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-07-21 19:53 UTC (permalink / raw)
  To: ben.dooks
  Cc: linux-kernel, linux-riscv, aou, linux-kernel, ben.dooks, Bin Meng

On Sun, 29 May 2022 08:22:00 PDT (-0700), ben.dooks@codethink.co.uk wrote:
> When trying to load modules built for RISC-V which include assembly files
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
>
> The R_RISCV_ALIGN relocations can be removed at the expense of code space
> by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
> ("RISC-V: Fixes to module loading") -mno-relax is added to the build
> variable KBUILD_CFLAGS_MODULE. See [1] for more info.
>
> The issue is that when kbuild builds a .S file, it invokes gcc with
> the -mno-relax flag, but this is not being passed through to the
> assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
> the assembler is invoked correctly. This may have now been fixed in
> gcc[2] and this addition should not stop newer gcc and as from working.
>
> [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
> [2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857
>
> Notes:
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>  arch/riscv/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 1f5c03082976..fca40511a8c6 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
>  endif
>
>  KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
> +KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
>
>  # GCC versions that support the "-mstrict-align" option default to allowing
>  # unaligned accesses.  While unaligned accesses are explicitly allowed in the

Sorry for being so slow here, I've gotten pretty buried and it wasn't 
clear this was a fix.  I put it in fixes with some tags.

Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2022-05-29 15:22 ` Ben Dooks
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2022-05-29 15:22 UTC (permalink / raw)
  To: linux-kernel, linux-riscv; +Cc: palmer, aou, linux-kernel, Ben Dooks, Bin Meng

When trying to load modules built for RISC-V which include assembly files
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

The R_RISCV_ALIGN relocations can be removed at the expense of code space
by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
("RISC-V: Fixes to module loading") -mno-relax is added to the build
variable KBUILD_CFLAGS_MODULE. See [1] for more info.

The issue is that when kbuild builds a .S file, it invokes gcc with
the -mno-relax flag, but this is not being passed through to the
assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
the assembler is invoked correctly. This may have now been fixed in
gcc[2] and this addition should not stop newer gcc and as from working.

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Notes:

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 1f5c03082976..fca40511a8c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents
@ 2022-05-29 15:22 ` Ben Dooks
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2022-05-29 15:22 UTC (permalink / raw)
  To: linux-kernel, linux-riscv; +Cc: palmer, aou, linux-kernel, Ben Dooks, Bin Meng

When trying to load modules built for RISC-V which include assembly files
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

The R_RISCV_ALIGN relocations can be removed at the expense of code space
by adding -mno-relax to gcc and as.  In commit 7a8e7da42250138
("RISC-V: Fixes to module loading") -mno-relax is added to the build
variable KBUILD_CFLAGS_MODULE. See [1] for more info.

The issue is that when kbuild builds a .S file, it invokes gcc with
the -mno-relax flag, but this is not being passed through to the
assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
the assembler is invoked correctly. This may have now been fixed in
gcc[2] and this addition should not stop newer gcc and as from working.

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Notes:

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 1f5c03082976..fca40511a8c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.35.1


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

end of thread, other threads:[~2022-07-25 11:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 14:44 [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents Ben Dooks
2021-07-20 14:44 ` Ben Dooks
2021-08-10  8:49 ` Ben Dooks
2021-08-10  8:49   ` Ben Dooks
2022-05-29 15:22 Ben Dooks
2022-05-29 15:22 ` Ben Dooks
2022-07-21 19:53 ` Palmer Dabbelt
2022-07-21 19:53   ` Palmer Dabbelt
2022-07-25 11:38   ` Ben Dooks
2022-07-25 11:42     ` Conor.Dooley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.