From patchwork Tue Jun 23 14:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 191489 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp1122816ecs; Tue, 23 Jun 2020 08:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa0BhDrFDZXzmycvc9yHpr+3VXc9QifZEvDx4l3lhCevdxzcL/g1cWMPDkRx5B8oCCz+6K X-Received: by 2002:a25:3b0a:: with SMTP id i10mr37893680yba.193.1592924796163; Tue, 23 Jun 2020 08:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592924796; cv=none; d=google.com; s=arc-20160816; b=EPgmnfMGzwM+Q9bz7bbUMo+wmB2YN9WT6UeRAemYXDXZWeaYcHN2e0vyEWk19IULim Wg3sJxI9DdjLtSmF3+S4kh9ZA5XJ50zQHD956u2hjjdqZed4RPwYlrkbOZtjufr85Mdm dM7Vv/ZZGoypLC1jnR3ez7N11wA+3LHJE5PIqAGx8mXWWCiQHFuljru9X2HFngXel7f5 ULhHVtDSpbSUAirUaeqGo9NT6SlFKQghKb5ceBbs7zEju6rMGAkCrwi+NZeKlap2/QML YuuS5TWSBBV16zTGddUy8UMktQZ77jpyA4KSyQlttC45AMWQq7IQiqqK4UJdmY4uuzl7 Pukg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QdipPuDFtPEbcTTK9bILm5/cYHhEDIazGm1KaZL1a6M=; b=tJYj75r0f8qDlUjzpilCXjYVs53V6TBrLMyqzxgrL9iY+BRj0PsM7CYFCN68K1at7j sjI7d9d8iD3oEum3IX/OaSYuthKxSo9auXYPDN93iy0alYQZBCFemG3EHar7+RWlg8WM go/mvsM0eKZPhHTL8Sqw2IHlSNnPdYSZCoZ8Z/Zz9LerjO7/0aFqRXgCekYk9DWHS8Dj UQoiYkIzN/hQO3j7AfVeiW5YT3Z3/NSFJEWKi1UIOvyDGYcPivdVblY4JIqiXymPxvSk VGSoTtl3LQHPHNOMQ3pnqNLi/1EeJV3Qg9KAYNUXGN2AgKEmfTw6IRepQ27PoRiDYSA1 H23Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="nml/dKZy"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 10si5684485ybj.338.2020.06.23.08.06.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jun 2020 08:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="nml/dKZy"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnkVP-0003J4-J2 for patch@linaro.org; Tue, 23 Jun 2020 11:06:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnkAT-0006Ol-Lq for qemu-devel@nongnu.org; Tue, 23 Jun 2020 10:44:57 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jnkAR-0003TH-Cg for qemu-devel@nongnu.org; Tue, 23 Jun 2020 10:44:57 -0400 Received: by mail-wm1-x344.google.com with SMTP id g75so3206076wme.5 for ; Tue, 23 Jun 2020 07:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QdipPuDFtPEbcTTK9bILm5/cYHhEDIazGm1KaZL1a6M=; b=nml/dKZy7+JWhIOU7Jr4T7lYiz8nvFVcJTfBhbqNruV8vZoAQEDD3b3asAdJG4YE8N 1ajKdcizhm3D0J2egCwRJH5ZvwLVCwlMdUFbYhip7BHWoNoN0hfd+h2OXSr5xAMr640w iur+GdilZwv8quTN0/yLhci3JNEt7Ct24hnFV1R/P0ILKdHOfMRTc+MjcihAuUU+bSUm PvqtwuGFvFQMujrd67we0ds1dcOauqk8Ye8dmVqK320npGmLrMRiAdlyTIMNCnIoAwVg +79uYNdcojL8jyBqStPLF9bLtROpb7wfPS1L9BLsoM2cxztqoro17M91FRJYusAow9fP +ObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QdipPuDFtPEbcTTK9bILm5/cYHhEDIazGm1KaZL1a6M=; b=C8zso7BjIOVOF1pZbqxqHt1ndUrYkgySpiDZHsWd43DUzD5zwtifJaSe+P6ylp9vjp 2hqlcN88usLPDEtYYO+y9tVaaawb7TcJ5NqE2/L4WMupo3foyBcIbOZbma4ZAe5+jcIa FznlyNUFRFqXTWTcujQT6AqMN4G/LzYXnORP7V9tVLpFZDiB13eTP2BXY2BdDpkWuKzk A/z0QU0xqTVQyYv0TQ/Ybbe3ApDWwxr8NfBST7Dj4VgLzGEl+vNURJkJwzOI36QP6vJ8 qpRyNIy++gLW0Q/1UkRyK6noNt1RpfK1Sri6XUdCzIFFBepDu4ajqwCoKUARtwHF+j4Z WsBA== X-Gm-Message-State: AOAM533mlt415FDgyH24xzSbpQ3GfJAzys/hzHMagD7xhPxzAyNRrDqz HNj7YXV0ew+omnWgAajOHn93L5WuJ58= X-Received: by 2002:a1c:2402:: with SMTP id k2mr20546657wmk.138.1592923493168; Tue, 23 Jun 2020 07:44:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l17sm4130205wmi.16.2020.06.23.07.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 07:44:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 95CE91FF7E; Tue, 23 Jun 2020 15:44:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH] risu: don't do a full register compare for OP_SIGILL Date: Tue, 23 Jun 2020 15:44:46 +0100 Message-Id: <20200623144446.4243-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" OP_SIGILL means we have an unexpected invalid operation. If this is a load or store the register state may be un-rectified pointing at the memblock so would be invalid. In this case just compare the PC and make sure the other end also faulted at the same place. Signed-off-by: Alex Bennée --- risu.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/risu.c b/risu.c index 8d907d9..6d6dcf9 100644 --- a/risu.c +++ b/risu.c @@ -124,7 +124,6 @@ static RisuResult send_register_info(void *uc) switch (op) { case OP_TESTEND: case OP_COMPARE: - case OP_SIGILL: header.size = reginfo_size(&ri[MASTER]); extra = &ri[MASTER]; break; @@ -132,6 +131,7 @@ static RisuResult send_register_info(void *uc) header.size = MEMBLOCKLEN; extra = memblock; break; + case OP_SIGILL: case OP_SETMEMBLOCK: case OP_GETMEMBLOCK: header.size = 0; @@ -203,7 +203,6 @@ static RisuResult recv_register_info(struct reginfo *ri) switch (header.risu_op) { case OP_COMPARE: case OP_TESTEND: - case OP_SIGILL: /* If we can't store the data, report invalid size. */ if (header.size > sizeof(*ri)) { return RES_BAD_SIZE; @@ -223,6 +222,7 @@ static RisuResult recv_register_info(struct reginfo *ri) respond(RES_OK); return read_buffer(other_memblock, MEMBLOCKLEN); + case OP_SIGILL: case OP_SETMEMBLOCK: case OP_GETMEMBLOCK: return header.size == 0 ? RES_OK : RES_BAD_SIZE; @@ -250,7 +250,6 @@ static RisuResult recv_and_compare_register_info(void *uc) switch (op) { case OP_COMPARE: case OP_TESTEND: - case OP_SIGILL: /* * If we have nothing to compare against, report an op mismatch. * Otherwise allow the compare to continue, and assume that @@ -270,7 +269,14 @@ static RisuResult recv_and_compare_register_info(void *uc) res = RES_END; } break; - + case OP_SIGILL: + /* We can only check the op and PC */ + if (header.risu_op != OP_SIGILL) { + res = RES_MISMATCH_OP; + } else if (header.pc != get_pc(&ri[APPRENTICE])) { + res = RES_MISMATCH_REG; + } + break; case OP_SETMEMBLOCK: if (op != header.risu_op) { res = RES_MISMATCH_OP;