From nobody Sun Apr 28 07:28:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523541860506790.8537855502381; Thu, 12 Apr 2018 07:04:20 -0700 (PDT) Received: from localhost ([::1]:42156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6cpn-000811-Du for importer@patchew.org; Thu, 12 Apr 2018 10:04:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6coE-0007Au-Ru for qemu-devel@nongnu.org; Thu, 12 Apr 2018 10:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6coA-00032U-3N for qemu-devel@nongnu.org; Thu, 12 Apr 2018 10:02:42 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6co3-0002uR-QG; Thu, 12 Apr 2018 10:02:31 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f6cnv-0000P0-0w; Thu, 12 Apr 2018 15:02:23 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Thu, 12 Apr 2018 15:02:22 +0100 Message-Id: <20180412140222.2096-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH for-2.12] linux-user/signal.c: Put AArch64 frame record in the right place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Richard Henderson , Laurent Vivier , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" AArch64 stack frames include a 'frame record' which holds a pointer to the next frame record in the chain and the LR on entry to the function. The procedure calling standard doesn't mandate where exactly this frame record is in the stack frame, but for signal frames the kernel puts it right at the top. We used to put it there too, but in commit 7f0f4208b3a96f22 we accidentally put the "enlarge to the 4K reserved space minimum" check after the "allow for the frame record" code, rather than before it, with the effect that the frame record would be inside the reserved space and immediately after the last used part of it. Move the frame record back out of the reserved space to where we used to put it. This bug shouldn't break any sensible guest code, but test programs that deliberately look at the internal details of the signal frame layout will not find what they are expecting to see. Fixes: 7f0f4208b3a96f22 Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson --- I'm marking this as for-2.12 on the basis that it puts our frame layout back to exactly what 2.11 had, and so seems safest. No sensible guest code should really care, though, so this is in the "only if we're doing an rc4" bucket; but I think that the softfloat fixes deserve an rc4 anyway. linux-user/signal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 8d9e6e8410..e6dfe0adfd 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1843,6 +1843,12 @@ static void target_setup_frame(int usig, struct targ= et_sigaction *ka, layout.total_size +=3D sizeof(struct target_aarch64_ctx); } =20 + /* We must always provide at least the standard 4K reserved space, + * even if we don't use all of it (this is part of the ABI) + */ + layout.total_size =3D MAX(layout.total_size, + sizeof(struct target_rt_sigframe)); + /* Reserve space for the return code. On a real system this would * be within the VDSO. So, despite the name this is not a "real" * record within the frame. @@ -1850,12 +1856,6 @@ static void target_setup_frame(int usig, struct targ= et_sigaction *ka, fr_ofs =3D layout.total_size; layout.total_size +=3D sizeof(struct target_rt_frame_record); =20 - /* We must always provide at least the standard 4K reserved space, - * even if we don't use all of it (this is part of the ABI) - */ - layout.total_size =3D MAX(layout.total_size, - sizeof(struct target_rt_sigframe)); - frame_addr =3D get_sigframe(ka, env, layout.total_size); trace_user_setup_frame(env, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { --=20 2.16.2