{"id":2223212,"url":"http://patchwork.ozlabs.org/api/patches/2223212/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260414025335.2847358-1-mattst88@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260414025335.2847358-1-mattst88@gmail.com>","list_archive_url":null,"date":"2026-04-14T02:53:35","name":"linux-user/ppc: Fix ppc64 rt_sigframe stack offset","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6cddeacdaaabf34e1506ffb832f73938a344a3ac","submitter":{"id":7917,"url":"http://patchwork.ozlabs.org/api/people/7917/?format=json","name":"Matt Turner","email":"mattst88@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260414025335.2847358-1-mattst88@gmail.com/mbox/","series":[{"id":499880,"url":"http://patchwork.ozlabs.org/api/series/499880/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499880","date":"2026-04-14T02:53:35","name":"linux-user/ppc: Fix ppc64 rt_sigframe stack offset","version":1,"mbox":"http://patchwork.ozlabs.org/series/499880/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223212/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223212/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=RBWjV6B6;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwB7F55L5z1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 03:27:53 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wChXc-0002oQ-HY; Tue, 14 Apr 2026 13:27:12 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <mattst88@gmail.com>)\n id 1wCTuN-0004Sa-Dd\n for qemu-devel@nongnu.org; Mon, 13 Apr 2026 22:53:47 -0400","from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <mattst88@gmail.com>)\n id 1wCTuM-0004aP-0Q\n for qemu-devel@nongnu.org; Mon, 13 Apr 2026 22:53:47 -0400","by mail-yw1-x1130.google.com with SMTP id\n 00721157ae682-78fc4425b6bso47267667b3.1\n for <qemu-devel@nongnu.org>; Mon, 13 Apr 2026 19:53:45 -0700 (PDT)","from localhost ([76.195.202.134])\n by smtp.gmail.com with UTF8SMTPSA id\n 00721157ae682-7b414d0faf4sm14305387b3.22.2026.04.13.19.53.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 13 Apr 2026 19:53:43 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776135224; x=1776740024; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=YBdiT7AseZaWPAh14FHjZWZ6g6o27t+1V3jw9kY798M=;\n b=RBWjV6B6F+C+3qAP+AHxkhYjJWVtVRY6sFJuVt27+bA1JsomxR/v1dd/KHO0fgISGx\n hJ9kfjOYw+8pn2dgsmG4WFU1EPtoNUgpRfgKPbWJ8ryaeR3M51ymHM0lq8TCbxBVaZiF\n aYHHlnzIDwQw90MtP8tK8xEgwH2LIpX5R9KG5vcQ/5bPcZq4JLgTEPHIu0VItXihV0QH\n IEDHuTnIVYLwOZaQfR7UzY6lE77IfT7/NDzCFqCYyMxiXq4vTEiLBrpDmWNK3wJZPFBt\n zQZiofxgbQyUTtKpixq3SudKsxI6jt2ADTPFKABYdmVL0Bb/4IrWX/M06LTTqmEfm0He\n aTeQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776135224; x=1776740024;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=YBdiT7AseZaWPAh14FHjZWZ6g6o27t+1V3jw9kY798M=;\n b=PmQb6NIVgcrzRgbczLcAf4FRSEdYQ60lgnfEiAzJLH7DhD4IiOkG7DOBCDzDb38hm+\n 75S1SSEyDaf8BqriunwhDiBCYDJ90TxcAZoHiVVl/dot9wXmelPnr4Ar3b71HVrYU3KA\n 6jIUUWV8A4X89DjORDeISeT6W+bjr1XwYPtxaha888p7DG0nSbYQS5ea8gbJMxBsd6GZ\n 96sJJN8vcMBdplDG3c2bHQ9HIHIeksAIaVnEBgJxGLdmD9PYUOqgWzaIvu8vzSlU0lO6\n fby0lzX2nM06teBOjquL5gdTIiQAS2kkKF0bb4J+nepNrgL/tdMCML5zNZqYiin6Mxf0\n I0IQ==","X-Gm-Message-State":"AOJu0YwW2Ns+/pcA6+Rraz+XO/s+MRyp2NTpUhQOtp1f1F/5aqkbjAoL\n rAD6rbPiEWg4TveY1PuPpxr5ffBSi76XuFqd7ZaoOYE0eAaEv38IE9jn","X-Gm-Gg":"AeBDiesHJlBwidlecnRkj670gb5iuArI6zTDYfwbAFfcdRVnNY64r6VDBn+5zs+dCzc\n nysi4FzWgeg521ps3Bv+HmRLu6yHrz+vOp3Pt3fblxLav2k5fVG0Km2r3N/3zSuRtgMZcRLvEok\n cR5tR5Jvhywa1OgbzeOItNAt00tsDOFj4dBkhrr8z6Es/F4V/YR3nxWZR2XjbpIUNroNpxFxLCI\n HPjgFd0E8qfumMIBzIiEFZDzufzVP0D9q78ZNXMeJoBugxPk64YsGsNnfGO9TdTDaF1kqDTQp6N\n 3pqd37a6sAX3Fr8Fgr3H/DpyemoBWKu3tMhYhf42Yd4pns9DGesnw4RdkoKcGuc9DBWmzdAaDIs\n xBRJrFCwxH1JmE8Kqm0Gxt2SugO5iV+cK+HEnuK9An1Z7DrHimMy2QjrbZ1AyZZKGs0KRbU8Y/R\n g+Tp7kOAYHCIugBg6I2V4=","X-Received":"by 2002:a05:690c:101:b0:7a1:6e8:d8fb with SMTP id\n 00721157ae682-7af6f03b254mr178694397b3.3.1776135224077;\n Mon, 13 Apr 2026 19:53:44 -0700 (PDT)","From":"Matt Turner <mattst88@gmail.com>","To":"Laurent Vivier <laurent@vivier.eu>","Cc":"qemu-devel@nongnu.org,\n\tMatt Turner <mattst88@gmail.com>","Subject":"[PATCH] linux-user/ppc: Fix ppc64 rt_sigframe stack offset","Date":"Mon, 13 Apr 2026 22:53:35 -0400","Message-ID":"<20260414025335.2847358-1-mattst88@gmail.com>","X-Mailer":"git-send-email 2.52.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::1130;\n envelope-from=mattst88@gmail.com; helo=mail-yw1-x1130.google.com","X-Spam_score_int":"-17","X-Spam_score":"-1.8","X-Spam_bar":"-","X-Spam_report":"(-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-Mailman-Approved-At":"Tue, 14 Apr 2026 13:27:11 -0400","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"The kernel's 64-bit signal delivery (signal_64.c) uses:\n\n    newsp = frame - __SIGNAL_FRAMESIZE\n\nwhile the 32-bit path (signal_32.c) uses:\n\n    newsp = frame - (__SIGNAL_FRAMESIZE + 16)\n\nThe extra 16 bytes in the 32-bit case is to place siginfo and ucontext\nat the same offsets as older kernels (see the comment in signal_32.c).\nThe 64-bit rt_sigframe starts with ucontext directly and does not need\nthis adjustment.\n\nQEMU's setup_rt_frame() unconditionally used (SIGNAL_FRAMESIZE + 16)\nfor both 32-bit and 64-bit, placing the handler's SP 16 bytes too low\non ppc64. Signal delivery and return still worked because do_rt_sigreturn\nhad the matching wrong offset, but the vDSO DWARF unwind info encodes\nthe correct kernel offset. This caused any DWARF unwinder (libunwind,\nlibgcc, etc.) to compute a CFA that is 16 bytes off, reading garbage\nregister values from the signal frame.\n\nGuard the +16 with #if !defined(TARGET_PPC64) in both setup_rt_frame\nand do_rt_sigreturn to match the kernel.\n\nThis was verified by A/B testing with libunwind's test suite:\n\n  ppc64le: Gtest-bt, Ltest-bt, Gtest-concurrent, Ltest-concurrent,\n           and Ltest-sig-context all change from FAIL to PASS.\n  ppc64be: Gtest-bt, Ltest-bt, and Ltest-sig-context all change\n           from FAIL to PASS.\n\nSigned-off-by: Matt Turner <mattst88@gmail.com>\n---\n linux-user/ppc/signal.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)","diff":"diff --git ./linux-user/ppc/signal.c ./linux-user/ppc/signal.c\nindex 24e5a02a78..b21aa2430e 100644\n--- ./linux-user/ppc/signal.c\n+++ ./linux-user/ppc/signal.c\n@@ -525,7 +525,15 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,\n     env->fpscr = 0;\n \n     /* Create a stack frame for the caller of the handler.  */\n+#if defined(TARGET_PPC64)\n+    newsp = rt_sf_addr - SIGNAL_FRAMESIZE;\n+#else\n+    /*\n+     * The +16 is to get the siginfo and ucontext in the same positions\n+     * as in older kernels. See Linux's arch/powerpc/kernel/signal_32.c.\n+     */\n     newsp = rt_sf_addr - (SIGNAL_FRAMESIZE + 16);\n+#endif\n     err |= put_user(env->gpr[1], newsp, target_ulong);\n \n     if (err)\n@@ -641,7 +649,11 @@ long do_rt_sigreturn(CPUPPCState *env)\n     struct target_rt_sigframe *rt_sf = NULL;\n     target_ulong rt_sf_addr;\n \n+#if defined(TARGET_PPC64)\n+    rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE;\n+#else\n     rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + 16;\n+#endif\n     if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))\n         goto sigsegv;\n \n","prefixes":[]}