linux-stable/arch/powerpc/kernel/vdso64
Michael Ellerman a88603f4b9 powerpc/vdso: Don't use r30 to avoid breaking Go lang
The Go runtime uses r30 for some special value called 'g'. It assumes
that value will remain unchanged even when calling VDSO functions.
Although r30 is non-volatile across function calls, the callee is free
to use it, as long as the callee saves the value and restores it before
returning.

It used to be true by accident that the VDSO didn't use r30, because the
VDSO was hand-written asm. When we switched to building the VDSO from C
the compiler started using r30, at least in some builds, leading to
crashes in Go. eg:

  ~/go/src$ ./all.bash
  Building Go cmd/dist using /usr/lib/go-1.16. (go1.16.2 linux/ppc64le)
  Building Go toolchain1 using /usr/lib/go-1.16.
  go build os/exec: /usr/lib/go-1.16/pkg/tool/linux_ppc64le/compile: signal: segmentation fault
  go build reflect: /usr/lib/go-1.16/pkg/tool/linux_ppc64le/compile: signal: segmentation fault
  go tool dist: FAILED: /usr/lib/go-1.16/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap bootstrap/cmd/...: exit status 1

There are patches in flight to fix Go[1], but until they are released
and widely deployed we can workaround it in the VDSO by avoiding use of
r30.

Note this only works with GCC, clang does not support -ffixed-rN.

1: https://go-review.googlesource.com/c/go/+/328110

Fixes: ab037dd87a ("powerpc/vdso: Switch VDSO to generic C implementation.")
Cc: stable@vger.kernel.org # v5.11+
Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Tested-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210729131244.2595519-1-mpe@ellerman.id.au
2021-07-29 23:13:12 +10:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
cacheflush.S powerpc/vdso: Merge __kernel_sync_dicache_p5() into __kernel_sync_dicache() 2020-12-04 01:01:17 +11:00
datapage.S powerpc/vdso: Remove __kernel_datapage_offset 2020-12-04 01:01:18 +11:00
gen_vdso_offsets.sh powerpc/vdso: Retrieve sigtramp offsets at buildtime 2020-12-04 01:01:17 +11:00
getcpu.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
gettimeofday.S powerpc/vdso: Switch VDSO to generic C implementation. 2020-12-04 01:01:10 +11:00
Makefile powerpc/vdso: Don't use r30 to avoid breaking Go lang 2021-07-29 23:13:12 +10:00
note.S
sigtramp.S powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64() semantics 2021-02-02 22:14:41 +11:00
vdso64.lds.S powerpc/vdso: Add support for time namespaces 2021-04-14 23:04:44 +10:00
vgettimeofday.c powerpc/vdso: Prepare for switching VDSO to generic C implementation. 2020-12-04 01:01:10 +11:00