From patchwork Tue May 19 02:53:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186906 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3446965ilb; Mon, 18 May 2020 19:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEnBk4WW7NS37eIhGqAlfTUYPvS4HsN5ckkWkgA2lbPg6IDPguiTSgwado5611YhK/poAP X-Received: by 2002:a05:620a:1f7:: with SMTP id x23mr19432940qkn.491.1589856946650; Mon, 18 May 2020 19:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856946; cv=none; d=google.com; s=arc-20160816; b=soISeuvtNGfr9MKwUnzvtWWb010gaajizmImB5KDcCJGho1iWfZFprEy8720Gbiqex UZdJ3kg6fSt07/1AXqU9xnWO7rx1pj4UE3l3MuvOPVUUpf6dbVlcXj6Wn5yDiNEogrkJ ChHx1zzkAnRSfzy12OLp39+qj9k8nnip+D2DTfKGTbqmg9QxTHd9OB+MnRLCjhNLeGg7 DYhBAlYOoBZ56VeawFasbg+mX3vfwUMsJFdXUVQQC7bGzb6Q1H5EwDwOZB1BvP3OInvK DkGD1v+R9WgAYvN5+O9S+lJWSOCkmJqpOfiNs4UGLpCop5qatXa5afiqIstTuTx+6Nzn AG1g== 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=J6GEOI64wSUnLIdW8jpIq6kLD++FF+yxc6i0EiqZJFU=; b=rhjU1DBgFlW1wymgOGwGTNIO1A/5yYgG4KvFrnA7DVsF44MUx1oWda/d4bzHVzHYLw ylzIf+PMLM6QywSnfdeT12Krc8P6XbmZeDKALCfRGn+T3oDtvEL2D8pIwM7548/A31mU 3x3WLNApnPJ2vWxEZamAX/Z/5R8AV+/J9sy7Rn2xUVWkdbwvxoZDRIohfadykAOma6Sx N0WQe4LbsC2mBGCtuNJoMrlNhQzQFlaIH4VMYzm4Td9ofPQuaL68HtiLl75XEomjxOif 1DbRTGKVI0gECz0kIivUMbZpaaJaM0ralRBkMLfb9ZW6TcCz1D9WSpz9KkLwHTFD7jSM V9dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yB4GxqVR; 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=pass (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 c15si6363538qvo.71.2020.05.18.19.55.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:55:46 -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=pass header.i=@linaro.org header.s=google header.b=yB4GxqVR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasPy-0008VK-40 for patch@linaro.org; Mon, 18 May 2020 22:55:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOH-00056h-Pj for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:01 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:35861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOH-0002OQ-1D for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:01 -0400 Received: by mail-pf1-x42d.google.com with SMTP id z1so5876663pfn.3 for ; Mon, 18 May 2020 19:54:00 -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=J6GEOI64wSUnLIdW8jpIq6kLD++FF+yxc6i0EiqZJFU=; b=yB4GxqVR9ejP+DUevjbKZtciyXoe7y3iRBX2baTlao2QsZ2hjQFnWCDEod1Q3B/Zi3 URENq4sg54ZZkcUce8dbCQoOUrXNnfrzKpPj/TcZWFlfJaw5G2QS0jq1IXsiDz9ss1uB AtcN/wEQXH+1Q4XddpVbZLbrOmCKMD+j1dZse1X2L0lef5ibZrJwov9uJBp9+eiKgexI 8vVujPI4N/k3CViP2dy7E6Boro459+Dqusrz+NzU8AuK0v+Cj1vV3TW2+gWK3K+0QsRR YQdrC/niOhcI0NHNhBt95lTbnfbCvIl2EEF/kM83vs8ktf5LTa47C7K/9pAblFea9EyA nDOg== 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=J6GEOI64wSUnLIdW8jpIq6kLD++FF+yxc6i0EiqZJFU=; b=TcI7drd9RDvJFRUgnLiKRjhIYISPAWQlE/s/eRJdtnYVF683q13c/G43uvP/Z7mSUH UMdcbIOGgs+oDRw0YtpzL9e9wkn/puJfAXtI+SB1nHQPR2s01Hmo2KRVLfM5O0WHr/QR 1QY8FPpcqLq1qtRvYvhhn7DexCC3P8hEErJV3Z7XJndNVzYFuS59T5Gab75B2fUH4tNk ts0fu9gGsFyESSSjVSbMsiG36IfafZjdvgTRTtQbpLuIHv3Q1HfYcDv/7nxywlX7Ksdr tWfOlwJ7Vn64ymxuAj0KeWiKbq399y2s7oWwC5Roc4mzDl8L19B7Mbm8AurVTGeBUNK3 op4A== X-Gm-Message-State: AOAM530N7yoxQbM0SAJH1wKpIy9/rKpy7PRKv6/yY8domA6J8FhjSoFR THu81SjsGUCjWgcWrym2CRwkI+dVPwk= X-Received: by 2002:a63:175c:: with SMTP id 28mr16761352pgx.44.1589856839108; Mon, 18 May 2020 19:53:59 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:53:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 01/17] Use bool for tracing variables Date: Mon, 18 May 2020 19:53:39 -0700 Message-Id: <20200519025355.4420-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.h | 3 ++- reginfo.c | 2 +- risu.c | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index 8d2d646..e2b4508 100644 --- a/risu.h +++ b/risu.h @@ -17,6 +17,7 @@ #include #include #include +#include /* Extra option processing for architectures */ extern const struct option * const arch_long_opts; @@ -96,7 +97,7 @@ int recv_and_compare_register_info(read_fn read_fn, * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(int trace); +int report_match_status(bool trace); /* Interface provided by CPU-specific code: */ diff --git a/reginfo.c b/reginfo.c index dd42ae2..1b2a821 100644 --- a/reginfo.c +++ b/reginfo.c @@ -141,7 +141,7 @@ int recv_and_compare_register_info(read_fn read_fn, * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(int trace) +int report_match_status(bool trace) { int resp = 0; fprintf(stderr, "match status...\n"); diff --git a/risu.c b/risu.c index 01525d2..79b1092 100644 --- a/risu.c +++ b/risu.c @@ -31,7 +31,7 @@ void *memblock; int apprentice_fd, master_fd; -int trace; +bool trace; size_t signal_count; #ifdef HAVE_ZLIB @@ -228,7 +228,7 @@ int master(void) signal_count); return 0; } else { - return report_match_status(0); + return report_match_status(false); } } set_sigill_handler(&master_sigill); @@ -250,7 +250,7 @@ int apprentice(void) #endif close(apprentice_fd); fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); - return report_match_status(1); + return report_match_status(true); } set_sigill_handler(&apprentice_sigill); fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", @@ -344,7 +344,7 @@ int main(int argc, char **argv) break; case 't': trace_fn = optarg; - trace = 1; + trace = true; break; case 'h': hostname = optarg; From patchwork Tue May 19 02:53:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186903 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3446337ilb; Mon, 18 May 2020 19:54:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMNF0/q2s6018cN0cXTjfS9+ShJIEeGCv2BiFo2ZJ2angqkuUKL6K6gA7GOx50P/Dftaok X-Received: by 2002:ac8:4cd1:: with SMTP id l17mr20044942qtv.20.1589856859330; Mon, 18 May 2020 19:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856859; cv=none; d=google.com; s=arc-20160816; b=IVZ9se6t6ChZeefSg+c4KJSp8hiUVkPgxO+gnFAYla4/DRqTaq+aRDgQi+Zmou8Upo 2NXodEOyN+SKYC/xsTSR2sAAb9AncMwK8A0A4lVh39A/DgEv5/ZQjf6RsyXll0D7bEQP kDJpHieR5qWiFPyjiTydwg8HGqI2UghX0ng/54/DQ0vPhihQihwZSIazZNMpz5TryL8d cAGyQ9vvzUXmEnpn2CzQBl9sOUDdl7ghbotpZ0Cn2SavxXlOdxBV9SWoozocgSnVHZUk A4ps4YEmv9aboGi29TT7yAMvsLG3ePnwvgv7PsMqr3ucvzKVDtBwuYSf2ZCNpQsKCy+x 5rxg== 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=hFfYOrqCfWexdaAHxTkkt1dBQCoR5xQQDuHTPb8NKqM=; b=OiW3f2Thp0YS6CrZBXpgG9LeZqKJjxtmNM2XLKvzsm3fJ0gzOWB6UP9wDcTGza69Vl 2oriYa5kZAKd+EfjFfF0uG0sDiR9h3IzdRl420GYi3vLCqO0N4UQrun3Wn0fp4xMOAFk 4aQl70jqch+ic8zg3mx1t/RcfNLI7MnWbSolq5d/WiJvVvw2MDHLx8oL+uIz3H+mO28U QYacsMx+gN+2MqNGVL/5cwJC2zFMBDvttZJMjLMTH8xDxCMO+tW13rzqXw5dP6Sx7z5B oY89HfK0f0QjqhKaxbHYlsZwZvDdvaLJVVEItT3TTqubA5wwzHWH+K4pN+WpTLUWCkxX Nu7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kovW2DMt; 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=pass (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 dy6si6116363qvb.185.2020.05.18.19.54.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:54:19 -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=pass header.i=@linaro.org header.s=google header.b=kovW2DMt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasOY-0005A3-KB for patch@linaro.org; Mon, 18 May 2020 22:54:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOJ-00057r-2D for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:03 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:34531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOI-0002Ob-7m for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:02 -0400 Received: by mail-pl1-x630.google.com with SMTP id d3so314320pln.1 for ; Mon, 18 May 2020 19:54:01 -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=hFfYOrqCfWexdaAHxTkkt1dBQCoR5xQQDuHTPb8NKqM=; b=kovW2DMtDlDpBwcUexCUcC7gk9c2YSE2hZUT12hhyYOqX78PFeQy2jXi61AtM17TWw abMlaH9hBkL9kddVVi/DJtjtafaY9t8tqXq8D4Psq99jq2xQNGvor7R8iQC3TVUEwo0Q 391+oAgDPHHfsXS0v2qQ8fWIumCXqj6JdIVJVVFdVubyzsPdVmkXoUBBqPqsv5lqVl04 mjyfDO3FlAz68AqixpTRfX+GeU/RukDKnP4Go8K5HP1PxqcNaXtOShBxhf0h9D3PelEC fjdhQ+dkb5xdDZnqA0aSQ6yUM88cQ5GplhXXLzPqq/nqGjj94YJdNkNO7pPc2M344Ksg Vxsg== 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=hFfYOrqCfWexdaAHxTkkt1dBQCoR5xQQDuHTPb8NKqM=; b=XbwOs09m/DWUoqnyQUAnkxrAjBDB4OJjS9ZJzLUTPlIb/FqZJ63llBCdP7iWFbg/VN o1HsihcbRfXd+uI+7W11O1p7bod+SfZstx0VE/i+dcPmS6L2oGPMKSKrXlFsA7549CCN ZBFt8Dk8MgRgJpyk/m0yYTPY/x2eAJAF+jssytQzfgb1VRfZ6fbz/w05n/KOpvDOU0aW wGmw/RjKHqwqeyyvM0tVD0h91xsi6i1d55VQKbzpoxvZNUd/mw555zR91PnwB+Vkeuc5 0BG20SkZKtR0oCcT1bRzWGc5DhXLqa9nCVnaza0Hd2AStQ6gBf1rggwWvF06e3n40XBm +tTA== X-Gm-Message-State: AOAM532czBmA/ezhg29XFYVIq7AI/bWoBmzgaSIDRuwmkSsj4nVvptJI KR0xI7dcLPX4Q9U8ddSWGKkl5Kr254A= X-Received: by 2002:a17:90a:2051:: with SMTP id n75mr2578110pjc.112.1589856840321; Mon, 18 May 2020 19:54:00 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:53:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 02/17] Unify master_fd and apprentice_fd to comm_fd Date: Mon, 18 May 2020 19:53:40 -0700 Message-Id: <20200519025355.4420-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Any one invocation cannot be both master and apprentice. Let's use only one variable for the file descriptor. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 79b1092..059348f 100644 --- a/risu.c +++ b/risu.c @@ -30,7 +30,7 @@ void *memblock; -int apprentice_fd, master_fd; +static int comm_fd; bool trace; size_t signal_count; @@ -50,7 +50,7 @@ sigjmp_buf jmpbuf; int read_sock(void *ptr, size_t bytes) { - return recv_data_pkt(master_fd, ptr, bytes); + return recv_data_pkt(comm_fd, ptr, bytes); } int write_trace(void *ptr, size_t bytes) @@ -58,9 +58,9 @@ int write_trace(void *ptr, size_t bytes) size_t res; #ifdef HAVE_ZLIB - if (master_fd == STDOUT_FILENO) { + if (comm_fd == STDOUT_FILENO) { #endif - res = write(master_fd, ptr, bytes); + res = write(comm_fd, ptr, bytes); #ifdef HAVE_ZLIB } else { res = gzwrite(gz_trace_file, ptr, bytes); @@ -71,14 +71,14 @@ int write_trace(void *ptr, size_t bytes) void respond_sock(int r) { - send_response_byte(master_fd, r); + send_response_byte(comm_fd, r); } /* Apprentice function */ int write_sock(void *ptr, size_t bytes) { - return send_data_pkt(apprentice_fd, ptr, bytes); + return send_data_pkt(comm_fd, ptr, bytes); } int read_trace(void *ptr, size_t bytes) @@ -86,9 +86,9 @@ int read_trace(void *ptr, size_t bytes) size_t res; #ifdef HAVE_ZLIB - if (apprentice_fd == STDIN_FILENO) { + if (comm_fd == STDIN_FILENO) { #endif - res = read(apprentice_fd, ptr, bytes); + res = read(comm_fd, ptr, bytes); #ifdef HAVE_ZLIB } else { res = gzread(gz_trace_file, ptr, bytes); @@ -218,11 +218,11 @@ int master(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB - if (trace && master_fd != STDOUT_FILENO) { + if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); } #endif - close(master_fd); + close(comm_fd); if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); @@ -244,11 +244,11 @@ int apprentice(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB - if (trace && apprentice_fd != STDIN_FILENO) { + if (trace && comm_fd != STDIN_FILENO) { gzclose(gz_trace_file); } #endif - close(apprentice_fd); + close(comm_fd); fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); return report_match_status(true); } @@ -375,31 +375,31 @@ int main(int argc, char **argv) if (ismaster) { if (trace) { if (strcmp(trace_fn, "-") == 0) { - master_fd = STDOUT_FILENO; + comm_fd = STDOUT_FILENO; } else { - master_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); #ifdef HAVE_ZLIB - gz_trace_file = gzdopen(master_fd, "wb9"); + gz_trace_file = gzdopen(comm_fd, "wb9"); #endif } } else { fprintf(stderr, "master port %d\n", port); - master_fd = master_connect(port); + comm_fd = master_connect(port); } return master(); } else { if (trace) { if (strcmp(trace_fn, "-") == 0) { - apprentice_fd = STDIN_FILENO; + comm_fd = STDIN_FILENO; } else { - apprentice_fd = open(trace_fn, O_RDONLY); + comm_fd = open(trace_fn, O_RDONLY); #ifdef HAVE_ZLIB - gz_trace_file = gzdopen(apprentice_fd, "rb"); + gz_trace_file = gzdopen(comm_fd, "rb"); #endif } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - apprentice_fd = apprentice_connect(hostname, port); + comm_fd = apprentice_connect(hostname, port); } return apprentice(); } From patchwork Tue May 19 02:53:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186907 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447017ilb; Mon, 18 May 2020 19:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+VlBElWi6gS8pS5Zo5RYflhZI09NYnyKJQkmBvpchwDUPAl3Rmd+0nbB+pSkcGv6lAKEJ X-Received: by 2002:ac8:4d96:: with SMTP id a22mr14735747qtw.10.1589856951692; Mon, 18 May 2020 19:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856951; cv=none; d=google.com; s=arc-20160816; b=zEzcASykJ4Cx1yjKHWS8C1kiOhmO6egcG2m5Wltg+siZx2Bw8Lp/t/LHa6GJ3RaZLq um5justr0xu48s2WtHYJblJNLD4dKvCIPi2nPbBYJSc8wwIFGiZkAT3UNR+gh0oVP6wq Gt+VyqlhrEsyPgV0Knq4GfYTa+1i4tQFqSC+RxxMnvQ7j9HcWlV/RrHiBx3k7WqEifnB uVgdp9qVAKs3igC2arxHKOtAltsIXlBwLYXOISBNgbWvym64J4lN0Pg0LCKGWSU7tTrG xmd5B8w+f45uojF+Cvr1T7E6qv2/iCLQtMlrb709ShfMIhZC1DPd6cg8fcEfM5Flg4d8 ogqw== 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=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=SnG9usxUm2o9pqFjKp+6hl8ew4oGKuwLyNN+L7kS1AZFAvexoEktPmNGOCQQ6rC294 HD6wb5FAyXnrQjNOCUBiu0mZ2pwaw2Ra5+lZ8eX6mw8S0wxeaS61SeMSiUHWd2IxT8vx UPZf31TdXGmAQK1EPUnuesvsoL/y1PAJRMxDR6cDBZ+TlYzZo/PVm8OrDMP9bQujYxSO PuzD96TMnfC+A1PdhLNUIBselEx0A8e5J8dSA5yH9sgkrhAuxjEypSJ2N3xwDkm8sV4U deMdmSY0sXn2LLr333c0KXPTQ7+AfF22lllNF2h0YE6iZDKelTvRlBxSnU7r1dsrWb5v q/lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDzPjGjL; 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=pass (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 d5si6604441qkf.76.2020.05.18.19.55.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:55:51 -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=pass header.i=@linaro.org header.s=google header.b=QDzPjGjL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasQ3-0000CE-8Z for patch@linaro.org; Mon, 18 May 2020 22:55:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOK-00059U-CB for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:04 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:50920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOJ-0002Om-Hg for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:04 -0400 Received: by mail-pj1-x1030.google.com with SMTP id nu7so706497pjb.0 for ; Mon, 18 May 2020 19:54:03 -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=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=QDzPjGjL4SM/hI5CHVYRhL25SSqtD7Z6l1jBJfKKHP5eMfGT0+Jf/9mX4vk5p8IL5R Re+sn4zVEOD4gtWMrIblWf+pUc+ddMXvSDlK8ktO7tCy3+fXmHpw9/X7WHTQKxJtPVgU +rIGkvC55aMVO3Ccy9QELodleKol4Yb1p6ztHScA/zZ9JCDUqxhsyxSklqPvIU2QTnbf s79nJ9CYr1BSXWb7covF+V0HGDo4e5AvMddeBaHW7ozm1lUG1zMujhszqx4BLBc/T+W7 s+F1qP/H78fLh5g9KvSSfI4hoVhfa2Ty2Zzas1/eDUCDuEd3MjmgPV71RpSlYHsyz7YE q1NQ== 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=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=qImDlZV72BHZT4cY8sc4o8fJ1XtpAKetak8BKOyTjkBa3FT1qWd1B0yJ+lTCj3DGcv PJ9tDJMqUFUp3nAyTEuw3ZkpgHj1oX+Ns9s2GirueDMcBLBPnHfgpyJ9auj3TI3oVnsB wT9pbKTT5ubTO1eaFA/S3UhfAdCQZmJJU/dAiXllCdayB4QkhiT1bYsX/i97h98sDziI DaxUHKffJQT01Rmh8Zyh1Sx6yQeZWi9HOVrFb8hksCi5nfc8f+JJzBvldRBM3EkGwXvs w34to5W+sJIutp6V0KW74anWk3RXIvoimtBTlkh+VqX35Xb2hFU0TM/hNMzuJDxf3PNF Is7g== X-Gm-Message-State: AOAM5308ANTc9yd66ClVQbLRvaGFXUr1bwwG8OU9W5biAk8IZ+3q/zzH RCPl2Qh2ld/k50xn35xSgPiAVFZBxXk= X-Received: by 2002:a17:90b:789:: with SMTP id l9mr2564325pjz.111.1589856841627; Mon, 18 May 2020 19:54:01 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 03/17] Hoist trace file opening Date: Mon, 18 May 2020 19:53:41 -0700 Message-Id: <20200519025355.4420-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code with --dump. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 059348f..1c66885 100644 --- a/risu.c +++ b/risu.c @@ -363,6 +363,21 @@ int main(int argc, char **argv) } } + if (trace) { + if (strcmp(trace_fn, "-") == 0) { + comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; + } else { + if (ismaster) { + comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + } else { + comm_fd = open(trace_fn, O_RDONLY); + } +#ifdef HAVE_ZLIB + gz_trace_file = gzdopen(comm_fd, ismaster ? "wb9" : "rb"); +#endif + } + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -373,31 +388,13 @@ int main(int argc, char **argv) load_image(imgfile); if (ismaster) { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDOUT_FILENO; - } else { - comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "wb9"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "master port %d\n", port); comm_fd = master_connect(port); } return master(); } else { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDIN_FILENO; - } else { - comm_fd = open(trace_fn, O_RDONLY); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "rb"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); comm_fd = apprentice_connect(hostname, port); } From patchwork Tue May 19 02:53:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186904 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3446352ilb; Mon, 18 May 2020 19:54:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylG6BebkpuxVq6xDN//NZS+FLqwxJKwzIsaBBvkZ4pX3XxeXKaFi82obbjD6g8XVuTviZW X-Received: by 2002:a37:6857:: with SMTP id d84mr8465709qkc.42.1589856861629; Mon, 18 May 2020 19:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856861; cv=none; d=google.com; s=arc-20160816; b=h9nqjaa2vTulu34vOl6X7S6YO7mx913p86zI5a7wUqFnMPlil0zSOfy6BqTgOASAnK 7X/EpmIWQXRABLKE7IiMMoutuf9wLfHZpGpQ0xfEyebO7lYOyQKFPCW3H87X+WOhI98f hSkDJTCTo+FthbEzklajnP6NJdZFyJqoR69erS/S3Ai6pApsVwsyJE0kQi4MjufxC4Bi W5zJrOoZflMuaJRgp1VY/GpfEE2rL+ASRH1ytG4GA2BLv6Fypyv5y8jQhVEPFtAlGnz5 xBS/DDnXsiKj1GFe9JOo12osRSZco4TJJoFzIK+47MXqhC1vI8JXovS5s6sqWmsBYzBD EF5g== 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=AybC5+AFZZgiZxEHJk4RYMN+nVSUkMOWZVM2DrgRF3s=; b=gQlVNTl6fZNK/F4wCuMAGrEY7eZa5Pyh0gZV9IQFhpL515bG0CmY1alkr0HRHRmU4u 7Wf1JHOz7NVLxDx3lJoyLaClSh41rkHANRD4iHd0ahb3L4cvF3yiMtLOGTXZmqtJYwUm Xu/e5IIFYm35vkCstmojyZm6TIDfKbAWV819FilGtEcmEKUjpUPOjpBG9ILoGFNsrqAW HgaFUU0/9wb4OscYcCUr0aE5Y3Y77/XKM+MWxuVVqVSz7womC04/+Chm0wRu7g9q3bsi znySHV9jlG6kwACmLQ2d4s7GSnpoX9ruOS93OjOoy6Ic5KnYw5kREXZ2XAoFJAHcyjnt MyJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a4ZpaKdt; 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=pass (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 l3si6810334qtn.119.2020.05.18.19.54.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:54:21 -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=pass header.i=@linaro.org header.s=google header.b=a4ZpaKdt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasOb-0005DZ-3l for patch@linaro.org; Mon, 18 May 2020 22:54:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOL-0005Ay-84 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:05 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:40259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOK-0002P8-F1 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:04 -0400 Received: by mail-pj1-x1041.google.com with SMTP id ci23so711346pjb.5 for ; Mon, 18 May 2020 19:54:04 -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=AybC5+AFZZgiZxEHJk4RYMN+nVSUkMOWZVM2DrgRF3s=; b=a4ZpaKdtnrsEGdVV9NMwg1AbtI8gOOs15h1CpoxTxPcFMAkYM/ASf10OXVcapBRh39 28frS27EVYX14eg7dKcYqL5oqiOuFBnEcsaSn0HblL3CzzLbWX8Lf+3/+hO3MPrhhVFJ XGVY21SJPw6q0sMHhiHv7wxiTCZWS4CKrVi9PB11g09hprqLx5Ed5YJtcVHWJ35e4TIe PwsQDcMsPyz/f7LK8UBOwDotKSVrQT4LCJ2x7EJHfGt69imPPT98oonmft5CaaiDAKLI gVMY6yI+3FnzjGRI1ig5ZVsQEbjIYNjJ7TfdpeAsx1UHv/kAlj2yrjMhCwpOtDS4Yivy jJ6g== 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=AybC5+AFZZgiZxEHJk4RYMN+nVSUkMOWZVM2DrgRF3s=; b=aR4b489cfUFrulnNodmUWN9hJ49pZ8RUYS5gagZViUR4klk5wpCtGtR8PrwGNjY+xp YCFbyLNr81jBOiWqSOn1W2Ctr3tXavYn+gLELEfIyg13MC67CjvHXdPfcjxh4urmWh2r NTOjMz5kyLDox4f2EB/mRi9OjxVKK9n8eRYZ9EQraxyy+c1VfJipdtpc7+bXJbPzs1nH 48SL/pwndToA2uDiE/5MSqh/XFGo1WAFtD6MB2MBbFemotyRSo6EcFntLz9Ckw+HMkCo x1qf1gcVKuYn7DrEjRL1TwxzlpBjfAVbd43rLM7ZI8QvQYy87NoBVwrP0TvnY5wkrxln XqgQ== X-Gm-Message-State: AOAM532VGfcPIoWxTbQ23kj/2YD740kB7dZYLZtdMs+6BwGfE2z9K5GX 8BNwoeG0k5683in7fyzJUcFefTtsOZk= X-Received: by 2002:a17:90a:1464:: with SMTP id j91mr2765954pja.87.1589856842794; Mon, 18 May 2020 19:54:02 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 04/17] Adjust tracefile open for write Date: Mon, 18 May 2020 19:53:42 -0700 Message-Id: <20200519025355.4420-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Truncate the new output file. Rely on umask to remove group+other file permissions, if desired. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 1c66885..f404d8f 100644 --- a/risu.c +++ b/risu.c @@ -368,7 +368,7 @@ int main(int argc, char **argv) comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; } else { if (ismaster) { - comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + comm_fd = open(trace_fn, O_WRONLY | O_CREAT | O_TRUNC, 0666); } else { comm_fd = open(trace_fn, O_RDONLY); } From patchwork Tue May 19 02:53:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186911 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447617ilb; Mon, 18 May 2020 19:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHsJxn0ZJK33dVGZV6w39NeCE8CeSz38gBRQWQRJw/5hijCwFLn2UJfJ3kw87+dbOUoVtx X-Received: by 2002:a0c:b44c:: with SMTP id e12mr18784718qvf.30.1589857032205; Mon, 18 May 2020 19:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857032; cv=none; d=google.com; s=arc-20160816; b=CjOVV1w/GVEVtzDtDp3AD5ofm7dOw8+dtDgfgKgTDDlHPDldO3v5wx3U/NTPn2Iy0R XXFF9qEwN4J8jT9/Ngh5MNDj/dbLff9+a90pcN1/qfdmikxZWMmz7LzWhjVzVWbWxM9f JbD3lpX3s6PTZPtEV3WCFYXRCBXoQYFq7kY+/pscSUPZg1v6RPMkow/ossCUMDKWN/ZH xC92G8DgucsZpoiYd3R+Nep6GznxYyaF1XA1LYVuqkeEDXRyKKiGf8gnaQqF4STefzHH HZBN8R6Q+CQRdHTNA+bSJIJQ5kRMSp101sBBpM9fufJMivWxuSm4C+26QH7zAztTBlXm baDg== 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=Gkn7wByXSMaAlsqr+FZUsAQqZ3Lrn4UK0Nd8TGF1NTg=; b=u8wTx5OEKTzfTYhBP1TShCIeX5cECfR6bVWTC76bNxRdBGd477wFnsfLrMGHTcmeuW OM3jIJFo62HLZycg9ZATRbmfSEfkD7BrIqnCrqtL1ZOq5W1uk5C2Dkm0v5onSK4Ux236 MpgGvOzPMJ3lMsNORzThIRth9RicdV21eo8MyZrFqpZVLHto2Am1SGHfVzmPXwbo53jr q/BUfvVNAHuEeP5em05LDEUVTQ9QTMuq0V2A1539txNaJU5U43jQL9osNfgrW8kFbocu CR42sQr+cU0tV5F8OABV0r492NzzoQugEz8HVrspzNYspK9CbxpGMMdgod8e1YFmdhob dpzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sggDIA9I; 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=pass (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 o21si7042428qtf.205.2020.05.18.19.57.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:57:12 -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=pass header.i=@linaro.org header.s=google header.b=sggDIA9I; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasRL-0003gp-Nx for patch@linaro.org; Mon, 18 May 2020 22:57:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasON-0005Et-1D for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:07 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:33611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOL-0002Pb-Tt for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:06 -0400 Received: by mail-pl1-x633.google.com with SMTP id t7so5040845plr.0 for ; Mon, 18 May 2020 19:54:05 -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=Gkn7wByXSMaAlsqr+FZUsAQqZ3Lrn4UK0Nd8TGF1NTg=; b=sggDIA9IMV1zv1XtEA6/+qvXi1YvJ7QzN5COet5oXvFn27dy4R6Ub0Zf8jG7D8gP0N opUD9EMRwkcRPzeEIe5nehvseUqPXncfftGT4pYMSDl0X8iOQDXcy9dhWyW91EjFFHOx OmrhG+qATc2UcOZo1oEa2E1D+7tT2gZSrJjqE5ePJEREuFl6skf0kzl9iI2b+efSC2TP EfrUleSH9U2BPNk382v4Wqan2wO8fZ+ygQ2UjZyXL/C4GfAiKHq/gnyRfdQ+eckphnIL 0axRsXcnxMwQh6Ks+QcamFM86U7xl4MxKHAT8AFIpSbOgCvucprmIccjmdeyRbPj5je9 2yHQ== 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=Gkn7wByXSMaAlsqr+FZUsAQqZ3Lrn4UK0Nd8TGF1NTg=; b=tgkN4b0zEPmnh2I0XtOK5rkXhbE5UVW5e83PkZlMqpWKURZyx609ODuTE/n1spRvH+ ZKMlzKajCxGbtwAwB1RSnFlt+MmS+h9XB+rjubKvvZxWOvlECnHnFTS5l0Ub1NmL7sTh LwvJXiOnLBwXAVKZBTuuh369kmCZ3iznE5bCJ8A70TWssoMy8ARDCr/cE0YnJO6/3+ts NJ9sbWYq9qCp08EcOBfRgIfl9bnQDZEcGKkLGd16TEPC+DkoZIWHvIFUOUA6L5qcaiaI IH6a0ZnaEcA6bOh4bz0myoFsdcKEhRvUvQ19l2Y4jgGxj5KtGENjPZq8V2oTx4Frw+rX 6xHA== X-Gm-Message-State: AOAM532XQFxYNlrE0Bm57UD84lO1Wbl6pouOnbz7CRVBwiRSFhwnCWff lMHf06wNS2mJR1m9poxNkIRD27Mc32U= X-Received: by 2002:a17:90a:8a08:: with SMTP id w8mr2705121pjn.53.1589856844037; Mon, 18 May 2020 19:54:04 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 05/17] Use EXIT_FAILURE, EXIT_SUCCESS Date: Mon, 18 May 2020 19:53:43 -0700 Message-Id: <20200519025355.4420-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Some of the time we exit via the return value from main. This can make it easier to tell what it is we're returning. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- comms.c | 26 +++++++++++++------------- risu.c | 22 +++++++++++----------- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_i386.c | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/comms.c b/comms.c index 6946fd9..861e845 100644 --- a/comms.c +++ b/comms.c @@ -31,7 +31,7 @@ int apprentice_connect(const char *hostname, int port) sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); - exit(1); + exit(EXIT_FAILURE); } struct hostent *hostinfo; sa.sin_family = AF_INET; @@ -39,12 +39,12 @@ int apprentice_connect(const char *hostname, int port) hostinfo = gethostbyname(hostname); if (!hostinfo) { fprintf(stderr, "Unknown host %s\n", hostname); - exit(1); + exit(EXIT_FAILURE); } sa.sin_addr = *(struct in_addr *) hostinfo->h_addr; if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { perror("connect"); - exit(1); + exit(EXIT_FAILURE); } return sock; } @@ -56,13 +56,13 @@ int master_connect(int port) sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); - exit(1); + exit(EXIT_FAILURE); } int sora = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &sora, sizeof(sora)) != 0) { perror("setsockopt(SO_REUSEADDR)"); - exit(1); + exit(EXIT_FAILURE); } sa.sin_family = AF_INET; @@ -70,11 +70,11 @@ int master_connect(int port) sa.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { perror("bind"); - exit(1); + exit(EXIT_FAILURE); } if (listen(sock, 1) < 0) { perror("listen"); - exit(1); + exit(EXIT_FAILURE); } /* Just block until we get a connection */ fprintf(stderr, "master: waiting for connection on port %d...\n", @@ -84,7 +84,7 @@ int master_connect(int port) int nsock = accept(sock, (struct sockaddr *) &csa, &csasz); if (nsock < 0) { perror("accept"); - exit(1); + exit(EXIT_FAILURE); } /* We're done with the server socket now */ close(sock); @@ -104,7 +104,7 @@ static void recv_bytes(int sock, void *pkt, int pktlen) continue; } perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } pktlen -= i; p += i; @@ -127,7 +127,7 @@ static void recv_and_discard_bytes(int sock, int pktlen) continue; } perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } pktlen -= i; } @@ -186,12 +186,12 @@ int send_data_pkt(int sock, void *pkt, int pktlen) if (safe_writev(sock, iov, 2) == -1) { perror("writev failed"); - exit(1); + exit(EXIT_FAILURE); } if (read(sock, &resp, 1) != 1) { perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } return resp; } @@ -217,6 +217,6 @@ void send_response_byte(int sock, int resp) unsigned char r = resp; if (write(sock, &r, 1) != 1) { perror("write failed"); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/risu.c b/risu.c index f404d8f..979341c 100644 --- a/risu.c +++ b/risu.c @@ -153,13 +153,13 @@ void apprentice_sigill(int sig, siginfo_t *si, void *uc) return; case 1: /* end of test */ - exit(0); + exit(EXIT_SUCCESS); default: /* mismatch */ if (trace) { siglongjmp(jmpbuf, 1); } - exit(1); + exit(EXIT_FAILURE); } } @@ -173,7 +173,7 @@ static void set_sigill_handler(void (*fn) (int, siginfo_t *, void *)) sigemptyset(&sa.sa_mask); if (sigaction(SIGILL, &sa, 0) != 0) { perror("sigaction"); - exit(1); + exit(EXIT_FAILURE); } } @@ -190,11 +190,11 @@ void load_image(const char *imgfile) int fd = open(imgfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "failed to open image file %s\n", imgfile); - exit(1); + exit(EXIT_FAILURE); } if (fstat(fd, &st) != 0) { perror("fstat"); - exit(1); + exit(EXIT_FAILURE); } size_t len = st.st_size; void *addr; @@ -207,7 +207,7 @@ void load_image(const char *imgfile) 0); if (!addr) { perror("mmap"); - exit(1); + exit(EXIT_FAILURE); } close(fd); image_start = addr; @@ -226,7 +226,7 @@ int master(void) if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); - return 0; + return EXIT_SUCCESS; } else { return report_match_status(false); } @@ -237,7 +237,7 @@ int master(void) fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + return EXIT_FAILURE; } int apprentice(void) @@ -258,7 +258,7 @@ int apprentice(void) fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + return EXIT_FAILURE; } int ismaster; @@ -355,7 +355,7 @@ int main(int argc, char **argv) break; case '?': usage(); - exit(1); + return EXIT_FAILURE; default: assert(c >= FIRST_ARCH_OPT); process_arch_opt(c, optarg); @@ -382,7 +382,7 @@ int main(int argc, char **argv) if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); usage(); - exit(1); + return EXIT_FAILURE; } load_image(imgfile); diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 00d1c8b..028c690 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -51,7 +51,7 @@ void process_arch_opt(int opt, const char *arg) if (test_sve <= 0 || test_sve > SVE_VQ_MAX) { fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); - exit(1); + exit(EXIT_FAILURE); } want = sve_vl_from_vq(test_sve); got = prctl(PR_SVE_SET_VL, want); @@ -62,7 +62,7 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", test_sve, (int)sve_vq_from_vl(got)); } - exit(1); + exit(EXIT_FAILURE); } #else abort(); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 194e0ad..60fc239 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Unable to parse '%s' in '%s' into an xfeatures integer mask\n", endptr, arg); - exit(1); + exit(EXIT_FAILURE); } } } From patchwork Tue May 19 02:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186905 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3446391ilb; Mon, 18 May 2020 19:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjR27yGzKv1MjqMInL/YP1TelRWM8a2a09orcZNiz4FsFmC7tuPtknmN6aMTuVeXV74MPK X-Received: by 2002:ac8:45d5:: with SMTP id e21mr15326752qto.336.1589856865954; Mon, 18 May 2020 19:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856865; cv=none; d=google.com; s=arc-20160816; b=EJ+LxJYSbdoduN593e7+Aj/yJ/v1mIq5hbPl1/E2cj41WcGs+mOTDc1x22td7wYYwW VfPM3a6yD8q1TVvuOU2fGFE6R5oC79ows7tBhMdZkrZSjY+mPePWYStefdBQZmghZ5Ic ByIBg6pyLRLYNFgBA/W+vMu1VC/kjTdH0T/cDnKPU6bENTHbFewYCj/B2ytYRHMpreNz YBKNNKfOdm9Fa76mAYNcQ8/lRWDMHhgwJ95OasZl6CVe9O7JsNgEms3R15c4Hm1K3xcr 1lox/7X6UxRH/HYP2SQGafdWakoVj2lkBbNiz8In89jdFR0ty9wmqCCl7GotgGVyi1U5 ctlw== 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=g+TVWgWDZ8IS/kHh58SBa/DlK1/0pDXOV4De7Fp0uPY=; b=BbqxIWH9bg7HC5P1h59C1Pf2PqmUS/ZSMEgjUBt7+HAuHP6nbc0bm74cfkAHcf01YU zlknaHEHZ5UfZsQK0strb8QYxieDW/k4DVbRSwVpeJnA5Mv6xddN4+Wi+CNBoT1Fb9+s vBnaIQOnB1DbXOIIjigpnYcKEWmj+uUFpj02VlYSK03WOlLoOdg7+6tnAZq9Bmp2wpGx 7O6HaOYvOi6ja/5HJ4dOi+08fpSQmrGvHP+XHY5lHtefng3Lj34sBA0vgnNYDC+QT1+v OjkmUfWuVkBY/AYbh33+bxKYulAPiLcv/pGD80vIPGYs+OGWn6ij+hwio0pMFOlX/pR5 26Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ArXsA2Ra; 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=pass (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 l10si6884880qtf.108.2020.05.18.19.54.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:54:25 -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=pass header.i=@linaro.org header.s=google header.b=ArXsA2Ra; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasOf-0005NL-C0 for patch@linaro.org; Mon, 18 May 2020 22:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasON-0005HG-QE for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:07 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:39353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOM-0002Q0-V2 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:07 -0400 Received: by mail-pj1-x1031.google.com with SMTP id n15so714445pjt.4 for ; Mon, 18 May 2020 19:54:06 -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=g+TVWgWDZ8IS/kHh58SBa/DlK1/0pDXOV4De7Fp0uPY=; b=ArXsA2Rao8ftzq6X3V6uaru9KibGQ2RCqIoi28zZccff4i0Ejkl8CdGXSZALFz7BYf frn1rg2yv/zJIJUCHp9C/HP+N6ntKqClWMD+BJHi+wb+FuSXjomtdNTT4Ic0JHSkaQ8r v2hIvirLQG/VyflOa0OeDKsGKgs+yvn+l/ITkqFHwsCoR1Y8vMbehAwhkEeGrY0NURae amwyz/YUFIxIVePbIsntFNAp2wvzJpePeUv3pxgNR6BmNLQQ0nJZN9csxBhMT/h+lq6G NxrRY7uLvb/TWzuYFs72OT3e6FKrLMV09wN9ebgXahrQj6zVIemvkV5BJLCNQL/C8KKV Q5rw== 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=g+TVWgWDZ8IS/kHh58SBa/DlK1/0pDXOV4De7Fp0uPY=; b=rD3tlXUslys9HdxvyM3uPCsMz6Y+asEXqlKkmS40FhSFHanyjwlInCzQvojcR3X43V 9hcvXaMq+qEN+JrMO3p7jOpKeqgvZP5I8MJryFVEWF3nYhjcJzJPOOLvhOjrdpTK/4D8 WGbBXYQ9sgCIDWqx0TUwfab3pMO4cb14LbcAJBMjiZJABnk4fDioRn5MPEoREtVGQ0mr Zr9epIElTbxKVdSSoEI0mI9wJz8U43N/EXomI0xB0B2PQ0MdQap+4IHhtxtB9wFMiCYB zXwTlZYYOHpknwz50sKk2reujugWMGQyG/l09XQ0HSm5DANEDGY8+SWoeM/bv/ZWWMt+ VOBw== X-Gm-Message-State: AOAM532rUqvb0pexDT8cm0j6m1a15fMiwPoP9y6MzoudZJhgH3mAe2w3 /8iJspeIYkz71jN1nVLYqHt4tjxNu9M= X-Received: by 2002:a17:90a:246d:: with SMTP id h100mr2435084pje.21.1589856845228; Mon, 18 May 2020 19:54:05 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 06/17] Make some risu.c symbols static Date: Mon, 18 May 2020 19:53:44 -0700 Message-Id: <20200519025355.4420-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These are unused in other translation units. Signed-off-by: Richard Henderson --- risu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 979341c..24ada8f 100644 --- a/risu.c +++ b/risu.c @@ -31,18 +31,18 @@ void *memblock; static int comm_fd; -bool trace; -size_t signal_count; +static bool trace; +static size_t signal_count; #ifdef HAVE_ZLIB #include -gzFile gz_trace_file; +static gzFile gz_trace_file; #define TRACE_TYPE "compressed" #else #define TRACE_TYPE "uncompressed" #endif -sigjmp_buf jmpbuf; +static sigjmp_buf jmpbuf; #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -113,7 +113,7 @@ void respond_trace(int r) } } -void master_sigill(int sig, siginfo_t *si, void *uc) +static void master_sigill(int sig, siginfo_t *si, void *uc) { int r; signal_count++; @@ -135,7 +135,7 @@ void master_sigill(int sig, siginfo_t *si, void *uc) } } -void apprentice_sigill(int sig, siginfo_t *si, void *uc) +static void apprentice_sigill(int sig, siginfo_t *si, void *uc) { int r; signal_count++; @@ -180,9 +180,9 @@ static void set_sigill_handler(void (*fn) (int, siginfo_t *, void *)) typedef void entrypoint_fn(void); uintptr_t image_start_address; -entrypoint_fn *image_start; +static entrypoint_fn *image_start; -void load_image(const char *imgfile) +static void load_image(const char *imgfile) { /* Load image file into memory as executable */ struct stat st; @@ -214,7 +214,7 @@ void load_image(const char *imgfile) image_start_address = (uintptr_t) addr; } -int master(void) +static int master(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB @@ -240,7 +240,7 @@ int master(void) return EXIT_FAILURE; } -int apprentice(void) +static int apprentice(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB @@ -261,9 +261,9 @@ int apprentice(void) return EXIT_FAILURE; } -int ismaster; +static int ismaster; -void usage(void) +static void usage(void) { fprintf(stderr, "Usage: risu [--master] [--host ] [--port ] " From patchwork Tue May 19 02:53:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186910 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447605ilb; Mon, 18 May 2020 19:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkU0AYVE7DzZKQOQwbOj3ypltLz0zUDm7/i2MbxX0HW/keX3iXldR8Q24r32DP6jdJcL6a X-Received: by 2002:aed:3783:: with SMTP id j3mr18407925qtb.306.1589857030792; Mon, 18 May 2020 19:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857030; cv=none; d=google.com; s=arc-20160816; b=J4VrFPsZtJJDQwnWji/39WLLkaRtxBLtI6aPKSN4SMOwkVaCSFkCKyZ1quHpjXfjOG ohUxY0efGgIpkclO393ABBGri/VPcw+SpoGWjQvkqKOVyP98sOWSt6kVgpbAoOdjjUBn +x3DVkJ3DJ+GZocDZkWkcCUqcyAeGZ7akk44+3YqwoO0NIWREEGa6MOUt5F/Jk3iUINh /hcEZ+kH6yTnXdbTZsPN7vTJN8VguXmlFw++Zc2SE+70fdNuCFX1SlMQtJQJFedcAoAo VECxt/upSYMUHyi2AhU2WJqOJuws6XjmGzxYiaVgsP1cW0NTXSMI5+IBeHdWJnpt8TdO FG0w== 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=ZGQGSgIKAGAYHQLVIaGjpxZ5J/uu0s5INYdsdKfSe6k=; b=tri4ny9L1/5RnLfMk8I2Z01iJqmXq1CWmToT0ouGiZ0jhuAFe3BUrQZsYJdfN1lP5b HNgXpb088HA4PBcUSAGReNtpGF7AzYBqj/AVqA33t9+F8/5h1m6RjW+iwV5ZhhtYyXSU bflHZa4peHetnV9P4wC9M3lAgVi/lfnXmYhr/b73eodTQsmTvtLmu/DCZADIR3LQZZf4 TQTE7iU677xgec4s6P0+CgS7cVxnGfGjesXltoFvOsAVHxNiKS198XtwlKDzo14sEB/I 09xxP+sJ0bQwtwsn5mO2fgBgjVE7+VhZToIYvnbfamAsJPceHmjgZNZb6TNPt0w3Qrla KwkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tEbelyIS; 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=pass (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 b24si6621122qkj.117.2020.05.18.19.57.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:57:10 -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=pass header.i=@linaro.org header.s=google header.b=tEbelyIS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasRK-0003aT-93 for patch@linaro.org; Mon, 18 May 2020 22:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOT-0005Me-I9 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:13 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:33039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOS-0002QL-CZ for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:13 -0400 Received: by mail-pg1-x52f.google.com with SMTP id s10so3478902pgm.0 for ; Mon, 18 May 2020 19:54:07 -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=ZGQGSgIKAGAYHQLVIaGjpxZ5J/uu0s5INYdsdKfSe6k=; b=tEbelyISa2Td5QL3ptJBzS69jUBLnvB3eTn4Nhmm/Cg6kcokuAL6Oi9Uvp0Au83sLo +utu+E2t2EafnibCvaKO/zmfYywRkmE7t1wiaLimM6WzlQiaKPjubNDbebVv01Y67N20 jAsZ4fU5V8uGy8+aEThZ+d5oz6kIdpDj3l1P5BUSr1wwmse0GtWlOXgTrDjfr6u/s5US zzAiuidp9REHIwMQKESCurq1rxTyMhsCZN2Kgvm4oLhNg/pso3xchwoLwR/eHQ8Qj/Qi FeqnlSxqGqI38u4AWpjq6wIn6Hhj2mrhrUKe9wYx0NaEOyI31ctYAPsZLFCpmBPo57OU mRYQ== 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=ZGQGSgIKAGAYHQLVIaGjpxZ5J/uu0s5INYdsdKfSe6k=; b=UbhFlBUOfpm6H+c0HHZqdc3NqLr0gP+pDfqbWcdGzUec+JBbAIXGpS3xxtReiwBQ+M ooxuAIzwR7Jql+irrTu5NeYX3BBSxGQQZ77CUngmHzruSYBR62909c7eDoGGGPfx7dA/ WiN6ZJzPyazycPgb/PyuU9y0lJyfGCVJIz1gbVQRhgWYQjy6E2/dIt2bnDqh8Imasupn 7PkMHir19OT2gcT87u6jkkBGwazml6EsudFuAMIqAgLXS/2QlqPKYHI/IIskdzinZMiD Buzs0qbOvZLyP/trWr/CsHa/nCHa9qVWLeDT0y0VGO0Hg8vjr/UF+PSJIkI0xNtWBwnF TgSQ== X-Gm-Message-State: AOAM531TqwXubnH9fDZ87DfGdtAAbb6EW/r8tYEyOUzw64aIBVptM5R4 F56zl/jODPYqBD08y8UDvXXzCKC4GeY= X-Received: by 2002:a63:63c6:: with SMTP id x189mr6919598pgb.36.1589856846455; Mon, 18 May 2020 19:54:06 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 07/17] Add enum RisuOp Date: Mon, 18 May 2020 19:53:45 -0700 Message-Id: <20200519025355.4420-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Formalize the set of defines, plus -1, into an enum. Signed-off-by: Richard Henderson --- risu.h | 23 +++++++++++++++-------- reginfo.c | 32 +++++++++++++++++++------------- risu_aarch64.c | 6 +++--- risu_arm.c | 6 +++--- risu_i386.c | 4 ++-- risu_m68k.c | 4 ++-- risu_ppc64.c | 4 ++-- 7 files changed, 46 insertions(+), 33 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index e2b4508..a7aa929 100644 --- a/risu.h +++ b/risu.h @@ -45,11 +45,17 @@ extern uintptr_t image_start_address; extern void *memblock; /* Ops code under test can request from risu: */ -#define OP_COMPARE 0 -#define OP_TESTEND 1 -#define OP_SETMEMBLOCK 2 -#define OP_GETMEMBLOCK 3 -#define OP_COMPAREMEM 4 +typedef enum { + /* Any other sigill besides the destignated undefined insn. */ + OP_SIGILL = -1, + + /* These are generated by the designated undefined insn. */ + OP_COMPARE = 0, + OP_TESTEND = 1, + OP_SETMEMBLOCK = 2, + OP_GETMEMBLOCK = 3, + OP_COMPAREMEM = 4, +} RisuOp; /* The memory block should be this long */ #define MEMBLOCKLEN 8192 @@ -114,10 +120,11 @@ void set_ucontext_paramreg(void *vuc, uint64_t value); /* Return the value of the parameter register from a reginfo. */ uint64_t get_reginfo_paramreg(struct reginfo *ri); -/* Return the risu operation number we have been asked to do, - * or -1 if this was a SIGILL for a non-risuop insn. +/* + * Return the risu operation number we have been asked to do, + * or OP_SIGILL if this was a SIGILL for a non-risuop insn. */ -int get_risuop(struct reginfo *ri); +RisuOp get_risuop(struct reginfo *ri); /* Return the PC from a reginfo */ uintptr_t get_pc(struct reginfo *ri); diff --git a/reginfo.c b/reginfo.c index 1b2a821..2d67c93 100644 --- a/reginfo.c +++ b/reginfo.c @@ -11,7 +11,7 @@ #include #include - +#include #include "risu.h" struct reginfo master_ri, apprentice_ri; @@ -25,7 +25,7 @@ int send_register_info(write_fn write_fn, void *uc) { struct reginfo ri; trace_header_t header; - int op; + RisuOp op; reginfo_init(&ri, uc); op = get_risuop(&ri); @@ -38,11 +38,18 @@ int send_register_info(write_fn write_fn, void *uc) } switch (op) { + case OP_COMPARE: case OP_TESTEND: - write_fn(&ri, reginfo_size()); - /* if we are tracing write_fn will return 0 unlike a remote - end, hence we force return of 1 here */ - return 1; + case OP_SIGILL: + /* + * Do a simple register compare on (a) explicit request + * (b) end of test (c) a non-risuop UNDEF + */ + if (write_fn(&ri, reginfo_size()) != 0) { + return -1; + } + /* For OP_TEST_END, force return 1 to exit. */ + return op == OP_TESTEND; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); break; @@ -53,12 +60,8 @@ int send_register_info(write_fn write_fn, void *uc) case OP_COMPAREMEM: return write_fn(memblock, MEMBLOCKLEN); break; - case OP_COMPARE: default: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - return write_fn(&ri, reginfo_size()); + abort(); } return 0; } @@ -74,8 +77,9 @@ int send_register_info(write_fn write_fn, void *uc) int recv_and_compare_register_info(read_fn read_fn, respond_fn resp_fn, void *uc) { - int resp = 0, op; + int resp = 0; trace_header_t header; + RisuOp op; reginfo_init(&master_ri, uc); op = get_risuop(&master_ri); @@ -97,7 +101,7 @@ int recv_and_compare_register_info(read_fn read_fn, switch (op) { case OP_COMPARE: case OP_TESTEND: - default: + case OP_SIGILL: /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ @@ -130,6 +134,8 @@ int recv_and_compare_register_info(read_fn read_fn, } resp_fn(resp); break; + default: + abort(); } return resp; diff --git a/risu_aarch64.c b/risu_aarch64.c index 492d141..f8a8412 100644 --- a/risu_aarch64.c +++ b/risu_aarch64.c @@ -29,16 +29,16 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) return ri->regs[0]; } -int get_risuop(struct reginfo *ri) +RisuOp get_risuop(struct reginfo *ri) { /* Return the risuop we have been asked to do - * (or -1 if this was a SIGILL for a non-risuop insn) + * (or OP_SIGILL if this was a SIGILL for a non-risuop insn) */ uint32_t insn = ri->faulting_insn; uint32_t op = insn & 0xf; uint32_t key = insn & ~0xf; uint32_t risukey = 0x00005af0; - return (key != risukey) ? -1 : op; + return (key != risukey) ? OP_SIGILL : op; } uintptr_t get_pc(struct reginfo *ri) diff --git a/risu_arm.c b/risu_arm.c index 5fcb2a5..a20bf73 100644 --- a/risu_arm.c +++ b/risu_arm.c @@ -56,17 +56,17 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) return ri->gpreg[0]; } -int get_risuop(struct reginfo *ri) +RisuOp get_risuop(struct reginfo *ri) { /* Return the risuop we have been asked to do - * (or -1 if this was a SIGILL for a non-risuop insn) + * (or OP_SIGILL if this was a SIGILL for a non-risuop insn) */ uint32_t insn = ri->faulting_insn; int isz = ri->faulting_insn_size; uint32_t op = insn & 0xf; uint32_t key = insn & ~0xf; uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0; - return (key != risukey) ? -1 : op; + return (key != risukey) ? OP_SIGILL : op; } uintptr_t get_pc(struct reginfo *ri) diff --git a/risu_i386.c b/risu_i386.c index 9962b8f..127e816 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -38,12 +38,12 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) return ri->gregs[REG_E(AX)]; } -int get_risuop(struct reginfo *ri) +RisuOp get_risuop(struct reginfo *ri) { if ((ri->faulting_insn & 0xf8ffff) == 0xc0b90f) { /* UD1 %xxx,%eax */ return (ri->faulting_insn >> 16) & 7; } - return -1; + return OP_SIGILL; } uintptr_t get_pc(struct reginfo *ri) diff --git a/risu_m68k.c b/risu_m68k.c index 1056eef..acdd57a 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -25,13 +25,13 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) return ri->gregs[R_A0]; } -int get_risuop(struct reginfo *ri) +RisuOp get_risuop(struct reginfo *ri) { uint32_t insn = ri->faulting_insn; uint32_t op = insn & 0xf; uint32_t key = insn & ~0xf; uint32_t risukey = 0x4afc7000; - return (key != risukey) ? -1 : op; + return (key != risukey) ? OP_SIGILL : op; } uintptr_t get_pc(struct reginfo *ri) diff --git a/risu_ppc64.c b/risu_ppc64.c index a3028f7..9df8d58 100644 --- a/risu_ppc64.c +++ b/risu_ppc64.c @@ -32,13 +32,13 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) return ri->gregs[0]; } -int get_risuop(struct reginfo *ri) +RisuOp get_risuop(struct reginfo *ri) { uint32_t insn = ri->faulting_insn; uint32_t op = insn & 0xf; uint32_t key = insn & ~0xf; uint32_t risukey = 0x00005af0; - return (key != risukey) ? -1 : op; + return (key != risukey) ? OP_SIGILL : op; } uintptr_t get_pc(struct reginfo *ri) From patchwork Tue May 19 02:53:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186908 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447038ilb; Mon, 18 May 2020 19:55:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyObnCOCCb6be6B8eC108lqnb6ab3tGxPd1gaUzvApJSkL5cY/EED+bfq/KkjGSLHuDPSuv X-Received: by 2002:a0c:f153:: with SMTP id y19mr18386849qvl.22.1589856953548; Mon, 18 May 2020 19:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856953; cv=none; d=google.com; s=arc-20160816; b=X7X2M6Scy7F4jkB/02EmP+7rgmbzCuuhwtP5FpjUOb/quI23aa1ZZGqbbvMMHjGUF8 7kqVf9apOFsYEl1j6p5QcmVttEpd7oKistQ4BIAkzvuWCx0oS/gaAkUKnOLpPpjj/2la 4qj6PWx/J/QOLo3JwZaq+JqXrcJnKqg7vvfAUApwAUH0wrgtaPcnCagF7Gd14uzYRf0V wtsvpn4c8YEvHZI/JGfRJ0yI5UtMafjroFAuQWfuuOZGElN1Sqk+DzXlSAl9rIpf0RjB k1A+doHdgcQ2pWoNUCVzrBT71vxITPzYlMJ8xUemURJUyOKK4o+994MPAcr7yXUh7hoW Czgw== 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=gp7XyqY5TSPLzgj7BvWTrIZcix0W6XLqOIrqT5GCvsY=; b=LPVSdPWeo2ITJ5Bpn4udmq+4vL8me92OiBtjG802rd2xQx0J7JafIaWuz0HFJuaQG9 ZxA0MQlbBpBLPNJS6HyDWKSXLHF/HEQMvtvp2KgupdMJFIZNGtEEUaQT1QQbjqXR5q8l 6BHZrA7hFoiH3PaPMJoFNZj27uuJJDI5TOkrZgfPD2ImiW20I/LW7hA1rYH3TKLPhCks AXb+QaN7rnnyDQkV6f7T9euGYrwVL5NRRLyPvz1ew7nUDWGomxGn+Dl+IJ4wk1YdVLfM DjOoptTOFKdMmjOnDMQO8MVwJdJsOlrUSs8riIpzjx/KhgCJK9UhdLm3DUYTabiomx/w mUsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HyIXsoxA; 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=pass (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 e19si8446565qtw.377.2020.05.18.19.55.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:55:53 -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=pass header.i=@linaro.org header.s=google header.b=HyIXsoxA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasQ5-0000FJ-0U for patch@linaro.org; Mon, 18 May 2020 22:55:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOU-0005Oi-8x for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:14 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:38280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOS-0002QT-9l for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:13 -0400 Received: by mail-pl1-x633.google.com with SMTP id m7so5030170plt.5 for ; Mon, 18 May 2020 19:54:09 -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=gp7XyqY5TSPLzgj7BvWTrIZcix0W6XLqOIrqT5GCvsY=; b=HyIXsoxAP0wm0sYWYWZhjK6tlGuJOz37NebDzEA3e7y8poh5KhOnNV2xrvh0kT3h18 95+L7kkD6xE8XAtgUMsYO1zE+xE8f29S7/uz0iedk8wMRwzUezX9yu0grqj/5W8ke7Vu JRiEcu2/HltpqkWL2C8LJ8eVjsIs7ZBzyw+VdXx0XgvuHxmT5xpXj3AEkQSo0wFc1ke9 0VeCrAekKiVaOxE1ejGGp1SHlVql/GHlkNFQi+64w54oAFYXi4VWZ7gOeF9cvZ8R75nU 9iimmt8JOeqXAIZytaj1QDbrhZOm66BK4+h5NkcK64+/x/+ilSWfK7wq+9+QYN4f+laF NIXQ== 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=gp7XyqY5TSPLzgj7BvWTrIZcix0W6XLqOIrqT5GCvsY=; b=ofLZDHTzZqONKtocMSSSlmfXjwANL3LCtd0E93Nz5zLutLhTxWDvpSqIokmsiHiGsp RXbW/K00vzBEZ4KOKAXNhIsY7SJ3XLv0knI6tEdjF8WJzNMBZTVIAip3lLn/FDSZK9Dm D+g9gE8efSgOysOCtfJhN1ivi3sYjdgwbD8lkBc5co1I6vxARtcMma/n9ftqTPPrcOdi +b4l2e1V3PkJTv0a8TK3o6Kr6KVInNspfqSi71cT9lytNfdhuBgKcPkW+gkL3xUpdxTF CVIQcks7JxX+QBtpq5Suq9U9eP7/gOusJ+MKOWR2YNIope0TmlbxlrU/w2ZDyf0I8+c/ t6DQ== X-Gm-Message-State: AOAM532Ir89+OrbWzslATEGGiylfp+qhO9AYdnFaOpyafH4ef2YElOAM CelGMeoyZZbwmPpYYQJ0mJ5yOnWIWWM= X-Received: by 2002:a17:90a:ee91:: with SMTP id i17mr2400729pjz.45.1589856847730; Mon, 18 May 2020 19:54:07 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 08/17] Add enum RisuResult Date: Mon, 18 May 2020 19:53:46 -0700 Message-Id: <20200519025355.4420-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Formalize the random set of numbers into an enum. Doing this makes it easy to see that one of the responses in recv_and_compare_register_info was inconsistent. Signed-off-by: Richard Henderson --- risu.h | 25 +++++++++++++++++-------- reginfo.c | 32 ++++++++++++++++---------------- risu.c | 18 +++++++++--------- 3 files changed, 42 insertions(+), 33 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index a7aa929..e6d07eb 100644 --- a/risu.h +++ b/risu.h @@ -57,6 +57,14 @@ typedef enum { OP_COMPAREMEM = 4, } RisuOp; +/* Result of operation */ +typedef enum { + RES_OK = 0, + RES_END, + RES_MISMATCH, + RES_BAD_IO, +} RisuResult; + /* The memory block should be this long */ #define MEMBLOCKLEN 8192 @@ -82,20 +90,21 @@ typedef struct { */ typedef int (*write_fn) (void *ptr, size_t bytes); typedef int (*read_fn) (void *ptr, size_t bytes); -typedef void (*respond_fn) (int response); +typedef void (*respond_fn) (RisuResult response); -/* Send the register information from the struct ucontext down the socket. - * Return the response code from the master. +/* + * Send the register information from the struct ucontext down the socket. * NB: called from a signal handler. */ -int send_register_info(write_fn write_fn, void *uc); +RisuResult send_register_info(write_fn write_fn, void *uc); -/* Read register info from the socket and compare it with that from the - * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch. +/* + * Read register info from the socket and compare it with that from the + * ucontext. * NB: called from a signal handler. */ -int recv_and_compare_register_info(read_fn read_fn, - respond_fn respond, void *uc); +RisuResult recv_and_compare_register_info(read_fn read_fn, + respond_fn respond, void *uc); /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on diff --git a/reginfo.c b/reginfo.c index 2d67c93..b909a1f 100644 --- a/reginfo.c +++ b/reginfo.c @@ -21,7 +21,7 @@ uint8_t apprentice_memblock[MEMBLOCKLEN]; static int mem_used; static int packet_mismatch; -int send_register_info(write_fn write_fn, void *uc) +RisuResult send_register_info(write_fn write_fn, void *uc) { struct reginfo ri; trace_header_t header; @@ -34,7 +34,7 @@ int send_register_info(write_fn write_fn, void *uc) header.pc = get_pc(&ri); header.risu_op = op; if (write_fn(&header, sizeof(header)) != 0) { - return -1; + return RES_BAD_IO; } switch (op) { @@ -46,10 +46,10 @@ int send_register_info(write_fn write_fn, void *uc) * (b) end of test (c) a non-risuop UNDEF */ if (write_fn(&ri, reginfo_size()) != 0) { - return -1; + return RES_BAD_IO; } /* For OP_TEST_END, force return 1 to exit. */ - return op == OP_TESTEND; + return op == OP_TESTEND ? RES_END : RES_OK; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); break; @@ -63,7 +63,7 @@ int send_register_info(write_fn write_fn, void *uc) default: abort(); } - return 0; + return RES_OK; } /* Read register info from the socket and compare it with that from the @@ -74,10 +74,10 @@ int send_register_info(write_fn write_fn, void *uc) * that says whether it is register or memory data, so if the two * sides get out of sync then we will fail obscurely. */ -int recv_and_compare_register_info(read_fn read_fn, - respond_fn resp_fn, void *uc) +RisuResult recv_and_compare_register_info(read_fn read_fn, + respond_fn resp_fn, void *uc) { - int resp = 0; + RisuResult resp = RES_OK; trace_header_t header; RisuOp op; @@ -85,18 +85,18 @@ int recv_and_compare_register_info(read_fn read_fn, op = get_risuop(&master_ri); if (read_fn(&header, sizeof(header)) != 0) { - return -1; + return RES_BAD_IO; } if (header.risu_op != op) { /* We are out of sync */ - resp = 2; + resp = RES_BAD_IO; resp_fn(resp); return resp; } /* send OK for the header */ - resp_fn(0); + resp_fn(RES_OK); switch (op) { case OP_COMPARE: @@ -107,12 +107,12 @@ int recv_and_compare_register_info(read_fn read_fn, */ if (read_fn(&apprentice_ri, reginfo_size())) { packet_mismatch = 1; - resp = 2; + resp = RES_BAD_IO; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { /* register mismatch */ - resp = 2; + resp = RES_MISMATCH; } else if (op == OP_TESTEND) { - resp = 1; + resp = RES_END; } resp_fn(resp); break; @@ -127,10 +127,10 @@ int recv_and_compare_register_info(read_fn read_fn, mem_used = 1; if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { packet_mismatch = 1; - resp = 2; + resp = RES_BAD_IO; } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ - resp = 2; + resp = RES_MISMATCH; } resp_fn(resp); break; diff --git a/risu.c b/risu.c index 24ada8f..8796975 100644 --- a/risu.c +++ b/risu.c @@ -69,7 +69,7 @@ int write_trace(void *ptr, size_t bytes) return (res == bytes) ? 0 : 1; } -void respond_sock(int r) +void respond_sock(RisuResult r) { send_response_byte(comm_fd, r); } @@ -98,11 +98,11 @@ int read_trace(void *ptr, size_t bytes) return (res == bytes) ? 0 : 1; } -void respond_trace(int r) +void respond_trace(RisuResult r) { switch (r) { - case 0: /* test ok */ - case 1: /* end of test */ + case RES_OK: + case RES_END: break; default: /* mismatch - if tracing we need to report, otherwise barf */ @@ -115,7 +115,7 @@ void respond_trace(int r) static void master_sigill(int sig, siginfo_t *si, void *uc) { - int r; + RisuResult r; signal_count++; if (trace) { @@ -125,7 +125,7 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } switch (r) { - case 0: + case RES_OK: /* match OK */ advance_pc(uc); return; @@ -137,7 +137,7 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) static void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - int r; + RisuResult r; signal_count++; if (trace) { @@ -147,11 +147,11 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) } switch (r) { - case 0: + case RES_OK: /* match OK */ advance_pc(uc); return; - case 1: + case RES_END: /* end of test */ exit(EXIT_SUCCESS); default: From patchwork Tue May 19 02:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186909 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447083ilb; Mon, 18 May 2020 19:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXX8cEFHKezunwcIeNyOiiYVKv6k1Tui/OpxeFdDmtam/fSkWE6LtOUt9DJ5s6yiKee1vG X-Received: by 2002:ac8:5381:: with SMTP id x1mr13961893qtp.388.1589856960044; Mon, 18 May 2020 19:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856960; cv=none; d=google.com; s=arc-20160816; b=jm9YsJxbTvtWP9LCw2Xr0xOAd0MjYX9NkMz4iUgb2ZIeOz/6JlcIgzk89seitcs4TK z4iHO3fB0iMFkhW1kKfo4j0iPSMzGy3Q0lX9twAw/O/MvuErL44FetFStO54jQEsz46i oqcSOf9sVtdsBO4MAvbMH2X6sA5yhB6D3zl+N9Wif21U80VsMdUJ8NHrEdEDsTx9X81a n/0tMoscCigMlYnAN02mwGftf05wwnoHb2c3jaRcFZBniqqTwGkmIQ+6N99KGqYwcquY D8beoGj7FvKbFsYxnUaNJXjID0fmrb9rpO5DZ4qg1ojBT0McoUaF/xF22BYl4IPdkWrb CvKg== 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=i6cN+V0oyKOXcFzwj12P4di1SZQuQTGDgSJO64rVCwQ=; b=yzBenqGYtDyugEN9nTEFTFwPpNdVjwhAC56rwsVvqdIC3zD/LjfCCEj9XAnWI3yPEL e4XCjnPXeTeFrHIFrPVLSTSZ1DXwuP5nUIE7m5WcC4osqxSr+v+dZQKCeUtzNXNMx1VT 4JSxu9h6QRrIK2HX4a7onpQTG8lwvx11n2Hdp6BTW26XNY50MYE1BH5zf6VQ8QtOisSE VufSjbyi71zgs9JOfgVhvQvwrjbpo/ouDtsxSs9NIU+T5L0Uii4RIt/lHalpCVy6thXL k0pLTT3tBYf0GQAvhx7bBMszWrn9dFvg2tywyNPhNZjg0XIZgXsbJ+Ma9jERJBgvt1FU gp0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ROiaR31o; 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=pass (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 5si7169374qtp.325.2020.05.18.19.55.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:56:00 -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=pass header.i=@linaro.org header.s=google header.b=ROiaR31o; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasQB-0000UJ-Em for patch@linaro.org; Mon, 18 May 2020 22:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOU-0005Pb-Im for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:14 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:46370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOS-0002Qa-Cx for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:14 -0400 Received: by mail-pg1-x532.google.com with SMTP id p21so5721508pgm.13 for ; Mon, 18 May 2020 19:54:10 -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=i6cN+V0oyKOXcFzwj12P4di1SZQuQTGDgSJO64rVCwQ=; b=ROiaR31orw2RW3U4tEeg/VJDeewODccnoD9B1iUPsw4wXgaO2J0YF5aIXil3ZTkYuX 3QA/vVU13JsLYPA9n+B5tVDPxB4cbXTqnEdh+qCbL2AmhIu1qZ6ooB60ACnJlFGQTzQE b3vFuyPX0JHu41y9ADcldb5YlytGwZpT3pz82lE4U+AYCb64u5Sb/VHplzipZnSezWed w1E8sxa12bg0Fg9Y4KIi1DPPIRLB+hGt6Ct0axhk8glOL4V/JB5HmO6BryoNTcAd/+rS lHVebDPnGZ2iNIKwO8G0ztjldVu7AnDNZCujS8eKpM5liJlgMsQJ3r0eDW8ecy4ntNUV P1NA== 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=i6cN+V0oyKOXcFzwj12P4di1SZQuQTGDgSJO64rVCwQ=; b=jfOFLCo4f2VW4NYGXGZ0dx3uuly8QkLklF8YYu8+nO7ULP99U21Ug22ueb6v7Ki/Vo CMglNru9oocjOiGRnmGYghhxczSLJcAC8l7gchK+rdATqXbI0FafWukplgQJ3sJJNb0r 1CTa2CnAFB6OAdpow/qyL4uVGweqfVP/WhiY2u51EjQp1XvDisKWU4eTlx0ZGgHdEij8 1dCRkdjtraFBV4xCT35fz0Lnv0CFGZPIhJFDQZjICXLKVuNXyuQTgnKl74OnApDG6B97 Ax9yoMgMSrgUpqlWhpz/2dZ7j2kADZnbvcobDW9JvqBY2DyAwAZ9NXNO5nM8B3m5sEUf Q54w== X-Gm-Message-State: AOAM533GXq6pqhAUqLFRG8X7UN8z236lMox1slHnOSuQC2BAaKoY34vS a5Wim8IcQOKbVHmis4J+seOcJfDuPDc= X-Received: by 2002:a62:fc52:: with SMTP id e79mr20575485pfh.297.1589856849122; Mon, 18 May 2020 19:54:09 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 09/17] Unify i/o functions and use RisuResult Date: Mon, 18 May 2020 19:53:47 -0700 Message-Id: <20200519025355.4420-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Push the trace check down from the function calling the reginfo function down into the i/o function. This means we don't have to pass a function pointer. Return a RisuResult from the i/o functions. This fixes a minor bug in send_register_info (even before the conversion to RisuResult), which returned the write_fn result directly. Signed-off-by: Richard Henderson --- risu.h | 25 ++++++++--------- comms.c | 8 +++--- reginfo.c | 60 ++++++++++++++++++++-------------------- risu.c | 82 ++++++++++++++++++++++--------------------------------- 4 files changed, 80 insertions(+), 95 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index e6d07eb..f44b781 100644 --- a/risu.h +++ b/risu.h @@ -34,13 +34,6 @@ void process_arch_opt(int opt, const char *arg); #include REGINFO_HEADER(ARCH) -/* Socket related routines */ -int master_connect(int port); -int apprentice_connect(const char *hostname, int port); -int send_data_pkt(int sock, void *pkt, int pktlen); -int recv_data_pkt(int sock, void *pkt, int pktlen); -void send_response_byte(int sock, int resp); - extern uintptr_t image_start_address; extern void *memblock; @@ -80,6 +73,13 @@ typedef struct { uint32_t risu_op; } trace_header_t; +/* Socket related routines */ +int master_connect(int port); +int apprentice_connect(const char *hostname, int port); +RisuResult send_data_pkt(int sock, void *pkt, int pktlen); +RisuResult recv_data_pkt(int sock, void *pkt, int pktlen); +void send_response_byte(int sock, int resp); + /* Functions operating on reginfo */ /* Function prototypes for read/write helper functions. @@ -88,23 +88,22 @@ typedef struct { * recv_and_compare_register_info which can either be backed by the * traditional network socket or a trace file. */ -typedef int (*write_fn) (void *ptr, size_t bytes); -typedef int (*read_fn) (void *ptr, size_t bytes); -typedef void (*respond_fn) (RisuResult response); +RisuResult write_buffer(void *ptr, size_t bytes); +RisuResult read_buffer(void *ptr, size_t bytes); +void respond(RisuResult response); /* * Send the register information from the struct ucontext down the socket. * NB: called from a signal handler. */ -RisuResult send_register_info(write_fn write_fn, void *uc); +RisuResult send_register_info(void *uc); /* * Read register info from the socket and compare it with that from the * ucontext. * NB: called from a signal handler. */ -RisuResult recv_and_compare_register_info(read_fn read_fn, - respond_fn respond, void *uc); +RisuResult recv_and_compare_register_info(void *uc); /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on diff --git a/comms.c b/comms.c index 861e845..21968da 100644 --- a/comms.c +++ b/comms.c @@ -168,7 +168,7 @@ ssize_t safe_writev(int fd, struct iovec *iov_in, int iovcnt) * Note that both ends must agree on the length of the * block of data. */ -int send_data_pkt(int sock, void *pkt, int pktlen) +RisuResult send_data_pkt(int sock, void *pkt, int pktlen) { unsigned char resp; /* First we send the packet length as a network-order 32 bit value. @@ -196,7 +196,7 @@ int send_data_pkt(int sock, void *pkt, int pktlen) return resp; } -int recv_data_pkt(int sock, void *pkt, int pktlen) +RisuResult recv_data_pkt(int sock, void *pkt, int pktlen) { uint32_t net_pktlen; recv_bytes(sock, &net_pktlen, sizeof(net_pktlen)); @@ -206,10 +206,10 @@ int recv_data_pkt(int sock, void *pkt, int pktlen) * a response back. */ recv_and_discard_bytes(sock, net_pktlen); - return 1; + return RES_BAD_IO; } recv_bytes(sock, pkt, pktlen); - return 0; + return RES_OK; } void send_response_byte(int sock, int resp) diff --git a/reginfo.c b/reginfo.c index b909a1f..fee025e 100644 --- a/reginfo.c +++ b/reginfo.c @@ -21,10 +21,11 @@ uint8_t apprentice_memblock[MEMBLOCKLEN]; static int mem_used; static int packet_mismatch; -RisuResult send_register_info(write_fn write_fn, void *uc) +RisuResult send_register_info(void *uc) { struct reginfo ri; trace_header_t header; + RisuResult res; RisuOp op; reginfo_init(&ri, uc); @@ -33,8 +34,9 @@ RisuResult send_register_info(write_fn write_fn, void *uc) /* Write a header with PC/op to keep in sync */ header.pc = get_pc(&ri); header.risu_op = op; - if (write_fn(&header, sizeof(header)) != 0) { - return RES_BAD_IO; + res = write_buffer(&header, sizeof(header)); + if (res != RES_OK) { + return res; } switch (op) { @@ -45,11 +47,12 @@ RisuResult send_register_info(write_fn write_fn, void *uc) * Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - if (write_fn(&ri, reginfo_size()) != 0) { - return RES_BAD_IO; + res = write_buffer(&ri, reginfo_size()); + /* For OP_TEST_END, force exit. */ + if (res == RES_OK && op == OP_TESTEND) { + res = RES_END; } - /* For OP_TEST_END, force return 1 to exit. */ - return op == OP_TESTEND ? RES_END : RES_OK; + break; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); break; @@ -58,12 +61,11 @@ RisuResult send_register_info(write_fn write_fn, void *uc) get_reginfo_paramreg(&ri) + (uintptr_t)memblock); break; case OP_COMPAREMEM: - return write_fn(memblock, MEMBLOCKLEN); - break; + return write_buffer(memblock, MEMBLOCKLEN); default: abort(); } - return RES_OK; + return res; } /* Read register info from the socket and compare it with that from the @@ -74,29 +76,29 @@ RisuResult send_register_info(write_fn write_fn, void *uc) * that says whether it is register or memory data, so if the two * sides get out of sync then we will fail obscurely. */ -RisuResult recv_and_compare_register_info(read_fn read_fn, - respond_fn resp_fn, void *uc) +RisuResult recv_and_compare_register_info(void *uc) { - RisuResult resp = RES_OK; + RisuResult res; trace_header_t header; RisuOp op; reginfo_init(&master_ri, uc); op = get_risuop(&master_ri); - if (read_fn(&header, sizeof(header)) != 0) { - return RES_BAD_IO; + res = read_buffer(&header, sizeof(header)); + if (res != RES_OK) { + return res; } if (header.risu_op != op) { /* We are out of sync */ - resp = RES_BAD_IO; - resp_fn(resp); - return resp; + res = RES_BAD_IO; + respond(res); + return res; } /* send OK for the header */ - resp_fn(RES_OK); + respond(RES_OK); switch (op) { case OP_COMPARE: @@ -105,16 +107,16 @@ RisuResult recv_and_compare_register_info(read_fn read_fn, /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - if (read_fn(&apprentice_ri, reginfo_size())) { + res = read_buffer(&apprentice_ri, reginfo_size()); + if (res != RES_OK) { packet_mismatch = 1; - resp = RES_BAD_IO; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { /* register mismatch */ - resp = RES_MISMATCH; + res = RES_MISMATCH; } else if (op == OP_TESTEND) { - resp = RES_END; + res = RES_END; } - resp_fn(resp); + respond(res); break; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); @@ -125,20 +127,20 @@ RisuResult recv_and_compare_register_info(read_fn read_fn, break; case OP_COMPAREMEM: mem_used = 1; - if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { + res = read_buffer(apprentice_memblock, MEMBLOCKLEN); + if (res != RES_OK) { packet_mismatch = 1; - resp = RES_BAD_IO; } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ - resp = RES_MISMATCH; + res = RES_MISMATCH; } - resp_fn(resp); + respond(res); break; default: abort(); } - return resp; + return res; } /* Print a useful report on the status of the last comparison diff --git a/risu.c b/risu.c index 8796975..78c6b8f 100644 --- a/risu.c +++ b/risu.c @@ -46,44 +46,15 @@ static sigjmp_buf jmpbuf; #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -/* Master functions */ +/* I/O functions */ -int read_sock(void *ptr, size_t bytes) -{ - return recv_data_pkt(comm_fd, ptr, bytes); -} - -int write_trace(void *ptr, size_t bytes) +RisuResult read_buffer(void *ptr, size_t bytes) { size_t res; -#ifdef HAVE_ZLIB - if (comm_fd == STDOUT_FILENO) { -#endif - res = write(comm_fd, ptr, bytes); -#ifdef HAVE_ZLIB - } else { - res = gzwrite(gz_trace_file, ptr, bytes); + if (!trace) { + return recv_data_pkt(comm_fd, ptr, bytes); } -#endif - return (res == bytes) ? 0 : 1; -} - -void respond_sock(RisuResult r) -{ - send_response_byte(comm_fd, r); -} - -/* Apprentice function */ - -int write_sock(void *ptr, size_t bytes) -{ - return send_data_pkt(comm_fd, ptr, bytes); -} - -int read_trace(void *ptr, size_t bytes) -{ - size_t res; #ifdef HAVE_ZLIB if (comm_fd == STDIN_FILENO) { @@ -95,21 +66,34 @@ int read_trace(void *ptr, size_t bytes) } #endif - return (res == bytes) ? 0 : 1; + return res == bytes ? RES_OK : RES_BAD_IO; } -void respond_trace(RisuResult r) +RisuResult write_buffer(void *ptr, size_t bytes) { - switch (r) { - case RES_OK: - case RES_END: - break; - default: - /* mismatch - if tracing we need to report, otherwise barf */ - if (!trace) { - abort(); - } - break; + size_t res; + + if (!trace) { + return send_data_pkt(comm_fd, ptr, bytes); + } + +#ifdef HAVE_ZLIB + if (comm_fd == STDOUT_FILENO) { +#endif + res = write(comm_fd, ptr, bytes); +#ifdef HAVE_ZLIB + } else { + res = gzwrite(gz_trace_file, ptr, bytes); + } +#endif + + return res == bytes ? RES_OK : RES_BAD_IO; +} + +void respond(RisuResult r) +{ + if (!trace) { + send_response_byte(comm_fd, r); } } @@ -119,9 +103,9 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) signal_count++; if (trace) { - r = send_register_info(write_trace, uc); + r = send_register_info(uc); } else { - r = recv_and_compare_register_info(read_sock, respond_sock, uc); + r = recv_and_compare_register_info(uc); } switch (r) { @@ -141,9 +125,9 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) signal_count++; if (trace) { - r = recv_and_compare_register_info(read_trace, respond_trace, uc); + r = recv_and_compare_register_info(uc); } else { - r = send_register_info(write_sock, uc); + r = send_register_info(uc); } switch (r) { From patchwork Tue May 19 02:53:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186916 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448753ilb; Mon, 18 May 2020 20:00:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrw5IMzxQ+ZUH7r9ggthV5Sf3xiOQSW4QaFXWvogcM4H/nbLfgfqPaDDNnMtEv/5ZhHG76 X-Received: by 2002:a0c:dc83:: with SMTP id n3mr19674047qvk.42.1589857204793; Mon, 18 May 2020 20:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857204; cv=none; d=google.com; s=arc-20160816; b=xGiPmeejRfuEqtaxo8H2oQqQz/jhDUpHE3lOe6II9gSPqWnvtQRrfSPmCMIauHBxZE 6qjx2SVzfqEHSRQc/eGb9eNgZngfL3CtJD0ehq05SCqMBkYt6E0TwCv7hVP0Omq2ZKW3 CFc8KtKDO47CkR3UCY8IulvMHN1t6ugj1+4dISEhc9d72R6/oKbKxmdoQcuCWR+wr3Sy gqdDwwZGRfZOkF9YvmvNTBxQisRmtWpjCGAvIi3CAx8obW8sOchr3+RAQTGHOVLAcvVa W+YXHUe5xZg9AYWk2DXx0AhpyMqcScRpNFZ42UINEh64lGtnzpfqaLeTs4HeaY/BX8gS gRgQ== 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=js3DaL9vdMvlvalMmzSSBkVboD7ayKmrqjH/PLK15lI=; b=vzyAhV7BGAXMWIwM3aJekg7liioCBfek6MIMqr4oMxQUwZdbpfRUEnb07Pf7dXHK51 KIZMMosD4QBxC3uOT9rzYH6VsYmRhHEp+/1VszxscA9pMFp5LsM48oBUHZEd0MlBe15+ W9gZk15Vkh4grevmL1c8NWlGhBfIBqQ/h7z4hEbreAs7fZgPda9hDH+37umzhgGl6RRO 6ts2g7UBebS7AxCd2wsYxfsIfYKn77SBpS5GdsmNfpMtognT5NiaMCsFVODozSg8p6fH yZTpMI5ASOzkSOEEWfjj9S1YHmJrYO5yZ+IWmgOwxruznLoGGjT7ieIDklG6gThG3o85 YzUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MGrsxa6w; 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=pass (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 y66si1373317qka.188.2020.05.18.20.00.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 20:00:04 -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=pass header.i=@linaro.org header.s=google header.b=MGrsxa6w; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasU8-0000ej-8I for patch@linaro.org; Mon, 18 May 2020 23:00:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOV-0005S4-LO for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:15 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:43418) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOS-0002Qe-Aw for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:15 -0400 Received: by mail-pg1-x532.google.com with SMTP id f4so5725454pgi.10 for ; Mon, 18 May 2020 19:54:11 -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=js3DaL9vdMvlvalMmzSSBkVboD7ayKmrqjH/PLK15lI=; b=MGrsxa6wM0rsT2BPjloLTXXty41U/u40ggiGWKt26FqLeKfGEe0U2FHWA6NbjgX+GT 5b2c1kL8FKnYNBI8jSztEeUMwSnOhheZimG6PS8VvEWuDLJ/vfNpwRI5P96vI8BNek0B AkYdklcoZzzCKsymPkPiot29qrOmJ4D/w5hiyPl3XJTKS9EmlVZlWbeGU+Eq05QJ/rDe AX4Rv/+iNGkHzlPOZAdGQZj0QonL4OtkZOEMXi5fVIm4UzypN4eYgzFh8ACu9PbB8zW4 HoENBh/BFWAcgIhStlyLR9szGWP+L2Qo3EawXNQXfUOEWxUkHW5k5ABULe1WV1OzWfLm fEfw== 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=js3DaL9vdMvlvalMmzSSBkVboD7ayKmrqjH/PLK15lI=; b=W707VWE7CW43ytc/dNvlxlxW56jq1yKtHBrgbma81guZ9LD3BkbtbM9p66v7dzHWhi A4351njIlikJ26abE3UpxMfn2Dlzn/TaNTtaa0ChEhwRWDGHjuGTAFhPa5GN1uRWVpgD jZbVJWCT/UyM2QNQIThifusHCN/RiMga9j/Tk5DOih4nS6er6Ic+j/Pyv6Tj4sZYJSKB 08NwisJCX0sxZAvZN7OpaeL3iQ1NyiouTkLfmQKIvQfKJ55COJAo3R5h/U87CrsCRrY9 drZNwXH5H/Ghqhv/NjEenTDgb5qvSv/tXSgoyKV6a+sKsuKSlKc/DhnvwrEqlOxtWAxU exDg== X-Gm-Message-State: AOAM530TMmdE9lNYR4Ojv5dVIS2JrcJDn7mIE2YJpr7mays29RqCj1vb S2ark/wrQtZeIqC5Q+pbMrsJ/YrTeb0= X-Received: by 2002:a63:503:: with SMTP id 3mr11684925pgf.15.1589856850498; Mon, 18 May 2020 19:54:10 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 10/17] Pass non-OK result back through siglongjmp Date: Mon, 18 May 2020 19:53:48 -0700 Message-Id: <20200519025355.4420-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than doing some work in the signal handler and some work outside, move all of the non-resume work outside. This works because we arranged for RES_OK to be 0, which is the normal return from sigsetjmp. Signed-off-by: Richard Henderson --- risu.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 78c6b8f..d09ac0b 100644 --- a/risu.c +++ b/risu.c @@ -107,15 +107,10 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } else { r = recv_and_compare_register_info(uc); } - - switch (r) { - case RES_OK: - /* match OK */ + if (r == RES_OK) { advance_pc(uc); - return; - default: - /* mismatch, or end of test */ - siglongjmp(jmpbuf, 1); + } else { + siglongjmp(jmpbuf, r); } } @@ -129,21 +124,10 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) } else { r = send_register_info(uc); } - - switch (r) { - case RES_OK: - /* match OK */ + if (r == RES_OK) { advance_pc(uc); - return; - case RES_END: - /* end of test */ - exit(EXIT_SUCCESS); - default: - /* mismatch */ - if (trace) { - siglongjmp(jmpbuf, 1); - } - exit(EXIT_FAILURE); + } else { + siglongjmp(jmpbuf, r); } } @@ -200,7 +184,9 @@ static void load_image(const char *imgfile) static int master(void) { - if (sigsetjmp(jmpbuf, 1)) { + RisuResult res = sigsetjmp(jmpbuf, 1); + + if (res != RES_OK) { #ifdef HAVE_ZLIB if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); @@ -226,15 +212,27 @@ static int master(void) static int apprentice(void) { - if (sigsetjmp(jmpbuf, 1)) { + RisuResult res = sigsetjmp(jmpbuf, 1); + + if (res != RES_OK) { #ifdef HAVE_ZLIB if (trace && comm_fd != STDIN_FILENO) { gzclose(gz_trace_file); } #endif close(comm_fd); - fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); - return report_match_status(true); + + switch (res) { + case RES_END: + return EXIT_SUCCESS; + default: + if (!trace) { + return EXIT_FAILURE; + } + fprintf(stderr, "finished early after %zd checkpoints\n", + signal_count); + return report_match_status(true); + } } set_sigill_handler(&apprentice_sigill); fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", From patchwork Tue May 19 02:53:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186914 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448282ilb; Mon, 18 May 2020 19:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP9rOD+3hvMISrjApUv6Ympwmte1tRCzGny1New/g9Q8V0KV9sTLN7QXnhH2QrDKPfi0yS X-Received: by 2002:a0c:b2c5:: with SMTP id d5mr19172413qvf.36.1589857133721; Mon, 18 May 2020 19:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857133; cv=none; d=google.com; s=arc-20160816; b=dNnM/7F8jU/9Am47zJe+DxCW8QKohr1D15DSrgpGT9Dw4OqFOvmpzHI+X/T+R8+BPa ZUtuWezRQNh8HoD6sGqHH4mKcq01onUdfu3Xrkvc86eI7usLdwbQhNHUIvCuAp/5cksF mguSwEQSCBldRRPscpxPt8Yit9R5yzd996HvwH38B3xqwLG24ZVsf95oZ2JOAs6j0Zt1 X8VXHVIrNeFaUH01LH6BYzW6+PsKoUq49OpQh//kKCCFVoLFI35RBl2G+CSQ/pWh7zsl gDTdPrf3GmNl1Gh1Tgkk3i+oS1ba59sGM+w0y7i5rRuEgmhkwGtWL/xsYuZkf6zzYl/w kQyw== 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=WGP8QqdErakMZvl9mkDGTTGLQKsm64P8H4F9SBenbew=; b=rL8uXEC2rvKp18oFGEcTnNmthrBQk4nqV8cU9LT7WKCUwDiKYhWiu9AfbSsTijDyXG tlFzOKzqVT/9xUzU6CgAKmGODLIa6KB5uHr05vcFdkg5y+dNICG7UgAa/soTPdlNJ0CJ ITdKi6HgjFDfXr/Lh5UdSzvvc3CCaHxVvD8kNiZ5lahL3+7+tbFCEsslbLdYrEMNPa2Z qLuoOthWp8N4brdE+ixuYalwCIhvRzhR9ZlJmf4fh7EAwTo1UQbD6WC758SFZnZkm2Pg rMwTseeHHI/mZYwag73CkQORUxb1SW2ZfvIhM5SZAhphizsaLgQWzZbFsNsbXKtpcH5e ApSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BcLRH7iX; 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=pass (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 h24si4578147qkk.236.2020.05.18.19.58.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:58:53 -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=pass header.i=@linaro.org header.s=google header.b=BcLRH7iX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasSz-0006XQ-7m for patch@linaro.org; Mon, 18 May 2020 22:58:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOV-0005Qz-9R for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:15 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:46371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOT-0002RD-TN for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:14 -0400 Received: by mail-pg1-x533.google.com with SMTP id p21so5721555pgm.13 for ; Mon, 18 May 2020 19:54:13 -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=WGP8QqdErakMZvl9mkDGTTGLQKsm64P8H4F9SBenbew=; b=BcLRH7iXL8nvDFpn6ZBeN3wT+/MKM1A4CrIsB1OnM0JapPkxXJNKuHQFPtZyuRoYc2 DoO4RFF6Zm3c7BTNrCtuRIXq9b0Qeez61oguBrn7EzBLDBDYbq0JWXHUyckLXYW0QfNt VT83adeS3a2KyJlwoaf0cbil+0QUnGjFZSpz7igfhkTEdphNqSdusL/mlbFWxvJx17Yp GnuHtUGPm7UjwNlHWq88AT3me+EQ9HnGurB6Uv4vJ1KIoQiHVGWDQkf2LujWAs18qt4z b210ra82HmoUXt81A0E8ch38QgDfm0egWCSLy9FEd5WCrVWIHhaQhtsNUrdMI3jn8dpT u5MQ== 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=WGP8QqdErakMZvl9mkDGTTGLQKsm64P8H4F9SBenbew=; b=rQIFo1SlQ/1m3B+zUlcyzBDOIm/zHndrEikg9DleGxM38DSdaRyqHSjobOJXNuPS7m HaAb2hQ6QoY9wRPQl+ONoHtkW7z1zM6JCFg8DJ5o3WnHVhPUNYln7WyYyaxomA/w9upi wO3OBFP3Er7rpkUJKBifKBv3kWIWexZRrD2t0I1YRMmOpwKgzLqZIDo08fvX5jaf9Kb3 N41HKmXJXhMKER+hwMmL/Yr6lrrz28bXZPnnpGAiyvarDyPXIbuUWglfiM8KSIRN6b7x 0H6js8RLRaptCJtcFCvvVEjeVv1tM815F0ziXx06G97ZUqU9OQH6sBxTJSBjQCCW2bRc 4Z8g== X-Gm-Message-State: AOAM530Y/+TUL9RDoEeuolbhzhNta9iK2Xk/sHDPyhiwTHiHSsH1vcRu KieblshUR4oNwU0O0xwsv6mt0JqhVvE= X-Received: by 2002:aa7:9a41:: with SMTP id x1mr20652819pfj.276.1589856852041; Mon, 18 May 2020 19:54:12 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 11/17] Always write for --master Date: Mon, 18 May 2020 19:53:49 -0700 Message-Id: <20200519025355.4420-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For trace, master of course must write to the file we create. For sockets, we can report mismatches from either end. At present, we are reporting mismatches from master. Reverse that so that we report mismatches from the apprentice, just as we do for trace. Signed-off-by: Richard Henderson --- risu.h | 2 +- reginfo.c | 38 ++++++++-------------- risu.c | 96 ++++++++++++++++++++++++++----------------------------- 3 files changed, 61 insertions(+), 75 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index f44b781..2ded5c4 100644 --- a/risu.h +++ b/risu.h @@ -111,7 +111,7 @@ RisuResult recv_and_compare_register_info(void *uc); * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(bool trace); +int report_match_status(void); /* Interface provided by CPU-specific code: */ diff --git a/reginfo.c b/reginfo.c index fee025e..c37c5df 100644 --- a/reginfo.c +++ b/reginfo.c @@ -14,9 +14,8 @@ #include #include "risu.h" -struct reginfo master_ri, apprentice_ri; - -uint8_t apprentice_memblock[MEMBLOCKLEN]; +static struct reginfo master_ri, apprentice_ri; +static uint8_t master_memblock[MEMBLOCKLEN]; static int mem_used; static int packet_mismatch; @@ -82,8 +81,8 @@ RisuResult recv_and_compare_register_info(void *uc) trace_header_t header; RisuOp op; - reginfo_init(&master_ri, uc); - op = get_risuop(&master_ri); + reginfo_init(&apprentice_ri, uc); + op = get_risuop(&apprentice_ri); res = read_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -107,7 +106,7 @@ RisuResult recv_and_compare_register_info(void *uc) /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - res = read_buffer(&apprentice_ri, reginfo_size()); + res = read_buffer(&master_ri, reginfo_size()); if (res != RES_OK) { packet_mismatch = 1; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -119,18 +118,18 @@ RisuResult recv_and_compare_register_info(void *uc) respond(res); break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + + set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + (uintptr_t)memblock); break; case OP_COMPAREMEM: mem_used = 1; - res = read_buffer(apprentice_memblock, MEMBLOCKLEN); + res = read_buffer(master_memblock, MEMBLOCKLEN); if (res != RES_OK) { packet_mismatch = 1; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { + } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH; } @@ -149,18 +148,13 @@ RisuResult recv_and_compare_register_info(void *uc) * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(bool trace) +int report_match_status(void) { int resp = 0; fprintf(stderr, "match status...\n"); if (packet_mismatch) { fprintf(stderr, "packet mismatch (probably disagreement " "about UNDEF on load/store)\n"); - /* We don't have valid reginfo from the apprentice side - * so stop now rather than printing anything about it. - */ - fprintf(stderr, "%s reginfo:\n", trace ? "this" : "master"); - reginfo_dump(&master_ri, stderr); return 1; } if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -168,7 +162,7 @@ int report_match_status(bool trace) resp = 1; } if (mem_used - && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) { + && memcmp(memblock, &master_memblock, MEMBLOCKLEN) != 0) { fprintf(stderr, "mismatch on memory!\n"); resp = 1; } @@ -177,15 +171,11 @@ int report_match_status(bool trace) return 0; } - fprintf(stderr, "%s reginfo:\n", trace ? "this" : "master"); + fprintf(stderr, "master reginfo:\n"); reginfo_dump(&master_ri, stderr); - fprintf(stderr, "%s reginfo:\n", trace ? "trace" : "apprentice"); + fprintf(stderr, "apprentice reginfo:\n"); reginfo_dump(&apprentice_ri, stderr); - if (trace) { - reginfo_dump_mismatch(&apprentice_ri, &master_ri, stderr); - } else { - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); - } + reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); return resp; } diff --git a/risu.c b/risu.c index d09ac0b..ea4b4d3 100644 --- a/risu.c +++ b/risu.c @@ -102,11 +102,7 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) RisuResult r; signal_count++; - if (trace) { - r = send_register_info(uc); - } else { - r = recv_and_compare_register_info(uc); - } + r = send_register_info(uc); if (r == RES_OK) { advance_pc(uc); } else { @@ -119,11 +115,7 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) RisuResult r; signal_count++; - if (trace) { - r = recv_and_compare_register_info(uc); - } else { - r = send_register_info(uc); - } + r = recv_and_compare_register_info(uc); if (r == RES_OK) { advance_pc(uc); } else { @@ -186,61 +178,65 @@ static int master(void) { RisuResult res = sigsetjmp(jmpbuf, 1); - if (res != RES_OK) { + switch (res) { + case RES_OK: + set_sigill_handler(&master_sigill); + fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", + image_start_address); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + return EXIT_FAILURE; + + case RES_END: #ifdef HAVE_ZLIB if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); } #endif close(comm_fd); - if (trace) { - fprintf(stderr, "trace complete after %zd checkpoints\n", - signal_count); - return EXIT_SUCCESS; - } else { - return report_match_status(false); - } + return EXIT_SUCCESS; + + case RES_BAD_IO: + fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); + return EXIT_FAILURE; + + default: + fprintf(stderr, "unexpected result %d\n", res); + return EXIT_FAILURE; } - set_sigill_handler(&master_sigill); - fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", - image_start_address); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - return EXIT_FAILURE; } static int apprentice(void) { RisuResult res = sigsetjmp(jmpbuf, 1); - if (res != RES_OK) { -#ifdef HAVE_ZLIB - if (trace && comm_fd != STDIN_FILENO) { - gzclose(gz_trace_file); - } -#endif - close(comm_fd); + switch (res) { + case RES_OK: + set_sigill_handler(&apprentice_sigill); + fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", + image_start_address); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + return EXIT_FAILURE; - switch (res) { - case RES_END: - return EXIT_SUCCESS; - default: - if (!trace) { - return EXIT_FAILURE; - } - fprintf(stderr, "finished early after %zd checkpoints\n", - signal_count); - return report_match_status(true); - } + case RES_END: + return EXIT_SUCCESS; + + case RES_MISMATCH: + fprintf(stderr, "mismatch after %zd checkpoints\n", signal_count); + report_match_status(); + return EXIT_FAILURE; + + case RES_BAD_IO: + fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); + return EXIT_FAILURE; + + default: + fprintf(stderr, "unexpected result %d\n", res); + return EXIT_FAILURE; } - set_sigill_handler(&apprentice_sigill); - fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", - image_start_address); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - return EXIT_FAILURE; } static int ismaster; From patchwork Tue May 19 02:53:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186912 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447837ilb; Mon, 18 May 2020 19:57:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNB100YMkUO3SNhENZmO/nr0wNS8quKDplqljJ1Xd0zZKUiB/MvHsO/kazqPhaoHyFyQ6N X-Received: by 2002:a37:9dc5:: with SMTP id g188mr18219753qke.193.1589857065800; Mon, 18 May 2020 19:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857065; cv=none; d=google.com; s=arc-20160816; b=nM73lbHzekGYuVgPtnq5Xn6cg75k3fGCaktbQzExUbTDbyXFYo60vRcHatM9b/QaFe phu7mVrKi6cSpdHduveh5Zf2L6WacjSmklTtxMQxedjOpDPINOtyjpkGztlnfFqVZMAl wXUTbnaeYbcBQ7tRRXUZ6ixCJLsDad67TsYwHuQQBqXdY82tfNsPnAhchyVZ4AK0KvQB nhsaiRcf2rEmqlok1xVOGpWFzAXpmlEtgVOJ22tPsQXMGBI6OMqFTy+Le0+ps2e3BQ1w i+omDUcmxRzVERVMo7ErMN3zkJyopCcUzfgLC4PmxrnDm7NoBmZXATU9U6QGpjgJUpBv EgWQ== 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=tqkKmnd9c2hIbo2X4DhmexDNHIE6TrbObnYZ+jtrN9c=; b=gC9PUNR33EdZ8hu/4YOLmHoefT9o7Bjs7tUJ4T7/NQu0OB/WXt7hZhMBkLasUas7AC apOWoHZGQ+ikRN3hb5mArgKolJ12jwzRWtu2+exU+m7uuG0PaMuiDB4k49pkMf79N5Z2 OMQYtpTGpHx9Cb4ssU9WsJg1AdJfMeHlDZNfN8zx90WJ0BoI/RUCCS/MRqGhMSqt7ZOK tmcrkNADPfPWPeQa6bTt0p9I27h2nsqNKeoNli9C36jw2WFTUvXbZxwBNrnzLy3q3ctY OXeyp8sLQ2g89Cpnk4x8eskaS726/VSqEj0Zw0hPZKfqvWXNo4OTmWsZdSVOvo+X+FEx /duA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xkIkTWl4; 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=pass (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 35si3596346qtg.242.2020.05.18.19.57.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:57:45 -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=pass header.i=@linaro.org header.s=google header.b=xkIkTWl4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasRt-00047c-CD for patch@linaro.org; Mon, 18 May 2020 22:57:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOV-0005Sl-SW for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:15 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:40971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOU-0002SE-T2 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:15 -0400 Received: by mail-pg1-x532.google.com with SMTP id r10so5732454pgv.8 for ; Mon, 18 May 2020 19:54:14 -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=tqkKmnd9c2hIbo2X4DhmexDNHIE6TrbObnYZ+jtrN9c=; b=xkIkTWl4Q062EuTllCJkfwEWdjAjxDrFfB2GevVVsqalJMQs17ZATA7K94MxLyiUvf 9Bbg9LgmwxKBGS9+EGr8MRYlVKYgjuq+0cH/LN8jRTkXZDHEVSLbGg4HIpsjPnK5AKj/ wVVK+QfHJMFhRKh1MQJLNfyBs3QnMDhv7R0iGt6xpXYGI9I00nfgcCb/NXbieXjzxmEH 2g08I2PluK+ZeUwGsMsmteBtYTVcuyV8oEzs+Sxrx4R0pKs3PbgeiCL85M1Gay6hjzxg d6rwTydLRBa4Cph6HzRWLldnDawKWZNE/rGn1PF4UBa/F2zkmQuUFb1J73weHNWK3vcp 5fjg== 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=tqkKmnd9c2hIbo2X4DhmexDNHIE6TrbObnYZ+jtrN9c=; b=sby51huspMvWNkgt+sICaOwiJdwWwyQhJWRK4W6t0hSNW7eq4leQkx99Ey1O2OQM+z sElU95f5XsGKFvt/2gwObxbhBDVrSaZOoILg63zToFjnSmszX78lIgxDw8/lJ6e6wJFm HkacHRLekzK1IGmYicipGzKylgXXZgwYULXQ2tRVrIqpc5sJoFCUOxBVAW20LW/reJzZ MJuQYGeWpKNINEF3kDxYA7rqIb6XXaTbgBtuDAOBLOn89aMOS3x16xgaNRSnrOj3uio2 xF7rwJh9jqVGYpZUd6t0QkiOh/JRxjYaXvZpae/FCsNh7od7YEsAaYWFqbYZCSwrZloF sHfg== X-Gm-Message-State: AOAM531BGWscQmd0b2zU3UjoCx2+1OkwfLq/GOv82g2nYRNOhfaN5jWb EC52/JH6Ctg+e+KvKSuoe88oH5mzUTU= X-Received: by 2002:a05:6a00:804:: with SMTP id m4mr13258262pfk.89.1589856853269; Mon, 18 May 2020 19:54:13 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 12/17] Simplify syncing with master Date: Mon, 18 May 2020 19:53:50 -0700 Message-Id: <20200519025355.4420-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not pass status like RES_BAD_IO from apprentice to master. This means that when master reports i/o error that we know it came from master; the apprentice will report its own i/o error. Signed-off-by: Richard Henderson --- reginfo.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/reginfo.c b/reginfo.c index c37c5df..31bc699 100644 --- a/reginfo.c +++ b/reginfo.c @@ -90,10 +90,9 @@ RisuResult recv_and_compare_register_info(void *uc) } if (header.risu_op != op) { - /* We are out of sync */ - res = RES_BAD_IO; - respond(res); - return res; + /* We are out of sync. Tell master to exit. */ + respond(RES_END); + return RES_BAD_IO; } /* send OK for the header */ @@ -115,7 +114,7 @@ RisuResult recv_and_compare_register_info(void *uc) } else if (op == OP_TESTEND) { res = RES_END; } - respond(res); + respond(res == RES_OK ? RES_OK : RES_END); break; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); @@ -133,7 +132,7 @@ RisuResult recv_and_compare_register_info(void *uc) /* memory mismatch */ res = RES_MISMATCH; } - respond(res); + respond(res == RES_OK ? RES_OK : RES_END); break; default: abort(); From patchwork Tue May 19 02:53:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186915 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448293ilb; Mon, 18 May 2020 19:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk9Zbs7Z7bwPzu2KfOwgM04RVRm0HTpxrX2Fb2E3FeqlR/X5o+Vj/te/S6t51Q0dM9+uWU X-Received: by 2002:a37:9807:: with SMTP id a7mr18315706qke.112.1589857135526; Mon, 18 May 2020 19:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857135; cv=none; d=google.com; s=arc-20160816; b=R5Tw2AxohdOEkSvmB24eiQ8CbKPZgM6xq13iwteP+3V2SKQjkkLQiJSYWyDRQivXMH TuMN4dQ3xg0xASAkiQnrSzzsMKXBIqUMQFR+dMeYldKD51/taxsZ3UrbHAra2FvBSKpy cMlhDBzg1iuD352XWmwybV5xCuG0im0rkplGa9gnuKJ6PiHuZQP+Ex8YLHzb24owHMbz +/ycMi71qnu6qSjz+KUs3z3GFaVBf/0tKikktVSYzn0/3GrTHmZgGxgdQ9ekcnUxiynx dU5HZ4i+GD4R4Y8fqJs5t3saxNytecJXGUkXRb6e4GeZpJ7WnCG7M0x751Avi1EZwWMu 54Wg== 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=DPjUnZGFzA9RASEgo9moUEv2ECNWzhiHEuAoKuGlTe8=; b=TP/pcc3pYK0zl7y1XNCIMUS93HrS3LVQ6SLnjw8j5YAVxy1Bw1mKVV4j4iNvBTmTDJ Lj3rLXJAJxL9NaOVsykL6U32uK7xwe6Ayjp6gFg3UH2WhvB5jAaxup/o6jPtEL3PMBNF CcJFZg2EmQCYxbe9DTBhA46JxMEu8WhmMv3NygRDCjLWzmuxoBRq+Lup1DvbrorK0ZE6 CrMMBWfSSSJdPbohmXpVGQKZpbOnrGrslgXRRF0tZW9kKLb8DXA0Jy0FhdrR8C/OzCYk 8Un1lwnTCQjUUaBbj2P1QrMmF2y+8SpGMVYtEoin3xGt9htEs2uiQbbNbLAcw3lHA7ug q9eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="G44V/9L3"; 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=pass (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 g11si1870669qtp.265.2020.05.18.19.58.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:58:55 -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=pass header.i=@linaro.org header.s=google header.b="G44V/9L3"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasT1-0006ci-2g for patch@linaro.org; Mon, 18 May 2020 22:58:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOX-0005Vp-Sc for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:17 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:45896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOW-0002U8-SI for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:17 -0400 Received: by mail-pf1-x444.google.com with SMTP id z26so5739008pfk.12 for ; Mon, 18 May 2020 19:54:15 -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=DPjUnZGFzA9RASEgo9moUEv2ECNWzhiHEuAoKuGlTe8=; b=G44V/9L3H6GlDY8K03/NMUj7y57rehEklPX2f0wzMsUH4H8YQdQcWoUsmKu/pynlbr CQTRPyCtWQyVTLHpDLnPl4y2AF28/wB1m+slD2E64dFxB1wjMU5U4fPweM5fr6LELCHU 3ZM3RdfFku607Qz91jnOYZIxbyYGlBukIliP5ncyoK2G/h7T03hHgGiAaJEJGZcqiNBc XKb3QjB6NKOtOk3wMgFL6C7NYzn0ISYSo2yYcigZsBvLv0dAO63X8rWVdFnsq2FbibBU c1dC8VmqUfSmzM4bmZ8NucYzGF70QpGlxpqtoqQEW0C3G3GS1F/eoOKYGNQ4+biBwBfx QalA== 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=DPjUnZGFzA9RASEgo9moUEv2ECNWzhiHEuAoKuGlTe8=; b=B2uUa18TKzAJvXviF/RIOyIgj1hWiCPUYh+2O7crRBD6ZrQJvpoKW5Rhykq6vTS1CZ rPgZhqmU6tWLaDv4ZOHXPKS9g4yCwBDnZiOi8Ky2jWhZAoTEhYk/EEVe/+hdUxTr0BFr CWdi/1PxwwH2Dplem3j8r0/XfmxXpz1611RBup2UuesimA3XtKMGzVLxuZhS4XtKYghG hdTXbo7dpTlYTwWfhKCgj/qVPcL5E15//V3rRSXrbXWDly/c0Ui65ct3zSl1QQt47sSr t6nX/QBHi6O6B1oPfU5OWxayrNE1CZlsZXDtATS38m/YptFuZaX79hqA7TaZxwP/g4Fc Nd3Q== X-Gm-Message-State: AOAM533fby5wU5cS6T/3mt1NAAlyZ4XgX/B4B2cB8P0tro4v7ckMUXqt vVAk2l1kEtQDdT4K1bHf5cb2UEpC1so= X-Received: by 2002:a63:c90f:: with SMTP id o15mr17191655pgg.67.1589856854446; Mon, 18 May 2020 19:54:14 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 13/17] Split RES_MISMATCH for registers and memory Date: Mon, 18 May 2020 19:53:51 -0700 Message-Id: <20200519025355.4420-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x444.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" By remembering the specific comparison that failed, we do not have to try again when it comes time to report. This makes the mem_used flag redundant. Also, packet_mismatch is now redundant with RES_BAD_IO. This means that the only thing that report_match_status does is to report on register status, so rename to report_mismatch_reg. Also, we know there is a failure, so don't return a status from the report. Signed-off-by: Richard Henderson --- risu.h | 13 ++++++------- reginfo.c | 45 ++++++++------------------------------------- risu.c | 10 +++++++--- 3 files changed, 21 insertions(+), 47 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index 2ded5c4..b234f93 100644 --- a/risu.h +++ b/risu.h @@ -54,7 +54,8 @@ typedef enum { typedef enum { RES_OK = 0, RES_END, - RES_MISMATCH, + RES_MISMATCH_REG, + RES_MISMATCH_MEM, RES_BAD_IO, } RisuResult; @@ -105,13 +106,11 @@ RisuResult send_register_info(void *uc); */ RisuResult recv_and_compare_register_info(void *uc); -/* Print a useful report on the status of the last comparison - * done in recv_and_compare_register_info(). This is called on - * exit, so need not restrict itself to signal-safe functions. - * Should return 0 if it was a good match (ie end of test) - * and 1 for a mismatch. +/* + * Print a useful report on the status of the last reg comparison + * done in recv_and_compare_register_info(). */ -int report_match_status(void); +void report_mismatch_reg(void); /* Interface provided by CPU-specific code: */ diff --git a/reginfo.c b/reginfo.c index 31bc699..a007f16 100644 --- a/reginfo.c +++ b/reginfo.c @@ -17,9 +17,6 @@ static struct reginfo master_ri, apprentice_ri; static uint8_t master_memblock[MEMBLOCKLEN]; -static int mem_used; -static int packet_mismatch; - RisuResult send_register_info(void *uc) { struct reginfo ri; @@ -107,10 +104,10 @@ RisuResult recv_and_compare_register_info(void *uc) */ res = read_buffer(&master_ri, reginfo_size()); if (res != RES_OK) { - packet_mismatch = 1; + /* fail */ } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { /* register mismatch */ - res = RES_MISMATCH; + res = RES_MISMATCH_REG; } else if (op == OP_TESTEND) { res = RES_END; } @@ -124,13 +121,12 @@ RisuResult recv_and_compare_register_info(void *uc) (uintptr_t)memblock); break; case OP_COMPAREMEM: - mem_used = 1; res = read_buffer(master_memblock, MEMBLOCKLEN); if (res != RES_OK) { - packet_mismatch = 1; + /* fail */ } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ - res = RES_MISMATCH; + res = RES_MISMATCH_MEM; } respond(res == RES_OK ? RES_OK : RES_END); break; @@ -141,40 +137,15 @@ RisuResult recv_and_compare_register_info(void *uc) return res; } -/* Print a useful report on the status of the last comparison - * done in recv_and_compare_register_info(). This is called on - * exit, so need not restrict itself to signal-safe functions. - * Should return 0 if it was a good match (ie end of test) - * and 1 for a mismatch. +/* + * Print a useful report on the status of the last reg comparison + * done in recv_and_compare_register_info(). */ -int report_match_status(void) +void report_mismatch_reg(void) { - int resp = 0; - fprintf(stderr, "match status...\n"); - if (packet_mismatch) { - fprintf(stderr, "packet mismatch (probably disagreement " - "about UNDEF on load/store)\n"); - return 1; - } - if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - fprintf(stderr, "mismatch on regs!\n"); - resp = 1; - } - if (mem_used - && memcmp(memblock, &master_memblock, MEMBLOCKLEN) != 0) { - fprintf(stderr, "mismatch on memory!\n"); - resp = 1; - } - if (!resp) { - fprintf(stderr, "match!\n"); - return 0; - } - fprintf(stderr, "master reginfo:\n"); reginfo_dump(&master_ri, stderr); fprintf(stderr, "apprentice reginfo:\n"); reginfo_dump(&apprentice_ri, stderr); - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); - return resp; } diff --git a/risu.c b/risu.c index ea4b4d3..398faac 100644 --- a/risu.c +++ b/risu.c @@ -224,9 +224,13 @@ static int apprentice(void) case RES_END: return EXIT_SUCCESS; - case RES_MISMATCH: - fprintf(stderr, "mismatch after %zd checkpoints\n", signal_count); - report_match_status(); + case RES_MISMATCH_REG: + fprintf(stderr, "mismatch reg after %zd checkpoints\n", signal_count); + report_mismatch_reg(); + return EXIT_FAILURE; + + case RES_MISMATCH_MEM: + fprintf(stderr, "mismatch mem after %zd checkpoints\n", signal_count); return EXIT_FAILURE; case RES_BAD_IO: From patchwork Tue May 19 02:53:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186917 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448766ilb; Mon, 18 May 2020 20:00:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaOLSPdHdqXF2ZdQAPlwtpkAyv/+INuPbenh5Aik1vjBuhqaEnCCThE6TDlKkGm7lQd3oE X-Received: by 2002:a37:8e45:: with SMTP id q66mr19091546qkd.497.1589857206341; Mon, 18 May 2020 20:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857206; cv=none; d=google.com; s=arc-20160816; b=EYU9ZeY8mcZAA86T/iHZZqxBAg7oY+jICeAFn89IX0SAbrzzH1ftiamvgGC0wsm5ly x7AGwjdFdYmxz35DTF93qEZK6zqj+mLfVZy2ZtvcVUSMvAxFAvMC7UMI8XwWml5+MDM9 TcpSkodGuAIpE/2bcoQY+E+HO1AaRUxsroAkaeKrMCeGJ+WkzxfhZ9zXwpDF1vkGTI9f OT+7+7B+vfg/7ufIxjiXtb8bVqdz72CxVImx8W+nP8T1IxhqSx53Wf8BQiw2d2INznYh KbNzlbYPag2kdjywJNSAyVuCBvblESokxZKZAkiQZDRaq66BS2JeQrQjLgc7/jKCpLqo QV5Q== 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=ryftU8k2hkpE8SBKJnjLqyziikg8zbnLkzl+yDCUuSA=; b=LknFt6dsmJF3tWjqf5bmTFerURAGazbh8kUThCMBZALacj3x0XMiPTM3K/V3OqatKX vCyRFlgO9fN4YS3JEyLxRq0sBqOef6PS3TyWs9AYa3aO1ftZE8fQ3e0LMOHREb4Mb6UJ zJ5oZF0ThSyujNY16VUejuLBh3ZLjPNwVC2iIbYeyt3atJxmUzpvrffwdq18MwNA5Q72 jTK0VhXveCKunDhxgbWrx3RBF7X/mluep2FJK8sokeuVoSxSIh1H0GkoXawRn4MJD2lE b1K8WXgJ9D7fAFuwRXt5IyGRHyCvB7lwfnq3OOjCnrDTsOYQWCpwRWANxwq/3FHHmgIS hAcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=im9OAiLa; 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=pass (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 13si6607171qka.296.2020.05.18.20.00.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 20:00:06 -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=pass header.i=@linaro.org header.s=google header.b=im9OAiLa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasU9-0000gl-K6 for patch@linaro.org; Mon, 18 May 2020 23:00:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOZ-0005ap-9G for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:19 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:46372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOX-0002Ur-N1 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:18 -0400 Received: by mail-pg1-x534.google.com with SMTP id p21so5721614pgm.13 for ; Mon, 18 May 2020 19:54:17 -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=ryftU8k2hkpE8SBKJnjLqyziikg8zbnLkzl+yDCUuSA=; b=im9OAiLamHIqOafI3tQsbysVXK8ot/8ZbuSUFqTn9R6Rb+StXyuOfV7yA+4Eu2x4lm mYeTJggiGdxC1GfX9Og90vqS4XXvwxpu3Q9rBP5yA5QKAup7/oLB6y8XSFweP+T4BF8f P0JckyFsavmmG0KbZWuTO8RmTH4uVg31dypak3+BEbtXbR4l33cKOemnLiA9G7BxrLKB bWVKQassqREJEzsF2J1T1keHfG1V7YxGwMdGJNayTc08P8+UI7Zrp3+7pOt9GvNonnBp FoqjzjDvrR9lPE3BR4lVzfp+fXcvgm31xjb+dk2bjE0gUYzAX+buYeMCynkTJYuG2Y80 vG5g== 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=ryftU8k2hkpE8SBKJnjLqyziikg8zbnLkzl+yDCUuSA=; b=FKUDOjn/G2EzLdMUj7HmSNak8XWjcJavSmvqQp+VG3rHHDG81ZX+4ltH3G4vmWOznE SVB/Jj7VUjtMR93UO6UjRtHZPyZkwMwg+It+VyOM7GZ97cjFUn67qVr/CtfHIGve5ere vbEoo970pNFfpbZx4sE0WXjCUOUoD1Fh2bkCYfwO7afHFUwCfi47+/5VJN+2rA/Ac7xW HZbUCgQTaz9OkZc7YS/aWgjAV0yNw6hWBd6niP+b5dTiCgwoCWZHTMfTpYorTBNs+uGf AvDMmx7kMuG2r5M2LL8Zd/8MJk4tZ60lGvGgwZyp9rweqlVygCi0M1gMMvwRDtLFivUn s9wA== X-Gm-Message-State: AOAM530Rgc7rlKerVFL0Aj2e4mMqOYtaGn/uWtgqRw56GhrpbItx4COq NZFIu2G7MCcZtzI3WWxUU4kHsEbBGNI= X-Received: by 2002:a63:f90a:: with SMTP id h10mr17788269pgi.57.1589856855815; Mon, 18 May 2020 19:54:15 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 14/17] Add magic and size to the trace header Date: Mon, 18 May 2020 19:53:52 -0700 Message-Id: <20200519025355.4420-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sanity check that we're not getting out of sync with the trace stream. This will be especially bad with the change in size of the sve save data. Signed-off-by: Richard Henderson --- risu.h | 8 ++- reginfo.c | 160 ++++++++++++++++++++++++++++++++++++++++++++---------- risu.c | 6 ++ 3 files changed, 143 insertions(+), 31 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index b234f93..eeb6775 100644 --- a/risu.h +++ b/risu.h @@ -56,6 +56,7 @@ typedef enum { RES_END, RES_MISMATCH_REG, RES_MISMATCH_MEM, + RES_MISMATCH_HEAD, RES_BAD_IO, } RisuResult; @@ -70,10 +71,14 @@ typedef enum { struct reginfo; typedef struct { - uintptr_t pc; + uint32_t magic; + uint32_t size; uint32_t risu_op; + uintptr_t pc; } trace_header_t; +#define RISU_MAGIC (('R' << 24) | ('i' << 16) | ('S' << 8) | 'u') + /* Socket related routines */ int master_connect(int port); int apprentice_connect(const char *hostname, int port); @@ -111,6 +116,7 @@ RisuResult recv_and_compare_register_info(void *uc); * done in recv_and_compare_register_info(). */ void report_mismatch_reg(void); +void report_mismatch_header(void); /* Interface provided by CPU-specific code: */ diff --git a/reginfo.c b/reginfo.c index a007f16..f187d9c 100644 --- a/reginfo.c +++ b/reginfo.c @@ -16,6 +16,7 @@ static struct reginfo master_ri, apprentice_ri; static uint8_t master_memblock[MEMBLOCKLEN]; +static trace_header_t master_header; RisuResult send_register_info(void *uc) { @@ -23,32 +24,57 @@ RisuResult send_register_info(void *uc) trace_header_t header; RisuResult res; RisuOp op; + void *extra; reginfo_init(&ri, uc); op = get_risuop(&ri); /* Write a header with PC/op to keep in sync */ + header.magic = RISU_MAGIC; header.pc = get_pc(&ri); header.risu_op = op; + + switch (op) { + case OP_TESTEND: + case OP_COMPARE: + case OP_SIGILL: + header.size = reginfo_size(); + extra = &ri; + break; + + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + header.size = 0; + extra = NULL; + break; + + case OP_COMPAREMEM: + header.size = MEMBLOCKLEN; + extra = memblock; + break; + + default: + abort(); + } + res = write_buffer(&header, sizeof(header)); if (res != RES_OK) { return res; } + if (extra) { + res = write_buffer(extra, header.size); + if (res != RES_OK) { + return res; + } + } switch (op) { case OP_COMPARE: - case OP_TESTEND: case OP_SIGILL: - /* - * Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - res = write_buffer(&ri, reginfo_size()); - /* For OP_TEST_END, force exit. */ - if (res == RES_OK && op == OP_TESTEND) { - res = RES_END; - } + case OP_COMPAREMEM: break; + case OP_TESTEND: + return RES_END; case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); break; @@ -56,12 +82,10 @@ RisuResult send_register_info(void *uc) set_ucontext_paramreg(uc, get_reginfo_paramreg(&ri) + (uintptr_t)memblock); break; - case OP_COMPAREMEM: - return write_buffer(memblock, MEMBLOCKLEN); default: abort(); } - return res; + return RES_OK; } /* Read register info from the socket and compare it with that from the @@ -75,34 +99,48 @@ RisuResult send_register_info(void *uc) RisuResult recv_and_compare_register_info(void *uc) { RisuResult res; - trace_header_t header; + size_t extra_size; RisuOp op; reginfo_init(&apprentice_ri, uc); op = get_risuop(&apprentice_ri); - res = read_buffer(&header, sizeof(header)); - if (res != RES_OK) { - return res; + switch (op) { + case OP_TESTEND: + case OP_COMPARE: + case OP_SIGILL: + extra_size = reginfo_size(); + break; + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + extra_size = 0; + break; + case OP_COMPAREMEM: + extra_size = MEMBLOCKLEN; + break; + default: + abort(); } - if (header.risu_op != op) { - /* We are out of sync. Tell master to exit. */ - respond(RES_END); - return RES_BAD_IO; + res = read_buffer(&master_header, sizeof(master_header)); + if (res != RES_OK) { + goto fail_header; + } + if (master_header.magic != RISU_MAGIC || + master_header.risu_op != op || + master_header.size != extra_size) { + res = RES_MISMATCH_HEAD; + goto fail_header; } /* send OK for the header */ respond(RES_OK); switch (op) { - case OP_COMPARE: case OP_TESTEND: + case OP_COMPARE: case OP_SIGILL: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - res = read_buffer(&master_ri, reginfo_size()); + res = read_buffer(&master_ri, extra_size); if (res != RES_OK) { /* fail */ } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -111,15 +149,17 @@ RisuResult recv_and_compare_register_info(void *uc) } else if (op == OP_TESTEND) { res = RES_END; } - respond(res == RES_OK ? RES_OK : RES_END); break; + case OP_SETMEMBLOCK: memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); - break; + return RES_OK; + case OP_GETMEMBLOCK: set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + (uintptr_t)memblock); - break; + return RES_OK; + case OP_COMPAREMEM: res = read_buffer(master_memblock, MEMBLOCKLEN); if (res != RES_OK) { @@ -128,12 +168,14 @@ RisuResult recv_and_compare_register_info(void *uc) /* memory mismatch */ res = RES_MISMATCH_MEM; } - respond(res == RES_OK ? RES_OK : RES_END); break; + default: abort(); } + fail_header: + respond(res == RES_OK ? RES_OK : RES_END); return res; } @@ -149,3 +191,61 @@ void report_mismatch_reg(void) reginfo_dump(&apprentice_ri, stderr); reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); } + +void report_mismatch_header(void) +{ + fprintf(stderr, "header mismatch detail (master : apprentice):\n"); + if (master_header.magic != RISU_MAGIC) { + fprintf(stderr, " magic: %08x vs %08x\n", + master_header.magic, RISU_MAGIC); + /* If the magic number is wrong, everything else is garbage too. */ + return; + } + + RisuOp a_op = get_risuop(&apprentice_ri); + RisuOp m_op = master_header.risu_op; + if (a_op != m_op) { + fprintf(stderr, " op : %d != %d\n", m_op, a_op); + /* If the opcode is mismatched, we can't compute size. */ + } else { + const char *kind; + size_t m_sz = master_header.size; + size_t a_sz; + + switch (a_op) { + case OP_TESTEND: + case OP_COMPARE: + case OP_SIGILL: + kind = "reginfo"; + a_sz = reginfo_size(); + break; + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + kind = "unexpected"; + a_sz = 0; + break; + case OP_COMPAREMEM: + kind = "memblock"; + a_sz = MEMBLOCKLEN; + break; + default: + abort(); + } + if (a_sz != m_sz) { + fprintf(stderr, " size : %zd != %zd (%s)\n", + m_sz, a_sz, kind); + } else { + /* If magic, op, and size are the same, how did we get here? */ + abort(); + } + } + + uint64_t a_pc = get_pc(&apprentice_ri); + uint64_t m_pc = master_header.pc; + if (a_pc != m_pc) { + fprintf(stderr, " pc : %016" PRIx64 " vs %016" PRIx64 "\n", + m_pc, a_pc); + } else { + fprintf(stderr, " pc : %016" PRIx64 "\n", a_pc); + } +} diff --git a/risu.c b/risu.c index 398faac..95b4674 100644 --- a/risu.c +++ b/risu.c @@ -233,6 +233,12 @@ static int apprentice(void) fprintf(stderr, "mismatch mem after %zd checkpoints\n", signal_count); return EXIT_FAILURE; + case RES_MISMATCH_HEAD: + fprintf(stderr, "mismatch header after %zd checkpoints\n", + signal_count); + report_mismatch_header(); + return EXIT_FAILURE; + case RES_BAD_IO: fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); return EXIT_FAILURE; From patchwork Tue May 19 02:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186913 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448181ilb; Mon, 18 May 2020 19:58:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1OKG3LU1udMERh/FFrQUs2eMQBiZKWekjRf7Ik1zAA3981ROjTBR+wARzqPxAG0RDb6jt X-Received: by 2002:a0c:aa4c:: with SMTP id e12mr6478190qvb.12.1589857119435; Mon, 18 May 2020 19:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857119; cv=none; d=google.com; s=arc-20160816; b=KW+0XtKUq4ROzbXjY0kOKQy5IKH5hZcUCcCQutS7tU8RrKfN7EXA5rzuAdcGe2KXwG onA2zcWNkPpqerIXjeKJ4dsxMR0PdoVUV1O+0l5YP8Ar5RSUAHKEX6zhuVlDnQQApgAe PD5LpQhlOts5ASV6wkFpS1psRuPc+xP4BWYK7Uk3Hiho0ndxHAdwA9KQlHJJ04Bcq6Gv 5y6DxLofvwtmfQlFEyr5TScp9HLqJ+CkpR9lBJFMC6YMhsccVpd+QDRWZ4l1YBtdXCKX eOQ9ZukjP1QM8CzY1SXV/j9Vb6+jNdaNtf6uZDE/9+iZ9q6ilT49HsP/7Hvbp4B0Cf8t znQw== 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=ilYiYwfPbx2qQQFy7b/Ot3fVz/Ep7kBx5xS7fCDZud0=; b=ev3dszGKo7WjD2TnV33aQ64PLJ0iivc1G4pamRNhBgTYd1ZNMNf5eyHzHfZiZcko1+ 8dgK+gvlX6d+EaD28aZ9CFJdgtGFR9xmf+56Zh0+EnxIdxzAovbvPSvGmQNqzp7C5VqW 3o55z5qxFiqaeiRVtISRDBHgGuCHlvA86Jj1bO9ZeR+17G5MuDEUXv2ovt3WdtK+jky5 xS1arz4yhdUrZxJ9gFlK6H2ZklkzLZzfPhadxynb28aPOxZRB1P2ETSD8HDqRbs1C6bI NA914+lciV62sovd/kBTLvjHy3QHkd2WfJYNcMB1VEB2gwk2v76qkxlztgyxNvXmy+D7 wGjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNRpgroy; 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=pass (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 h22si6724653qtq.95.2020.05.18.19.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:58:39 -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=pass header.i=@linaro.org header.s=google header.b=XNRpgroy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasSk-0006u0-VW for patch@linaro.org; Mon, 18 May 2020 22:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOa-0005eY-JB for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:20 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:36789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOZ-0002W4-J0 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:20 -0400 Received: by mail-pg1-x52e.google.com with SMTP id c75so4728850pga.3 for ; Mon, 18 May 2020 19:54:18 -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=ilYiYwfPbx2qQQFy7b/Ot3fVz/Ep7kBx5xS7fCDZud0=; b=XNRpgroyCQAQtseX2XqU1SxiCNiUdWkvLOClEGW2w2byClMHpPILQjbm3tAkZ6YQ0g SfGgG8p3EXxa0Wd3tk2nxhJ4crqtL0NEH9KxFD9R9noOnsPwWK0OpNijQjWN90xq5TAx 0dXwoyx83BTY3sTmExGR8HoefpZCyhTvWg/sV1Et2PfoZXVDtmVNfuDE6f2UY0xD51uz aGL/FSFwobTo6zP/aNGzBQ8Yen/pt++uzgG4zLrascyU7XGbQ4fKiJyR6UnGwNRWELKM znAmUibRLqCoV66szH5xxZ3I9pLEvAdhsWyw5aEVjSmDj9vpu0OKVwsPR5Vo1IWcRu6y cWdQ== 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=ilYiYwfPbx2qQQFy7b/Ot3fVz/Ep7kBx5xS7fCDZud0=; b=cdnJd0ctj3DJdDE+8raOL21BxgHt1xzebRgbqppXwRShlJ7kOV6f6WLFddaGCKzmS1 OT4VbFHGIVTdb1mM/2qpiN5B11p78MawE7JMfculAJsAItgMo5DLOAUUIe8oUV1wtVwL lmSh5qRztiiQ4qAhjAJ+ODr3K4xHmpNaeAyS8U+4zs1HAcsqW+GgDDdGhEfMcHMAEd7L f0OMmQBC2QXQeMGRVwrY9fWcHUfTXelgmD4gygPVKQdl4j9vtuNx8RowKzXY3U2D1bY0 KvF7r/sdaTxaAFNEWmuzLCn17QL0TKQdfxvvk9SrL/8Ng+M45EO/17JVCf6tCaqF4BHE ioyw== X-Gm-Message-State: AOAM531UJz2FIeXD+6Xbb6k2uALvWq3BWl2+zXrxN5IiUrHijVmhki6I i8jKsfXDo2gQdaBhNOREbRVrIkUAdMY= X-Received: by 2002:a63:5114:: with SMTP id f20mr11932150pgb.148.1589856857419; Mon, 18 May 2020 19:54:17 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 15/17] Compute reginfo_size based on the reginfo Date: Mon, 18 May 2020 19:53:53 -0700 Message-Id: <20200519025355.4420-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will allow dumping of SVE frames without having to know the SVE vector length beforehand. Signed-off-by: Richard Henderson --- risu.h | 2 +- reginfo.c | 6 +++--- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_arm.c | 2 +- risu_reginfo_i386.c | 2 +- risu_reginfo_m68k.c | 2 +- risu_reginfo_ppc64.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index eeb6775..054cef7 100644 --- a/risu.h +++ b/risu.h @@ -155,6 +155,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f); int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); /* return size of reginfo */ -const int reginfo_size(void); +int reginfo_size(struct reginfo *ri); #endif /* RISU_H */ diff --git a/reginfo.c b/reginfo.c index f187d9c..411c2a6 100644 --- a/reginfo.c +++ b/reginfo.c @@ -38,7 +38,7 @@ RisuResult send_register_info(void *uc) case OP_TESTEND: case OP_COMPARE: case OP_SIGILL: - header.size = reginfo_size(); + header.size = reginfo_size(&ri); extra = &ri; break; @@ -109,7 +109,7 @@ RisuResult recv_and_compare_register_info(void *uc) case OP_TESTEND: case OP_COMPARE: case OP_SIGILL: - extra_size = reginfo_size(); + extra_size = reginfo_size(&master_ri); break; case OP_SETMEMBLOCK: case OP_GETMEMBLOCK: @@ -217,7 +217,7 @@ void report_mismatch_header(void) case OP_COMPARE: case OP_SIGILL: kind = "reginfo"; - a_sz = reginfo_size(); + a_sz = reginfo_size(&apprentice_ri); break; case OP_SETMEMBLOCK: case OP_GETMEMBLOCK: diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 028c690..7044648 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg) #endif } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { int size = offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC @@ -194,7 +194,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) { - return memcmp(r1, r2, reginfo_size()) == 0; + return memcmp(r1, r2, reginfo_size(r1)) == 0; } #ifdef SVE_MAGIC diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 3662f12..3832e27 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,7 +36,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 60fc239..902d33e 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,7 +74,7 @@ void process_arch_opt(int opt, const char *arg) } } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 32b28c8..361f172 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,7 +23,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 071c951..c86313c 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,7 +32,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } From patchwork Tue May 19 02:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186919 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3450117ilb; Mon, 18 May 2020 20:02:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbHelIO4AfbaO3I1ruVdnb7+80n7caa/yDuTBd/XRpm0hgfHdPMYquS8W14eOV1JgK1KkC X-Received: by 2002:a37:b847:: with SMTP id i68mr18474850qkf.431.1589857326336; Mon, 18 May 2020 20:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857326; cv=none; d=google.com; s=arc-20160816; b=roAl6A1j3elYg4PfjpnN70I6KcPXzzwLLT5BOTaADmS0Kl3Aqn+a+g2ht1zzIE3TwF mTE5YX6MjuDgLJ5Jmc+wNW5m6eU4PHIGCRlTZZgar11CiHrQWqYhdpQBVeUqa9n3EYwD i+Y+wLrIQapiWS0rZLOE3WYlUd/ZYzOLU80iWVibzUByYbVxv/5yR50p7NPscCVQgMES 6a+vmIjevQ0PKLu/byt8Mq3Uz+QGGNTZO34bddzak7tAZSWsjP0g+4LPaH5XiZ4Dj+jI yuH8aQvPDs7tYBPQc1VFCB62fz24F6yca+vyxuQhqhgZMm198NHUUvc47pbfEb6dZSsD n+bA== 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=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=SUKOqjsg1NC7a/gO4WSuT5VlAUbylTcN+lDcJca/j+XlSu08tnUwOr25xtf9u6qKV6 Owen8+xtWimWMN86eigyJU+5vBZjf2wskw3PJAWdfPRDL2epWM1H/5WzM2peXgAY4OO3 apOWsVB8kIGTyyLdKRuBzpz33ZCZ5+0/UnUPsAYzIqt8qZ7V4fMQ1hTuMz5kwCvft5+2 5mv8NU2fW67bqE2XJQfsKrmF7eoXCs0IBfkKs2+G3bvuq57Mctssvh/eLp5nfuNV2kHZ uf9Vh9zXKK7cvJn04LZhOs1SjV6tHADwq9HDTNB0xFVYszuAHUuHCfqYQ99iaGNewTEh BrNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DOUm4Kug; 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=pass (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 f67si6489802qtb.318.2020.05.18.20.02.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 20:02:06 -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=pass header.i=@linaro.org header.s=google header.b=DOUm4Kug; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasW5-0003mV-PF for patch@linaro.org; Mon, 18 May 2020 23:02:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOc-0005ie-1C for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:22 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:35247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOa-0002X7-T3 for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:21 -0400 Received: by mail-pf1-x42c.google.com with SMTP id n18so5869244pfa.2 for ; Mon, 18 May 2020 19:54:20 -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=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=DOUm4KugWp/kOGDAKBupoFDC4SqvBW90J9aXblWXvgZeGWiKVjvmUmslh5vjIBVCXz GxzF4JkYikUtnNbzTDVN9Lzr1LpibCDVdwSBJkxfPMDgkUEgnOp4Rt8A7Rj+MskHS43G G8HWgtdCaDplTZK8yJYTfOifAsYt+yWc83g4bC6s8y4ZLpO6O1HEnOasE1GZdwZGrPa+ BpnO5t86Tuq6Nhj6AFC6sQIxt0/XS5Jzy/Kb52oVWcz+s3G3bBI5ArRsrvwOsEYdHphO YqSwIG6RjWbhJLatGe3qKdEArwBHpRzyJwtifjJR/iZe5mi1nanE6UxCsDK6jSVOh5rf yZTQ== 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=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=k37VGu/Z+lg/4cJT/T3ETM/fS8wwi0S7dfopHYf4LQV4cHosJjSCNWpqOXlW0z5ZBo GzkWt4P+iR+S0pMU7xkNo1QuigTlIL2gkWT7Al4mK9yPYhUJTAAhWP8NayY08V+oftD6 Kf4Sm+OqjdvP0IfRk+Rjxr8Vi+owVH1kvj+k73nOcZs4Vt2cZnKKSm3Kv7Wgx6mHLve1 JfjtYlSoeOzPglvapQlokiSk0oM0eqs1JjjW4dlvPibuuHdAaTIwCCxZuF0SfljJi7cq Gr72jX1Y/8v6J/+MvAMAN32jJsWAUqA1AQ+csJuqnPbmVy6x37RJ1kDjfkI+wiueGlGL nzzg== X-Gm-Message-State: AOAM530x5bTsyhCk7m8ojia70PiIFIGd/QFSi5F2q8rdGAW95oFKLtus VkfFgLHV/RrEk19PlDeK3ASZM2ZQ23g= X-Received: by 2002:a63:fb14:: with SMTP id o20mr17903000pgh.144.1589856858940; Mon, 18 May 2020 19:54:18 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 16/17] aarch64: Reorg sve reginfo to save space Date: Mon, 18 May 2020 19:53:54 -0700 Message-Id: <20200519025355.4420-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mirror the signal frame by storing all of the registers as a lump. Use the signal macros to pull out the values. Signed-off-by: Richard Henderson --- risu_reginfo_aarch64.h | 16 +---- risu_reginfo_aarch64.c | 135 +++++++++++++++++++++-------------------- 2 files changed, 73 insertions(+), 78 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index c33b86f..01076b4 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -17,20 +17,8 @@ struct simd_reginfo { __uint128_t vregs[32]; - char end[0]; }; -#ifdef SVE_MAGIC -struct sve_reginfo { - /* SVE */ - uint16_t vl; /* current VL */ - __uint128_t zregs[SVE_NUM_ZREGS][SVE_VQ_MAX]; - uint16_t pregs[SVE_NUM_PREGS][SVE_VQ_MAX]; - uint16_t ffr[SVE_VQ_MAX]; - char end[0]; -}; -#endif - /* The kernel headers set this based on future arch extensions. The current arch maximum is 16. Save space below. */ #undef SVE_VQ_MAX @@ -47,11 +35,13 @@ struct reginfo { /* FP/SIMD */ uint32_t fpsr; uint32_t fpcr; + uint32_t sve_vl; union { struct simd_reginfo simd; #ifdef SVE_MAGIC - struct sve_reginfo sve; + char sve[SVE_SIG_CONTEXT_SIZE(16) - SVE_SIG_REGS_OFFSET] + __attribute__((aligned(16))); #endif }; }; diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 7044648..a1020ac 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -71,15 +71,30 @@ void process_arch_opt(int opt, const char *arg) int reginfo_size(struct reginfo *ri) { - int size = offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC - if (test_sve) { - size = offsetof(struct reginfo, sve.end); + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + return (offsetof(struct reginfo, sve) + + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); } #endif - return size; + return offsetof(struct reginfo, simd) + sizeof(ri->simd); } +#ifdef SVE_MAGIC +static uint64_t *reginfo_zreg(struct reginfo *ri, int vq, int i) +{ + return (uint64_t *)(ri->sve + SVE_SIG_ZREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} + +static uint16_t *reginfo_preg(struct reginfo *ri, int vq, int i) +{ + return (uint16_t *)(ri->sve + SVE_SIG_PREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} +#endif + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { @@ -152,8 +167,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } - ri->sve.vl = sve->vl; - if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ @@ -164,24 +177,9 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } - /* Copy ZREG's one at a time */ - for (i = 0; i < SVE_NUM_ZREGS; i++) { - memcpy(&ri->sve.zregs[i], - (void *)sve + SVE_SIG_ZREG_OFFSET(vq, i), - SVE_SIG_ZREG_SIZE(vq)); - } - - /* Copy PREG's one at a time */ - for (i = 0; i < SVE_NUM_PREGS; i++) { - memcpy(&ri->sve.pregs[i], - (void *)sve + SVE_SIG_PREG_OFFSET(vq, i), - SVE_SIG_PREG_SIZE(vq)); - } - - /* Finally the FFR */ - memcpy(&ri->sve.ffr, (void *)sve + SVE_SIG_FFR_OFFSET(vq), - SVE_SIG_FFR_SIZE(vq)); - + ri->sve_vl = sve->vl; + memcpy(ri->sve, (char *)sve + SVE_SIG_REGS_OFFSET, + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } #endif /* SVE_MAGIC */ @@ -225,18 +223,20 @@ static void sve_dump_preg_diff(FILE *f, int vq, const uint16_t *p1, fprintf(f, "\n"); } -static void sve_dump_zreg_diff(FILE *f, int vq, const __uint128_t *z1, - const __uint128_t *z2) +static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, + const uint64_t *zb) { const char *pad = ""; int q; for (q = 0; q < vq; ++q) { - if (z1[q] != z2[q]) { + uint64_t za0 = za[2 * q], za1 = za[2 * q + 1]; + uint64_t zb0 = zb[2 * q], zb1 = zb[2 * q + 1]; + + if (za0 != zb0 || za1 != zb1) { fprintf(f, "%sq%-2d: %016" PRIx64 "%016" PRIx64 - " vs %016" PRIx64 "%016" PRIx64"\n", pad, q, - (uint64_t)(z1[q] >> 64), (uint64_t)z1[q], - (uint64_t)(z2[q] >> 64), (uint64_t)z2[q]); + " vs %016" PRIx64 "%016" PRIx64"\n", + pad, q, za1, za0, zb1, zb0); pad = " "; } } @@ -263,28 +263,30 @@ int reginfo_dump(struct reginfo *ri, FILE * f) if (test_sve) { int q, vq = test_sve; - fprintf(f, " vl : %d\n", ri->sve.vl); + fprintf(f, " vl : %d\n", ri->sve_vl); - for (i = 0; i < 32; i++) { - fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", i, 0, - (uint64_t)(ri->sve.zregs[i][0] >> 64), - (uint64_t)ri->sve.zregs[i][0]); + for (i = 0; i < SVE_NUM_ZREGS; i++) { + uint64_t *z = reginfo_zreg(ri, vq, i); + + fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + i, 0, z[1], z[0]); for (q = 1; q < vq; ++q) { - fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", q, - (uint64_t)(ri->sve.zregs[i][q] >> 64), - (uint64_t)ri->sve.zregs[i][q]); + fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + q, z[q * 2 + 1], z[q * 2]); } } - for (i = 0; i < 16; i++) { - fprintf(f, " P%-2d : ", i); - sve_dump_preg(f, vq, &ri->sve.pregs[i][0]); + for (i = 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *p = reginfo_preg(ri, vq, i); + + if (i == SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg(f, vq, p); fprintf(f, "\n"); } - fprintf(f, " FFR : "); - sve_dump_preg(f, vq, &ri->sve.ffr[0]); - fprintf(f, "\n"); - return !ferror(f); } #endif @@ -338,31 +340,34 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) #ifdef SVE_MAGIC if (test_sve) { - int vq = sve_vq_from_vl(m->sve.vl); + int vq = sve_vq_from_vl(m->sve_vl); - if (m->sve.vl != a->sve.vl) { - fprintf(f, " vl : %d vs %d\n", m->sve.vl, a->sve.vl); + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); } for (i = 0; i < SVE_NUM_ZREGS; i++) { - if (!sve_zreg_is_eq(vq, &m->sve.zregs[i], &a->sve.zregs[i])) { - fprintf(f, " Z%-2d ", i); - sve_dump_zreg_diff(f, vq, &m->sve.zregs[i][0], - &a->sve.zregs[i][0]); - } - } - for (i = 0; i < SVE_NUM_PREGS; i++) { - if (!sve_preg_is_eq(vq, &m->sve.pregs[i], &a->sve.pregs[i])) { - fprintf(f, " P%-2d : ", i); - sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], - &a->sve.pregs[i][0]); - } - } - if (!sve_preg_is_eq(vq, &m->sve.ffr, &a->sve.ffr)) { - fprintf(f, " FFR : "); - sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], &a->sve.pregs[i][0]); - } + uint64_t *zm = reginfo_zreg(m, vq, i); + uint64_t *za = reginfo_zreg(a, vq, i); + if (!sve_zreg_is_eq(vq, zm, za)) { + fprintf(f, " Z%-2d ", i); + sve_dump_zreg_diff(f, vq, zm, za); + } + } + for (i = 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *pm = reginfo_preg(m, vq, i); + uint16_t *pa = reginfo_preg(a, vq, i); + + if (!sve_preg_is_eq(vq, pm, pa)) { + if (i == SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg_diff(f, vq, pm, pa); + } + } return !ferror(f); } #endif From patchwork Tue May 19 02:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186918 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3448946ilb; Mon, 18 May 2020 20:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvpN8zFf91STPJ6L+InLK0jHTFoPGp2bSGHrvnRkhwZ4h6zV00XRpI89cpqkcfabqneZEk X-Received: by 2002:ad4:4f87:: with SMTP id em7mr10071508qvb.192.1589857224503; Mon, 18 May 2020 20:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589857224; cv=none; d=google.com; s=arc-20160816; b=ukiXRTrtApN/yEUa/hyN344ZExxibCsKL6+Op9N68q756YXv+InPsUJeUyvhMgie4K VZEJBGYrhNMRwLJ2yulDt9hZX7x/nwzKKmZ7W4/KIrOY6PrJe121FFK3UeYDvNQ5zl7q 212+XGjjybeJEC3OQcEE5Rbcbk6pFTQ2eFDJ6Yz3CQiPT07TnJXd87ElCQYq1H91EJwX BoDPq5EW8X9Pn/3gzRDtPCK4cvMApcyBWCoEWAORGpss/pNMV9/eDom0Y/IMIVKkzWbm Qv6CeOHS3+okAYmVGjItSZ6I4IaU5y72/DClI3eg5sssE7e+8lmvH5RqcXYj1kw350NG uR6w== 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=7oeS1yq+JuN20j7v7YlPjXCqUmCXhfYGwbcqS/Ex0lQ=; b=enITpUvxU2XdqInxwHNUCbZgOEIw5wxEvuYB2wLCKxN8qoYkP7Lit1GKPOi5yxPqKr PgLkoEuydsU/uYS7EPmLzQbSSJI4SUV9TOaptmpUwEPutDr2OMAXnOs0aJ5B/TMd+O0B vO2cEJo+PvGQNTQTh1If/gwRk3lVSn67S+J1fueGAOwUbXJTNb9a6KxTwhAfAwVQE21b ssm9AIdwb1c78f+jvlB86WD0S2sWn5tCdAO/KFXxZMZ6EArx6OqPif9jjcWBhoFgCn0p TRmw03bwDkK5XaBStyGwrVjE3KQNE6QabumNkT2vBCOmEq7NiIerYZJjgtUnK/8S+b91 WhPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPRpokFC; 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=pass (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 bh9si6499797qvb.32.2020.05.18.20.00.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 20:00:24 -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=pass header.i=@linaro.org header.s=google header.b=iPRpokFC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasUS-00013v-0B for patch@linaro.org; Mon, 18 May 2020 23:00:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOd-0005mh-Bh for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:23 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOc-0002XL-2Y for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:23 -0400 Received: by mail-pf1-x42e.google.com with SMTP id 145so5851239pfw.13 for ; Mon, 18 May 2020 19:54:21 -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=7oeS1yq+JuN20j7v7YlPjXCqUmCXhfYGwbcqS/Ex0lQ=; b=iPRpokFCK6wQcIorE/5znHNzBns5F8QhUi/eWDuUptzms0PHkODWyIbYVqxtwwktIm PlNAN7WNt293oK9k1AuTMZfp4Hg/E3D6NqVUhQHm/ghahTFPO1CL+REgj3MTwRr+KDpn u8yE1blINsgBpTdlbINjfATn7iIP4FJUuMbqK8erfqp4fN2e2plnv+4JmtfLBkDtgFOm SSwBUWxI4CtWsoZBQ8FlLz50xt57rt4YbE/gFcCkuh4Ndy1RfIVKZjGgrneD5ttHLkEy ZbD3rnGnaVUUtyphXOVTpV6OWpl1UpFAgzDL0orpiijBMFvfE/c9fl8Qmz9raAhI2TAB KQgQ== 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=7oeS1yq+JuN20j7v7YlPjXCqUmCXhfYGwbcqS/Ex0lQ=; b=ktybrfxp4qz5i+3EcI9X9fGmqby7GmkFttdeITMXStfpJNMbeJjfiTEdaYCTvy+YHy 2fuvYnKjhuFF7mrAXqkPPA+dNsFoz13RGkONXMMiU+Zcpby39BfGtsR4SL26A0A9BRJu 5rCt0YNQA/fSbrZFT+loeNbOeoX4il1YtAgA93hsKWJgxUvuBHVa3nk9pLhBiCio0+TF JHWoH5vg5iD2YtUQzxh2sO39/LjzF2/rKVyqzSQajpwq1bin2gph66us03mijsDr3Ulb EGYUC4GQiVaWt5Ula1CZkGLwz0Y9wp/RJvVh+eN8r/7mxPkAQh3AH1s8PAi58O7Zj7zq +oWQ== X-Gm-Message-State: AOAM5327z6X4sUyk3j5PxhMpF0vmYmJcR30/5YBurVMkwItLzZUy2eIL ZisNuaN0P3pBkOvA+QsToyve1aVaPto= X-Received: by 2002:a63:c146:: with SMTP id p6mr11521519pgi.55.1589856860213; Mon, 18 May 2020 19:54:20 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 17/17] Add --dump option to inspect trace files Date: Mon, 18 May 2020 19:53:55 -0700 Message-Id: <20200519025355.4420-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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_PASS=-0.001, URIBL_BLOCKED=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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adjust some of the aarch64 code to look at the reginfo struct instead of looking at test_sve, so that we do not need to pass the --test-sve option in order to dump sve trace files. Signed-off-by: Richard Henderson --- risu.h | 1 + risu.c | 108 ++++++++++++++++++++++++++++++++++++++++- risu_reginfo_aarch64.c | 55 +++++++++++++-------- risu_reginfo_arm.c | 4 ++ risu_reginfo_i386.c | 4 ++ risu_reginfo_m68k.c | 4 ++ risu_reginfo_ppc64.c | 4 ++ 7 files changed, 159 insertions(+), 21 deletions(-) -- 2.20.1 Tested-by: Alex Bennée Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index 054cef7..3bfe765 100644 --- a/risu.h +++ b/risu.h @@ -23,6 +23,7 @@ extern const struct option * const arch_long_opts; extern const char * const arch_extra_help; void process_arch_opt(int opt, const char *arg); +void arch_init(void); #define FIRST_ARCH_OPT 0x100 /* GCC computed include to pull in the correct risu_reginfo_*.h for diff --git a/risu.c b/risu.c index 95b4674..d7c7556 100644 --- a/risu.c +++ b/risu.c @@ -249,6 +249,93 @@ static int apprentice(void) } } +static int dump_trace(void) +{ + trace_header_t header; + union { + struct reginfo ri; + unsigned char memblock[MEMBLOCKLEN]; + } u; + const char *op_name; + + while (1) { + if (read_buffer(&header, sizeof(header))) { + fprintf(stderr, "Trace header read failed\n"); + return EXIT_FAILURE; + } + + if (header.magic != RISU_MAGIC) { + fprintf(stderr, "Unexpected header magic (%#x)\n", header.magic); + return EXIT_FAILURE; + } + + switch (header.risu_op) { + case OP_COMPARE: + op_name = "COMPARE"; + break; + case OP_TESTEND: + op_name = "TESTEND"; + break; + case OP_SETMEMBLOCK: + op_name = "SETMEMBLOCK"; + break; + case OP_GETMEMBLOCK: + op_name = "GETMEMBLOCK"; + break; + case OP_COMPAREMEM: + op_name = "COMPAREMEM"; + break; + case OP_SIGILL: + op_name = "SIGILL"; + break; + default: + op_name = ""; + break; + } + + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + case OP_SIGILL: + if (header.size > sizeof(u.ri)) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + if (read_buffer(&u.ri, header.size)) { + fprintf(stderr, "Reginfo read failed\n"); + return EXIT_FAILURE; + } + if (header.size != reginfo_size(&u.ri)) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + printf("%s: (pc %#lx)\n", op_name, (unsigned long)header.pc); + reginfo_dump(&u.ri, stdout); + putchar('\n'); + if (header.risu_op == OP_TESTEND) { + return EXIT_SUCCESS; + } + break; + + case OP_COMPAREMEM: + if (header.size != MEMBLOCKLEN) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + if (read_buffer(&u.memblock, MEMBLOCKLEN)) { + fprintf(stderr, "Memblock read failed\n"); + return EXIT_FAILURE; + } + /* TODO: Dump 8k of data? */ + /* fall through */ + + default: + printf("%s\n", op_name); + break; + } + } +} + static int ismaster; static void usage(void) @@ -261,6 +348,7 @@ static void usage(void) fprintf(stderr, "between master and apprentice risu processes.\n\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, " --master Be the master (server)\n"); + fprintf(stderr, " -d, --dump=FILE Dump " TRACE_TYPE " trace file\n"); fprintf(stderr, " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n"); fprintf(stderr, " -h, --host=HOST Specify master host machine (apprentice only)" @@ -281,11 +369,12 @@ static struct option * setup_options(char **short_opts) {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"trace", required_argument, 0, 't'}, + {"dump", required_argument, 0, 'd'}, {0, 0, 0, 0} }; struct option *lopts = &default_longopts[0]; - *short_opts = "h:p:t:"; + *short_opts = "d:h:p:t:"; if (arch_long_opts) { const size_t osize = sizeof(struct option); @@ -316,6 +405,7 @@ int main(int argc, char **argv) char *trace_fn = NULL; struct option *longopts; char *shortopts; + bool dump = false; longopts = setup_options(&shortopts); @@ -330,6 +420,10 @@ int main(int argc, char **argv) case 0: /* flag set by getopt_long, do nothing */ break; + case 'd': + trace_fn = optarg; + trace = dump = true; + break; case 't': trace_fn = optarg; trace = true; @@ -351,6 +445,11 @@ int main(int argc, char **argv) } } + if (dump && ismaster) { + usage(); + exit(1); + } + if (trace) { if (strcmp(trace_fn, "-") == 0) { comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; @@ -366,6 +465,10 @@ int main(int argc, char **argv) } } + if (dump) { + return dump_trace(); + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -375,6 +478,9 @@ int main(int argc, char **argv) load_image(imgfile); + /* Select requested SVE vector length. */ + arch_init(); + if (ismaster) { if (!trace) { fprintf(stderr, "master port %d\n", port); diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index a1020ac..fb8e11a 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -44,8 +44,6 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { #ifdef SVE_MAGIC - long want, got; - assert(opt == FIRST_ARCH_OPT); test_sve = strtol(arg, 0, 10); @@ -53,22 +51,37 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); exit(EXIT_FAILURE); } - want = sve_vl_from_vq(test_sve); - got = prctl(PR_SVE_SET_VL, want); - if (want != got) { - if (got < 0) { - perror("prctl PR_SVE_SET_VL"); - } else { - fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", - test_sve, (int)sve_vq_from_vl(got)); - } - exit(EXIT_FAILURE); - } #else abort(); #endif } +void arch_init(void) +{ +#ifdef SVE_MAGIC + long want, got1, got2; + + if (test_sve == 0) { + return; + } + + want = sve_vl_from_vq(test_sve); + asm(".arch_extension sve\n\trdvl %0, #1" : "=r"(got1)); + if (want != got1) { + got2 = prctl(PR_SVE_SET_VL, want); + if (want != got2) { + if (got2 < 0) { + perror("prctl PR_SVE_SET_VL"); + got2 = got1; + } + fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", + test_sve, (int)sve_vq_from_vl(got1)); + exit(EXIT_FAILURE); + } + } +#endif +} + int reginfo_size(struct reginfo *ri) { #ifdef SVE_MAGIC @@ -170,6 +183,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ + goto do_simd; } else { fprintf(stderr, "risu_reginfo_aarch64: " "failed to get complete SVE state\n"); @@ -182,6 +196,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } + do_simd: #endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { @@ -260,8 +275,9 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpcr : %08x\n", ri->fpcr); #ifdef SVE_MAGIC - if (test_sve) { - int q, vq = test_sve; + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + int q; fprintf(f, " vl : %d\n", ri->sve_vl); @@ -339,13 +355,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } #ifdef SVE_MAGIC - if (test_sve) { + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); + } + if (m->sve_vl) { int vq = sve_vq_from_vl(m->sve_vl); - if (m->sve_vl != a->sve_vl) { - fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); - } - for (i = 0; i < SVE_NUM_ZREGS; i++) { uint64_t *zm = reginfo_zreg(m, vq, i); uint64_t *za = reginfo_zreg(a, vq, i); diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 3832e27..2982435 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,6 +36,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 902d33e..68f2323 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,6 +74,10 @@ void process_arch_opt(int opt, const char *arg) } } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 361f172..499fdc4 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,6 +23,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index c86313c..3b04747 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,6 +32,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo);