LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] riscv: add correct as-options for assembly in modules
@ 2021-07-12 17:48 Ben Dooks
  2021-07-16 10:23 ` Ben Dooks
  2021-07-16 10:44 ` Bin Meng
  0 siblings, 2 replies; 10+ messages in thread
From: Ben Dooks @ 2021-07-12 17:48 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Ben Dooks

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

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
the fix for gcc adds -mno-relax to the command line when building
C files. However this was never applied to assembly flags, and gcc
does no pass -mno-relax to gas when presented with a .S file.

The fix (other than making gcc always pass -mno-relax to gas) is
to add -Wa,-mno-relax to gcc to make sure the as is invoked with
the right options.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 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	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: add correct as-options for assembly in modules
  2021-07-12 17:48 [PATCH] riscv: add correct as-options for assembly in modules Ben Dooks
@ 2021-07-16 10:23 ` Ben Dooks
  2021-07-16 10:44 ` Bin Meng
  1 sibling, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2021-07-16 10:23 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou

On 12/07/2021 18:48, Ben Dooks wrote:
> When trying to load modules built for riscv which include assembly
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
> 
> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
> the fix for gcc adds -mno-relax to the command line when building
> C files. However this was never applied to assembly flags, and gcc
> does no pass -mno-relax to gas when presented with a .S file.
> 
> The fix (other than making gcc always pass -mno-relax to gas) is
> to add -Wa,-mno-relax to gcc to make sure the as is invoked with
> the right options.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

Just wanted to find out if anyone has had time to review this.
If this is ok, should we also send to -stable ?

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


-- 
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] riscv: add correct as-options for assembly in modules
  2021-07-12 17:48 [PATCH] riscv: add correct as-options for assembly in modules Ben Dooks
  2021-07-16 10:23 ` Ben Dooks
@ 2021-07-16 10:44 ` Bin Meng
  2021-07-16 15:33   ` Ben Dooks
  1 sibling, 1 reply; 10+ messages in thread
From: Bin Meng @ 2021-07-16 10:44 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-kernel, linux-kernel, linux-riscv, Paul Walmsley,
	Palmer Dabbelt, Albert Ou

On Tue, Jul 13, 2021 at 2:28 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> When trying to load modules built for riscv which include assembly

nits: RISC-V

> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
>
> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
> the fix for gcc adds -mno-relax to the command line when building
> C files. However this was never applied to assembly flags, and gcc
> does no pass -mno-relax to gas when presented with a .S file.

does not pass

FYI

The GCC bug was fixed recently via:
https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

>
> The fix (other than making gcc always pass -mno-relax to gas) is
> to add -Wa,-mno-relax to gcc to make sure the as is invoked with
> the right options.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/riscv/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>

Otherwise,
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

* Re: [PATCH] riscv: add correct as-options for assembly in modules
  2021-07-16 10:44 ` Bin Meng
@ 2021-07-16 15:33   ` Ben Dooks
  2021-07-16 22:37     ` Bin Meng
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Dooks @ 2021-07-16 15:33 UTC (permalink / raw)
  To: Bin Meng
  Cc: linux-kernel, linux-kernel, linux-riscv, Paul Walmsley,
	Palmer Dabbelt, Albert Ou

On 16/07/2021 11:44, Bin Meng wrote:
> On Tue, Jul 13, 2021 at 2:28 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>>
>> When trying to load modules built for riscv which include assembly
> 
> nits: RISC-V
> 
>> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
>> due to R_RISCV_ALIGN relocations being generated by the assembler.
>>
>> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
>> the fix for gcc adds -mno-relax to the command line when building
>> C files. However this was never applied to assembly flags, and gcc
>> does no pass -mno-relax to gas when presented with a .S file.
> 
> does not pass

I'll see if I can make this simpler. Should this get done for a v2?

> FYI
> 
> The GCC bug was fixed recently via:
> https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

thanks, I think it still useful to fix this in the kernel.

>>
>> The fix (other than making gcc always pass -mno-relax to gas) is
>> to add -Wa,-mno-relax to gcc to make sure the as is invoked with
>> the right options.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>>   arch/riscv/Makefile | 1 +
>>   1 file changed, 1 insertion(+)
>>
> 
> Otherwise,
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> 


-- 
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] riscv: add correct as-options for assembly in modules
  2021-07-16 15:33   ` Ben Dooks
@ 2021-07-16 22:37     ` Bin Meng
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Meng @ 2021-07-16 22:37 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-kernel, linux-kernel, linux-riscv, Paul Walmsley,
	Palmer Dabbelt, Albert Ou

On Fri, Jul 16, 2021 at 11:33 PM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> On 16/07/2021 11:44, Bin Meng wrote:
> > On Tue, Jul 13, 2021 at 2:28 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
> >>
> >> When trying to load modules built for riscv which include assembly
> >
> > nits: RISC-V
> >
> >> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> >> due to R_RISCV_ALIGN relocations being generated by the assembler.
> >>
> >> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
> >> the fix for gcc adds -mno-relax to the command line when building
> >> C files. However this was never applied to assembly flags, and gcc
> >> does no pass -mno-relax to gas when presented with a .S file.
> >
> > does not pass
>
> I'll see if I can make this simpler. Should this get done for a v2?
>

Yes, please send v2.

> > FYI
> >
> > The GCC bug was fixed recently via:
> > https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857
>
> thanks, I think it still useful to fix this in the kernel.
>
> >>
> >> The fix (other than making gcc always pass -mno-relax to gas) is
> >> to add -Wa,-mno-relax to gcc to make sure the as is invoked with
> >> the right options.
> >>
> >> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> >> ---
> >>   arch/riscv/Makefile | 1 +
> >>   1 file changed, 1 insertion(+)
> >>
> >
> > Otherwise,
> > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Regards,
Bin

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

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

On 29/05/2022 16:19, Ben Dooks wrote:
> When trying to load modules built for riscv which include assembly
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
> 
> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
> CFLAGS have -mno-relax added. This however does not get applied to
> KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
> is not passed and the above error is seen. Fix it by adding the flags
> '-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.
> 
> This may have been fixed in gcc, in:
>   https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Apologies, this was the wrong branch. Will resen

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

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

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

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
CFLAGS have -mno-relax added. This however does not get applied to
KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
is not passed and the above error is seen. Fix it by adding the flags
'-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.

This may have been fixed in gcc, in:
 https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
--
Changes since v1:
- added Bin Meng's review of the original patch
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0289a97325d1..cf2ea9a1ac20 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -58,6 +58,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	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: add correct as-options for assembly in modules
  2021-12-08 19:26 Ben Dooks
  2022-01-10 15:51 ` Ben Dooks
@ 2022-01-11  7:41 ` Bin Meng
  1 sibling, 0 replies; 10+ messages in thread
From: Bin Meng @ 2022-01-11  7:41 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-kernel, linux-kernel, linux-riscv, Palmer Dabbelt, Albert Ou

On Thu, Dec 9, 2021 at 3:26 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> When trying to load modules built for riscv which include assembly
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
>
> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
> CFLAGS have -mno-relax added. This however does not get applied to
> KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
> is not passed and the above error is seen. Fix it by adding the flags
> '-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.
>
> This may have been fixed in gcc, in:
>  https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> --
> Changes since v1:
> - added Bin Meng's review of the original patch

Looks like you forgot to include the RB tag? :)

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

> ---
>  arch/riscv/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>

Regards,
Bin

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

* Re: [PATCH] riscv: add correct as-options for assembly in modules
  2021-12-08 19:26 Ben Dooks
@ 2022-01-10 15:51 ` Ben Dooks
  2022-01-11  7:41 ` Bin Meng
  1 sibling, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2022-01-10 15:51 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Palmer Dabbelt, Albert Ou, Bin Meng

On 08/12/2021 19:26, Ben Dooks wrote:
> When trying to load modules built for riscv which include assembly
> the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
> due to R_RISCV_ALIGN relocations being generated by the assembler.
> 
> In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
> CFLAGS have -mno-relax added. This however does not get applied to
> KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
> is not passed and the above error is seen. Fix it by adding the flags
> '-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.
> 
> This may have been fixed in gcc, in:
>   https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Can I just check this can be included in the next release?

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

* [PATCH] riscv: add correct as-options for assembly in modules
@ 2021-12-08 19:26 Ben Dooks
  2022-01-10 15:51 ` Ben Dooks
  2022-01-11  7:41 ` Bin Meng
  0 siblings, 2 replies; 10+ messages in thread
From: Ben Dooks @ 2021-12-08 19:26 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Palmer Dabbelt, Albert Ou, Bin Meng, Ben Dooks

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

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
CFLAGS have -mno-relax added. This however does not get applied to
KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
is not passed and the above error is seen. Fix it by adding the flags
'-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.

This may have been fixed in gcc, in:
 https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
Changes since v1:
- added Bin Meng's review of the original patch
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0289a97325d1..cf2ea9a1ac20 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -58,6 +58,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.33.0


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

end of thread, other threads:[~2022-05-29 15:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 17:48 [PATCH] riscv: add correct as-options for assembly in modules Ben Dooks
2021-07-16 10:23 ` Ben Dooks
2021-07-16 10:44 ` Bin Meng
2021-07-16 15:33   ` Ben Dooks
2021-07-16 22:37     ` Bin Meng
2021-12-08 19:26 Ben Dooks
2022-01-10 15:51 ` Ben Dooks
2022-01-11  7:41 ` Bin Meng
2022-05-29 15:19 Ben Dooks
2022-05-29 15:23 ` Ben Dooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).