All of lore.kernel.org
 help / color / mirror / Atom feed
* undefined symbol in modpost "zero"
@ 2022-12-23 16:38 Ben Dooks
  2022-12-23 16:59 ` Ben Dooks
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Dooks @ 2022-12-23 16:38 UTC (permalink / raw)
  To: linux-riscv, Jisheng Zhang, Emil Renner Berthing <kernel

I'm getting the following error from modpost:

ERROR: modpost: "zero" [arch/riscv/kvm/kvm.ko] undefined!
ERROR: modpost: "zero" [drivers/gpu/drm/drm.ko] undefined!
ERROR: modpost: "zero" [drivers/nvme/host/nvme.ko] undefined!
ERROR: modpost: "zero" [drivers/i2c/algos/i2c-algo-bit.ko] undefined!

This seems to be coming from arch/riscv/include/asm/jump_label.h
with the arch_static_branch_jump() assembling some code:

>     40  {
>     41          asm_volatile_goto(
>     42                  "       .option push                            \n\t"
>     43                  "       .option norelax                         \n\t"
>     44                  "       .option norvc                           \n\t"
>     45                  "1:     jal             zero, %l[label]         \n\t"
>     46                  "       .option pop                             \n\t"
>     47                  "       .pushsection    __jump_table, \"aw\"    \n\t"
>     48                  "       .align          " RISCV_LGPTR "         \n\t"
>     49                  "       .long           1b - ., %l[label] - .   \n\t"
>     50                  "       " RISCV_PTR "   %0 - .                  \n\t"
>     51                  "       .popsection                             \n\t"
>     52                  :  :  "i"(&((char *)key)[branch]) :  : label);
>     53
>     54          return false;
>     55  label:
>     56          return true;
>     57  }
> 

Changing the jal zero to jal x0 doesn't fix it, it just comes up with
"x0" being undefined.

gcc version 12.2.0 (Debian 12.2.0-9)
GNU assembler version 2.39.50 (riscv64-linux-gnu) using BFD version (GNU 
Binutils for Debian) 2.39.50.20221208

I suspect this is a gas bug where it means to assemble a J instruction
to the label without outputting the unused symbol "zero" into the symbol
table. Is the right thing to fix gas, or can the kernel be changed?

FYI:

tmp.s:
      1          .text
      2
      3  1:
      4          jal zero, 1b


produces:

0000000000000000 <.L1^B1>:
    0:   0000006f                j       0 <.L1^B1>
                         0: R_RISCV_JAL  .L1^B1

and

$ riscv64-linux-gnu-nm -a tmp.o
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 n .riscv.attributes
0000000000000000 t .text
                  U zero

Current fix is to:


diff --git a/arch/riscv/include/asm/jump_label.h 
b/arch/riscv/include/asm/jump_label.h
index 6d58bbb5da46..a4abbacd0b62 100644
--- a/arch/riscv/include/asm/jump_label.h
+++ b/arch/riscv/include/asm/jump_label.h
@@ -42,7 +42,7 @@ static __always_inline bool 
arch_static_branch_jump(struct static_key * const ke
                 "       .option push                            \n\t"
                 "       .option norelax                         \n\t"
                 "       .option norvc                           \n\t"
-               "1:     jal             zero, %l[label]         \n\t"
+               "1:     j               %l[label]               \n\t"
                 "       .option pop                             \n\t"
                 "       .pushsection    __jump_table, \"aw\"    \n\t"
                 "       .align          " RISCV_LGPTR "         \n\t"


This fixes modpost, not sure if this should be applied or not.

-- 
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 related	[flat|nested] 4+ messages in thread

* Re: undefined symbol in modpost "zero"
  2022-12-23 16:38 undefined symbol in modpost "zero" Ben Dooks
@ 2022-12-23 16:59 ` Ben Dooks
  2022-12-24 15:28   ` Conor Dooley
  2022-12-27 19:05   ` Conor Dooley
  0 siblings, 2 replies; 4+ messages in thread
From: Ben Dooks @ 2022-12-23 16:59 UTC (permalink / raw)
  To: linux-riscv, Jisheng Zhang, Emil Renner Berthing <kernel

On 23/12/2022 16:38, Ben Dooks wrote:
> I'm getting the following error from modpost:
> 
> ERROR: modpost: "zero" [arch/riscv/kvm/kvm.ko] undefined!
> ERROR: modpost: "zero" [drivers/gpu/drm/drm.ko] undefined!
> ERROR: modpost: "zero" [drivers/nvme/host/nvme.ko] undefined!
> ERROR: modpost: "zero" [drivers/i2c/algos/i2c-algo-bit.ko] undefined!
> 
> This seems to be coming from arch/riscv/include/asm/jump_label.h
> with the arch_static_branch_jump() assembling some code:
> 
>>     40  {
>>     41          asm_volatile_goto(
>>     42                  "       .option 
>> push                            \n\t"
>>     43                  "       .option 
>> norelax                         \n\t"
>>     44                  "       .option 
>> norvc                           \n\t"
>>     45                  "1:     jal             zero, 
>> %l[label]         \n\t"
>>     46                  "       .option 
>> pop                             \n\t"
>>     47                  "       .pushsection    __jump_table, 
>> \"aw\"    \n\t"
>>     48                  "       .align          " RISCV_LGPTR 
>> "         \n\t"
>>     49                  "       .long           1b - ., %l[label] - 
>> .   \n\t"
>>     50                  "       " RISCV_PTR "   %0 - 
>> .                  \n\t"
>>     51                  "       
>> .popsection                             \n\t"
>>     52                  :  :  "i"(&((char *)key)[branch]) :  : label);
>>     53
>>     54          return false;
>>     55  label:
>>     56          return true;
>>     57  }
>>
> 
> Changing the jal zero to jal x0 doesn't fix it, it just comes up with
> "x0" being undefined.
> 
> gcc version 12.2.0 (Debian 12.2.0-9)
> GNU assembler version 2.39.50 (riscv64-linux-gnu) using BFD version (GNU 
> Binutils for Debian) 2.39.50.20221208
> 
> I suspect this is a gas bug where it means to assemble a J instruction
> to the label without outputting the unused symbol "zero" into the symbol
> table. Is the right thing to fix gas, or can the kernel be changed?
> 
> FYI:
> 
> tmp.s:
>       1          .text
>       2
>       3  1:
>       4          jal zero, 1b
> 
> 
> produces:
> 
> 0000000000000000 <.L1^B1>:
>     0:   0000006f                j       0 <.L1^B1>
>                          0: R_RISCV_JAL  .L1^B1
> 
> and
> 
> $ riscv64-linux-gnu-nm -a tmp.o
> 0000000000000000 b .bss
> 0000000000000000 d .data
> 0000000000000000 n .riscv.attributes
> 0000000000000000 t .text
>                   U zero
> 
> Current fix is to:
> 
> 
> diff --git a/arch/riscv/include/asm/jump_label.h 
> b/arch/riscv/include/asm/jump_label.h
> index 6d58bbb5da46..a4abbacd0b62 100644
> --- a/arch/riscv/include/asm/jump_label.h
> +++ b/arch/riscv/include/asm/jump_label.h
> @@ -42,7 +42,7 @@ static __always_inline bool 
> arch_static_branch_jump(struct static_key * const ke
>                  "       .option push                            \n\t"
>                  "       .option norelax                         \n\t"
>                  "       .option norvc                           \n\t"
> -               "1:     jal             zero, %l[label]         \n\t"
> +               "1:     j               %l[label]               \n\t"
>                  "       .option pop                             \n\t"
>                  "       .pushsection    __jump_table, \"aw\"    \n\t"
>                  "       .align          " RISCV_LGPTR "         \n\t"
> 
> 
> This fixes modpost, not sure if this should be applied or not.
> 

I just checked riscv64-linux-gnu-nm vmlinux.o and it has

                  U zero


So I guess the linker just ignores this undefined symbol as it is never
actually used for a relocation.

-- 
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] 4+ messages in thread

* Re: undefined symbol in modpost "zero"
  2022-12-23 16:59 ` Ben Dooks
@ 2022-12-24 15:28   ` Conor Dooley
  2022-12-27 19:05   ` Conor Dooley
  1 sibling, 0 replies; 4+ messages in thread
From: Conor Dooley @ 2022-12-24 15:28 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-riscv, Jisheng Zhang


[-- Attachment #1.1: Type: text/plain, Size: 4919 bytes --]

On Fri, Dec 23, 2022 at 04:59:51PM +0000, Ben Dooks wrote:
> On 23/12/2022 16:38, Ben Dooks wrote:
> > I'm getting the following error from modpost:
> > 
> > ERROR: modpost: "zero" [arch/riscv/kvm/kvm.ko] undefined!
> > ERROR: modpost: "zero" [drivers/gpu/drm/drm.ko] undefined!
> > ERROR: modpost: "zero" [drivers/nvme/host/nvme.ko] undefined!
> > ERROR: modpost: "zero" [drivers/i2c/algos/i2c-algo-bit.ko] undefined!
> > 
> > This seems to be coming from arch/riscv/include/asm/jump_label.h
> > with the arch_static_branch_jump() assembling some code:
> > 
> > >     40  {
> > >     41          asm_volatile_goto(
> > >     42                  "       .option
> > > push                            \n\t"
> > >     43                  "       .option
> > > norelax                         \n\t"
> > >     44                  "       .option
> > > norvc                           \n\t"
> > >     45                  "1:     jal             zero,
> > > %l[label]         \n\t"
> > >     46                  "       .option
> > > pop                             \n\t"
> > >     47                  "       .pushsection    __jump_table,
> > > \"aw\"    \n\t"
> > >     48                  "       .align          " RISCV_LGPTR
> > > "         \n\t"
> > >     49                  "       .long           1b - ., %l[label] -
> > > .   \n\t"
> > >     50                  "       " RISCV_PTR "   %0 -
> > > .                  \n\t"
> > >     51                  "
> > > .popsection                             \n\t"
> > >     52                  :  :  "i"(&((char *)key)[branch]) :  : label);
> > >     53
> > >     54          return false;
> > >     55  label:
> > >     56          return true;
> > >     57  }
> > > 
> > 
> > Changing the jal zero to jal x0 doesn't fix it, it just comes up with
> > "x0" being undefined.
> > 
> > gcc version 12.2.0 (Debian 12.2.0-9)
> > GNU assembler version 2.39.50 (riscv64-linux-gnu) using BFD version (GNU
> > Binutils for Debian) 2.39.50.20221208

Hey Ben, said I'd give it a run yesterday but didnt...

gcc version 12.2.0 2ee5e430018 ("Update ChangeLog and version files for release")
binutils 2.39 74340608801 (24/12/22)

So that's gcc @ the 12.2 tag & binutils at the tip of the 2.39 branch.
Kernel is from today too:
72a85e2b0a1e ("Merge tag 'spi-fix-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi")

I did my usual defconfig (which builds kvm as a module) and allmodconfig
but I see nothing odd out of modpost.

Could you share your config perhaps, or point out what I may be
overlooking setup wise?

> > I suspect this is a gas bug where it means to assemble a J instruction
> > to the label without outputting the unused symbol "zero" into the symbol
> > table. Is the right thing to fix gas, or can the kernel be changed?
> > 
> > FYI:
> > 
> > tmp.s:
> >       1          .text
> >       2
> >       3  1:
> >       4          jal zero, 1b
> > 
> > 
> > produces:
> > 
> > 0000000000000000 <.L1^B1>:
> >     0:   0000006f                j       0 <.L1^B1>
> >                          0: R_RISCV_JAL  .L1^B1
> > 
> > and
> > 
> > $ riscv64-linux-gnu-nm -a tmp.o
> > 0000000000000000 b .bss
> > 0000000000000000 d .data
> > 0000000000000000 n .riscv.attributes
> > 0000000000000000 t .text
> >                   U zero
> > 
> > Current fix is to:
> > 
> > 
> > diff --git a/arch/riscv/include/asm/jump_label.h
> > b/arch/riscv/include/asm/jump_label.h
> > index 6d58bbb5da46..a4abbacd0b62 100644
> > --- a/arch/riscv/include/asm/jump_label.h
> > +++ b/arch/riscv/include/asm/jump_label.h
> > @@ -42,7 +42,7 @@ static __always_inline bool
> > arch_static_branch_jump(struct static_key * const ke
> >                  "       .option push                            \n\t"
> >                  "       .option norelax                         \n\t"
> >                  "       .option norvc                           \n\t"
> > -               "1:     jal             zero, %l[label]         \n\t"
> > +               "1:     j               %l[label]               \n\t"
> >                  "       .option pop                             \n\t"
> >                  "       .pushsection    __jump_table, \"aw\"    \n\t"
> >                  "       .align          " RISCV_LGPTR "         \n\t"
> > 
> > 
> > This fixes modpost, not sure if this should be applied or not.
> > 
> 
> I just checked riscv64-linux-gnu-nm vmlinux.o and it has
> 
>                  U zero

I checked the output of nm on my allmodconfig kernel and I do not see
this symbol. Ditto for my regular defconfig that I use.
You mentioned on IRC that you did a rebase on top of Linus' tree, what
is in the extra content on top of that?

> 
> 
> So I guess the linker just ignores this undefined symbol as it is never
> actually used for a relocation.


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

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

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

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

* Re: undefined symbol in modpost "zero"
  2022-12-23 16:59 ` Ben Dooks
  2022-12-24 15:28   ` Conor Dooley
@ 2022-12-27 19:05   ` Conor Dooley
  1 sibling, 0 replies; 4+ messages in thread
From: Conor Dooley @ 2022-12-27 19:05 UTC (permalink / raw)
  To: linux-riscv; +Cc: linux-riscv, Jisheng Zhang, Ben Dooks


[-- Attachment #1.1: Type: text/plain, Size: 4469 bytes --]

On Fri, Dec 23, 2022 at 04:59:51PM +0000, Ben Dooks wrote:
> On 23/12/2022 16:38, Ben Dooks wrote:
> > I'm getting the following error from modpost:
> > 
> > ERROR: modpost: "zero" [arch/riscv/kvm/kvm.ko] undefined!
> > ERROR: modpost: "zero" [drivers/gpu/drm/drm.ko] undefined!
> > ERROR: modpost: "zero" [drivers/nvme/host/nvme.ko] undefined!
> > ERROR: modpost: "zero" [drivers/i2c/algos/i2c-algo-bit.ko] undefined!
> > 
> > This seems to be coming from arch/riscv/include/asm/jump_label.h
> > with the arch_static_branch_jump() assembling some code:
> > 
> > >     40  {
> > >     41          asm_volatile_goto(
> > >     42                  "       .option
> > > push                            \n\t"
> > >     43                  "       .option
> > > norelax                         \n\t"
> > >     44                  "       .option
> > > norvc                           \n\t"
> > >     45                  "1:     jal             zero,
> > > %l[label]         \n\t"
> > >     46                  "       .option
> > > pop                             \n\t"
> > >     47                  "       .pushsection    __jump_table,
> > > \"aw\"    \n\t"
> > >     48                  "       .align          " RISCV_LGPTR
> > > "         \n\t"
> > >     49                  "       .long           1b - ., %l[label] -
> > > .   \n\t"
> > >     50                  "       " RISCV_PTR "   %0 -
> > > .                  \n\t"
> > >     51                  "
> > > .popsection                             \n\t"
> > >     52                  :  :  "i"(&((char *)key)[branch]) :  : label);
> > >     53
> > >     54          return false;
> > >     55  label:
> > >     56          return true;
> > >     57  }
> > > 
> > 
> > Changing the jal zero to jal x0 doesn't fix it, it just comes up with
> > "x0" being undefined.
> > 
> > gcc version 12.2.0 (Debian 12.2.0-9)
> > GNU assembler version 2.39.50 (riscv64-linux-gnu) using BFD version (GNU
> > Binutils for Debian) 2.39.50.20221208
> > 
> > I suspect this is a gas bug where it means to assemble a J instruction
> > to the label without outputting the unused symbol "zero" into the symbol
> > table. Is the right thing to fix gas, or can the kernel be changed?
> > 
> > FYI:
> > 
> > tmp.s:
> >       1          .text
> >       2
> >       3  1:
> >       4          jal zero, 1b
> > 
> > 
> > produces:
> > 
> > 0000000000000000 <.L1^B1>:
> >     0:   0000006f                j       0 <.L1^B1>
> >                          0: R_RISCV_JAL  .L1^B1
> > 
> > and
> > 
> > $ riscv64-linux-gnu-nm -a tmp.o
> > 0000000000000000 b .bss
> > 0000000000000000 d .data
> > 0000000000000000 n .riscv.attributes
> > 0000000000000000 t .text
> >                   U zero
> > 
> > Current fix is to:
> > 
> > 
> > diff --git a/arch/riscv/include/asm/jump_label.h
> > b/arch/riscv/include/asm/jump_label.h
> > index 6d58bbb5da46..a4abbacd0b62 100644
> > --- a/arch/riscv/include/asm/jump_label.h
> > +++ b/arch/riscv/include/asm/jump_label.h
> > @@ -42,7 +42,7 @@ static __always_inline bool
> > arch_static_branch_jump(struct static_key * const ke
> >                  "       .option push                            \n\t"
> >                  "       .option norelax                         \n\t"
> >                  "       .option norvc                           \n\t"
> > -               "1:     jal             zero, %l[label]         \n\t"
> > +               "1:     j               %l[label]               \n\t"
> >                  "       .option pop                             \n\t"
> >                  "       .pushsection    __jump_table, \"aw\"    \n\t"
> >                  "       .align          " RISCV_LGPTR "         \n\t"
> > 
> > 
> > This fixes modpost, not sure if this should be applied or not.
> > 
> 
> I just checked riscv64-linux-gnu-nm vmlinux.o and it has
> 
>                  U zero
> 
> 
> So I guess the linker just ignores this undefined symbol as it is never
> actually used for a relocation.

For anyone not paying attention to the RISC-V IRC, it is an upstream
binutils issue that does not affect released versions (yet) although it
does affect what is in debian-testing.

The upstream report for the issue is here:
https://sourceware.org/bugzilla/show_bug.cgi?id=29940

and for debian here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1026979

Thanks,
Conor.


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

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

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

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

end of thread, other threads:[~2022-12-27 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 16:38 undefined symbol in modpost "zero" Ben Dooks
2022-12-23 16:59 ` Ben Dooks
2022-12-24 15:28   ` Conor Dooley
2022-12-27 19:05   ` 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.