{"id":2224132,"url":"http://patchwork.ozlabs.org/api/patches/2224132/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260416182527.3862296-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":"<20260416182527.3862296-1-mattst88@gmail.com>","list_archive_url":null,"date":"2026-04-16T18:25:27","name":"linux-user/ppc: Fix ppc64 rt_sigframe stack offset","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2d21272ea9d5c0b0abab7e9167fc412e43da566c","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/20260416182527.3862296-1-mattst88@gmail.com/mbox/","series":[{"id":500211,"url":"http://patchwork.ozlabs.org/api/series/500211/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500211","date":"2026-04-16T18:25:27","name":"linux-user/ppc: Fix ppc64 rt_sigframe stack offset","version":1,"mbox":"http://patchwork.ozlabs.org/series/500211/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224132/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224132/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=mrrPaxQx;\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 4fxXwl18Ctz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 08:38:31 +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 1wDVLR-0007gk-AI; Thu, 16 Apr 2026 18:37:57 -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 1wDRPG-0001H0-7q\n for qemu-devel@nongnu.org; Thu, 16 Apr 2026 14:25:38 -0400","from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d])\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 1wDRPC-0004rr-T7\n for qemu-devel@nongnu.org; Thu, 16 Apr 2026 14:25:37 -0400","by mail-yw1-x112d.google.com with SMTP id\n 00721157ae682-7a469383e0bso66574797b3.2\n for <qemu-devel@nongnu.org>; Thu, 16 Apr 2026 11:25:33 -0700 (PDT)","from localhost (107-220-129-194.lightspeed.chrlnc.sbcglobal.net.\n [107.220.129.194]) by smtp.gmail.com with UTF8SMTPSA id\n 00721157ae682-7b7667f96f5sm26500827b3.18.2026.04.16.11.25.31\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 16 Apr 2026 11:25:31 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776363932; x=1776968732; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=tsmzOeoP7uNAK2BdhTFC+4QKbukVOAW6xDOyhAheOzs=;\n b=mrrPaxQxf0zlusfGc8OwZf8bKXtuerUs+XyLPtlH+q4VgbpbmMVL5x55Ip3S1blpdh\n SRLHrlbubSqdDxIhxWn4u65lQaMWGJ1uyoPtxwlk1QMiIabluXXtKqhO1+8d9pdcSkif\n CV+R+RNO76RJ60qeRR6Z+BrPkKl+udZNe8qwqRKiqIDFVgO4Utpqw0y5VLuqARWHxzAL\n X4aZlBeppuvAFkqTJOYrDnsihXK9FszhpG6izSnSM5i62cAjM8i67vnP23K6UzEIe8eN\n PGIjKTQhG4jzX2XgO8HL7fc8F9zNGbmLiTuYRMlq2KruQzIQyuGQhFB6cV7ZPVTXTLdt\n SaWA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776363932; x=1776968732;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=tsmzOeoP7uNAK2BdhTFC+4QKbukVOAW6xDOyhAheOzs=;\n b=sGzMe6vZh8VH+W5uKx2xSfRQL8hgQjHC0aw4cGMGnBtBrSbBTh/i5wbfPfKHRpfw9s\n JODEEEwCIG6n0BLsZeSaS6iLxYN3hAs+W+nn3tta14wCzOnnGfOvNprOUv7IQq7XppyA\n uw4zO4RsZs+uJigYo7tMSGP77jee1lVwFUXWotWQPcchouL/Fz43RAA/GDiRHcE22IAF\n 8GyczaN0qPIE7WrVT0HDjr9tiUmEDGbRiF7WHTSk6TM0oDrxKQV+Fsj8zrSGGOgzAdte\n Z6SQ4HDYFo1TfaM6QYCqENgyfyNItjJonBcmcqon5WwTpTRCRnHXs3NRs7hWtb7/f7ie\n wgsw==","X-Gm-Message-State":"AOJu0YyQDEpWm6KEjjQv3zigxe8xsHw/mdfsX+uSqJoKVzBIqJ7TovfV\n RpqpeLodMAY3lJRZ9Y+pRDi4FjiAJE4LrpJkHFc1GL4XQjz1dOoq5ags","X-Gm-Gg":"AeBDievYIimxooyWqzsDB/BfLdxO+mp8PEinFSPoMXuLyAHWGU9qsNsfAKb6AhuHoAU\n k1v6rwnvRCORBYkcIJzSMP38vlpaqjTzcWG3xjY9b+vRvag9osM1mUy6Fc08fb+EOAJ/TxWCggw\n QrL9NneXVUF3BWlC9Zgns7Qy3sPO3b8qHfm1l3flyUGnMiD1e3iPdILkyeb2vWTxZkYOga+JoR3\n bNcn0n9Z8qKvZSA0I8jBySDAvDjqthNSpFguaWF2GehUmisgldLuimsdLMMcv8Sg9JWtAsiPkQv\n +reL8SF8ICI7Ch1OGZE3yu196DA0oADLqD/eq4MTb8Al4XlfFivWRs4IQtgEoWgtyCuqsTps2Pp\n Qzl9KSjxONUHYDo9Bzh733FoIj+4NnN0ik1IZd6U0LGfVo7th/22U0b5sQaRCzDxWqi7R/1z9Rh\n 9TwFtnnFfXD5xvcHqCWZjLD+zuEmuxhtQTTuIRU8/1paXBnYa2SXz7sFhMiSeghFqrFiDTrS5fx\n DDsgwjOxKtjtg==","X-Received":"by 2002:a05:690c:660c:b0:7b8:b3:58fa with SMTP id\n 00721157ae682-7b9e3084368mr2202967b3.31.1776363932360;\n Thu, 16 Apr 2026 11:25:32 -0700 (PDT)","From":"Matt Turner <mattst88@gmail.com>","To":"Laurent Vivier <laurent@vivier.eu>","Cc":"qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,\n Matt Turner <mattst88@gmail.com>","Subject":"[PATCH] linux-user/ppc: Fix ppc64 rt_sigframe stack offset","Date":"Thu, 16 Apr 2026 14:25:27 -0400","Message-ID":"<20260416182527.3862296-1-mattst88@gmail.com>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260414025335.2847358-1-mattst88@gmail.com>","References":"<20260414025335.2847358-1-mattst88@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::112d;\n envelope-from=mattst88@gmail.com; helo=mail-yw1-x112d.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":"Thu, 16 Apr 2026 18:37:49 -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\nDefine RT_SIGFRAME_ADJUST (0 on ppc64, 16 on ppc32) and use it in both\nsetup_rt_frame and 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 | 16 ++++++++++++++--\n 1 file changed, 14 insertions(+), 2 deletions(-)","diff":"diff --git ./linux-user/ppc/signal.c ./linux-user/ppc/signal.c\nindex 24e5a02a78..a9c10e0987 100644\n--- ./linux-user/ppc/signal.c\n+++ ./linux-user/ppc/signal.c\n@@ -210,6 +210,18 @@ QEMU_BUILD_BUG_ON(offsetof(struct target_rt_sigframe, uc.tuc_mcontext)\n \n #endif\n \n+#ifdef TARGET_PPC64\n+#define RT_SIGFRAME_ADJUST 0\n+#else\n+/*\n+ * For 32-bit rt sigframes we have an extra 16 bytes of gap\n+ * on top of __SIGNAL_FRAMESIZE; this is to get the siginfo\n+ * and ucontext in the same positions as in older kernels.\n+ * See Linux's arch/powerpc/kernel/signal_32.c.\n+ */\n+#define RT_SIGFRAME_ADJUST 16\n+#endif\n+\n #if defined(TARGET_PPC64)\n \n struct target_func_ptr {\n@@ -525,7 +537,7 @@ 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-    newsp = rt_sf_addr - (SIGNAL_FRAMESIZE + 16);\n+    newsp = rt_sf_addr - (SIGNAL_FRAMESIZE + RT_SIGFRAME_ADJUST);\n     err |= put_user(env->gpr[1], newsp, target_ulong);\n \n     if (err)\n@@ -641,7 +653,7 @@ long do_rt_sigreturn(CPUPPCState *env)\n     struct target_rt_sigframe *rt_sf = NULL;\n     target_ulong rt_sf_addr;\n \n-    rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + 16;\n+    rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + RT_SIGFRAME_ADJUST;\n     if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))\n         goto sigsegv;\n \n","prefixes":[]}