From nobody Sun Apr 28 17:49:46 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497970001433560.059571143523; Tue, 20 Jun 2017 07:46:41 -0700 (PDT) Received: from localhost ([::1]:49190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNKQR-0003X1-0d for importer@patchew.org; Tue, 20 Jun 2017 10:46:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNKOu-0002aZ-Hq for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:45:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNKOo-0002Fo-O6 for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:45:04 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37303) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNKOo-0002C4-Gd for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:44:58 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dNKOe-0006k7-1g; Tue, 20 Jun 2017 15:44:48 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 20 Jun 2017 15:44:45 +0100 Message-Id: <1497969886-17773-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497969886-17773-1-git-send-email-peter.maydell@linaro.org> References: <1497969886-17773-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 1/2] risu_reginfo_arm.c: Fix handling of size values in sigframe 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , 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" The code in reginfo_init_vfp() to parse the signal frame was mishandling the size counts: * the size includes the bytes for the magic and size fields, so the code to skip forward over unknown or undersize blocks was adding 4 more than it should * the size is in bytes but the "is this block too small" test was checking against an expected size in words This didn't cause any problems because the kernel happens to generate signal frames with the VFP section first. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e --- risu_reginfo_arm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 0cb9087..b0d5da7 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,7 +36,12 @@ static void reginfo_init_vfp(struct reginfo *ri, ucontex= t_t *uc) unsigned long *rs =3D uc->uc_regspace; =20 for (;;) { - switch (*rs++) { + unsigned long magic =3D *rs++; + unsigned long size =3D *rs++; + + size -=3D 8; /* Account for the magic/size fields */ + + switch (magic) { case 0: { /* We didn't find any VFP at all (probably a no-VFP @@ -57,11 +62,11 @@ static void reginfo_init_vfp(struct reginfo *ri, uconte= xt_t *uc) */ int i; /* Skip if it's smaller than we expected (should never happen!= ) */ - if (*rs < ((32 * 2) + 1)) { - rs +=3D (*rs / 4); + if (size < ((32 * 2) + 1) * 4) { + rs +=3D size / 4; break; } - rs++; + for (i =3D 0; i < 32; i++) { ri->fpregs[i] =3D *rs++; ri->fpregs[i] |=3D (uint64_t) (*rs++) << 32; @@ -86,7 +91,7 @@ static void reginfo_init_vfp(struct reginfo *ri, ucontext= _t *uc) } default: /* Some other kind of block, ignore it */ - rs +=3D (*rs / 4); + rs +=3D size / 4; break; } } --=20 2.7.4 From nobody Sun Apr 28 17:49:46 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14979699940721007.0450054982848; Tue, 20 Jun 2017 07:46:34 -0700 (PDT) Received: from localhost ([::1]:49189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNKQI-0003Po-AF for importer@patchew.org; Tue, 20 Jun 2017 10:46:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNKOo-0002Wy-Ij for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:44:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNKOn-0002Fb-Qk for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:44:58 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37303) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNKOn-0002C4-JI for qemu-devel@nongnu.org; Tue, 20 Jun 2017 10:44:57 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dNKOe-0006kM-MX; Tue, 20 Jun 2017 15:44:48 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 20 Jun 2017 15:44:46 +0100 Message-Id: <1497969886-17773-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497969886-17773-1-git-send-email-peter.maydell@linaro.org> References: <1497969886-17773-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 2/2] risu_reginfo_arm.c: Move orphan comment to risu.h. 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , 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" Move an orphan comment that describes the reginfo structure into risu.h, and expand it a little. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e --- risu.h | 5 +++++ risu_reginfo_arm.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/risu.h b/risu.h index 3fbeda8..70c2184 100644 --- a/risu.h +++ b/risu.h @@ -48,6 +48,11 @@ extern int test_fp_exc; /* The memory block should be this long */ #define MEMBLOCKLEN 8192 =20 +/* This is the data structure we pass over the socket for OP_COMPARE + * and OP_TESTEND. It is a simplified and reduced subset of what can + * be obtained with a ucontext_t*, and is architecture specific + * (defined in risu_reginfo_*.h). + */ struct reginfo; =20 /* Functions operating on reginfo */ diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index b0d5da7..6b9ee7b 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -19,11 +19,6 @@ =20 extern int insnsize(ucontext_t *uc); =20 -/* This is the data structure we pass over the socket. - * It is a simplified and reduced subset of what can - * be obtained with a ucontext_t* - */ - static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) { /* Read VFP registers. These live in uc->uc_regspace, which is --=20 2.7.4