)]}'
{
  "commit": "16ab7e49d4070c4f68e88836b123dbe6da8bb015",
  "tree": "01c6beab23307eefb8311fe994dcb5dfb99c5704",
  "parents": [
    "37c117f2bf227b14b0be3e1c2411174a6f27b4fe"
  ],
  "author": {
    "name": "Derek Parker",
    "email": "parkerderek86@gmail.com",
    "time": "Thu Jun 17 20:22:40 2021 +0000"
  },
  "committer": {
    "name": "Carlos Amedee",
    "email": "carlos@golang.org",
    "time": "Tue Aug 03 15:01:00 2021 +0000"
  },
  "message": "[release-branch.go1.16] runtime: fix crash during VDSO calls on PowerPC\n\nThis patch reinstates a fix for PowerPC with regard to making VDSO calls\nwhile receiving a signal, and subsequently crashing. The crash happens\nbecause certain VDSO calls can modify the r30 register, which is where g\nis stored. This change was reverted for PowerPC because r30 is supposed\nto be a non-volatile register. This is true, but that only makes a\nguarantee across function calls, but not \"within\" a function call. This\npatch was seemingly fine before because the Linux kernel still had hand\nrolled assembly VDSO function calls, however with a recent change to C\nfunction calls it seems the compiler used can generate instructions\nwhich temporarily clobber r30. This means that when we receive a signal\nduring one of these calls the value of r30 will not be the g as the\nruntime expects, causing a segfault.\n\nYou can see from this assembly dump how the register is clobbered during\nthe call:\n\n(the following is from a 5.13rc2 kernel)\n\n```\nDump of assembler code for function __cvdso_clock_gettime_data:\n   0x00007ffff7ff0700 \u003c+0\u003e:     cmplwi  r4,15\n   0x00007ffff7ff0704 \u003c+4\u003e:     bgt     0x7ffff7ff07f0 \u003c__cvdso_clock_gettime_data+240\u003e\n   0x00007ffff7ff0708 \u003c+8\u003e:     li      r9,1\n   0x00007ffff7ff070c \u003c+12\u003e:    slw     r9,r9,r4\n   0x00007ffff7ff0710 \u003c+16\u003e:    andi.   r10,r9,2179\n   0x00007ffff7ff0714 \u003c+20\u003e:    beq     0x7ffff7ff0810 \u003c__cvdso_clock_gettime_data+272\u003e\n   0x00007ffff7ff0718 \u003c+24\u003e:    rldicr  r10,r4,4,59\n   0x00007ffff7ff071c \u003c+28\u003e:    lis     r9,32767\n   0x00007ffff7ff0720 \u003c+32\u003e:    std     r30,-16(r1)\n   0x00007ffff7ff0724 \u003c+36\u003e:    std     r31,-8(r1)\n   0x00007ffff7ff0728 \u003c+40\u003e:    add     r6,r3,r10\n   0x00007ffff7ff072c \u003c+44\u003e:    ori     r4,r9,65535\n   0x00007ffff7ff0730 \u003c+48\u003e:    lwz     r8,0(r3)\n   0x00007ffff7ff0734 \u003c+52\u003e:    andi.   r9,r8,1\n   0x00007ffff7ff0738 \u003c+56\u003e:    bne     0x7ffff7ff07d0 \u003c__cvdso_clock_gettime_data+208\u003e\n   0x00007ffff7ff073c \u003c+60\u003e:    lwsync\n   0x00007ffff7ff0740 \u003c+64\u003e:    mftb    r30      \u003c---- RIGHT HERE\n\u003d\u003e 0x00007ffff7ff0744 \u003c+68\u003e:    ld      r12,40(r6)\n```\n\nWhat I believe is happening is that the kernel changed the PowerPC VDSO\ncalls to use standard C calls instead of using hand rolled assembly. The\nhand rolled assembly calls never touched r30, so this change was safe to\nroll back. That does not seem to be the case anymore as on the 5.13rc2\nkernel the compiler *is* generating assembly which modifies r30, making\nthis change again unsafe and causing a crash when the program receives a\nsignal during these calls (which will happen often due to async\npreempt). This change happened here:\nhttps://lwn.net/ml/linux-kernel/235e5571959cfa89ced081d7e838ed5ff38447d2.1601365870.git.christophe.leroy@csgroup.eu/.\n\nI realize this was reverted due to unexplained hangs in PowerPC\nbuilders, but I think we should reinstate this change and investigate\nthose issues separately:\nhttps://github.com/golang/go/commit/f4ca3c1e0a2066ca4f7bd6203866d282ed34acf2\n\nFixes #46858\n\nChange-Id: Ib18d7bbfc80a1a9cb558f0098878d41081324b52\nGitHub-Last-Rev: c3002bcfca3ef58b27485e31328e6297b7a9dfe7\nGitHub-Pull-Request: golang/go#46767\nReviewed-on: https://go-review.googlesource.com/c/go/+/328110\nRun-TryBot: Lynn Boger \u003claboger@linux.vnet.ibm.com\u003e\nTryBot-Result: Go Bot \u003cgobot@golang.org\u003e\nReviewed-by: Cherry Mui \u003ccherryyz@google.com\u003e\nTrust: Lynn Boger \u003claboger@linux.vnet.ibm.com\u003e\n(cherry picked from commit 16e82be454cbf41299e6a055d54d489ca4612ee0)\nReviewed-on: https://go-review.googlesource.com/c/go/+/334410\nRun-TryBot: Cherry Mui \u003ccherryyz@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3f70707ab4e3697655aa73a79c03b8d7bbe6f7f1",
      "old_mode": 33188,
      "old_path": "src/runtime/signal_unix.go",
      "new_id": "89f936ea88dbf8c0490bdde9d3a2182b4c4ad430",
      "new_mode": 33188,
      "new_path": "src/runtime/signal_unix.go"
    },
    {
      "type": "modify",
      "old_id": "fd69ee70a5ccde10f2f03874f0dca85c9a4fedd6",
      "old_mode": 33188,
      "old_path": "src/runtime/sys_linux_ppc64x.s",
      "new_id": "7be8c4c7242485df682ae19d99e3b4a4d30834b3",
      "new_mode": 33188,
      "new_path": "src/runtime/sys_linux_ppc64x.s"
    }
  ]
}
