LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom
@ 2024-09-25 17:50 Jason A. Donenfeld
  2024-09-25 18:38 ` Jason A. Donenfeld
  2024-09-30 11:36 ` Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Jason A. Donenfeld @ 2024-09-25 17:50 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, linuxppc-dev; +Cc: Jason A. Donenfeld

For gettimeofday, -ffixed-r30 was passed to work around a bug in Go
code, where the vDSO trampoline forgot to save and restore this register
across function calls. But Go requires a different trampoline for every
call, and there's no reason that new Go code needs to be broken and add
more bugs.  So remove -ffixed-r30 for getrandom.

Fixes: 8072b39c3a75 ("powerpc/vdso: Wire up getrandom() vDSO implementation on VDSO64")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
Michael - can you take this through your tree as a ppc fix?

 arch/powerpc/kernel/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 56fb1633529a..31ca5a547004 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -22,7 +22,7 @@ endif
 
 ifneq ($(c-getrandom-y),)
   CFLAGS_vgetrandom-32.o += -include $(c-getrandom-y)
-  CFLAGS_vgetrandom-64.o += -include $(c-getrandom-y) $(call cc-option, -ffixed-r30)
+  CFLAGS_vgetrandom-64.o += -include $(c-getrandom-y)
 endif
 
 # Build rules
-- 
2.46.0



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

* Re: [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom
  2024-09-25 17:50 [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom Jason A. Donenfeld
@ 2024-09-25 18:38 ` Jason A. Donenfeld
  2024-09-25 18:48   ` Christophe Leroy
  2024-09-30 11:36 ` Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Jason A. Donenfeld @ 2024-09-25 18:38 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, linuxppc-dev

On Wed, Sep 25, 2024 at 07:50:22PM +0200, Jason A. Donenfeld wrote:
> For gettimeofday, -ffixed-r30 was passed to work around a bug in Go
> code, where the vDSO trampoline forgot to save and restore this register
> across function calls. But Go requires a different trampoline for every
> call, and there's no reason that new Go code needs to be broken and add
> more bugs.  So remove -ffixed-r30 for getrandom.

Strangely, I am _unable to_ make the Go code not crash with this patch
applied. I'm not quite sure what I'm doing wrong yet, or if this points
to another issue.


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

* Re: [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom
  2024-09-25 18:38 ` Jason A. Donenfeld
@ 2024-09-25 18:48   ` Christophe Leroy
  2024-09-25 23:21     ` Jason A. Donenfeld
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Leroy @ 2024-09-25 18:48 UTC (permalink / raw)
  To: Jason A. Donenfeld, mpe, npiggin, linuxppc-dev



Le 25/09/2024 à 20:38, Jason A. Donenfeld a écrit :
> On Wed, Sep 25, 2024 at 07:50:22PM +0200, Jason A. Donenfeld wrote:
>> For gettimeofday, -ffixed-r30 was passed to work around a bug in Go
>> code, where the vDSO trampoline forgot to save and restore this register
>> across function calls. But Go requires a different trampoline for every
>> call, and there's no reason that new Go code needs to be broken and add
>> more bugs.  So remove -ffixed-r30 for getrandom.
> 
> Strangely, I am _unable to_ make the Go code not crash with this patch
> applied. I'm not quite sure what I'm doing wrong yet, or if this points
> to another issue.

Do you mean that without this patch the Go code works and with this 
patch it crashes ? That's strange taken into account that the chacha 
function plays up with r30 regardless of this patch.

Christophe


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

* Re: [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom
  2024-09-25 18:48   ` Christophe Leroy
@ 2024-09-25 23:21     ` Jason A. Donenfeld
  0 siblings, 0 replies; 5+ messages in thread
From: Jason A. Donenfeld @ 2024-09-25 23:21 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: mpe, npiggin, linuxppc-dev

On Wed, Sep 25, 2024 at 08:48:31PM +0200, Christophe Leroy wrote:
> 
> 
> Le 25/09/2024 à 20:38, Jason A. Donenfeld a écrit :
> > On Wed, Sep 25, 2024 at 07:50:22PM +0200, Jason A. Donenfeld wrote:
> >> For gettimeofday, -ffixed-r30 was passed to work around a bug in Go
> >> code, where the vDSO trampoline forgot to save and restore this register
> >> across function calls. But Go requires a different trampoline for every
> >> call, and there's no reason that new Go code needs to be broken and add
> >> more bugs.  So remove -ffixed-r30 for getrandom.
> > 
> > Strangely, I am _unable to_ make the Go code not crash with this patch
> > applied. I'm not quite sure what I'm doing wrong yet, or if this points
> > to another issue.
> 
> Do you mean that without this patch the Go code works and with this 
> patch it crashes ? That's strange taken into account that the chacha 
> function plays up with r30 regardless of this patch.

Yea, that's what I meant.

It turned out to be a Go runtime bug, which won't affect other vDSO
functions but does affect getrandom(). I fixed the issue and sent a
patch up to Google. So this is not the kernel's issue.

Therefore, this patch can move forward.

Jason


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

* Re: [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom
  2024-09-25 17:50 [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom Jason A. Donenfeld
  2024-09-25 18:38 ` Jason A. Donenfeld
@ 2024-09-30 11:36 ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2024-09-30 11:36 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, linuxppc-dev, Jason A. Donenfeld

On Wed, 25 Sep 2024 19:50:22 +0200, Jason A. Donenfeld wrote:
> For gettimeofday, -ffixed-r30 was passed to work around a bug in Go
> code, where the vDSO trampoline forgot to save and restore this register
> across function calls. But Go requires a different trampoline for every
> call, and there's no reason that new Go code needs to be broken and add
> more bugs.  So remove -ffixed-r30 for getrandom.
> 
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/vdso: allow r30 in vDSO code generation of getrandom
      https://git.kernel.org/powerpc/c/4b058c9f281f5b100efbf665dd5a1a05e1654d6d

cheers


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

end of thread, other threads:[~2024-09-30 11:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 17:50 [PATCH] powerpc/vdso: allow r30 in vDSO code generation of getrandom Jason A. Donenfeld
2024-09-25 18:38 ` Jason A. Donenfeld
2024-09-25 18:48   ` Christophe Leroy
2024-09-25 23:21     ` Jason A. Donenfeld
2024-09-30 11:36 ` Michael Ellerman

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