Skip to contentSkip to conversation

powerpc/vdso: allow r30 in vDSO code generation of getrandom

PATCH Applied Jason A. Donenfeld 3 participants 5 messages Sep 25, 2024 – Sep 30, 2024 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/vdso: allow r30 in vDSO code generation of getrandom

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

---
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(-)
arch/powerpc/kernel/vdso/Makefile +1 -1
index 56fb1633529a..31ca5a547004 100644
@@ -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
Signature · 1 line
2.46.0
#1 lore raw
Quoted 5 lines · 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.

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.

#2 lore raw

Le 25/09/2024 à 20:38, Jason A. Donenfeld a écrit :

Quoted 10 lines · Jason A. Donenfeld
Quoted 5 lines

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

#3 lore raw
Quoted 10 lines · Christophe Leroy

Le 25/09/2024 à 20:38, Jason A. Donenfeld a écrit :

Quoted 7 lines · Jason A. Donenfeld
Quoted 5 lines

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.

Quoted 7 lines
Quoted 3 lines

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

#4 lore raw
In reply to Jason A. Donenfeld
Quoted 8 lines · 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.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/vdso: allow r30 in vDSO code generation of getrandom

      https://git.kernel.org/powerpc/c/4b058c9f281f5b100efbf665dd5a1a05e1654d6d

cheers