From patchwork Fri Jul 8 15:46:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588549 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp781031mab; Fri, 8 Jul 2022 08:51:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sMFDLMbgBJ6QLmSQctn/lPttyffzl+ph4VPRSrzgjHSr8DhBrF0pW3vnjpWflMyfv8VB49 X-Received: by 2002:ac8:7d96:0:b0:31e:a602:a1d5 with SMTP id c22-20020ac87d96000000b0031ea602a1d5mr2702655qtd.468.1657295480789; Fri, 08 Jul 2022 08:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657295480; cv=none; d=google.com; s=arc-20160816; b=DcZAxQjPQaYkCHXYjaW+erQxa3pXAjdfb5ff1ztjV5XXSPEjwICuJsCatWfBCc8NKq I4GNc2z36eoJrM2ivsZeu5+ZiPAJGcpRHDSiVzjtEnbVXvftSCD3lLB0jNZd/zCBjWzX RCwDxSnQo0+X2rCYVnktkYHWhfOzxRpmdTUieNqMb2nNBnTJZhJZEIUrN2aSaTTznPip 00emgZRW9Jkd0/d3Z9fD5aTIVFPBbZpFomzLWblIFgFE4b1+9X07gj2uQ7Hx72m6LeYF Qmat/kvLo2qOVcPMMC7IDC0OT3bupEAz8o6ZqBfmc9OW191Grwlcvq34+dwelg0qagmK kXjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=iiRXuoRm0+6hZcCT7CVhc/aX8fiaQgpUOM3IjX/kYqE=; b=icM1KUeYyLyNolK9d4sGaseeBHE5KwDwd5T1IEvjJpdsDmsJhg0XawA68qB51u1npk tmxelaej8XEuGZVZVVpiQ1riWnbs1cqx7HTo3ChZjeoeyJ0AAY+EhoJRC4RJwPCtA4v+ 5gGf9eAgs9ZQsSz7dX/34comn3ib0HCyyrh2izDoVVLYtbyxr7EkrmK1gnUZseYVd6AF Do/9WDHguZsp3OYAOQMxRV1fkNNrjXG32ZYPnPB8pvkI8SZHHA7f4N/H7emxWJkhEhQZ 1gZi0p0sQfIWFtI9iFi9/djpsyZWzlcMI7NDibzI5GAFw//JBxzGsyhmktBOlECak9np SJdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EXmm3to5; 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 f36-20020a05622a1a2400b0031778f44a11si21909708qtb.220.2022.07.08.08.51.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 08:51:20 -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=EXmm3to5; 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]:54082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qGG-0001Ni-DG for patch@linaro.org; Fri, 08 Jul 2022 11:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCG-0003v4-TS for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:13 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:34613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCF-0002LY-Ce for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:12 -0400 Received: by mail-pf1-x430.google.com with SMTP id 70so8743622pfx.1 for ; Fri, 08 Jul 2022 08:47: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=iiRXuoRm0+6hZcCT7CVhc/aX8fiaQgpUOM3IjX/kYqE=; b=EXmm3to53nsWS9DEDIkMCrgn8NrlmwgZC0zqNF0sq2jMvUgM86rlQVlpm+BOjLiMig zI73swUSdOvgPIT2s6enl1Vqs85aLOgSY58HzaHM0QivPslefXfMr1f38LYGIUHIVwtk JMO0rEA8IlkAymc8l1yRM/WanxNeIp2isRHADdMWKIv57E3iiDgGeuWdYwrcDo2qWM8h kMHCBnZBiXLG4ZWyfQ7Nfqf3zXK3OWt2uNRE2VQSG7gQjNWz4XJgyxCDF5ajolKLc1G4 F8iaXDUNsu2MvglKfZJKq6ciNbQyvLvbAQ7PWFmLrmdLakH4CdzjX9/6ix+/5hJo1IEk wm1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iiRXuoRm0+6hZcCT7CVhc/aX8fiaQgpUOM3IjX/kYqE=; b=vIurX2nZMKyB5zgt1DBTqiIz/Bd95zPoJmHn3RHTVOVufeJ6h2xJCvSvSTRcJYDwh5 EoSJuqVKXm54foAfLJDFTqt+jXCmUPD/iKAVWqdjRCVvGDn8QdyUi8fs/ADor97/ngI+ /oThj58UlUfZJiHOeXC3LVQflcGDyCJcRlbvUGAY1fO92Taf+hUHPbZ/j3RrumkYU3p7 mN1JT0hfuUIZpPCUM54S+m0tO7HClPcYgT+EmDzpWxwPrZDAMGqGbahqFSKBQpmWSadq UIK4kl03HABa2uzGzlvuahRiMtlbJhDSareiH0lEDQHmSHVjFkZM79kTK0E9sL0qKqZR /4XA== X-Gm-Message-State: AJIora/m0GIP0660MFCMBMJyTW6VklrJVLB+VonmQUNAtc3yvmeo2ylA s+1Sp0gXZ4CrbUqpbNIhiRfOwXNMBpYASMtm X-Received: by 2002:a63:481a:0:b0:411:7951:cbcd with SMTP id v26-20020a63481a000000b004117951cbcdmr3866584pga.66.1657295229649; Fri, 08 Jul 2022 08:47:09 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 01/29] Use bool for tracing variables Date: Fri, 8 Jul 2022 21:16:32 +0530 Message-Id: <20220708154700.18682-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée 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(-) 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 Fri Jul 8 15:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588568 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp813405mab; Fri, 8 Jul 2022 09:28:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vSqHK7Jd1mkGyoacdCbXZLomiGhOYSkmytcIST6ubr34FRK9aH1qMuWRVsPywg8U2i80PH X-Received: by 2002:ae9:e21a:0:b0:6ae:fa03:479b with SMTP id c26-20020ae9e21a000000b006aefa03479bmr3046869qkc.108.1657297719888; Fri, 08 Jul 2022 09:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297719; cv=none; d=google.com; s=arc-20160816; b=AhOlwsNhDiopFGMWOrGzvWWOUmk5L3oGVzEFZn20wIUq75mRYy1/5zNoCflp7bhDYo Jt3TAsmQEFmFP1zWjKzT4E6IE2RBdmYvnFcOXpaZ3Q/zbP8wTS7lXBpkRev6YgO0zqVB tzox2Fw1czB482XGBQ8SYiqfQIR7AhjOIhyuESBT2MSDnCKxD9OmUF2dpujeohoEIPIH uj542w6ZNKzjk13o/RdhZ7XPNDbhYqrqHUn34bhCnm3QH2HLu0JGw9ybpgaaCBvhtx6E OKoiJQTwdrRLFg2+40adf7SxiftRdFHH78UPrN6OcayGP9OExcS3hx39MYpsNUFQRMsu 5IJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=W9clK9K4+8X5B/4DNlH9mx5SK0k7ufsF0qklyhZjD3QdhEn99hKXLMNTsP6BnpWe56 9DiCzyOBlsN+1Np+b40CJ61Aun0bUWhbNzEUTFETiMNkTNAMmVGKeoySvsgoXoDS1Meo CclqZzgyVQoWqYPscgBKJpeBrJ5Ea38BNz7u3MaTgKMN+IIWraMrQnzpEkM72gxwZZwL tXbrBoyMiVi2efYYBEDZ6U5Y7FCivMhAMAvrZbB8++84WagjAlRfAiD8t320vEWbGX4h 1/TggR7Z5HGKJE/RuFe1f2csqCUZpOHZRHWaI1A4X5sSvV8D/il6dmWYb+V5TlVrJja6 kYHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j99DO5x8; 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 fq8-20020a056214258800b004702c38f4casi26805610qvb.234.2022.07.08.09.28.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:28: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=j99DO5x8; 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]:54456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qqN-0001lw-Fc for patch@linaro.org; Fri, 08 Jul 2022 12:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCJ-0003wr-Tc for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:15 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:50772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCI-0002Mv-6W for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:15 -0400 Received: by mail-pj1-x102e.google.com with SMTP id a15so11634223pjs.0 for ; Fri, 08 Jul 2022 08:47: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=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=j99DO5x8nS4GWZgN7/isM8hAHv2aQ/GA/Ij2mh7eapSfu61OmoN7atzL7BbqmhY00O KrhP2DoYzTl3/b5I011Xo/8pNm5bJZAjvbHQxGOEY/ky39O3gBPFsREaavJmssmQCnw2 9wZYv0apGloRI0uTNcbZVuvGYWocwiuq1UqV/Dx5yJLf30g6vwZeTyl94PfG7ORonzj4 qL5KQ1Wsn7eTgf5T53NXxzGtJQTn3VXdc9rao4LQTpfmauNq5XWlzRrkxya39qwfZHNE mY6YfpZU2+DDhKr3wPHGVkIx7KDXB1U1GwuBeFsYkufJTtJfoW7uOQsk1YbbsoFW/8Uz 6Apw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=470DCiE7J5GUwbvx47uUzYB1XcAXqqrbP+wNxCfea1rzRDF13SwuaDfjnq9st00dOP pGnIVdwCGRsS+HLvPWlCYT3HvIjBx6CsLW768lLj+MiQCk8Qy6VRzfKhxeY2gi5rB8So ysRtm1z+VS3KIB22hvA95VAWuLtqkXTc4/Ffxf8hOe8L8X0TnqG5hXAIHZHY2XgL58Tx zZyuVn/QtiPqrfSL6bfUoc/+QqJQgNI4332n9UsoT1MeKy3dZGzLqkMyOj+3eODEZIPQ d7vR+k2SYDDLKqOQC2zIBGiX/Kbje0G2IM+SY3uOg948E7Ot32GHsqEGkabeyrM68hgt hLvQ== X-Gm-Message-State: AJIora8SEWwVON8/gHAgtOSjs0DNwnbQapz8xeIVEgivxARKy5ZYuo2+ tPs196R/txizFJO8BPJw1mzpmES7e41oM8Ov X-Received: by 2002:a17:90b:1b49:b0:1ec:a756:edc with SMTP id nv9-20020a17090b1b4900b001eca7560edcmr502319pjb.200.1657295232878; Fri, 08 Jul 2022 08:47:12 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 02/29] Unify master_fd and apprentice_fd to comm_fd Date: Fri, 8 Jul 2022 21:16:33 +0530 Message-Id: <20220708154700.18682-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) 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 Fri Jul 8 15:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588564 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp806842mab; Fri, 8 Jul 2022 09:20:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vn8ZpJNAPAJs/N6GCdTEan6eMTywgDDFINwr6BgSXfizkM7BM43dD15m7lEI+RXZ5rogof X-Received: by 2002:a05:622a:1441:b0:31d:2a48:250 with SMTP id v1-20020a05622a144100b0031d2a480250mr3779660qtx.98.1657297239146; Fri, 08 Jul 2022 09:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297239; cv=none; d=google.com; s=arc-20160816; b=KwyJVZW5On/KRRtgml2uleaJV98TkWH+Sb1vjNIY0hMffgEecuQm8OiErxJKY5wYfD YKHjJFyTjFsIsSDhTyBwdfF7dR41n3laWg2/Lvmx0rL1KUCs2hQ4cud8Z14I2eLMLXWw Zja6V4fuMFe1+u7KptNMJh1U+fcX7xVIO/wnvhDIozovYqXEdiNXUvuqG/mFy202mwjr NYyEj0PcahqiYIveVRpdGGZpzRJ2iUnBgKSz5sPGs3/RQeBjxL3g3bohp29zkSETV98n QLrcTgSxF0VTJFDynAm/tdaGxjFvJCZNCTXYqjm2YQKlNWBhmEtKCvTd0W1hgUqT7RBu Ep1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=clO33w1aTNIXh4Ul1IORFEhQRHqOxEZ6XPvEx7IfV4Hzv06HsByOGe4gE5ggBtjRlU eWvaftU/aqm9rtx0dXHAzLS2tKC3sl3CyPEPnEtvv3jf9t6g4C8IR+P0CJVZEO/zjhJW 1/jCBc0yTk3UZT7OJw1klIbGXhxeUCwhj5z5y+QY6DPXLumz+GNXCHXq/rsGBH/OwyM4 gswFauLGCwrF4YNGjOXoLrWF0mHjo3Dy48AIwpnxgqcBAegEAOWdsL8pvWyhU2pyo3B5 vgoPyrVxvkjNL4wK73TwtwfZBr5qrNzhXjd5/GdqbSYl4dCj4Qklw0jPv4bsJgEK2azd KDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SxdaRVYR; 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 v7-20020a05622a014700b0031bc8f772dcsi24370445qtw.702.2022.07.08.09.20.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:20: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=SxdaRVYR; 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]:33976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qic-0003sY-P3 for patch@linaro.org; Fri, 08 Jul 2022 12:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCN-00049N-7a for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:19 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:33516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCL-0002P4-Hi for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:18 -0400 Received: by mail-pj1-x1036.google.com with SMTP id j1-20020a17090aeb0100b001ef777a7befso1886999pjz.0 for ; Fri, 08 Jul 2022 08:47: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=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=SxdaRVYRJDPH3zg3QYyQIu17dr/IVBcHr5XUHILGbaLIQeYPWWgY+954kvq/VXxQiN Jw/KmgOemd78xk8dMQSinK5JUeBmDvrtLd3N3LOo1Vwhm0gqkdKRvaaFspYV1/5LilqS 9MTTRuLtyCmJdgPIwtNvjy8ca8Hwf0tydMm1zVPJq/EAJVPbf4FM5OTdb3HDhp1fA5Pp IQjZNzJVOm2u92lYvJe3YF+/hgYEqP9+NID9iI8ItveucyWvXTbBzHeBDP6Jr+kMNcqI Y/gJovEEwgzDZbsKoeRKzz73ZtfMcQ38u6QbVkw0g/Y0x3nxNFvsIRoRbD9LTpZ+qxRB iNfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=E+YS8uf/uVG9bovpZK08NODums+not2tIjm4kW5n/0GzV021399pgOscrW/XAUZZ/B EH8q5gUD4NE1pSDUY9yZA5b8v1kw6Nes/qoUVAHj7KdFyxk5DSAB5Aaan6wBHl6enCfz tdD/lyY2aDUEy/IUNA/uBq4WmNbxmIdGQLUdKRNb+UOmHwyn3aClPJOtCV/r8jLtDbfH 591/9Pvt+/m4Cr3HzUgQtYf3MqpWJfaogj6KGuRZj2rjI3cUVVocygR5MM5K7GqcAuN/ 7vgDTzb/UdOc8Ag+Y8Ufmk70YwknyPn4jK8usZKfPyOyjPtFAKTz4N1ZDYJMFN2+J0cx Heeg== X-Gm-Message-State: AJIora+uGF+uNrsag5DqmGD9UzT0eugZKAZvLYxMIdyND5wMfPd35uru XWqXAfIKVC0RopjGlk9rW4ocnd7mby6rFBtM X-Received: by 2002:a17:90a:3e09:b0:1ef:8399:398b with SMTP id j9-20020a17090a3e0900b001ef8399398bmr482263pjc.39.1657295236189; Fri, 08 Jul 2022 08:47:16 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 03/29] Hoist trace file and socket opening Date: Fri, 8 Jul 2022 21:16:34 +0530 Message-Id: <20220708154700.18682-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code with --dump. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Hoist socket connecting as well as trace file opening. --- risu.c | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/risu.c b/risu.c index 059348f..2f6a677 100644 --- a/risu.c +++ b/risu.c @@ -363,6 +363,29 @@ 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 + } + } else { + if (ismaster) { + fprintf(stderr, "master port %d\n", port); + comm_fd = master_connect(port); + } else { + fprintf(stderr, "apprentice host %s port %d\n", hostname, port); + comm_fd = apprentice_connect(hostname, port); + } + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -373,34 +396,8 @@ 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 { - 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 { - fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - comm_fd = apprentice_connect(hostname, port); - } return apprentice(); } } From patchwork Fri Jul 8 15:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588567 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp813108mab; Fri, 8 Jul 2022 09:28:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1twlhGnu1E3v34uzd2nl/FgyvpNab4SvsASq+8whkGK/e/EaIWxN45Ahb58sp8/LpEjDWbf X-Received: by 2002:a05:620a:4150:b0:6b1:4472:6a82 with SMTP id k16-20020a05620a415000b006b144726a82mr2918014qko.696.1657297693593; Fri, 08 Jul 2022 09:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297693; cv=none; d=google.com; s=arc-20160816; b=OWImpVsCFzNCHMOvZG1Cx5IdwGJoTmkG8uX7JwicZL3mlmDpZhw5U97fyHDGhCGqE1 2V6Lxnv6j2kzJuLNxn3SvnU8qosS6H+lZmD2ZoNFjIFVTgtSRP887KtOY+oPWuuCzQ5Q MK73ZyRqcLRs78yFasXvcKrqtaoYK3y0j/TvM+al8+QY5D1D1K7rZ/xiiKyWkXrMSs1s ncRRQjJrynofHL5jP5kq97JclSjjTkvKQI5Nhq3c1LeQVs8uQUoCAX/Go84HL6xuAUrg Hsed6Rb3btOP/NK6xPaVTq0KO/reGrZjab8d/SvMmHb9E9zqatUR4hM7wIyht1NDCvWg PMnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=opEz47JE2jF71CZWR53DtauRYpdQpOBqzfW1h3P7OCY=; b=WzpF5lPXKI6UfFPLvMjk73Xd6kYpzNsUGcMSGEDbevUEDi09kf4uSR66ARnloa8Fzz 7dFTQ9Nitu4HRA/9fMr6Rvc31wjGeUqy/CW1Yy+ubRBjgwGzOi6Olgjh/UZeOKA9yJhk mVn0jkruPn/b+ucEmbQucr5o+Xe5eXf5QJ/8ejM1Nh3NugMJ/txJriVc7PLtxOwdwm+4 KnA8mcftUhole1xVecLdgStAvyty9xK+2R7FnZYLhXnyP99HfDB5TXFu6yvlQ8RecE1G 4EL0GkraV0S6kYrobs7AM7kny3/hl0fAEBTyyJ/DiZgPqenHSZAmXXG3essjPYjmynt5 mqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uzmrF8gV; 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 q23-20020a37f717000000b006ab961fa964si7951000qkj.390.2022.07.08.09.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:28:13 -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=uzmrF8gV; 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]:52992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qpw-0000UM-Nr for patch@linaro.org; Fri, 08 Jul 2022 12:28:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCP-0004Is-JR for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:22 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:38450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCO-0002Mw-1W for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:21 -0400 Received: by mail-pl1-x632.google.com with SMTP id m14so16675721plg.5 for ; Fri, 08 Jul 2022 08:47:19 -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=opEz47JE2jF71CZWR53DtauRYpdQpOBqzfW1h3P7OCY=; b=uzmrF8gVa/Q/F0vYfgs0h1pR8CtiCJAtSDfJEFH9PcSvREy69QAgJycgleaiZUzlmn 7tvhoPKKVRA7LxK/BtnhlUyPcfRougztvfCgRNV/wVaYAYVxS4j4ybQlQDE4V1fdlLs6 M5okr4wH0dJv8g15Zv0GQtIbTL91AcguCF51he06vNRVIS6jkJPHZLQnlJqQXhR3gukz J/hKH267tbhqnNeoHNzq4YhPGxVkch0Vyxh+2lQ4gEAZTVReVsiTCQ77Keyu6yc1KS5r lTKb9ic3dea3UO6WHYQcz7MviMKbsRVd3o+4VHyXCsp8c0bUmzJJtT9cTIftuYzOK/mA lmEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=opEz47JE2jF71CZWR53DtauRYpdQpOBqzfW1h3P7OCY=; b=FYU3J6TkgMsQdZKZTO+AIxOsoWc/8lZeyGDgHDgoEOFYfet5TdhckqUCsdWDnVlIXD wbDFTgYrxykG7ZVqcw9QEpEHCQXOoBpoZkPT1gMq2fdoWS3vw6xNOdJK4EpL5buOuw/Y Ux4Q06SjzFpYPefqze+CcuJBPy4tDk8ztWIbk17zebm9oS5ldb2K8bX5fUOOy71saJRj SFu8XsRo9n5FVmiGCXPokDZfOxIE1agKebyzFeaQcFag5JSfHOeh2n+hSC1YIfx13CZo CC8U1NtTYRTD20DvIrY+E8EUx/ScfcycXNWCiPMvWultddBj4mbfwPI9hiP0JX5GoDky dYHg== X-Gm-Message-State: AJIora8JLkuCsY5+C4HJZZVoHugityQeXTF73ogdk9A/3rBDro8zcY9o gDFxs7WEzdP7YOXBuCHqDLmzZ6MacWYE9SPa X-Received: by 2002:a17:902:ea09:b0:16b:a264:381f with SMTP id s9-20020a170902ea0900b0016ba264381fmr4256745plg.150.1657295239294; Fri, 08 Jul 2022 08:47:19 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 04/29] Adjust tracefile open for write Date: Fri, 8 Jul 2022 21:16:35 +0530 Message-Id: <20220708154700.18682-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/risu.c b/risu.c index 2f6a677..819b786 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 Fri Jul 8 15:46:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588553 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp783357mab; Fri, 8 Jul 2022 08:54:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s6RbdSrvbsIqI3X1tSicGLgjtLAXTZK/KWIlteLPJmqWJ056BNLWw8Zr5OBj6xqSPwmIuL X-Received: by 2002:ac8:4e4e:0:b0:31d:49ca:1935 with SMTP id e14-20020ac84e4e000000b0031d49ca1935mr3490879qtw.258.1657295667397; Fri, 08 Jul 2022 08:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657295667; cv=none; d=google.com; s=arc-20160816; b=hXcU+MK/qpWBwuBRmDdj5TsB3Ybd0N7c+CzReLwCAYzhLSfsUz72Sw3fFQBcrcA8r9 h3I9ytfO5Uza/Hlt0z1zKebD791Knr4s9CqIX9M+Mb1aHJ+sKLQvJKIyIQIDmrBBAqER 3D9vbI4Ai7iK1d5NBMbvfb95zkRYejH3ppv9uZ/+wZB5Vd87PN7JG2vqz1jNIMHZKlf7 hbKfmvTekgAMDojVWeC3nBHUzHfC9KUyLyM2TV1bnbgKMbt0263U0hRmvz3tqggqXSYo bFiEBi2/aid3oaxqjvPSsUA9EJiVkwVIrcg4OgTehZgJjDRReWM3+WRSgi+3LyhjDq2Y vKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=FL72vkFvgwgvsAn8p5rzjDKtjVBK69qL0lGF/pFqJgo=; b=txwYj6ztfLSXYzqFrhWG+RG9qN5htQQrJMoAiJrSkbcViy0A6SKxW5Xqf2Op8pQtaK kAf+cNoAYmyHHMuyA5XjVJ6o52lPbpfzdshqjzoJcv0WdValTxUSUe+cO/stKMX9UXB4 FuLILagMPLbubwkJ0zbfh8i6y3nwK7G5oJoiudZ3Uv312znwCZL5hfskwX8/phAdw/YO eU0mV6za1YhldhgBpnBK2E3X1TMtgNzYkmV9P/z2VhPKCL36oOpvGHo3viClDc4ATjtG Vtpuq/HMXXDULMBYh9mPZ7TOhRBJXYVXGj1BOEDMlW6FLgZsx9G+1x/PNhahM/pbaZzY iRfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=veVyr+8x; 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 ck10-20020a05622a230a00b0031ea826b3e9si829175qtb.509.2022.07.08.08.54.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 08:54:27 -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=veVyr+8x; 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]:36780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qJH-0000Ly-06 for patch@linaro.org; Fri, 08 Jul 2022 11:54:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCT-0004Wd-UU for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:26 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:39522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCR-0002RF-W9 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:25 -0400 Received: by mail-pj1-x102e.google.com with SMTP id v4-20020a17090abb8400b001ef966652a3so2310385pjr.4 for ; Fri, 08 Jul 2022 08:47:23 -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=FL72vkFvgwgvsAn8p5rzjDKtjVBK69qL0lGF/pFqJgo=; b=veVyr+8xjmrlWnpVTUg4LxeNFhQkz8OUr1tIvFsfkMaqoMXCynvRtcMDnEebrSPZrT tjyDpOWBUo+XUaOeqKnNAZ+cwn3GUkH0bwKc/ub/LQ0ap744NlvIQpyH5x4uVUoP9V3k egT9eNteTrxk9iDoK5rH3egujD+mP9zUtR6bCZNG3E23mh0VEbnKnOJd7B1vwoBDJGEN GuU3K0dlOblZRvatfZzrKaxGTGiFJ1iXuSfn5XaH07xAvM7VQNcvSLu7Hrl70RohxppZ 6NBkANZm4z62+jnV+0+lR/Loz5F0F8Ry0gyREu0L9VbjekCUIfhKKTe6lgZOMylS96YU bQLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FL72vkFvgwgvsAn8p5rzjDKtjVBK69qL0lGF/pFqJgo=; b=Tde04S9R901Eh13zhm4AJnTP+/+iLX53zwmgc005UBp/w0kR18p2fEv/FP1n568tcf ZjChDToZykrZ6Urm1ptWMkQLV/sNiLigYHFSTUA49fW1G4f1h07mj5GWEjBAjJPdMPQS ++KDlv0Z8islqMmxgSIbQu22GTYekICKJMDYtQkn2ij/qxewkpukEYPdNMeRd9l4ZcNQ axaDaUD+ZQcOvAqMzo1ONaZQ0+DGBHBwWSmrt7AxWx5Aq2WfB6Uk5sEziMDlQMFiLjQv zd1duoDWCfmllXWD9dYfux1mqjPRYWqO+AZj9mWuQkPfiLFKtOgRzRBEgKUwR2jPZvfX UzfQ== X-Gm-Message-State: AJIora/lkoc+L/34atbywRFgAkK5rEDqEH93TdvSd8gfA5FwqH4w+1Wa gVOrK5jF2yfIkZ2hphFLKCgg0rhu3oV9PKH7 X-Received: by 2002:a17:903:26d3:b0:16b:d80c:c068 with SMTP id jg19-20020a17090326d300b0016bd80cc068mr4311152plb.76.1657295242646; Fri, 08 Jul 2022 08:47:22 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 05/29] Use EXIT_FAILURE, EXIT_SUCCESS Date: Fri, 8 Jul 2022 21:16:36 +0530 Message-Id: <20220708154700.18682-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: Alex Bennée 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(-) 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 819b786..26dc116 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); @@ -390,7 +390,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 Fri Jul 8 15:46:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588565 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp809703mab; Fri, 8 Jul 2022 09:24:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7roMxXsciHU2P6/yjNMpPBBYqR+VSGFNGrxCikfjknyXTkrD2MrcAoOAfD48RapmrGHAl X-Received: by 2002:a05:6214:519b:b0:473:1c23:f871 with SMTP id kl27-20020a056214519b00b004731c23f871mr3487270qvb.28.1657297448975; Fri, 08 Jul 2022 09:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297448; cv=none; d=google.com; s=arc-20160816; b=UVNIbeB/BQXsO2OCKz64GkgA/ccNU83bHGCojT54+I9F+znemPVIL3Uo80WNfOyMYN UqInHVKKVjrPYOa6fPZx5S5abTdJmHby/4U2s4hdqaNNrUo8wTKjWp5FD3UCjjffozju +54I/pASxGaB54yUmTWqM8Sxdv40qTJUZsUhLqSVI8q/iz7oUHmazBC+L7a66ANMjtg7 JsUyQJZpUdGNgHvRXcTxJq41rhn14731zJmm75SgBE150E7sEDdjB9HmB3pOcdxgKeJO 6hqaOaD0+rpJ+8/dVurLpT+jwpfzyhG+ycLYFSStDf8R/D8ci2JT0xLN58j+fEFlRkti Fs9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=K0p7VBr3aZVoDI9pUwFSD+XBTDwjM0eTDqSKAizakb0=; b=N3V4R6d528iD6z3U2PJVSCXBb6UA3Y4w+nVulDC3yeQP08yud1wd5aAr5JuoMrm2y+ atKcd8IBXdWzuTgB1TBmrIoW+xQ4QmUqYxmLkE6nDzYw/gATWB5bTKLjdNLhEf890gBl x1MvtX22ubtIvx8zY/I9kUDDhs3dX8EJLjUnltFbtqjEemfPzuoBZrRcBzZnYl5IMzEo nAtAPq62dqbTlsqVnDXYzWjuaLP8raAQXPDbkMwJu8myaIncy742okqroefhc62HLxB/ w4l6WrhvCDz73eCq2XDWr/6xPLcUARXbftKRTQkOtyd5Wmblp+y4g9+54jhscKHYMQkW YHLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBZ9gPj0; 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 z22-20020a05620a261600b006af1307c9f9si21611330qko.164.2022.07.08.09.24.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:24:08 -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=tBZ9gPj0; 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]:43852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qm0-0002SY-IE for patch@linaro.org; Fri, 08 Jul 2022 12:24:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCW-0004bu-BE for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:28 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:44988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCU-0002Rb-Q1 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:28 -0400 Received: by mail-pj1-x102a.google.com with SMTP id o3-20020a17090a744300b001ef8f7f3dddso2145581pjk.3 for ; Fri, 08 Jul 2022 08:47:26 -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=K0p7VBr3aZVoDI9pUwFSD+XBTDwjM0eTDqSKAizakb0=; b=tBZ9gPj0DZBefJt/34Pl0I6eyKEqPtgKbpHB8j1hu/pI/eH8IeNpmxNIve/MA/i0v0 bZ6W36dIcwyZMj6iJb4Hss65t7DF9E8kPim71tWkEtBQdEkHkS/ZyTMHxXpuiofYGmRx GHyBTB4a1JSDNNUwJQYDVIunNQcPJxE1RrFWhNEXKYpJH2uh4CbLf9uYBfhXIu2EuDRo B/kZGFyv4gVxq318jo5jN9NKAL4WDYFMo6G6vjKc0B7K4TTMuNoGlBq8L0a5zeK6bxKw m0aOVb8TEq1ixaNeKhzgy3QfVenNYYyENp7AJMbhRQq9XxoOFv0a+2dUWIcnJxAZl5si xdWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K0p7VBr3aZVoDI9pUwFSD+XBTDwjM0eTDqSKAizakb0=; b=bKtclX8hKzFx3jNe8ZDmyswfNBxBKnbC29yG1IHMMav6PTo2DAMxxfZ7bIJU/ErlT1 93G/R5SGAuLWeMuqMnFtgsrNXeWY+oEkqt+5ti7zHYOHieHwdSm0ZEDBJgFV2WASj9Mj 9QM/NdKv4Zp1oifdyTtu0yD3PkQko0A09jAYWdrLN9Sy0LSzrT5erTskmf18p1FXaiRl resO4a4OZTusAxrK8ZpW8jamb/TqcJx8DVInbwdRs9hHSVGCwXkd6dBiX4rju/6elIPS GPNVr4prOgiq6XuR+h+30/gT83vkhLYrJBPkuxP2yMMDl8e+dv5LGijlvydRsX3vu4UG X9XA== X-Gm-Message-State: AJIora/NEfduxXux2sWM8kdx0juOdGvGqwIRM6N9lAWxxkBZeY41r4DM Zusa698YMvRzjuM1qHu44AzMx2Zdph9LpkBn X-Received: by 2002:a17:90b:4b49:b0:1ef:a03e:b671 with SMTP id mi9-20020a17090b4b4900b001efa03eb671mr525032pjb.108.1657295245521; Fri, 08 Jul 2022 08:47:25 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 06/29] Make some risu.c symbols static Date: Fri, 8 Jul 2022 21:16:37 +0530 Message-Id: <20220708154700.18682-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These are unused in other translation units. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/risu.c b/risu.c index 26dc116..ab17c71 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 Fri Jul 8 15:46:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588570 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp814753mab; Fri, 8 Jul 2022 09:30:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veffaFvM7jCyc6rSHL2HcUiMIB+5CfkwosakgunVIXph11LRWO4OcN4yJkUOOiHApwsE7J X-Received: by 2002:ac8:5e0a:0:b0:31b:f15f:76b with SMTP id h10-20020ac85e0a000000b0031bf15f076bmr3725229qtx.502.1657297819322; Fri, 08 Jul 2022 09:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297819; cv=none; d=google.com; s=arc-20160816; b=clM/luxrGuixGke9XlIo3h+HTFgiTjhOJPqlMdtkSxaZgnwNPZEZKphVR706Mv1eK2 7+mtMBVTudN0w9IoN4XQV6WxXodVXiLNiBMWEMt/MmGz2wKa2icvZmuY6MQaq/TtmWoa s2x5dgHlE0HXTW2JOlTw/XV3LvvmI22KwGFDlmqbtA0uSQCYVgPKbt+nu1A1vIzdBczo vWIvUeRVDFLla+07yx7ZrxTrjlOrarcmnryrgrgZImqZ80lRmAryBzi2jb7oCG249RIo mJYoNAkDDcOOPDzDCjKji4+Cv2Uny4Vi7KsWcCohr2EyOGo4Qd2REoktGugYJP0HCCi0 Dogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=q073Mp4VcMDO3I3Vy8AI4TpHUeDs1rzP3KM+D2Dojc0=; b=SYNMi8fTMqh+rDwmEWEFYp40L3BNPXbgF81o53DS0AwoPjOYBMVzQG9RwkELWkhPeu mVvi7zQMww5XreBMcSu7Pja4x7hl2skirXwypVVRYh4/HX2Z0cct8idZ5FTOQ7w/SFk6 tZVpp1/rI7oRzVxPYpc+kdG+S+ymZxEcRupzJAjr9hHP7bppZjthYth/fOas2f9MZpfk 6AoQ/j3cxHnGPflR2Ww94XJbMj10CV+JwGNcwAM+5OtwCTwUvYBrqnt8pqanDWI3Eayj 0l0WF2WU9xqmChuDap11YjX+Q5yPnaDTUGZi9TbPbxQhcnyAwycjzZwRafrpPQV4KSvM x3Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fgKbjynV; 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 d17-20020a05620a241100b006af6ce5a7a8si25894175qkn.374.2022.07.08.09.30.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:30: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=fgKbjynV; 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]:59376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qrt-0005aB-Ul for patch@linaro.org; Fri, 08 Jul 2022 12:30:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCa-0004qJ-8i for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:32 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:33291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCY-0002Rz-8x for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:31 -0400 Received: by mail-pf1-x42f.google.com with SMTP id n12so23903068pfq.0 for ; Fri, 08 Jul 2022 08:47:29 -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=q073Mp4VcMDO3I3Vy8AI4TpHUeDs1rzP3KM+D2Dojc0=; b=fgKbjynVbMpZLRFnegJPE3DU229xWRdL/RcAZA3xZHUUrpy9bIyhxsExtYz95Wty6V k1wQXM40TezwxDwBleIGmj1IMqDUuz76zAviOLhY0mMyo4N5g+wtpNh7wxhho216Vodu b5hIW7HNDWvTiEg7rGBCdWEJIVF6hFVUamJNvawstYqUvpCaf3Cm0PHEvdmzGBDSck8E xFJZHtuRHToCEu1BK7PFgnUn49D8t0WaiKd87+I+jmJMHuy8KgVrRx9IhiwHvkxR6q9y P4Q400tSpzUJNw9mvZJCkVoKry1/Yhs+TZ6+Sx5Dmu8xRVzgzShP3EYP7HORZ4Ohr9Us uiAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q073Mp4VcMDO3I3Vy8AI4TpHUeDs1rzP3KM+D2Dojc0=; b=OwsNQ+ARx91AVu+p4FWcbx1rLTWV+NGURQ06vlI/tM+X/srEy0F4oiWFEJTJ8VSlK0 R5uwZMsjXWunW69nB5VYj5E6+gSYFrZOtcy+4fU64s7IlAnfKrRcUwZWtuJEixxYnuqt PSPPRZuPgSmYviV47JYxbXcdvZ8mIonzA8OOWho+4ENUinpMcfwoWJ5NkAU3K47MDVBa lAZOOpbclr1gYcM87lE84DX9UPeva9MZ1g9Lr8sNf0wkiE5blmRQzkoPTjEB2LVb4Odp Zo5KAAzLrKFNWMcwVVRxZcVLpo/w3anmZyYo1uWjMHwMbhw6djPwOKRA9Qiyb7sHLnlg 2VhA== X-Gm-Message-State: AJIora/caY20iDATAjL2Lp5hSDcnq0UZ9iatmPDl0EcpYQTe0VMf1bQg C47xYIG1g03HxcQGw7+LYnaOYQyBFulzahR+ X-Received: by 2002:a63:e658:0:b0:40d:dfde:89f7 with SMTP id p24-20020a63e658000000b0040ddfde89f7mr3857658pgj.178.1657295248857; Fri, 08 Jul 2022 08:47:28 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 07/29] Add enum RisuOp Date: Fri, 8 Jul 2022 21:16:38 +0530 Message-Id: <20220708154700.18682-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Formalize the set of defines, plus -1, into an enum. Reviewed-by: Alex Bennée 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(-) 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 Fri Jul 8 15:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588566 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp812409mab; Fri, 8 Jul 2022 09:27:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sopfgYgpAUJ8f0cSMZQEyB3xtCDq5cv5nuRK9fwLDTQCP+7AZ9byw9hY/3q/uOW1B1yxOe X-Received: by 2002:a05:622a:11cf:b0:31d:3d5e:6309 with SMTP id n15-20020a05622a11cf00b0031d3d5e6309mr3855145qtk.625.1657297632538; Fri, 08 Jul 2022 09:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297632; cv=none; d=google.com; s=arc-20160816; b=CV3AvCC+jzFEUWxAhzRuqOFqjC8ZpeBFfLtPiY0G/fcHSLT6DYUllHAcZfDLLLa1g1 CYJb9SHpiLkO+rCXdqAyRfJAMBdHw5TUtFYOwf/gND9HwQgrAel4ijglNoBym8WzWliv TwtS1pufzn6TJUgmFHEfn1CfjIQV2WC99fWUX/BBu8x0fV0zXbgM+3tFeN10C72kvABl k4QDaNXypbBAeKs9XqOzks1wps7iKged3C0xb78m8XErmNLPqVJJ9q+Eh5pc8V8yrPfk U7hdVHDoO2WncdEUEpwkfoOpsU32sm9QRiERdy32ZCdVEe1vdFZzI0B4hNvLfvzKIn5B iZgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=qhmfc0Bs2SrTe50tDkhCkofVbawYB7l8nD2/4Z7gVmI=; b=Dr2X6G0x703N1Wy5xWGh0aS4rdlVC3WtyHQ7uZzjx4HsVkB3CH/60uYGH2ufSiK1u2 BTfE9zOySJCa0T1PcLwqdBvQnl0KF20oQsl+kCjaV0pn/s6xhXhZLkyWXS2W/7Ih6Zu9 iwO+SQaB+6hTR1pN0q3C8kzT8YhAMDlXUpvLf5cRwsOBweUI/4hzqJx7rSwweRRYhNUr zO9/HzV/HCusMhYEtJkLXgNwnd+Rh679AW1DM+bgGLbjIKu7o4rqaHxYrzL8eYi8bxJo ihGUkFmLiEWMnhXdyIpCs33LLyQr8IK0YpxTOnapvm0355dXj2/Ae9peV4fSrJKAIhAa VL/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YwwW7u5u; 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 r9-20020a0562140c4900b004703dc4034asi23558266qvj.297.2022.07.08.09.27.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:27: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=YwwW7u5u; 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]:51220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qoy-0007hi-4x for patch@linaro.org; Fri, 08 Jul 2022 12:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCe-000562-Dj for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:36 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:44988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCb-0002Rb-IV for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:35 -0400 Received: by mail-pj1-x102a.google.com with SMTP id o3-20020a17090a744300b001ef8f7f3dddso2145815pjk.3 for ; Fri, 08 Jul 2022 08:47:33 -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=qhmfc0Bs2SrTe50tDkhCkofVbawYB7l8nD2/4Z7gVmI=; b=YwwW7u5uJpkoRDfoxBb61fLnmcvQXo3pRZ/zsLICXNOG1rE6bYHit1n42QaaDpvasQ HU8g0JKMC0VjMwZ7UD3dE3tY/zFVnCPoCRbZztdiWsTkcSDSs0qp6a8dGpWyXxIjastl nDVdpwKfp1UNn4nBxvf+KeHUIV897DpEh3q4K1pXDJ/G+nwS5HuBCs3fsLjjx7cyBWtb O0F9tqo2lMrntmIJ+crr5dtlkf4oNMPY4r6tMUp8qLzPxHYQzvZ6cPTdXfAFR7qeKZOs 3Q5DVUyg23Tut7KQTxySjaiOR7M+7wZBfI/EtUUXb56QFOXtPomNrWuWPJy9eU5Hz2tP kheg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qhmfc0Bs2SrTe50tDkhCkofVbawYB7l8nD2/4Z7gVmI=; b=zD/qbk3m5T/S+KBWE9ZiNvambzfmTafPKP1ZCYCp9keDkrEYHvkd4/7iyBHxYQP0Bc nBUMWLKRmsMjja2eroJkMJ1w9JCgT52oqWB59FvdGZ9RX6gMP8DZ3syDFS9Trn0LkuPK UbnYlNZq7FzgJXb/6EjuXBskvHw3gJwQLyxuHAAaX8xFBwEGtiAUBTBNdhz1D9VqCJGS +xrvcUquxCQ8ITuUWlwc/6E3wcHAyHgvVSsooxqRsDQQ2+XAQYdfFQApW9GCeFt9q3fE Cj8gJhvweNhF9wd+TDGxBaoiSI+5Hu2hOZD6bDcYs7342DU7UflDAxVtalDYnw52erFO T3Yw== X-Gm-Message-State: AJIora+QPJM+Me1ACCKLImLvuGobJHpl8bCH60zNsfQV6ookAlE+5x67 bc+juDtqD5h8JIjoE/zr8ZHYzETXGj9si0rj X-Received: by 2002:a17:902:f650:b0:15f:3a10:a020 with SMTP id m16-20020a170902f65000b0015f3a10a020mr4182527plg.61.1657295252711; Fri, 08 Jul 2022 08:47:32 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 08/29] Add enum RisuResult Date: Fri, 8 Jul 2022 21:16:39 +0530 Message-Id: <20220708154700.18682-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.h | 25 +++++++++++++++++-------- reginfo.c | 32 ++++++++++++++++---------------- risu.c | 18 +++++++++--------- 3 files changed, 42 insertions(+), 33 deletions(-) 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 ab17c71..7b14f72 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 Fri Jul 8 15:46:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588571 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp815929mab; Fri, 8 Jul 2022 09:31:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhlso8nhqrca+Cs7JCCfwQoJFz8FHDHLsSi2SYz7apmmSfP0mPaNDAmN6njjPiM+AtgeQU X-Received: by 2002:a37:a142:0:b0:6b5:57d4:10df with SMTP id k63-20020a37a142000000b006b557d410dfmr2776200qke.765.1657297879914; Fri, 08 Jul 2022 09:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297879; cv=none; d=google.com; s=arc-20160816; b=P14crf7N+CO53xhh6jkOD/FqBrAJtUzDpHJzxOStExNqigVh6TJXnHiibRvp0rjtxC DGZNQoFKWx9s5Q/V1Jwyu4VggTdEWTVj7UpLBo3WfQeAW7Z9nvRAm2xLNdWxKEZUu1di nYrew7twbHtoRctfT/ulERsRQegIa7lSKTz87bv1261E0GhOKVmfNefM43kmBOHPIjGd npPeRYmodGRJeIAscYVMZ7a8llyWTZtrBw0WSAaZm5XcSm+zqgw7+4fGtyRqunAyDWy0 QD+vt37JPUenXwAOusXkYLYVVI2CxFYfgmWtsTIA/S69F6GtEvLCbEg+6YPjwiHsvhXU qX7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=yTx/5ruVCbUKysedstiOKE1WBZU/tfL0M/E004Rb0lk=; b=Ir8HMyB/d7LviNucgDL2Zm2xrMZYf7QcigrBWEL4t/Kk/SHpTRObRoo6JZNycuirEs gczpZBYOI/xGudsimRZOXLVXbUJzy0qtLsbzUgU9jpt5CacGwof3IFPiuCSrCuwKzYHg NOTdC6RHb5ZU7usuBXRIlh048aNpLjSym9Ath+z9AX3Xwop15yMyciIa5MbNMXEY499o Cwogf1+iBxS0sNu+X1aHTEEjtkqvbdlUT2/GvsCWclGb0GniIOTNOOrMeq6SbzBPcysL UOmC7dlwMewX8GnsMPhQ85gBqKJxjlWaFE+A8ZgIm1Uk3SZ3DH2RizFg9wv2m/bO4T6U 1zPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kEKcNuIs; 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 w7-20020a05620a444700b006b56d053937si564537qkp.749.2022.07.08.09.31.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:31: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=kEKcNuIs; 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]:60894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qsx-0006hz-Ep for patch@linaro.org; Fri, 08 Jul 2022 12:31:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCm-0005EQ-Fr for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:44 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:45960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCi-0002TL-Gn for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:43 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d5so16627671plo.12 for ; Fri, 08 Jul 2022 08:47:38 -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=yTx/5ruVCbUKysedstiOKE1WBZU/tfL0M/E004Rb0lk=; b=kEKcNuIsGd3ymiSL+f9wvpBfp3Rzpjkp1pmTYO239PYmADKcEgwCswQIT2RVKdHWur 6PG4gLqgeeG5Vz/2V5odC2taOyYBwBRptB/5gWLX7GrbLYqhSxDtqKdRaydYYWpIJ2ap K0MQhKIwhVgoqCe/PpsS8E9RKPVnVggw94Od+c/ylKHRw6nieXItXQc/TMdr8T5h+tNQ elONXWwVj0f6/N2S38Mx8TacF3IWgRImGdAGlRtWbyNFxtfCaDtupVnXt2AfMr/H5MCT P/Z0CN6I7CFDNXN0FqEhqax/Xdn7TZd8QcdplucZU0gnPlgD983qffbIJQuMaRcjmbM4 K9Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yTx/5ruVCbUKysedstiOKE1WBZU/tfL0M/E004Rb0lk=; b=08bWTRWgfPLs38jnKuu+bkt0wOZuG3ZjxvvyLOQtdWpDQh8nnUlf0KSd4HuCoaqJt/ OVI2bgcSpzLqFX2sUv2KFUImnc5g3LyHytdWn1o2h81F6SRRt18J/GMPzQ4n7oGJvLRn IAUMFQaGWRE6gCDnq5BeWnXe4eQTZMb3jaXlh9aYOZaquhIl7qI+stHZ1zJlMuuFgYNb DecYBM+oe3fwLWJr6KI4SWnZrG8mE48IDgqc1FfycCPz6lH0atuJT4yiAWs582M+zmgj Wv8cAfWHp6pxywsYD2vNuP7YLrbO/Q83lGgDMt/w8k893Qyun4GEsSCk0TV48P6d2jl5 OMEQ== X-Gm-Message-State: AJIora/4m5eRYJ758xKXwiiuhhUZU8p0yzl+iDQUfQwNSAHidu3X9lLr 1vOP9qLyOkSzQtwun3mWTiZnrlgfIwmbMQgN X-Received: by 2002:a17:90a:f692:b0:1ef:9ad9:7e94 with SMTP id cl18-20020a17090af69200b001ef9ad97e94mr519048pjb.148.1657295257467; Fri, 08 Jul 2022 08:47:37 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 09/29] Unify i/o functions and use RisuResult Date: Fri, 8 Jul 2022 21:16:40 +0530 Message-Id: <20220708154700.18682-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.h | 32 +++++++++------------- comms.c | 8 +++--- reginfo.c | 60 ++++++++++++++++++++-------------------- risu.c | 82 ++++++++++++++++++++++--------------------------------- 4 files changed, 81 insertions(+), 101 deletions(-) diff --git a/risu.h b/risu.h index e6d07eb..c83b803 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,31 +73,32 @@ 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. - * - * We pass the helper function to send_register_info and - * 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); +/* Function prototypes for read/write helper functions. */ +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 7b14f72..1917311 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 Fri Jul 8 15:46:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588569 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp813990mab; Fri, 8 Jul 2022 09:29:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sIWbYDxApKKgFD0adVknpqQv2hFBiWKntCbg6KbFh/BgoOtIoe4MS2+TDNjvoML6mmv7tW X-Received: by 2002:a05:620a:101c:b0:6b4:8cb4:6b5a with SMTP id z28-20020a05620a101c00b006b48cb46b5amr2881994qkj.28.1657297764991; Fri, 08 Jul 2022 09:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297764; cv=none; d=google.com; s=arc-20160816; b=qH+u05WsoNfkjEQWWRcR/Fmrprh3r7Ilf5hl6IkAFG2d+6OE3809Uqnxk7+GjS7SiQ 8FYQ1YsIPOm4b3wZI9HckLsU4g0+yj7tKhUmmaF+QAkIzPXK1bXhFHl6L31LKJow0qoo YvJ/50hKmCiODj/RDlsQpwp3H4UFhJL5FFbdUwREBqN0zEpOAB1iXNbhrQNsi8Ea6nHq /rfsCuxvkg7436WRZva8FhRbLluCam7XMxLeZhs+enmGihCtjGcdmAPIYWmMcb+Ol4qj gPP+FZDqYvSmMX6MwGAQDWZrjGAMCc+drYKNESe4LRb570Sd2GT5mHxeSA9JuLNDMb42 QQJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=ZlB23Fd4G5DghSJ6Ko6JaiFeI6h2RDPKt6G6Hp0Fq+M=; b=x/5UyImUNZM8S6ARZBzq8MzWV9l/6SnK3EwzVgVRhy7P2K1r1xloveGagksLzw2ne2 NZeApTwyoH7et49+NP/B1pQgZAYG006mtCwJD4NinLRPIGCLl3oOXYIbgjTSpcv+oiky LgaGZLheQUflwUTIl3cmoUzNtfqMMwoztyEBOC9o5HWhjP9vKpnW8ZmHY+XzZnzod74U L1opMpEQcMyhGhTifYP0DJyMGL60TIJXxdTqQ7azpgG/FfREIUbyoIpzZnq6nq///Udg zWk4cBogt0FoGckufWrVNlCwx2ukOp/5LJf34YTtTvw/LST5trknq5s5BitHHk5Hstz8 qk9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IjxlJlRC; 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 t21-20020a05620a451500b006b25f42a306si17561561qkp.467.2022.07.08.09.29.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:29: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=IjxlJlRC; 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]:57682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qr6-0004Nb-JQ for patch@linaro.org; Fri, 08 Jul 2022 12:29:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCn-0005GZ-2l for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:45 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:41806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCj-0002TW-Mw for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:44 -0400 Received: by mail-pl1-x636.google.com with SMTP id j12so9874419plj.8 for ; Fri, 08 Jul 2022 08:47:41 -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=ZlB23Fd4G5DghSJ6Ko6JaiFeI6h2RDPKt6G6Hp0Fq+M=; b=IjxlJlRCDRhD8hxXxc8hPtfWuV+wWnz6N8Z/z74To6ZzYZyUhUjhSoi4NP+eSn/m6Q egPgXub7dZuVz/t8hQV8ANRwS5rm2/cGZA4QAza4S1owrv87PNtEgcRrI5BI1023Y+DC /SRRnHhHW2pBIt+G8DhIJz0xQPxhtAjvfXGo4Cmd4s66aM84R/dZDKqbrskPUOkBEsVe +LAiy/Pr2iYRIvyPtqTrtQMYRzADORex23Oe9CNzUN3zLPP7syKCdiZ3HUiL3c8NbOGl W8aAJYE78aAT4zBsXRDMZEhM9+zYfLTKuB23tYOMu8HREynGWJNROHo9EX3H5KWEcrhS 2qPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZlB23Fd4G5DghSJ6Ko6JaiFeI6h2RDPKt6G6Hp0Fq+M=; b=AmqgppjgAm2KSKOpo3vhGSRAn9oPsLRwV68LtEYSaO+ZiD52A/PLQGxrrVYBtJ7oLw zgqbZ4GrhGPhXGor1dFwQA2MIwbgqvUkj2v5JpqIqgrmmJWyPqczrb3k1945nN+wZCIC hvo0QUjVn3bHdxK7VK49/MXfNwiUImxCzZxnJmmu4cRZniYVRm/aIXewGwzbbnYkRqQu KHftEpPzIUP/S/HwPpSsz5rOvaWpQucpJMzQUEbJ4XnXQMTasr3kxrhgwThURBNJaXY7 4Ym21HlU88Q7kNqivu2gkIgvHYo2bOr6zvsmwASZlYkZ+Eh/Oq2ijI0u52NjF5SNJgc8 HytA== X-Gm-Message-State: AJIora/DzIAXPwNlo6PD66dLtKp3LsYJ1Hdgtwmhg3h+37g7JE3uVd3W iyfP5WZBA2lDC3XUqHC4JGxwZualO9a4ddJV X-Received: by 2002:a17:90a:b701:b0:1e8:6d19:bcb with SMTP id l1-20020a17090ab70100b001e86d190bcbmr496093pjr.218.1657295260291; Fri, 08 Jul 2022 08:47:40 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 10/29] Pass non-OK result back through siglongjmp Date: Fri, 8 Jul 2022 21:16:41 +0530 Message-Id: <20220708154700.18682-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/risu.c b/risu.c index 1917311..f238117 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 Fri Jul 8 15:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588574 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp819227mab; Fri, 8 Jul 2022 09:35:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCrLoD2kQe1Oj4u7cWY6dBo81E3RkMiLx9ay3qRPJlWjuiMvLyScb1JWn3UL8zVLs1yb9x X-Received: by 2002:a05:622a:448:b0:31d:3e0d:4527 with SMTP id o8-20020a05622a044800b0031d3e0d4527mr3855651qtx.354.1657298126671; Fri, 08 Jul 2022 09:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298126; cv=none; d=google.com; s=arc-20160816; b=CV9GAaxnaifvKa+Yuy1rJK9UOfX79mSY38rEt6vtbu8HkuoWCgCsWxSjdAF4N32u26 GISpHhGOJmxcs34fLltHqrmj8wrUTBKcqhX8Dg4t77nnqzldf7pJFLG2PgHzoqe+TzYV Nafm6ACsIQysGEpY1cf8pvOOcrm/9MiLTQ98xFehc2UjfIEwpknGICjgZVbDwgECTTZC wT/487RjPngIdeZJAGkr91kSMUHQSNVJZRDFTp0bS3D490MUZ7xie8WtNZx+I1d8899h zGl/DjwLya9vYuUeuXco7A8Oo8TwUTG1XidxEMQs7gzJATXsmOgvpfcIySFbb3kQp42t vu3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=JF+lOPliqQPvdxG0ISzOEougk8wObZ8ufYNLrAEw48c=; b=w2FIU69kUtAphcpjELJu6EUr1y6yqNVf3/X2wYayjUqbJveYLMw42cNWgfoc1Hmbhf SUkv9QBUcfcSqSJMbrHwvSwF5Ju+JnbGTHIhPSfbhuddh/LR2xNcPv/g6VQeRaX+emXy vbaoxbDDlYOamCo26zUykLhB9LbnSaegKnkZtJ2hq9vvdIZWUcS2C8C3jkJ04hyB/B3M ug4fmIy+XKRKWvzK0UZ2QFGKr5+BkPRdvJ5PG+oG4gxZ/qKqq26Iq+RVH4Y92HpDotwj krHhS967yKZho7nw+FBvtFYYLK9BArqX1W2aisIQYP2WYTh3c0cdYQ537IdzQnTEu+0q Bt4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J1T1cDM1; 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 j14-20020a05620a410e00b006b281940d6bsi14690180qko.475.2022.07.08.09.35.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:35:26 -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=J1T1cDM1; 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]:41926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qww-00053W-6v for patch@linaro.org; Fri, 08 Jul 2022 12:35:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD0-0005m9-6A for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:58 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:38442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCm-0002Tp-W7 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:57 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so2311625pjo.3 for ; Fri, 08 Jul 2022 08:47:44 -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=JF+lOPliqQPvdxG0ISzOEougk8wObZ8ufYNLrAEw48c=; b=J1T1cDM1E86OfZ4vUIrR0CWJwSqtz1cezRr9rDc+GpVcAwjuKqQdTxZPk16tn8HIfH y+/5IW2TJXMUdn2eDTraPAhy1Se1iW23x9VdAdlO7t/VfVZ3IDGpyzAs/HZkY68ldMzb 9Vvn69gi3O04jjL+PpRf7EzYbRBxyRf99DuG8DwnUBKiHMpCGCcYLQD8xldCUeGkhlUo r6amPaS1TeFb8NmBfVnLn3yGfSATLMBYp5NzDwc/q6eslel6u2VnDAABu16KVmBIboS1 NZ9PV1Ai427DfeSIrajBLH8p4aWaX+6L2Zpv1m1D/gzKst6Xf8jNvElZ3f/6XptnUheX odEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JF+lOPliqQPvdxG0ISzOEougk8wObZ8ufYNLrAEw48c=; b=aKBPqHqO/SSZ2GdsA8CvUf694KrIa4XXqafArYwKQGZdNn427GpmM8s4WtuK+v0WHk DqHXBOaJ32pKkFvadyiCoKzJ5KkQdfKtJGRqX083J/wFbz28PVUm2hH3WwB7Q7rdawOj GKe3PaPCcEeaggAkimDhYzVyQKwQjIfgMi7esXEBBWAInCEr9IZntwIGQbZlx267eTNj AGg5RscDMaWKYTd3nLaz6HWSLN9t7amc2H3HGv41Ako8xfJX7TL6akuq5/y7gTNoLH4T tAMkgiOdyATxS0Jem+iCJW9azWClCkGLFP9sqFDK7gH3EZTQWWgpV6vEsb/ACXocRCoK Rf7A== X-Gm-Message-State: AJIora+Oon/uTY4BAlLY7fzZj68YX2pNeeOyMuuExOrNsG1DD1LWdXkV 7qvwYygqJVpCqmnvcWDempGnsHsvkDfCZ+gu X-Received: by 2002:a17:902:e751:b0:16c:19fd:5428 with SMTP id p17-20020a170902e75100b0016c19fd5428mr4388026plf.48.1657295263520; Fri, 08 Jul 2022 08:47:43 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 11/29] Always write for --master Date: Fri, 8 Jul 2022 21:16:42 +0530 Message-Id: <20220708154700.18682-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.h | 2 +- reginfo.c | 38 ++++++++-------------- risu.c | 96 ++++++++++++++++++++++++++----------------------------- 3 files changed, 61 insertions(+), 75 deletions(-) diff --git a/risu.h b/risu.h index c83b803..f383b64 100644 --- a/risu.h +++ b/risu.h @@ -106,7 +106,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 f238117..199f697 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 Fri Jul 8 15:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588573 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp818135mab; Fri, 8 Jul 2022 09:33:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utvHqhzaJ417eXnVky5RjeFcMBOj4IOjn5g9rtWnHHuRJzGnvTxiOdsR+YPUqttp3dHa/I X-Received: by 2002:ad4:5c62:0:b0:473:4585:292f with SMTP id i2-20020ad45c62000000b004734585292fmr1989734qvh.16.1657298037225; Fri, 08 Jul 2022 09:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298037; cv=none; d=google.com; s=arc-20160816; b=KJE/xAiQvHg/cPH4UdmZnWnNGgGzxITEeoLerzkXcXByHkNaVSHjshYfHugcMhVBVf wuOTtPHy+xvN3COd280MBaCneTGM2ipVNbbIIL0HIJYG2orMhoANRByoseEM4OZHGdDS d8WvaDr4COd4+5TrmFTroqFZZAgWbhICShBFRuyiqQL04zzruDm/kuENT2tW4u+rlwmk sMcppxkxT98YjSbPP9hNWk/eD1ZtB7Ed7Gbtgv7zxL96GLSeGl1aox+XNWRm5jvJGd8U XRlOjJgoCHYg2WVzJEgbArHG3YHMAwF5mR1bhtub/CdDSLZAF1m00OJeAe0AvBKQED0U gZLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=9LHt//Kp5lBRa8NZxlYvTpSA0XqF6ZFwISz/AY+ddgg=; b=qz91pu8sY7GtSEoyu2hUE8JeT7dlWkzhZdjDGBz2HWOZGOHiqj5iB64/6R0xryZ+tZ IPGgz5cEeovGYxbg0Df6b+EcsckEgIR1yokuyOVcrp45jqSRW8/qR3IS2arDjIH0q5D4 z+Rns6pBKnzfq8j6U5kvtX6A4dKVU5UWc6OFUMGsmtqBwpPpzVofJC2kJe+fGzLZgfpA +rTm6Oij6RN0dj1Yc5Ka7sH1C+O8dtowuBuA0TVQ0r64l5cS9ZveU/esddMO5NP55MfX L+RSokViKEknz2ounJRrQgMOqtL0OkJElbzT/4YKEfwAgTgzR0FxgiZuoxt1p9cqY2yK 78Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a+kDYS9+; 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 q24-20020ac84118000000b0031777be5aecsi23800555qtl.473.2022.07.08.09.33.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:33:57 -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=a+kDYS9+; 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]:38684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qvU-0002kP-Ql for patch@linaro.org; Fri, 08 Jul 2022 12:33:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCr-0005Nr-Np for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:49 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:54194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCp-0002UX-Mo for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:49 -0400 Received: by mail-pj1-x1033.google.com with SMTP id ju17so13255705pjb.3 for ; Fri, 08 Jul 2022 08:47:47 -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=9LHt//Kp5lBRa8NZxlYvTpSA0XqF6ZFwISz/AY+ddgg=; b=a+kDYS9+DDHnlujQ7FveWMcc1yZAsL2DMiepCLOj9kTLof9Fswmv4XC1B8lbk9k2Ag R3ycjYLibZttVRN/ZePK4C54n9w70W7XHhGqMtf9IqY9eniBI6ZHgN7nF5YKhzlpZOsZ HFG/w6xyplbq9ZmzDHgciliaRw5Z94u+nr0WMuZVjHtOllIN1cAwE/Fbg6qEXc4JY6EG wJ5vdw+9M26p+2askJ4dhzQT43dbE95yyP3kLmR3WbsVwkymLja5ABtDDoUMOzdLAvxJ Axk4dxITK2xUrLYEtl9pC328plrYaDrkxglrUPuzmnPlkXmyZcBeDJxsPXUnGyDM+Q7f CEQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9LHt//Kp5lBRa8NZxlYvTpSA0XqF6ZFwISz/AY+ddgg=; b=DfPdbf0FPzN0lfL26Ymwe35OzCjvQnNdYia3bS6atNWhu3NWIr3GC0q5bP6UoI6q0m 1gwwsRn93rXb9qucLyhNHG8+NyqUvmRSqUy2vRO6gREobAJUCZ8O8ME+ZgzSWPQRIz2g 3r2jETlH/AYjfa2en0Qu24amWr7OR3nV5pb9YG5taW3mHZknDmLSft5KCU9z8KlZudqm qzi+SnbOQxd710WH5gEfd4EXgAAwugUjbPFZg1ht3CM1iQiEmSf30tLhiMC7EqI1A8w7 xlvza4JOWy2dKBfgnJ6PNt3QCXONvfz1NkZozv09P1rrIGUBc8Mg1OfWyKfV+87xxJco /uqg== X-Gm-Message-State: AJIora/7FLPW9DEX/vFmhFOSrl8LT5S1A1Jq1jH4ZAzryvhD4ocuw8nh ec30+PYAViL/MVIKhzj8iRXu8rdx0yVpUHbt X-Received: by 2002:a17:903:2445:b0:16a:32da:cc9 with SMTP id l5-20020a170903244500b0016a32da0cc9mr4237591pls.148.1657295266402; Fri, 08 Jul 2022 08:47:46 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 12/29] Simplify syncing with master Date: Fri, 8 Jul 2022 21:16:43 +0530 Message-Id: <20220708154700.18682-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- reginfo.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 Fri Jul 8 15:46:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588572 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp817174mab; Fri, 8 Jul 2022 09:32:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vnBsGjUegb+dRD/ACYTwhz1LJutpgad9MkPSrDFMsg968dJcY4je539BD7ENX6uiv6s6M2 X-Received: by 2002:a05:622a:451:b0:31b:f69e:15c1 with SMTP id o17-20020a05622a045100b0031bf69e15c1mr3817306qtx.3.1657297969302; Fri, 08 Jul 2022 09:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297969; cv=none; d=google.com; s=arc-20160816; b=NwdNKAK8sWeKjx5siyVm+aSyqvu+woi/Ld2YbIqh2mWfHNM8U0ILv7QbP1zjEDhSkr FCB/HbTyDsRzegT3Yx7Mq1PY/vAE/TItxmRSFhkkmGl2XOp3iqxxaqNgzbu4Wvo51fh3 DneO5onH9efI/a3A7wwaMl4EAIs+XKePVHUP+GVEWFI9/Rm12EGHE9SNsctyYv4B94m9 FYwapKDin84Skj9qz4WQvERCtnRBlhYMn5AG/a2CMhwMXbo9GdR3Dw2WqK95mGlokFsa bZ27QPS5N0pOP8Fb1r6fRrj14GqIm1Fq9UjbWKYykpDCJ5wOwt+fRgPxmeBZMZ1FxZCW 7v9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Pvi9qlovHhKpDCenz2S7UQUGmj2q8e/6gUB6XkPNY2s=; b=iYdnpl7hgEnVRUz79Uw4QaLRtgoAEPMXSHPoKLozOD4TskcqB/Ar/1bFmXLWMko551 KdU95nJtJL/gJZl8ocbL6qsdS8D/AnzytzPBniAbOPSdI71+Zsrk9QHBSM6CFG+UeIS7 ip5ODRQUrvJs4+o+x54T4Rtd2gBeVFA/sUdDL4UV/zAT+X5DxQPT3l06yvxeeZe5y3sJ W48MDB5kBQg97Tnb7RFFUqMnWIVz7DLMm7+3w29qu0HLDvlUTLDdQxq736f2xr/S0ttZ wbmG1zFDf5jqrU1hPwcsHa/EDS5vIoI6FIFgSJYYcUBHz2XB1CgIcbkhmjb1YT+0Dxj7 LaeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XQ7ca/Ye"; 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 fq7-20020a056214258700b004730bde8494si7172529qvb.81.2022.07.08.09.32.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:32:49 -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="XQ7ca/Ye"; 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]:36622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9quO-0001GI-Rc for patch@linaro.org; Fri, 08 Jul 2022 12:32:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCv-0005TF-0z for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:53 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:37643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCs-0002Ux-M8 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:52 -0400 Received: by mail-pl1-x630.google.com with SMTP id f11so4115099plr.4 for ; Fri, 08 Jul 2022 08:47:50 -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=Pvi9qlovHhKpDCenz2S7UQUGmj2q8e/6gUB6XkPNY2s=; b=XQ7ca/YeFeNHGK2uvPtpJUOFlHRPUvGDHCiH6WRQaz6VsRUZePHP1ruXD6QrLs5JHM S48cFs0MWP0iMA3t7F+PbL9elu9Pl2TTgIFwbnOx0jC7s4QxkloARw67cwhek8/CWETg 9Wy/6jlhnVr86TdIKAdqyZ1AuXjh2tYYc1ETtuKKH6tncAIe3msmrGJpWzpa2wCaKp0z BqlkNhoX4IQHirJOIp5AlvGWKOLLvP8ux8MfkylCyYfkthoM7FLimHXt0ztv1CYZ9TVf iNEt/OEbrc3bNU91wSWjWPSc1VFMR31N2fGeDh0kmj+dJN/kbtz/86hLyGbnAbitIJ+q xvZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pvi9qlovHhKpDCenz2S7UQUGmj2q8e/6gUB6XkPNY2s=; b=yBc99TFJHLw7vWPHbFt9SJCl1NjWgIsbcmT+UA03wcGWVn6hF461Ww3JzGswzrc13O mTZfm3PKraz6UxOF7oK/6Vd9t8+FSPESm5hyKIPTh6x6okV6eP66/PNoEbPiP3NpvTYO hcRptWrO+a7kQZVykZJIkDoaUSS9SsXdNTMWY/KjHMHL6PuowXr5wqhkDOJf0ha665lb cTJQpGfsuv8uftuTCUVi1C14S1qJMFILHnmdVR9cHg/8vYm1TYl+zjUToJD7l6IWHDoW vKelQJjc8b+DdRJCvEWj8nfbgd23/76mcYoTq7j2wKgNCIZza1Ta3yErmyufWKVT631U 6Mow== X-Gm-Message-State: AJIora/PxX5sHNCgVpnc75ZOPpr18ug/fCNL5tBzQowXx/2NYOUeaFPe CsbDgVcG+dSQrwwNLcCB9PBZvVG6jzTik0v8 X-Received: by 2002:a17:902:a502:b0:15e:c251:b769 with SMTP id s2-20020a170902a50200b0015ec251b769mr4384608plq.115.1657295269405; Fri, 08 Jul 2022 08:47:49 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RISU PATCH v4 13/29] Split RES_MISMATCH for registers and memory Date: Fri, 8 Jul 2022 21:16:44 +0530 Message-Id: <20220708154700.18682-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-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-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.h | 13 ++++++------- reginfo.c | 45 ++++++++------------------------------------- risu.c | 10 +++++++--- 3 files changed, 21 insertions(+), 47 deletions(-) diff --git a/risu.h b/risu.h index f383b64..77d6128 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; @@ -100,13 +101,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 199f697..d6c2deb 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 Fri Jul 8 15:46:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588556 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp786939mab; Fri, 8 Jul 2022 08:59:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJ0yVpYDf2C+YdDPE3xFaLlLFOPuCIJwhWB6/1B7oiuTHm6q0+5QRzbiumXMWPgjO0gAK8 X-Received: by 2002:ac8:590e:0:b0:31e:a2d9:465 with SMTP id 14-20020ac8590e000000b0031ea2d90465mr3601815qty.231.1657295985245; Fri, 08 Jul 2022 08:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657295985; cv=none; d=google.com; s=arc-20160816; b=Yl+iWuu64hj8ndOrV72BeJVNY1GSXGHVuFJpQHH1D2hO5yC72x0/HWq59/HSCWLWlB ui+HagYS1Sz1k1c5qcYm8ocsigLTH9qD9U2ch/hxLQ61Frl6KCnDgwmNsIPEMUghab3C j5zsk2GqaVZSKTsL06NVqXJVhSXS+gqSi4RxtT2/qzm6kOviZUwNPUsWomF+9iCEWELa avmgBLVJeNFanYxkSh3GqgY915iQhQ63IWxSRsjHpn4o2R6waTFYgsO0k0OKIwgoz9Ie rYumqFg3OlS2hLrbpl4/h+CdDgb2CNGjNhWPw/glk2YMbYIJTkwm9NhkOEI7Ly9fIHNr zFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Wwg5T7n5d4hEzm3DL2nMuno/i3EhmUsngOLpxo3zUx0=; b=Fr6CSQhr2zSLt+rGk5toohBlTchYLxajluXZkVkZOinU/aHdz5iVtUuJRRZZ7fPsq8 ZinTdoCm3UUI7pCSDg8Grux/ohQApygYCyYCtSsOF4kwv3iGGg1o6aW2cp4+NRNhBiXm yTjPM85DR9Rnt2lUJdCdSblABWEUEA4CpwHn8ztjqHRAkdAps5p3Z57eGax51vXUdLCk N/RS90CymdNXVun7FnSsJrqgGcuGfSM0DoNgrkC/1WXr5u8Yh+3yMQ/QFOlH1cqfUeNQ wbO3zQFHw6xLI8UOK6MxnKhMxo5BKZwGIRXYwd/PHpB9LZb/0dyJlterF0cEwJfExz3f 7K7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YedpQGh9; 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 bp39-20020a05622a1ba700b0031d25225393si19029966qtb.258.2022.07.08.08.59.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 08:59: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=YedpQGh9; 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]:50206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qOO-000121-QX for patch@linaro.org; Fri, 08 Jul 2022 11:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCy-0005hs-HP for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:57 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:33592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCv-0002VG-JW for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:56 -0400 Received: by mail-pg1-x531.google.com with SMTP id 72so1177528pge.0 for ; Fri, 08 Jul 2022 08:47:53 -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=Wwg5T7n5d4hEzm3DL2nMuno/i3EhmUsngOLpxo3zUx0=; b=YedpQGh97aaq2xTLJzikAZNr+edJLKplkc7dv2TTfR2VfCxO5ghAEFVny5JGu8UDVJ JEI6iL/Hy+w53gkBGIw3nSLnw0eqanltg4X3YW704In310Ss3TS4RCyBxQU9h5Pgk8Xu QR9wgapEkRN6l6LckDG0F1uBTumAqV4Nc+WcJiqbPVmRtmWD9ok6Baa7XKnrqvPFDpj6 EQnTIj9uwYyOlMYVRVFcu1uiiXP8h8FQZQv35Rwet1zA3duKnv7Hae7QQtQBTpxliBzM a9xB03GbpzwCEl146BPw8njZbKp65dtXvgDb6MDhKO/+BGu1biGqMmN1gcz6Ks/+ksGR eomQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wwg5T7n5d4hEzm3DL2nMuno/i3EhmUsngOLpxo3zUx0=; b=dJcYL/Rsdd/s2QMlqIQ/tUNseXnzoPjbrhYVONncYX941oO5gyENMJYpRL5+GcfuGD 4dk9fF1nt4JohSRv5SsENk7pO6jiaismV/w8u2JK6r4nyVjVxQNQgcBmFj0WFBJD/Elc 7dOcb1/yxuf96fs8HAstn6iwwCnynH9qemtClweRDGGzYiZvXOcDeDQpFiGjQyEA9+/x M0HwpZNS2f0KYwxRsh4CAU5RZn5Ffr2x9QAyjyK+gWY7Zc8XI+svwyJktmyJ2AsDfe0k COAxXB8o3GFEEJK82X8GVkow2oWt2GJQTL77T+Y3M+2iUCFnk95Cx9C+xrDnuIQQfbl3 5sCw== X-Gm-Message-State: AJIora8ZLpm/Ns5l6sF9hwMeaxUOKfpoJIrsTzeLl2YTlV8wKRXb8WIp GoL/dyXURG2iQmX7MpzVkSFaiKU6aSernAHy X-Received: by 2002:a05:6a00:22d6:b0:525:74b3:d020 with SMTP id f22-20020a056a0022d600b0052574b3d020mr4543389pfj.80.1657295272144; Fri, 08 Jul 2022 08:47:52 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 14/29] Merge reginfo.c into risu.c Date: Fri, 8 Jul 2022 21:16:45 +0530 Message-Id: <20220708154700.18682-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The distinction between the two is artificial. Following patches will rearrange the functions involved to make it easier for dumping of the trace file. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- Makefile | 2 +- risu.h | 28 +--------- reginfo.c | 151 ------------------------------------------------------ risu.c | 129 ++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 126 insertions(+), 184 deletions(-) delete mode 100644 reginfo.c diff --git a/Makefile b/Makefile index 6ab014a..ad7f879 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ CFLAGS ?= -g ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) -U$(ARCH) $(BUILD_INC) $(CFLAGS) $(EXTRA_CFLAGS) PROG=risu -SRCS=risu.c comms.c reginfo.c risu_$(ARCH).c risu_reginfo_$(ARCH).c +SRCS=risu.c comms.c risu_$(ARCH).c risu_reginfo_$(ARCH).c HDRS=risu.h risu_reginfo_$(ARCH).h BINS=test_$(ARCH).bin diff --git a/risu.h b/risu.h index 77d6128..dd9fda5 100644 --- a/risu.h +++ b/risu.h @@ -35,7 +35,6 @@ void process_arch_opt(int opt, const char *arg); #include REGINFO_HEADER(ARCH) extern uintptr_t image_start_address; -extern void *memblock; /* Ops code under test can request from risu: */ typedef enum { @@ -83,34 +82,9 @@ void send_response_byte(int sock, int resp); /* Functions operating on reginfo */ -/* Function prototypes for read/write helper functions. */ -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(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(void *uc); - -/* - * Print a useful report on the status of the last reg comparison - * done in recv_and_compare_register_info(). - */ -void report_mismatch_reg(void); - /* Interface provided by CPU-specific code: */ -/* Move the PC past this faulting insn by adjusting ucontext - */ +/* Move the PC past this faulting insn by adjusting ucontext. */ void advance_pc(void *uc); /* Set the parameter register in a ucontext_t to the specified value. diff --git a/reginfo.c b/reginfo.c deleted file mode 100644 index a007f16..0000000 --- a/reginfo.c +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Linaro Limited - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Peter Maydell (Linaro) - initial implementation - *****************************************************************************/ - -#include -#include -#include -#include "risu.h" - -static struct reginfo master_ri, apprentice_ri; -static uint8_t master_memblock[MEMBLOCKLEN]; - -RisuResult send_register_info(void *uc) -{ - struct reginfo ri; - trace_header_t header; - RisuResult res; - RisuOp op; - - reginfo_init(&ri, uc); - op = get_risuop(&ri); - - /* Write a header with PC/op to keep in sync */ - header.pc = get_pc(&ri); - header.risu_op = op; - res = write_buffer(&header, sizeof(header)); - 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; - } - break; - case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); - break; - case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, - get_reginfo_paramreg(&ri) + (uintptr_t)memblock); - break; - case OP_COMPAREMEM: - return write_buffer(memblock, MEMBLOCKLEN); - default: - abort(); - } - return res; -} - -/* 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. - * NB: called from a signal handler. - * - * We don't have any kind of identifying info in the incoming data - * 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(void *uc) -{ - RisuResult res; - trace_header_t header; - RisuOp op; - - reginfo_init(&apprentice_ri, uc); - op = get_risuop(&apprentice_ri); - - res = read_buffer(&header, sizeof(header)); - if (res != RES_OK) { - return res; - } - - if (header.risu_op != op) { - /* We are out of sync. Tell master to exit. */ - respond(RES_END); - return RES_BAD_IO; - } - - /* send OK for the header */ - respond(RES_OK); - - 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 = read_buffer(&master_ri, reginfo_size()); - if (res != RES_OK) { - /* fail */ - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - /* register mismatch */ - res = RES_MISMATCH_REG; - } 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; - case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + - (uintptr_t)memblock); - break; - case OP_COMPAREMEM: - res = read_buffer(master_memblock, MEMBLOCKLEN); - if (res != RES_OK) { - /* fail */ - } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { - /* memory mismatch */ - res = RES_MISMATCH_MEM; - } - respond(res == RES_OK ? RES_OK : RES_END); - break; - default: - abort(); - } - - return res; -} - -/* - * Print a useful report on the status of the last reg comparison - * done in recv_and_compare_register_info(). - */ -void report_mismatch_reg(void) -{ - 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); -} diff --git a/risu.c b/risu.c index d6c2deb..a0e20d5 100644 --- a/risu.c +++ b/risu.c @@ -28,7 +28,10 @@ #include "config.h" #include "risu.h" -void *memblock; +static void *memblock; +static struct reginfo master_ri, apprentice_ri; +static uint8_t master_memblock[MEMBLOCKLEN]; + static int comm_fd; static bool trace; @@ -48,7 +51,7 @@ static sigjmp_buf jmpbuf; /* I/O functions */ -RisuResult read_buffer(void *ptr, size_t bytes) +static RisuResult read_buffer(void *ptr, size_t bytes) { size_t res; @@ -69,7 +72,7 @@ RisuResult read_buffer(void *ptr, size_t bytes) return res == bytes ? RES_OK : RES_BAD_IO; } -RisuResult write_buffer(void *ptr, size_t bytes) +static RisuResult write_buffer(void *ptr, size_t bytes) { size_t res; @@ -90,13 +93,60 @@ RisuResult write_buffer(void *ptr, size_t bytes) return res == bytes ? RES_OK : RES_BAD_IO; } -void respond(RisuResult r) +static void respond(RisuResult r) { if (!trace) { send_response_byte(comm_fd, r); } } +static RisuResult send_register_info(void *uc) +{ + struct reginfo ri; + trace_header_t header; + RisuResult res; + RisuOp op; + + reginfo_init(&ri, uc); + op = get_risuop(&ri); + + /* Write a header with PC/op to keep in sync */ + header.pc = get_pc(&ri); + header.risu_op = op; + res = write_buffer(&header, sizeof(header)); + 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; + } + break; + case OP_SETMEMBLOCK: + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); + break; + case OP_GETMEMBLOCK: + set_ucontext_paramreg(uc, + get_reginfo_paramreg(&ri) + (uintptr_t)memblock); + break; + case OP_COMPAREMEM: + return write_buffer(memblock, MEMBLOCKLEN); + default: + abort(); + } + return res; +} + static void master_sigill(int sig, siginfo_t *si, void *uc) { RisuResult r; @@ -110,6 +160,71 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } } +static RisuResult recv_and_compare_register_info(void *uc) +{ + RisuResult res; + trace_header_t header; + RisuOp op; + + reginfo_init(&apprentice_ri, uc); + op = get_risuop(&apprentice_ri); + + res = read_buffer(&header, sizeof(header)); + if (res != RES_OK) { + return res; + } + + if (header.risu_op != op) { + /* We are out of sync. Tell master to exit. */ + respond(RES_END); + return RES_BAD_IO; + } + + /* send OK for the header */ + respond(RES_OK); + + 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 = read_buffer(&master_ri, reginfo_size()); + if (res != RES_OK) { + /* fail */ + } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + /* register mismatch */ + res = RES_MISMATCH_REG; + } 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; + case OP_GETMEMBLOCK: + set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + + (uintptr_t)memblock); + break; + case OP_COMPAREMEM: + res = read_buffer(master_memblock, MEMBLOCKLEN); + if (res != RES_OK) { + /* fail */ + } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { + /* memory mismatch */ + res = RES_MISMATCH_MEM; + } + respond(res == RES_OK ? RES_OK : RES_END); + break; + default: + abort(); + } + + return res; +} + static void apprentice_sigill(int sig, siginfo_t *si, void *uc) { RisuResult r; @@ -226,7 +341,11 @@ static int apprentice(void) case RES_MISMATCH_REG: fprintf(stderr, "mismatch reg after %zd checkpoints\n", signal_count); - report_mismatch_reg(); + 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 EXIT_FAILURE; case RES_MISMATCH_MEM: From patchwork Fri Jul 8 15:46:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588558 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp791820mab; Fri, 8 Jul 2022 09:03:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1shvgNFk2GJoGvJuTiaNsFKtFcUPRKeZmtKO5yXlrfhPpbit1ekCQCgsjkWQcWqrWFUrjMV X-Received: by 2002:a05:620a:2234:b0:6af:692:1fbf with SMTP id n20-20020a05620a223400b006af06921fbfmr2805643qkh.579.1657296239604; Fri, 08 Jul 2022 09:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657296239; cv=none; d=google.com; s=arc-20160816; b=xivMC3nKLtnYcl9hm0Q/yi8jzZpUTUX810aQV9vNJ4A2YpN7S8dcudyWozR+gIZYEo B49gdLip13tgzD5oMgZ7Un36L7uw0n7UFYxlE87YUjEksJVIeAAVordH+GgmbUF5n++d 9Q2MFJJtLufhAMC9rULBkgJ3gT1Rw3/a20sZEyGAsQWy4VRiRB25K7VAEbIVNZZxqgax R9SLhku/rmzcU6O6WzEVfL0zD8A2UH5d1QOtWVvTk1nmir3en9dKnlTpcrf59tf5NJYQ hwXrGSYHGmdCE/CUJKptYCVVLgd/ZFJAHssXWGqOOGNnvhY/ssPK8RziE1Byp07yClfW wytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=giE62K4N3abY45AouFUPnOIWPyjnV5qJ7GSggV1mLASq7B8CQC3q3kcZnXXoYEBHnW FH8Eq6M9r9qU5BoRdK22EkaAm2I3VbM4zuPdl0D2XMLg7vnyEd0vHhasrkp383xVbs6b zUPPrs6yfSbE0aKZsc5V4UCiJ4yNCwxlhsTGjS4iAqX5A5X9iA64jy17UThSaUmKokQY TzidE/kV3zwDzLg+PTBfKwUilZ6wpGGkHoJYhrVpHFAXheBrIOMwZb14o0CmeGGekoNv zNTOy353hggGW/P5E2pQRLs8xCeBm3Aj+3cYPqaz61M/SbxaxKN7GVylS1uXZK9s+VZz stqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DuagrhYq; 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 bv15-20020a05622a0a0f00b0031d344f0955si14160209qtb.501.2022.07.08.09.03.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:03:59 -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=DuagrhYq; 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]:58930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qSV-00077p-67 for patch@linaro.org; Fri, 08 Jul 2022 12:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD0-0005lf-1j for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:58 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:45670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCx-0002VZ-PX for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:57 -0400 Received: by mail-pg1-x534.google.com with SMTP id 145so22655318pga.12 for ; Fri, 08 Jul 2022 08:47:55 -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=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=DuagrhYqV+ZRFMS7oGkdtwG2d+FTcHaYcxd38DHWg8s9b+f4kXIuZMHpoNhHQmntWY Z9l6I0THVH8+tfVSDX4QFZrLX4VD/DFnjIaj3/pwv8KlSO3gBISaXliUFm6B85hZ/cTc SpFbmwKU84mUDCeftWbADk8xhM7Sm1w59gpv5+pf+X3+sbDQaxGVXcQ2iijv2hxqM5FU JCTTjPMElmgc9A3xq8UiQANfcvfQUhUSZsUhUT8BTiInzDahu9UmImTH8K747X6AYyiY XLPPvoJrreIfZuTrm8X1R4Ugo4DSfkyQhoA21kxsqGqIbQxnGKXpAGrbyT1KcSEWnlJx xzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=s/MhwsYjzv3Ek9ADy1BXmOd9cdT1QhiroofU5WmoJdZAPgSL9YkB9aYUkEpZsoIg7+ R/HKlMjq5pUC7r9bMXfgiIWjXDRwK+1YOobX8ezLhFkFUHu7SDEoWIjTHeAmMEsXm6qp CefGDp2IsghrW0T4NU5JrsmH5V3m32H3+zUJg27WBeIKqzhUzBA57lEJXaZHnzRzY7d+ goPgQrXVr0DYVTVIIzWAipA1qGo138FwNZMGHIlFdHk1nDryb/erXtr9ykchVynof21r wssX9RlhuVel0z5rWyLuf2sAzCgj5ztL+6W0CYvaVqVD6KRLp3jIYez/4qQuRSSMbW8x zJgg== X-Gm-Message-State: AJIora+e5J74WCQAwC4o6f3Y84eN6oLc/9EkRJ0Mg+kkKBHn+QQvXpS6 S6Tqpmhu+tCBPO0+8n+n7z+cuDduhXSkrsNp X-Received: by 2002:a65:694a:0:b0:412:b98:4604 with SMTP id w10-20020a65694a000000b004120b984604mr4026000pgq.50.1657295274570; Fri, 08 Jul 2022 08:47:54 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 15/29] Rearrange reginfo and memblock buffers Date: Fri, 8 Jul 2022 21:16:46 +0530 Message-Id: <20220708154700.18682-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-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-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For send_register_info from master_sigill, do not keep a reginfo buffer on the stack. At the moment, this struct is quite large for aarch64. Put the two reginfo buffers into an array, for the benefit of future dumping. For recv_and_compare_register_info, index this array with constants, so it's a simple rename. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.c | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/risu.c b/risu.c index a0e20d5..b91ad38 100644 --- a/risu.c +++ b/risu.c @@ -28,10 +28,16 @@ #include "config.h" #include "risu.h" -static void *memblock; -static struct reginfo master_ri, apprentice_ri; -static uint8_t master_memblock[MEMBLOCKLEN]; +enum { + MASTER = 0, APPRENTICE = 1 +}; +static struct reginfo ri[2]; +static uint8_t other_memblock[MEMBLOCKLEN]; +static trace_header_t header; + +/* Memblock pointer into the execution image. */ +static void *memblock; static int comm_fd; static bool trace; @@ -102,16 +108,15 @@ static void respond(RisuResult r) static RisuResult send_register_info(void *uc) { - struct reginfo ri; - trace_header_t header; + uint64_t paramreg; RisuResult res; RisuOp op; - reginfo_init(&ri, uc); - op = get_risuop(&ri); + reginfo_init(&ri[MASTER], uc); + op = get_risuop(&ri[MASTER]); /* Write a header with PC/op to keep in sync */ - header.pc = get_pc(&ri); + header.pc = get_pc(&ri[MASTER]); header.risu_op = op; res = write_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -126,18 +131,19 @@ static RisuResult send_register_info(void *uc) * Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - res = write_buffer(&ri, reginfo_size()); + res = write_buffer(&ri[MASTER], reginfo_size()); /* For OP_TEST_END, force exit. */ if (res == RES_OK && op == OP_TESTEND) { res = RES_END; } break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); + paramreg = get_reginfo_paramreg(&ri[MASTER]); + memblock = (void *)(uintptr_t)paramreg; break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, - get_reginfo_paramreg(&ri) + (uintptr_t)memblock); + paramreg = get_reginfo_paramreg(&ri[MASTER]); + set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: return write_buffer(memblock, MEMBLOCKLEN); @@ -162,12 +168,12 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) static RisuResult recv_and_compare_register_info(void *uc) { + uint64_t paramreg; RisuResult res; - trace_header_t header; RisuOp op; - reginfo_init(&apprentice_ri, uc); - op = get_risuop(&apprentice_ri); + reginfo_init(&ri[APPRENTICE], uc); + op = get_risuop(&ri[APPRENTICE]); res = read_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -190,10 +196,10 @@ static 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(&master_ri, reginfo_size()); + res = read_buffer(&ri[MASTER], reginfo_size()); if (res != RES_OK) { /* fail */ - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + } else if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { /* register mismatch */ res = RES_MISMATCH_REG; } else if (op == OP_TESTEND) { @@ -202,17 +208,18 @@ static RisuResult recv_and_compare_register_info(void *uc) respond(res == RES_OK ? RES_OK : RES_END); break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); + paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); + memblock = (void *)(uintptr_t)paramreg; break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + - (uintptr_t)memblock); + paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); + set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: - res = read_buffer(master_memblock, MEMBLOCKLEN); + res = read_buffer(other_memblock, MEMBLOCKLEN); if (res != RES_OK) { /* fail */ - } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { + } else if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH_MEM; } @@ -221,7 +228,6 @@ static RisuResult recv_and_compare_register_info(void *uc) default: abort(); } - return res; } @@ -342,10 +348,10 @@ static int apprentice(void) case RES_MISMATCH_REG: fprintf(stderr, "mismatch reg after %zd checkpoints\n", signal_count); fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); + reginfo_dump(&ri[MASTER], stderr); fprintf(stderr, "apprentice reginfo:\n"); - reginfo_dump(&apprentice_ri, stderr); - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); + reginfo_dump(&ri[APPRENTICE], stderr); + reginfo_dump_mismatch(&ri[MASTER], &ri[APPRENTICE], stderr); return EXIT_FAILURE; case RES_MISMATCH_MEM: From patchwork Fri Jul 8 15:46:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588575 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp819484mab; Fri, 8 Jul 2022 09:35:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slF0peFYbEgTLE7aCz2GnZqC9eBZIwWhGAdW8vTCYIqRb9qijGf7U0XLCZy0lU4450K5Hg X-Received: by 2002:a05:620a:2556:b0:6a7:9f07:602 with SMTP id s22-20020a05620a255600b006a79f070602mr2915733qko.207.1657298144679; Fri, 08 Jul 2022 09:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298144; cv=none; d=google.com; s=arc-20160816; b=G3QBGyoxCz2ygAsdoRw+oE5p+bphoohz9RMSPfz226gmraXb8Si99vwrvGwUaS1zPJ bteRBQ2QqlCENbIkcTK2cKNnX5DBeA5zHZLNCRG/ZMi3kEPnmCr/f+WJCjm6FfW20ygO wbSACxAucipYXq8Myv3rhz8O3Vj4MzEstyt3qUqEDwP+KnifNyZGWvuF3NdxstVxmb1b +2uyzBhC8dePz5GgQTIglnFAjQl4cIuYPZAxcSL8oATOI87mEQjCL3IdSd7LXP1AoAE7 B2lmkcECck4p3CDMDl5ms6fSjmJsfbgKL3Uv6z1pugr51kI4yK5YZoH9CIGPsqnoJUPc 9rfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=v19iYVQqyPYqii6GOgeAb6KeSVjO7ZLU6D0RHily+Q/bLDs31nAfQAX7holQCPmMOF BKNapjW8lG6yWcpd6zwA05dJD8dDwTJ+KfkLOr36XfCtaDNYZCppasLygLkt7ej4wuaV 86A24G9fMR6VgUe1y08QJcuizH2IMiMZpDNTB9WRFmoadtOJpBSDeOp2tZX/zqcTGeLl 1CH1zI4mA/y+rtlPjZGwUFoEr8u5QnF7MYhKO1Gqh1LyESOlKvkATRbbUBCsiEVjGsNf W3xWfmG3wT27H3O+xy8OovOU4hB1yAfZJW8uHIeHKATlOrtbnnG8CMlbWsi3IO/rDFh3 d+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDdTgLPq; 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 bl11-20020a05622a244b00b0031cc5db5aeasi9910729qtb.713.2022.07.08.09.35.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:35:44 -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=bDdTgLPq; 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]:43298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qxE-0006Dl-9t for patch@linaro.org; Fri, 08 Jul 2022 12:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD1-0005qn-Bs for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:59 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:37643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCz-0002Ux-PM for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:59 -0400 Received: by mail-pl1-x630.google.com with SMTP id f11so4115351plr.4 for ; Fri, 08 Jul 2022 08:47:57 -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=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=bDdTgLPqjoJsQLTGlQpoH2VllST0upphtnER5sE74xLt8M0k8GiIbBk6DoQReqsOxh D8fWlxZRYBzi+YAW66mq1XnNRURgbE9uts8JuApSsVlPb6B5Qb9YaSJljEfjC5kuHQ/n MD4F8OL9qOKbBAxPq/X0P5yJFQeCcN6JngRk1VIFMXQJNWc/SIkQhjq5jlXZView9o0H 3jGofyxe3IcHDuKf+seMGFMB1VLIAdKkVB8DcfXexBPwqZb0YX7DpxIEJa2hH35vGWiI +LKx+WjWPf7LLRIFneW9E/3h/5rFW2S9i1saERHLoKAaIAeI24eQsUIIMxOS5ZrUenCl nxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=KUcFRKlH9QyCitfGdJq9Mk6bZvP1PzLur3aAzgV2TNfv/CemeBdBQVTSrJrPrPR9UQ o9nGFjTCdYQ4P48IV03JHYERAT04T1tC0nEEwYiXL3PlTFNWyEZG1kCQqI0EnaTL8eA5 Hdgi2jHweeiveGEFEOYfOv9cdp4aZG1Vr9ytGvqS9tl9ROJhV3jaFFz7pl3FPkJ+3kvh vD5ZmAuX/x12nkGC40kInceh1e6ZzJNGb67od4JC/6oDW8ah3pFtc29uNrCzd8m0b5Dz 58ld97pQxgc8XisYsQA47oqCzjKCVHgvawGyhXP4WehWVUx5OeNyKWXcTZutze7iWz4q ZYGg== X-Gm-Message-State: AJIora8LPFj/C7y2og71wDnZGzl0xlX3JUSBXAV2XQ3Tgspd7UMrx2wf hxEg2H17dKOT0hGjfP+x1C7q3iLB8QJvhflM X-Received: by 2002:a17:90a:e391:b0:1ef:83c2:2527 with SMTP id b17-20020a17090ae39100b001ef83c22527mr541978pjz.94.1657295276984; Fri, 08 Jul 2022 08:47:56 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 16/29] Split out recv_register_info Date: Fri, 8 Jul 2022 21:16:47 +0530 Message-Id: <20220708154700.18682-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-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-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code when dumping. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/risu.c b/risu.c index b91ad38..80bc3b1 100644 --- a/risu.c +++ b/risu.c @@ -166,6 +166,34 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } } +static RisuResult recv_register_info(struct reginfo *ri) +{ + RisuResult res; + + res = read_buffer(&header, sizeof(header)); + if (res != RES_OK) { + return res; + } + + /* send OK for the header */ + respond(RES_OK); + + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + case OP_SIGILL: + return read_buffer(ri, reginfo_size()); + case OP_COMPAREMEM: + return read_buffer(other_memblock, MEMBLOCKLEN); + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + return RES_OK; + default: + /* TODO: Create a better error message. */ + return RES_BAD_IO; + } +} + static RisuResult recv_and_compare_register_info(void *uc) { uint64_t paramreg; @@ -173,33 +201,26 @@ static RisuResult recv_and_compare_register_info(void *uc) RisuOp op; reginfo_init(&ri[APPRENTICE], uc); - op = get_risuop(&ri[APPRENTICE]); - res = read_buffer(&header, sizeof(header)); + res = recv_register_info(&ri[MASTER]); if (res != RES_OK) { + /* I/O error. Tell master to exit. */ + respond(RES_END); return res; } + op = get_risuop(&ri[APPRENTICE]); if (header.risu_op != op) { /* We are out of sync. Tell master to exit. */ respond(RES_END); return RES_BAD_IO; } - /* send OK for the header */ - respond(RES_OK); - 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 = read_buffer(&ri[MASTER], reginfo_size()); - if (res != RES_OK) { - /* fail */ - } else if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { + if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { /* register mismatch */ res = RES_MISMATCH_REG; } else if (op == OP_TESTEND) { @@ -216,10 +237,7 @@ static RisuResult recv_and_compare_register_info(void *uc) set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: - res = read_buffer(other_memblock, MEMBLOCKLEN); - if (res != RES_OK) { - /* fail */ - } else if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { + if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH_MEM; } From patchwork Fri Jul 8 15:46:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588578 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp822132mab; Fri, 8 Jul 2022 09:39:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vvZDdPSxVVwYiG7rwyIOa8SrXFEUJTtG4G45abyqN1uwcuB1ttaZFy/DGnWFfRmgWMmdPM X-Received: by 2002:ac8:5acc:0:b0:31d:296c:e30e with SMTP id d12-20020ac85acc000000b0031d296ce30emr3791820qtd.624.1657298350100; Fri, 08 Jul 2022 09:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298350; cv=none; d=google.com; s=arc-20160816; b=qahDTFy08+RS7Lc9pQppCVZNV7cBS4WlWLgt2DJwq2WVI38zL9g8kiqxI+QMS9A65B ojNZ/5YRoAkOvFmVmK+T9k19Na9OYM6CfQYVR1QA3bGgM32u2+FwDv6YdYyMz/2dqyvb xPK8h3KtmUrrw0BRxR13gzkZBHnHmrGdrNd5LvCJYxzI01RZep5khMX/CGD8zx7CFJJp 6jigdFpHEGIvRj5uGR/T34bQ5Li/SA30/7rfSDsCvTJWFvhlkKSdyOmR8CUlp/8WW5VZ YSVLE21yuMOc7QaELmSNHRFRaWQyOv2UsT/tEKwkl17IQ6I/VDeknEIroMGy5tZVqCMw ox5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=gGqem9bZjG2DPsS841S7DVBWN/tLpAM4ih8tuyrEJjA=; b=mEsDGC20lR351R4J2dSf3m84pG8dSxfX30T5I8usWPSNXbdKv2aGtAAqiB5s6PALhm BqT1i4s+UD8EioGQ4MXNuQjjyhrDqYEuYq3bua+GPOTEZvvRraP1wApOqCxdb4HTLESc kK7drKfrgBqfrhCI9oS/NVKnQFl8t6R0M8P4HQJfLOGcA8SOyB+K2OCISA0x/2jp5ZQI KAwe1WYK+VoQGGkt6J6f3L4ts/XNfn6H3zgQwZmkiWwLBJTxjvkqz6e0xhAHMd2fqeSO uSmzZWfF+Dsh2UK8WMz3KfEBuDT5TnzpcDWgbheCBSViXlDgzAqr09b1190WejIxInD9 F1tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U3jCDad5; 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 gw5-20020a0562140f0500b004704e74849dsi23976346qvb.110.2022.07.08.09.39.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:39: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=U3jCDad5; 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]:50676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9r0X-0003Nd-Mb for patch@linaro.org; Fri, 08 Jul 2022 12:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD6-0005xM-Fe for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:04 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:46947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qD4-0002Ws-Lz for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:04 -0400 Received: by mail-pl1-x634.google.com with SMTP id l12so11314275plk.13 for ; Fri, 08 Jul 2022 08:48: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=gGqem9bZjG2DPsS841S7DVBWN/tLpAM4ih8tuyrEJjA=; b=U3jCDad59bvy9857Am6RQ1xs4MTmW8+/AIKxX7dWQ0SQBiV+T4yzaca3DbYxXoeF5g wgsKvBUNxqTF7yKC/DswQna4ILw4zPjViYaRtdxgn0m2RFFs/Lr1DdhC6dXsZ8v+t/L8 CF6mzkDBnXB8nMJ/Bkr9vxNcKP7NYPmxkdBcNaePcPGxG4fFVHJv361kzKQk991tXj5B 5zUdQFum1X+awyoZVE0u7UEUuy6d1ixR4UDN0+FGjVbpD1C1Csau8w3T68fGZHNC/rtB 9k8BFCPOiW8QxDk6OSRP0UFUxdQMJkA4R7DRaYjHUqbYgqWpnCeQm9TXeEf2Rl1bmkaP 2Dsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gGqem9bZjG2DPsS841S7DVBWN/tLpAM4ih8tuyrEJjA=; b=jN8rlTA5ucu0mULKHI8jve5Mo87cszvirenGaI87mpptqpIrSsTVOdIgzgpu5vfKQB aSKvplJEIWK2VQBNY865BhRs+1fUfLGXHg9mp9OU4U1tRV6GlnJMa8nJkchtKAT3WNj0 BFJye9/S4N9A44BwO91/wCP6Ar8At9jINKF0su/J4tzblJZwXisSnGq6YoNSK90kQF7J LLcu1xAnGhJiNRjLELJdF9GdYrT/MiwggNictmGUDpr3PPYyPWMCGTmawjppWgETq2Qt 4LmpZge56QQugLSrIoRbwB5tLjMwO+P9hW79Xd5SnHquRYgmzNKyR0ync9zIxK/vY8bi eENw== X-Gm-Message-State: AJIora8S8Mfn4lbUq2lGpkqfVa0KPs/V+LSfWuOqZEf+jnkZGuHgm5ch Am5FV/WKtcP9Ydg0iA3LsHfyoZXJSSrm4zXX X-Received: by 2002:a17:902:d510:b0:16c:3cd:db78 with SMTP id b16-20020a170902d51000b0016c03cddb78mr4309535plg.17.1657295279790; Fri, 08 Jul 2022 08:47:59 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 17/29] Add magic and size to the trace header Date: Fri, 8 Jul 2022 21:16:48 +0530 Message-Id: <20220708154700.18682-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Reviewed-by: Peter Maydell --- risu.h | 10 +++- risu.c | 162 ++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 136 insertions(+), 36 deletions(-) diff --git a/risu.h b/risu.h index dd9fda5..bfcf0af 100644 --- a/risu.h +++ b/risu.h @@ -55,7 +55,11 @@ typedef enum { RES_END, RES_MISMATCH_REG, RES_MISMATCH_MEM, + RES_MISMATCH_OP, RES_BAD_IO, + RES_BAD_MAGIC, + RES_BAD_SIZE, + RES_BAD_OP, } RisuResult; /* The memory block should be this long */ @@ -69,10 +73,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); diff --git a/risu.c b/risu.c index 80bc3b1..a248db1 100644 --- a/risu.c +++ b/risu.c @@ -111,32 +111,54 @@ static RisuResult send_register_info(void *uc) uint64_t paramreg; RisuResult res; RisuOp op; + void *extra; reginfo_init(&ri[MASTER], uc); op = get_risuop(&ri[MASTER]); /* Write a header with PC/op to keep in sync */ + header.magic = RISU_MAGIC; header.pc = get_pc(&ri[MASTER]); header.risu_op = op; + + switch (op) { + case OP_TESTEND: + case OP_COMPARE: + case OP_SIGILL: + header.size = reginfo_size(); + extra = &ri[MASTER]; + break; + case OP_COMPAREMEM: + header.size = MEMBLOCKLEN; + extra = memblock; + break; + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + header.size = 0; + extra = NULL; + 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[MASTER], 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: paramreg = get_reginfo_paramreg(&ri[MASTER]); memblock = (void *)(uintptr_t)paramreg; @@ -145,12 +167,10 @@ static RisuResult send_register_info(void *uc) paramreg = get_reginfo_paramreg(&ri[MASTER]); set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; - case OP_COMPAREMEM: - return write_buffer(memblock, MEMBLOCKLEN); default: abort(); } - return res; + return RES_OK; } static void master_sigill(int sig, siginfo_t *si, void *uc) @@ -175,22 +195,35 @@ static RisuResult recv_register_info(struct reginfo *ri) return res; } - /* send OK for the header */ - respond(RES_OK); + if (header.magic != RISU_MAGIC) { + /* If the magic number is wrong, we can't trust the rest. */ + return RES_BAD_MAGIC; + } switch (header.risu_op) { case OP_COMPARE: case OP_TESTEND: case OP_SIGILL: - return read_buffer(ri, reginfo_size()); + /* If we can't store the data, report invalid size. */ + if (header.size > sizeof(*ri)) { + return RES_BAD_SIZE; + } + respond(RES_OK); + return read_buffer(ri, header.size); + case OP_COMPAREMEM: + if (header.size != MEMBLOCKLEN) { + return RES_BAD_SIZE; + } + respond(RES_OK); return read_buffer(other_memblock, MEMBLOCKLEN); + case OP_SETMEMBLOCK: case OP_GETMEMBLOCK: - return RES_OK; + return header.size == 0 ? RES_OK : RES_BAD_SIZE; + default: - /* TODO: Create a better error message. */ - return RES_BAD_IO; + return RES_BAD_OP; } } @@ -204,48 +237,71 @@ static RisuResult recv_and_compare_register_info(void *uc) res = recv_register_info(&ri[MASTER]); if (res != RES_OK) { - /* I/O error. Tell master to exit. */ - respond(RES_END); - return res; + goto done; } op = get_risuop(&ri[APPRENTICE]); - if (header.risu_op != op) { - /* We are out of sync. Tell master to exit. */ - respond(RES_END); - return RES_BAD_IO; - } switch (op) { case OP_COMPARE: case OP_TESTEND: case OP_SIGILL: - if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { + /* + * If we have nothing to compare against, report an op mismatch. + * Otherwise allow the compare to continue, and assume that + * something in the reginfo will be different. + */ + if (header.risu_op != OP_COMPARE && + header.risu_op != OP_TESTEND && + header.risu_op != OP_SIGILL) { + res = RES_MISMATCH_OP; + } else if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { /* register mismatch */ res = RES_MISMATCH_REG; + } else if (op != header.risu_op) { + /* The reginfo matched. We should have matched op. */ + res = RES_MISMATCH_OP; } else if (op == OP_TESTEND) { res = RES_END; } - respond(res == RES_OK ? RES_OK : RES_END); break; + case OP_SETMEMBLOCK: + if (op != header.risu_op) { + res = RES_MISMATCH_OP; + break; + } paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); memblock = (void *)(uintptr_t)paramreg; break; + case OP_GETMEMBLOCK: + if (op != header.risu_op) { + res = RES_MISMATCH_OP; + break; + } paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; + case OP_COMPAREMEM: + if (op != header.risu_op) { + res = RES_MISMATCH_OP; + break; + } if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH_MEM; } - respond(res == RES_OK ? RES_OK : RES_END); break; + default: abort(); } + + done: + /* On error, tell master to exit. */ + respond(res == RES_OK ? RES_OK : RES_END); return res; } @@ -346,6 +402,25 @@ static int master(void) } } +static const char *op_name(RisuOp op) +{ + switch (op) { + case OP_SIGILL: + return "SIGILL"; + case OP_COMPARE: + return "COMPARE"; + case OP_TESTEND: + return "TESTEND"; + case OP_SETMEMBLOCK: + return "SETMEMBLOCK"; + case OP_GETMEMBLOCK: + return "GETMEMBLOCK"; + case OP_COMPAREMEM: + return "COMPAREMEM"; + } + abort(); +} + static int apprentice(void) { RisuResult res = sigsetjmp(jmpbuf, 1); @@ -364,7 +439,7 @@ static int apprentice(void) return EXIT_SUCCESS; case RES_MISMATCH_REG: - fprintf(stderr, "mismatch reg after %zd checkpoints\n", signal_count); + fprintf(stderr, "Mismatch reg after %zd checkpoints\n", signal_count); fprintf(stderr, "master reginfo:\n"); reginfo_dump(&ri[MASTER], stderr); fprintf(stderr, "apprentice reginfo:\n"); @@ -373,15 +448,32 @@ static int apprentice(void) return EXIT_FAILURE; case RES_MISMATCH_MEM: - fprintf(stderr, "mismatch mem after %zd checkpoints\n", signal_count); + fprintf(stderr, "Mismatch mem after %zd checkpoints\n", signal_count); + return EXIT_FAILURE; + + case RES_MISMATCH_OP: + /* Out of sync, but both opcodes are known valid. */ + fprintf(stderr, "Mismatch header after %zd checkpoints\n" + "mismatch detail (master : apprentice):\n" + " opcode: %s vs %s\n", + signal_count, op_name(header.risu_op), + op_name(get_risuop(&ri[APPRENTICE]))); return EXIT_FAILURE; case RES_BAD_IO: - fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); + fprintf(stderr, "I/O error\n"); + return EXIT_FAILURE; + case RES_BAD_MAGIC: + fprintf(stderr, "Unexpected magic number: %#08x\n", header.magic); + return EXIT_FAILURE; + case RES_BAD_SIZE: + fprintf(stderr, "Unexpected payload size: %u\n", header.size); + return EXIT_FAILURE; + case RES_BAD_OP: + fprintf(stderr, "Unexpected opcode: %d\n", header.risu_op); return EXIT_FAILURE; - default: - fprintf(stderr, "unexpected result %d\n", res); + fprintf(stderr, "Unexpected result %d\n", res); return EXIT_FAILURE; } } From patchwork Fri Jul 8 15:46:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588580 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp825437mab; Fri, 8 Jul 2022 09:43:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vraTTW7d6PTXF5xmoBjZxuG0SEyXsCPhCYXkoBBjaUitO2mUZecWQJVFcShAsNgVCbRCzg X-Received: by 2002:a37:8a47:0:b0:6b5:561c:b90b with SMTP id m68-20020a378a47000000b006b5561cb90bmr2958237qkd.427.1657298595649; Fri, 08 Jul 2022 09:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298595; cv=none; d=google.com; s=arc-20160816; b=b1/ELgJdOhugH4g1dgKpwggjyZ5JWEsHxTuvQbEfhH9grEDc59zUPS/E20qBLNhOB3 1TxKFjbII+MOMNeQDVwiSHwtvZ1oyVF1/65PI5F0yVlKCoRrlyz5W1R6BopIkQ9MHFkv SvZIDbf6YFwLuvnx1zPbbE9uagojWZyWfGHDuEeVFl/2iho9U+ao264GfdRSIX23LXJ5 A3hVOWqKtb0gm/A4d3D3LuYnjIhSA7nts50Bf4ic/E6Jc5dECoNxVTa0/FopCny6VQ0C 9S9TjaPZqOqK1HaDOnxBQUyoaj4LuuRMjcU5m6mnT1/9WTg/9WK9vAO4TU1pm0gzTrVh YWJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=cT93Lxc9mPWCnChsVCUCuYS7cifJUMOpzXauTBVN+y4=; b=zcET+Hsa7isXOYGxBwtUhLpZWBPHeR0UOfspMhq2GDX0vwx/2ZeKRSfTuYYVgGZQlv umbokj0HcqikYf21CfWHaoNkZBfFCEWYVNgc8nIMwDIAzImssrkPSaZ8tQ4TjdivR5YH gQ1jz3U7PoSJe5e91aUElyItZLXFkLyGz6AAjv7Bgcclcjc34ojvbylVtYqvueFkmT9L qpDuCWDaLmIxFDCZ92t5Bna16IrSTgTLDDiWZLhiZhxZ/emZY7oYn3Zi6J+Y/i32JrMS HIj/LHq27wwXRE0jLYksxosEClhKZ9tHn6l7YIxLKGx7wHdJXk8bzZeV8Si7RQZjFzxb lkgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kLncZh2c; 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 x19-20020ae9f813000000b006a57a0a0143si22638152qkh.303.2022.07.08.09.43.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:43:15 -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=kLncZh2c; 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]:58484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9r4V-0000lA-5Y for patch@linaro.org; Fri, 08 Jul 2022 12:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD7-0005yd-PG for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:08 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:36643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qD5-0002X2-EK for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:05 -0400 Received: by mail-pj1-x1036.google.com with SMTP id z12-20020a17090a7b8c00b001ef84000b8bso2313765pjc.1 for ; Fri, 08 Jul 2022 08:48: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=cT93Lxc9mPWCnChsVCUCuYS7cifJUMOpzXauTBVN+y4=; b=kLncZh2cCRZ0gNjwCfYl6p1PQyezmnZItOPl8xO95pu1Ti/hLdJbXVrou1ysqmXazB 7PH9ENNq2Q5B4DeJMpxogBK0l9MYkeHiCoSBZRhkcmK9VEMZJQAetH+5Luc3G4n0inb9 LARN+uSTx4uiUHwup0IrGD6hc5c5iEwp35LUboyTZJLxBrlWbxIBv34Qpf5aoFe0hpqw C4tp7+sNjjLemzpJZ9JnbnTPg5lfeeyADPfE8iDUbLEcgKmjKPNMJhauhx+Z6rOoRp9G Wz9bi7yTWfEIMMcehYPdAIKBTtok6KK1GAbp5ntrwgD7JOUg4Go66lcXxxsC3xnC9f9+ uhXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cT93Lxc9mPWCnChsVCUCuYS7cifJUMOpzXauTBVN+y4=; b=56ty48uOle20mumGwG7910h2faCvekxIYN2KGZ7xmkX2227Rcop4sBQu+zTpC/24Me wQVmU+tDPgAVORsxr0nsK8u/0siLtUC+KBiLLSbnuukFR7u9at9yya6Va79Ojn7/U+Pi Jt/kgf27+vMHemtGajckMtiD9ryVq6mNBA4DYRDT8BDQQbB0sScU5bixgP3LDJMJypAP 1wYUCn1YDYuVZTJ+wlf0iDm1c2WSuHoqdnEeBgI6qk2xWeVCNeJSlI9GP7W5qWjEo7N1 Vm1UsVG1Wt51+JG38ei8uLagAPH/jvPbpai+VzL1MeuN0GH8x828aXXN3TcZdi2OzFE/ Qg7g== X-Gm-Message-State: AJIora+5AXlNjQ0mbgA0rtzfUZ7ijKTUqpOO2PK3GHwNQYaQyt9Mm45n WDkDBHtrcmtKGc0pt4hvQNrSPs5Dws2rRmnN X-Received: by 2002:a17:902:7402:b0:16c:9e2:3b1c with SMTP id g2-20020a170902740200b0016c09e23b1cmr4179855pll.128.1657295282168; Fri, 08 Jul 2022 08:48:02 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 18/29] Compute reginfo_size based on the reginfo Date: Fri, 8 Jul 2022 21:16:49 +0530 Message-Id: <20220708154700.18682-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Reviewed-by: Peter Maydell --- risu.h | 2 +- risu.c | 9 +++++++-- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_arm.c | 4 ++-- risu_reginfo_i386.c | 4 ++-- risu_reginfo_m68k.c | 4 ++-- risu_reginfo_ppc64.c | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/risu.h b/risu.h index bfcf0af..3cad3d5 100644 --- a/risu.h +++ b/risu.h @@ -126,6 +126,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/risu.c b/risu.c index a248db1..a70b778 100644 --- a/risu.c +++ b/risu.c @@ -125,7 +125,7 @@ static RisuResult send_register_info(void *uc) case OP_TESTEND: case OP_COMPARE: case OP_SIGILL: - header.size = reginfo_size(); + header.size = reginfo_size(&ri[MASTER]); extra = &ri[MASTER]; break; case OP_COMPAREMEM: @@ -209,7 +209,12 @@ static RisuResult recv_register_info(struct reginfo *ri) return RES_BAD_SIZE; } respond(RES_OK); - return read_buffer(ri, header.size); + res = read_buffer(ri, header.size); + if (res == RES_OK && header.size != reginfo_size(ri)) { + /* The payload size is not self-consistent with the data. */ + return RES_BAD_SIZE; + } + return res; case OP_COMPAREMEM: if (header.size != MEMBLOCKLEN) { 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..47c52e8 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,9 +36,9 @@ 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); + return sizeof(*ri); } static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 60fc239..50505ab 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,9 +74,9 @@ void process_arch_opt(int opt, const char *arg) } } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { - return sizeof(struct reginfo); + return sizeof(*ri); } static void *xsave_feature_buf(struct _xstate *xs, int feature) diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 32b28c8..4eb30cd 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,9 +23,9 @@ 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); + return sizeof(*ri); } /* reginfo_init: initialize with a ucontext */ diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 071c951..39e8f1c 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,9 +32,9 @@ 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); + return sizeof(*ri); } /* reginfo_init: initialize with a ucontext */ From patchwork Fri Jul 8 15:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588577 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp821132mab; Fri, 8 Jul 2022 09:38:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v5+4g5nu+ZkpEpc2wnbEZdFAujUsuN5JSV1s/s2oIWzkYryT/OKPqyk2/7+MjF3STnSP6w X-Received: by 2002:ae9:c019:0:b0:6b5:6b9e:2651 with SMTP id u25-20020ae9c019000000b006b56b9e2651mr1356749qkk.725.1657298281139; Fri, 08 Jul 2022 09:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298281; cv=none; d=google.com; s=arc-20160816; b=fiGpYAG4jS9fyKJfe0DHND7o0EoekpUQ3+Wt62E4Qccjo6oH5QH1w4dUJnxlWD8dTT HD548OASBKgeYwAFyHfMv0K84VBgDCORuaoeBk/032/L55jd8z40vdXrn1ODJXRAMOvr rFiGG3Ksw9uD5XgqzVj+KT67IFErWhtUlSLlX4iHLmBYITBcjdqFFXFFOA9zaiqoHr3P +Kka/qClbb+uuzp2HbgeAhcNNr/roUsBNHG1GYs+4mYVWT+b9WCMH2DuXQIvYUuofbs7 PKdFCp44JC0uVEQz9ChlEAUdJ5Y0syWtbfw2tHt+MKTaeQBjGsX3YLABAVxPBw1JkuIV RKkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=vlO0Hy0xq7x5BD/ngIXXowwVL1t8ftN3CmLzeuQQxqU=; b=BMR66sp8jS9dV6NU/4zFING1xJcduuobZdzR6jUAWBG/A3ok3dkXr37R4Gi8/fFmgZ /0+nB3uW7pKmShxPuSM350pgDpxtq6rtDs6o8yVdsjFVWKR2sXNWiskHqmXaNM1oEvy1 b43H81JXBQQMtxp5rYDTHKYA5TadpBR6ci1cDSxHPcl9ckLthKqigR52f3SxyyDojvxt /6LRTLd3XQAOkRTNuPD64hhgeVDnBOOo1L8qcq5gwABzZwj2VvwCKekQcB7qCx95A/lM w/Fpt+wU63sTIinfLuc6k346rKV5y4jf/RZItA3y0uKSXTIGe9Wb5uOvYDTKxbjKP2s6 7Hzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="k7NtZtb/"; 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 3-20020a056214202300b00473001ebfd7si11146057qvf.277.2022.07.08.09.38.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:38:01 -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="k7NtZtb/"; 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]:48486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qzQ-0001gA-Nf for patch@linaro.org; Fri, 08 Jul 2022 12:38:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD8-0005yi-Ux for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:08 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:53036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qD7-0002Ra-A4 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:06 -0400 Received: by mail-pj1-x1036.google.com with SMTP id fz10so12265977pjb.2 for ; Fri, 08 Jul 2022 08:48: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=vlO0Hy0xq7x5BD/ngIXXowwVL1t8ftN3CmLzeuQQxqU=; b=k7NtZtb/c/RkM48ccJZB8FEawARumCpACdsbVAjUMYfQBdDRkLJvoSlJBjkWs0sbop knQ1w33qO9tHTCwgcBw7LwdkhKAnHB4Aelc0jSFkbg89qLRu3iZTmLSe/2RuX+WA/x3c 3RTtUqArfNriGtvemu1ILADTB6L11CH5yFB3+eHmfT54inJlKfHrGKNrMTEGR+cJrezP cTxpMtiKlzvODNybmacg5nMuN0umBo4oiT8CEAMc0KH5rxUxrjoeFvdtx3ibsKqoXJ5j dtYJDt5hwwGcDo4FPwH1XQXLjcpeDQcl8g6fUj4Al19fYB+klYtk0a5UWL1tPXJvcmPu +9Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vlO0Hy0xq7x5BD/ngIXXowwVL1t8ftN3CmLzeuQQxqU=; b=F6z/Mlad4TEMGZMQ+2zc1ejgxaV+IsvhXfbCYqzGOPDrOms75aOIXEuP5vp8LWKgI7 e6MiHILsZJt6Lq/cWYbTQe+4mq4NXRgiLEmW6o3vFtB+KPiCyHmhyNIJm/kZsmAIhcFP zOvEfab0DHfpsLtbTDgID8i1u4doJ/MXNjglFRe6JeSZPJebhAWg3Rl7KuqMEV05hC+V pEMuFIfPBr2CrlSwlWLWrrahS6zW9jHeNaU41FZBmmLaal7APY7veJRBXSwB+2WD+jqF ptS+xQnyZ6tq6yNI157fikvSbczsnv45L/V8ClpYRyEiEJ3i0LBGVKBUn7utyNYuDs/o EtPA== X-Gm-Message-State: AJIora/gXazXOEZn819Sn3EdrtATiehyxDhdkfIMzmVWbH7dNkC3eKny BW7fjbpBLRC5rbhhmY4YjS4/NFFZjUZPRiDh X-Received: by 2002:a17:90a:474c:b0:1ec:f898:d85b with SMTP id y12-20020a17090a474c00b001ecf898d85bmr518525pjg.11.1657295284590; Fri, 08 Jul 2022 08:48:04 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 19/29] aarch64: Assume system support for SVE Date: Fri, 8 Jul 2022 21:16:50 +0530 Message-Id: <20220708154700.18682-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" SVE support is no longer new, assume it's present. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu_reginfo_aarch64.h | 4 ---- risu_reginfo_aarch64.c | 24 ------------------------ 2 files changed, 28 deletions(-) diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index c33b86f..efbca56 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -20,7 +20,6 @@ struct simd_reginfo { char end[0]; }; -#ifdef SVE_MAGIC struct sve_reginfo { /* SVE */ uint16_t vl; /* current VL */ @@ -29,7 +28,6 @@ struct sve_reginfo { 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. */ @@ -50,9 +48,7 @@ struct reginfo { union { struct simd_reginfo simd; -#ifdef SVE_MAGIC struct sve_reginfo sve; -#endif }; }; diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 7044648..16a57ba 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -24,11 +24,6 @@ #include "risu.h" #include "risu_reginfo_aarch64.h" -#ifndef SVE_MAGIC -const struct option * const arch_long_opts; -const char * const arch_extra_help; -#else - /* Should we test SVE register state */ static int test_sve; static const struct option extra_opts[] = { @@ -39,11 +34,9 @@ static const struct option extra_opts[] = { const struct option * const arch_long_opts = &extra_opts[0]; const char * const arch_extra_help = " --test-sve= Compare SVE registers with VQ\n"; -#endif void process_arch_opt(int opt, const char *arg) { -#ifdef SVE_MAGIC long want, got; assert(opt == FIRST_ARCH_OPT); @@ -64,19 +57,14 @@ void process_arch_opt(int opt, const char *arg) } exit(EXIT_FAILURE); } -#else - abort(); -#endif } 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); } -#endif return size; } @@ -86,9 +74,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) int i; struct _aarch64_ctx *ctx, *extra = NULL; struct fpsimd_context *fp = NULL; -#ifdef SVE_MAGIC struct sve_context *sve = NULL; -#endif /* necessary to be able to compare with memcmp later */ memset(ri, 0, sizeof(*ri)); @@ -110,14 +96,12 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) case FPSIMD_MAGIC: fp = (void *)ctx; break; -#ifdef SVE_MAGIC case SVE_MAGIC: sve = (void *)ctx; break; case EXTRA_MAGIC: extra = (void *)((struct extra_context *)(ctx))->datap; break; -#endif case 0: /* End of list. */ ctx = extra; @@ -137,7 +121,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) ri->fpsr = fp->fpsr; ri->fpcr = fp->fpcr; -#ifdef SVE_MAGIC if (test_sve) { int vq = test_sve; @@ -184,7 +167,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } -#endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { ri->simd.vregs[i] = fp->vregs[i]; @@ -197,7 +179,6 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) return memcmp(r1, r2, reginfo_size(r1)) == 0; } -#ifdef SVE_MAGIC static int sve_zreg_is_eq(int vq, const void *z1, const void *z2) { return memcmp(z1, z2, vq * 16) == 0; @@ -241,7 +222,6 @@ static void sve_dump_zreg_diff(FILE *f, int vq, const __uint128_t *z1, } } } -#endif /* reginfo_dump: print state to a stream, returns nonzero on success */ int reginfo_dump(struct reginfo *ri, FILE * f) @@ -259,7 +239,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpsr : %08x\n", ri->fpsr); fprintf(f, " fpcr : %08x\n", ri->fpcr); -#ifdef SVE_MAGIC if (test_sve) { int q, vq = test_sve; @@ -287,7 +266,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f) return !ferror(f); } -#endif for (i = 0; i < 32; i++) { fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", i, @@ -336,7 +314,6 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) fprintf(f, " fpcr : %08x vs %08x\n", m->fpcr, a->fpcr); } -#ifdef SVE_MAGIC if (test_sve) { int vq = sve_vq_from_vl(m->sve.vl); @@ -365,7 +342,6 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) return !ferror(f); } -#endif for (i = 0; i < 32; i++) { if (m->simd.vregs[i] != a->simd.vregs[i]) { From patchwork Fri Jul 8 15:46:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588576 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp820392mab; Fri, 8 Jul 2022 09:36:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tAgvke2BPGarMbnIAdalv4FitzDkvOUT0DjeHiruUvzkRHwp6H7fRuOvpr2FSfr1MlcD9f X-Received: by 2002:a05:6214:519d:b0:473:2532:1f5a with SMTP id kl29-20020a056214519d00b0047325321f5amr3346852qvb.59.1657298216651; Fri, 08 Jul 2022 09:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298216; cv=none; d=google.com; s=arc-20160816; b=Xx3HvT6PXwx9XQZhyLPoG4nu66oGcaYnxahUzW13jbZjoJ2Ee2gH7QzVTw4h7kGTGY 5Fp4KjtD0TugSF8AM2suY1bENIJKYmwSduhea1xLKpRHJOImeow/wLlh+JiX8Oeit+mr PLIczuBKiVFIPieQt67SBjpTznKavgHdS5LXl5ZKpuTjwgtbZDl66KyXwoTFsghEfkr3 3nnDpRE77U57/sgCnOiOHBKAdvTWjuCwtvq+OkUKSyDu1tzPNQTw3tPVCShoo2+/KCqE O4c3TMFpWVt+esBGbiJam9Fhct+AyqWmUN5Lt7Lz8HbUhUbX4em4Zpvbi0iIKXY1rhKC nA+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=loeSKEoq2daOdPkhNfaGpJOqptRl1Z7V1/Ub8FEvBaI=; b=p4oO4NhzdfZKhpbEbpGAIs6dZ8LOoxx6tg99VHdt6GOBZg3H34b0VdTczWCpo26snk Ax/rbnPaYfW6ObB34Y6HA30GZcLoadsYGBmPVNEmKxOQFkGwTdDDv4h7vFlGJ+IV9IkQ oQfxD6OYW++joeCjvsBupvp08rW4l0ogXpRdif0roYkwORfWQ+BwxFyeIPbG8kIolagy wwQzXBt2902hjGpRfZqGcYHeEZ7L0/WKg7MIq2yKYCnY84BAvFCC3PLtImVwytdOvUWF 5Pt5sEYRa4059L2SgkXM7Ng+fRzLkli9xdCcx8gs37J8sCv1Urrj0/OCLOW2xcRCAr2z toPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yAWiX0ID; 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 h22-20020a05620a245600b006af32e252d6si27977618qkn.278.2022.07.08.09.36.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:36:56 -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=yAWiX0ID; 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]:46602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qyO-00008T-4p for patch@linaro.org; Fri, 08 Jul 2022 12:36:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDC-000603-NR for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:12 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:45960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDA-0002TL-Mm for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:10 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d5so16628722plo.12 for ; Fri, 08 Jul 2022 08:48:08 -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=loeSKEoq2daOdPkhNfaGpJOqptRl1Z7V1/Ub8FEvBaI=; b=yAWiX0IDExF2W3/az9f1pb9+g5X8j3M/IFU0SQUgjQIG5zT2TaQKlW0yTc1zKc5YaH MrKYR8cQFs59MdWDICOKzQEa0JcNe6NLG9RKf1Pp/nZYyKk+2EKCpLsj1Qd/TeBhwov+ mYHQJBiFYHN+8h4nDeuYazoExfrv+RDF3Sh4Uq/914U4x75CjbB2fwL7MHbYJOooyfc7 kCfcb0DxMSrpAmcdiWqYTyiu+Y/pA7dle1rYHB4zYBhYQmOLb+camM8+ZJ1aYh+wQPu6 8BdF1qwy8EgC8aags+FeRCbmfC+cAtcV5/ESPB8sKecVSsNEpo0ZMprTpEV/b33M8JfB 6ZAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=loeSKEoq2daOdPkhNfaGpJOqptRl1Z7V1/Ub8FEvBaI=; b=wZA/bOhlrTUWWUpSBsOZFiGVfP7oaSRk1MBs7GTO8AN3w4hnl8TVj0rM1fkGP3/UlK whxGtmmUKfLsx57h4Soo+Wz4YpWIwQFzrwmCxASMo16WTWRkXcAo5E4bb7NXS8bFchG5 i1/dU5O31IL+hDORAJoynP1vN2S25Xz/be6cuqVcVGC6xNd5HaRH44AP4jhxi8pvY7bL 5CGNAJx1+GITqmx0H4eFDmovjldzmalwKB4inqKchsIcbzJrK5qCrxNi57AbBSOr5lug 75Qes6kRX57RrBS5s1X6vyaE3+mpMDs8t1LGaCf2DFtgBTNv99bzSVJUnewT8pLFg7hZ i3Hw== X-Gm-Message-State: AJIora99z4NONmS4bPn24D6i0TGd7Im1blKQjEUY9V2q3sRsOMJEJFA6 Z10GmKxkFJSgaXFkoVYKdUvvGPA2nkyaKBbV X-Received: by 2002:a17:90a:6383:b0:1ef:c181:3777 with SMTP id f3-20020a17090a638300b001efc1813777mr556182pjj.50.1657295287871; Fri, 08 Jul 2022 08:48:07 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 20/29] aarch64: Reorg sve reginfo to save space Date: Fri, 8 Jul 2022 21:16:51 +0530 Message-Id: <20220708154700.18682-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Reviewed-by: Peter Maydell --- risu_reginfo_aarch64.h | 45 ++++++----- risu_reginfo_aarch64.c | 171 ++++++++++++++++++++--------------------- 2 files changed, 108 insertions(+), 108 deletions(-) diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index efbca56..536c12b 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -13,27 +13,17 @@ #ifndef RISU_REGINFO_AARCH64_H #define RISU_REGINFO_AARCH64_H -#include /* for SVE_MAGIC */ - -struct simd_reginfo { - __uint128_t vregs[32]; - char end[0]; -}; - -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]; -}; +#include /* The kernel headers set this based on future arch extensions. The current arch maximum is 16. Save space below. */ #undef SVE_VQ_MAX #define SVE_VQ_MAX 16 +#define ROUND_UP(SIZE, POW2) (((SIZE) + (POW2) - 1) & -(POW2)) +#define RISU_SVE_REGS_SIZE(VQ) ROUND_UP(SVE_SIG_REGS_SIZE(VQ), 16) +#define RISU_SIMD_REGS_SIZE (32 * 16) + struct reginfo { uint64_t fault_address; uint64_t regs[31]; @@ -45,11 +35,28 @@ struct reginfo { /* FP/SIMD */ uint32_t fpsr; uint32_t fpcr; + uint16_t sve_vl; + uint16_t reserved; - union { - struct simd_reginfo simd; - struct sve_reginfo sve; - }; + char extra[RISU_SVE_REGS_SIZE(SVE_VQ_MAX)] + __attribute__((aligned(16))); }; +static inline uint64_t *reginfo_vreg(struct reginfo *ri, int i) +{ + return (uint64_t *)&ri->extra[i * 16]; +} + +static inline uint64_t *reginfo_zreg(struct reginfo *ri, int vq, int i) +{ + return (uint64_t *)&ri->extra[SVE_SIG_ZREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET]; +} + +static inline uint16_t *reginfo_preg(struct reginfo *ri, int vq, int i) +{ + return (uint16_t *)&ri->extra[SVE_SIG_PREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET]; +} + #endif /* RISU_REGINFO_AARCH64_H */ diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 16a57ba..81a77ba 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -61,9 +61,13 @@ void process_arch_opt(int opt, const char *arg) int reginfo_size(struct reginfo *ri) { - int size = offsetof(struct reginfo, simd.end); - if (test_sve) { - size = offsetof(struct reginfo, sve.end); + int size = offsetof(struct reginfo, extra); + + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + size += RISU_SVE_REGS_SIZE(vq); + } else { + size += RISU_SIMD_REGS_SIZE; } return size; } @@ -128,6 +132,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) fprintf(stderr, "risu_reginfo_aarch64: failed to get SVE state\n"); return; } + if (sve->vl != sve_vl_from_vq(vq)) { fprintf(stderr, "risu_reginfo_aarch64: " "unexpected SVE state: %d != %d\n", @@ -135,42 +140,22 @@ 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. */ - } else { - fprintf(stderr, "risu_reginfo_aarch64: " - "failed to get complete SVE state\n"); - } + if (sve->head.size <= SVE_SIG_CONTEXT_SIZE(0)) { + /* Only AdvSIMD state is present. */ + } else if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { + fprintf(stderr, "risu_reginfo_aarch64: " + "failed to get complete SVE state\n"); + return; + } else { + ri->sve_vl = sve->vl; + memcpy(reginfo_zreg(ri, vq, 0), + (char *)sve + SVE_SIG_REGS_OFFSET, + SVE_SIG_REGS_SIZE(vq)); 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)); - - return; } - for (i = 0; i < 32; i++) { - ri->simd.vregs[i] = fp->vregs[i]; - } + memcpy(reginfo_vreg(ri, 0), fp->vregs, RISU_SIMD_REGS_SIZE); } /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ @@ -206,18 +191,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 = " "; } } @@ -239,38 +226,41 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpsr : %08x\n", ri->fpsr); fprintf(f, " fpcr : %08x\n", ri->fpcr); - 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); + 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); } for (i = 0; i < 32; i++) { - fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", i, - (uint64_t) (ri->simd.vregs[i] >> 64), - (uint64_t) (ri->simd.vregs[i])); + uint64_t *v = reginfo_vreg(ri, i); + fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", + i, v[1], v[0]); } return !ferror(f); @@ -314,44 +304,47 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) fprintf(f, " fpcr : %08x vs %08x\n", m->fpcr, a->fpcr); } - if (test_sve) { - 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); - } + if (m->sve_vl) { + int vq = sve_vq_from_vl(m->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); } for (i = 0; i < 32; i++) { - if (m->simd.vregs[i] != a->simd.vregs[i]) { + uint64_t *mv = reginfo_vreg(m, i); + uint64_t *av = reginfo_vreg(a, i); + + if (mv[0] != av[0] || mv[1] != av[1]) { fprintf(f, " V%-2d : " "%016" PRIx64 "%016" PRIx64 " vs " - "%016" PRIx64 "%016" PRIx64 "\n", i, - (uint64_t) (m->simd.vregs[i] >> 64), - (uint64_t) m->simd.vregs[i], - (uint64_t) (a->simd.vregs[i] >> 64), - (uint64_t) a->simd.vregs[i]); + "%016" PRIx64 "%016" PRIx64 "\n", + i, mv[1], mv[0], av[1], av[0]); } } From patchwork Fri Jul 8 15:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588582 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp830111mab; Fri, 8 Jul 2022 09:49:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLwIfp3KIiIW3ZM0y0+BNLlsysd62ppjDDK8MZNYbv6KXk1w1Wvxd55RjmkWAbeA7oJS42 X-Received: by 2002:a05:620a:12c2:b0:6af:474:99b2 with SMTP id e2-20020a05620a12c200b006af047499b2mr2961955qkl.402.1657298952364; Fri, 08 Jul 2022 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298952; cv=none; d=google.com; s=arc-20160816; b=ifkMt51TdhtYn6QjdQPc8fMt3JTtOXlRbfaZfk6CXYLfQ7v729mY5MeZyxFmkTpO9L ROjpfEapwWRduxbg12Y0IKyjWLgim2SoNIousFPuZhIVy0EWsY7CfG79lq2BwqzFlKh/ MThDPZhCdEYe/Dd9bPCO8nkykNwLrTkbWopBNaTBA2GltNKUdL2NfUspypYO8kwwQhM/ wuHe3kIzzAcuh+2k3ev9pqoncJI57u61NbLkgTVCQA+lJlHbdJ2L/Y19vxNrnuJxcIaI f09jifkFvF9dyz5z5WwgI/dslHVvng6BJY8UInta/U9iAb8WIKeeZZXcZZJ1NUC29aew QS7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=OwqfXs1ctqU0QGS8GCRxY+Fnt9l80nbupzRO9DnIL6Y=; b=txPYE7iVoKMdSS1xUu1AqTSHOLIUtaHF9f1RiIyrEWs2JvaRN8PoUAEyEfZUBosFGv bC2VFFQ5kYUgfKNgS4kZd8AaPglmIyFyqyV5MceNI0ZcjQkzXXCjebHRBo9LDCZCLDPY g0yadPl+dA0pn20CQrL8XzM95Ch2YIIDiucleNtC/9LFiSg5LVVc44M+AVrK57FgSE7b EqytF+cCL+pzhm2ctpkEdlLvqp3CYU9wA9qDgwBqiDMPouyw9CAo3b8LgwK2mesxdArl z64Hujb0fSKBQwgdrcjWQwa6WuYt1hqG0UbG4Sfkn5SbaVSpZfEaJ+zHYmVBWsJXpCPK HVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v0tapvvj; 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 c19-20020ac87dd3000000b0030520ccb80fsi28096295qte.615.2022.07.08.09.49.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:49: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=v0tapvvj; 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]:38636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rAF-0006gl-TN for patch@linaro.org; Fri, 08 Jul 2022 12:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDG-000618-0j for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:14 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:46782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDD-0002VH-PQ for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:13 -0400 Received: by mail-pg1-x52d.google.com with SMTP id s27so22651756pga.13 for ; Fri, 08 Jul 2022 08:48: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=OwqfXs1ctqU0QGS8GCRxY+Fnt9l80nbupzRO9DnIL6Y=; b=v0tapvvjc/RSRu8EnB650HvpopRNbuUYSXh6pl4cfi/QTYviVdu9TzuHKXJ59YqFCv qFjTx5+QZHe6TGX7HgibiT3dzzUXwU3vtfScGb4Qo2iPYeZFhsKsnZ0LaUQi0hRHYrHw MwHD+RNE7vNM0uXMKfEPjW8QE8u33wdcEikX6w0z8axIY92/q7jzLuF6zrj8UUtHiX/h hlBahTo7hl3B0BTzqWJVnuoLOHSapnB/2+M5oL8eWL6PSzUFr7c0+YtK31sWDsaKAL9a v9wKVVi3Bd8kWi9RIu3yi0NQxL3JPMbdspw+k0vIb8e4Squr23zJVdkUPH7TSHA+ZV7/ AMiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwqfXs1ctqU0QGS8GCRxY+Fnt9l80nbupzRO9DnIL6Y=; b=m9wdXQ/qSq8+ZjmWIh9cEyPAykZgJ4XKNKrdHs26qJYHBZl8a/TwIXPxEGfSjRyWqs 4+BB4X/Zrwzk+p3B7SlgnrveguPoBIL+or2nbCEWoV/CtDykGxFRuf+a6E2PI5+xKoRf S318bPclOSFXYoXetk1TpJenkE6dAGZ13s0mzV0E942SFzmp9ZJiHAIHGn84DGkhiNnI 0WSQRyUglTdCQewbS668U77N81dCEmPlTL3vXpPU0jY5gqLGd+bLuYKYjPZWA1gJDlJp ll8cQxbnL9K4RJwh/HxoCZcJAx8QNxpb5asyGLWsR54BHFh1I5CX3O58UPIAu0CkLIcV doMA== X-Gm-Message-State: AJIora/Ie7AX1zPgIxSmUYZFDP1ZEjV0p8QPCZ3zFYsr3Af+EcN95KdN +9oruta7maPasGvUkA/YEdr5+qiZPk36gF+r X-Received: by 2002:a05:6a00:f0e:b0:528:1b63:c9be with SMTP id cr14-20020a056a000f0e00b005281b63c9bemr4562339pfb.61.1657295290997; Fri, 08 Jul 2022 08:48:10 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 21/29] aarch64: Use arch_init to configure sve Date: Fri, 8 Jul 2022 21:16:52 +0530 Message-Id: <20220708154700.18682-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. Diagnose EINVAL as either cpu or kernel does not support SVE. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.h | 1 + risu.c | 3 +++ risu_reginfo_aarch64.c | 31 ++++++++++++++++++++----------- risu_reginfo_arm.c | 4 ++++ risu_reginfo_i386.c | 4 ++++ risu_reginfo_m68k.c | 4 ++++ risu_reginfo_ppc64.c | 4 ++++ 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/risu.h b/risu.h index 3cad3d5..bdb70c1 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 a70b778..1c096a8 100644 --- a/risu.c +++ b/risu.c @@ -617,6 +617,9 @@ int main(int argc, char **argv) load_image(imgfile); + /* E.g. select requested SVE vector length. */ + arch_init(); + if (ismaster) { return master(); } else { diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 81a77ba..be47980 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "risu.h" @@ -37,8 +38,6 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { - long want, got; - assert(opt == FIRST_ARCH_OPT); test_sve = strtol(arg, 0, 10); @@ -46,16 +45,26 @@ 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)); +} + +void arch_init(void) +{ + long want, got; + + if (test_sve) { + want = sve_vl_from_vq(test_sve); + got = prctl(PR_SVE_SET_VL, want); + if (want != got) { + if (got >= 0) { + fprintf(stderr, "Unsupported VQ for SVE (%d != %d)\n", + test_sve, (int)sve_vq_from_vl(got)); + } else if (errno == EINVAL) { + fprintf(stderr, "System does not support SVE\n"); + } else { + perror("prctl PR_SVE_SET_VL"); + } + exit(EXIT_FAILURE); } - exit(EXIT_FAILURE); } } diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 47c52e8..202120b 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(*ri); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 50505ab..e9730be 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(*ri); diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 4eb30cd..4c25e77 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(*ri); diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 39e8f1c..c80e387 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(*ri); From patchwork Fri Jul 8 15:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588579 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp824985mab; Fri, 8 Jul 2022 09:42:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHjCGgmVAfSwkcpwW2pPtQl/IC/r3x+hnagPaeo5q0lJfFLVmL46aLMIKRrYdToEQePBxY X-Received: by 2002:a05:620a:27d0:b0:6af:1fed:2d10 with SMTP id i16-20020a05620a27d000b006af1fed2d10mr2928836qkp.127.1657298563411; Fri, 08 Jul 2022 09:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298563; cv=none; d=google.com; s=arc-20160816; b=u+RqhTNyr7NvYrQW7A27XkTk0121O13RplISdeXtkDX2VczFY9TrRJu40KpQdg0/z8 +ZaGQcywI4Wzaseu0d+Ya2b4m3ed3Lgo6erxPjH1uibHVNbbdIsG6NE3wbh8ozz4L9/n bdPxll8junj9FAHjB2RApIcSJ4K56Jekt5u7tJcnDVMxoWN349epl/07qTQgarcOgGSn m/u5vpX0wsHARts2MbPCaAFoT2NPVAK+R6stXE6harO21ErN/fbn9SvHuKiiqiQrPySV IMlxh0l19E1+r2KrEtblGKuLz0ACaWZBVy+/ouu72YF4YzkA4G1ZbHTPKifqtxgQ1reV zxaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=myUdBY5H3tCXb2rWK3d2K6+iu2kUnl6sA6mhAcxF+sg=; b=EABS3SolX9TyuIh6tCNvSjfKTfzUHU+weG4614ZPir9aaMGPSo5C2xvdsMnxlgO13F bmJucdGQHaa6BG0fZlHIERcYFR0qL7kDCp9WPQZGooORCC+JlZjuMIRXZeBxJXV0gGAu kSi45v02bb2bjtSfRJMKFaz4vtBqJVIiD2bkWKJufmynYd8k8L8jKLIY04v2yzVAJeVS VcHrlFGIjPeHsuLxX2o4oyyy0YKnlpfjflOhBavWtotYJYPdzpBI8/M8iWtHotQGhOfO iHaGmwCaIrJmFsf3eoLVDsGIjrLKTxcrOhceF8TXPzLldQMcU7X3xdDvj63pWUDhMeOw Q/SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rCchghh7; 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 hr13-20020a05621423cd00b00470b51c742asi25552039qvb.509.2022.07.08.09.42.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:42:43 -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=rCchghh7; 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]:56812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9r3z-00083a-0f for patch@linaro.org; Fri, 08 Jul 2022 12:42:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDK-00063t-QG for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:20 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:42655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDJ-0002Z2-7i for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:18 -0400 Received: by mail-pg1-x533.google.com with SMTP id o18so21494706pgu.9 for ; Fri, 08 Jul 2022 08:48: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=myUdBY5H3tCXb2rWK3d2K6+iu2kUnl6sA6mhAcxF+sg=; b=rCchghh7ehU5GXG+b3vmNZ3ff+p/FNFnmXx/WMgqVLAvfmjWeA4pmVn0blCirazz7C hH9MKyzDmBpDLN7oofbkhX17/Wowk4++60Kf8j9b2TPV5hhxEHqghQcm1nTELshNtpR/ 5Jsf1svcQQVj4jNAsrDsn5KPJOfcLT7lHtmF/57dw3DanFCj2xNRsm+NbgmPJEMVPkwK +sxSLC9KgD4QCtwNFf5X61uNMyBJB/+jSkURI/gezI2w//gW1Mi9o7OxBJE3GOszohHJ q/UBPZoYoszX2hfyQtQCZMm0ax6X9Bk9zIqMRAdlWGS9j1PYDqXVpeN6IDdO+mM3baxq 8Jeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=myUdBY5H3tCXb2rWK3d2K6+iu2kUnl6sA6mhAcxF+sg=; b=iIv4EAcK3vSS2qS2/x7owHBvZp54mcKuP7MZ0eM1RVih/5L3DWSfrWw5fgFyboCxRB GDEjnWgGTyJ56/JmaGMPt2qKaXKfLAczd3WGBdJYJvwmHQ4zHdli3Lf1FzmTu91Fq9IO txZvH5nkeI/AAHqOsOgectNLBIJIVO87AS5R/Duwtjfi+RwV8mwlBn4ueWznmSkq6PhJ zlWl6yQJmj1Z+MCys1/8TaCC1NTEitDjkJGCzNeiQ3d91KCpK9QCGsfj+WRVvcCmXccI mJSh2liswsAJG1zK/U1DS16qL1lWjyPE8d6vFQlA3FWLEoS4bUGzKBvHRXnJv6oAkTwH UDcQ== X-Gm-Message-State: AJIora9eihz6TI1LHrgCZMj9BKNNwo5OCcfJtOQj+OOrdJaEbjuq/t+w jvR5W22l9LN+tfA4RhF64mphNi8cvXYua9NV X-Received: by 2002:a05:6a00:1941:b0:50d:807d:530b with SMTP id s1-20020a056a00194100b0050d807d530bmr4354348pfk.17.1657295294218; Fri, 08 Jul 2022 08:48:14 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 22/29] ppc64: Use uint64_t to represent double Date: Fri, 8 Jul 2022 21:16:53 +0530 Message-Id: <20220708154700.18682-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-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-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We want to do exact bitwise comparisons of the data, not be held hostage to IEEE comparisons and NaNs. Signed-off-by: Richard Henderson Reviewed-by: Matheus Ferst --- risu_reginfo_ppc64.h | 3 ++- risu_reginfo_ppc64.c | 29 +++++++++-------------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/risu_reginfo_ppc64.h b/risu_reginfo_ppc64.h index 7f2c962..4b1d8bd 100644 --- a/risu_reginfo_ppc64.h +++ b/risu_reginfo_ppc64.h @@ -20,7 +20,8 @@ struct reginfo { uint64_t nip; uint64_t prev_addr; gregset_t gregs; - fpregset_t fpregs; + uint64_t fpregs[32]; + uint64_t fpscr; vrregset_t vrregs; }; diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index c80e387..9899b36 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -45,6 +45,7 @@ int reginfo_size(struct reginfo *ri) void reginfo_init(struct reginfo *ri, ucontext_t *uc) { int i; + memset(ri, 0, sizeof(*ri)); ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.regs->nip); @@ -54,16 +55,11 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) ri->gregs[i] = uc->uc_mcontext.gp_regs[i]; } - for (i = 0; i < NFPREG; i++) { - ri->fpregs[i] = uc->uc_mcontext.fp_regs[i]; - } + memcpy(ri->fpregs, uc->uc_mcontext.fp_regs, 32 * sizeof(double)); + ri->fpscr = uc->uc_mcontext.fp_regs[32]; - for (i = 0; i < 32; i++) { - ri->vrregs.vrregs[i][0] = uc->uc_mcontext.v_regs->vrregs[i][0]; - ri->vrregs.vrregs[i][1] = uc->uc_mcontext.v_regs->vrregs[i][1]; - ri->vrregs.vrregs[i][2] = uc->uc_mcontext.v_regs->vrregs[i][2]; - ri->vrregs.vrregs[i][3] = uc->uc_mcontext.v_regs->vrregs[i][3]; - } + memcpy(ri->vrregs.vrregs, uc->uc_mcontext.v_regs->vrregs, + sizeof(ri->vrregs.vrregs[0]) * 32); ri->vrregs.vscr = uc->uc_mcontext.v_regs->vscr; ri->vrregs.vrsave = uc->uc_mcontext.v_regs->vrsave; } @@ -91,10 +87,6 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) } for (i = 0; i < 32; i++) { - if (isnan(m->fpregs[i]) && isnan(a->fpregs[i])) { - continue; - } - if (m->fpregs[i] != a->fpregs[i]) { return 0; } @@ -141,10 +133,10 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, "\tdscr : %16lx\n\n", ri->gregs[44]); for (i = 0; i < 16; i++) { - fprintf(f, "\tf%2d: %.4f\tf%2d: %.4f\n", i, ri->fpregs[i], + fprintf(f, "\tf%2d: %016lx\tf%2d: %016lx\n", i, ri->fpregs[i], i + 16, ri->fpregs[i + 16]); } - fprintf(f, "\tfpscr: %f\n\n", ri->fpregs[32]); + fprintf(f, "\tfpscr: %016lx\n\n", ri->fpscr); for (i = 0; i < 32; i++) { fprintf(f, "vr%02d: %8x, %8x, %8x, %8x\n", i, @@ -181,13 +173,10 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) } for (i = 0; i < 32; i++) { - if (isnan(m->fpregs[i]) && isnan(a->fpregs[i])) { - continue; - } - if (m->fpregs[i] != a->fpregs[i]) { fprintf(f, "Mismatch: Register f%d\n", i); - fprintf(f, "m: [%f] != a: [%f]\n", m->fpregs[i], a->fpregs[i]); + fprintf(f, "m: [%016lx] != a: [%016lx]\n", + m->fpregs[i], a->fpregs[i]); } } From patchwork Fri Jul 8 15:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588583 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp835064mab; Fri, 8 Jul 2022 09:56:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKEKejPM65zV9KdTMmWz1w12hkcZMN2olNgJf45VwOuq68ckA7J8k+oNKUZS7x4EBLMEdr X-Received: by 2002:a05:622a:1905:b0:31e:a245:4f1c with SMTP id w5-20020a05622a190500b0031ea2454f1cmr3969221qtc.598.1657299371252; Fri, 08 Jul 2022 09:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657299371; cv=none; d=google.com; s=arc-20160816; b=mLs46+urgodlbDjVSTvbMcEukojjYojL4fXecbCyQLev5bTwqItlmWmVWf2YMcn+rT 64jAeSlZmCCj76pyVewdJnoKl138zxrHlXWmTdaGToH03vRYnZ0AD71vSlTeoUPKopPe 5nAV1WlmYvFrSqIhCeQuffSDjz1TBm7wMi6tfX/ZqnKhFwHinWQMDPEM/PupM+mncr17 cBXYBuixtRW1vM9L+aAx5ix6w/QSYHP5ydj1XFEFB46ZRYWRidnjzmYZlaxbVNBc5WoJ y2jnNU7q21LwueYteBbyxURHz/+HWdi/NpBTlPwt+zFLtfemdlzyrIEZcoovJe+6mnM0 h05w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=OYX/d+01tGy3cBxW/0xpcYjEwZc6/OMjB3i/YA7k0a4=; b=h2B2JeUPkGRFGcZgJHbwUyRvqx8205oZ7rHh5L9v4BkIH+/WzLFlCjc/E95A+In7il wYwWEynK3emMC54cHc9+DrW/h1ZVoG6irhbg3ybuMNBpOH378+tnWm/jz7J15yzsHRKL A5vEAAUJs86Ns86E7fIZIxtt1N62lG3xt+KHUSU/s5M8yTHX1/5l/nGdLXXNkD1e0oaQ AcdUXbY2GVrtzLcBDjKszzsNkF4KUKyeLy/katlGu6UtT7MElkcx2l7UcreFdry84mR6 t8SG+EkZPsX8VnU1uy8nKk+7z9fGBgXxYE3HXRN8jRaL30PJkQpIea4Ag5+OeCKGx6s0 ub5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SQ593bbc; 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 kl27-20020a056214519b00b004731c231a20si4752211qvb.179.2022.07.08.09.56.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:56:11 -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=SQ593bbc; 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]:45452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rH0-0003l5-NN for patch@linaro.org; Fri, 08 Jul 2022 12:56:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDM-00065a-LS for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:20 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:51735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDK-0002ZH-98 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:20 -0400 Received: by mail-pj1-x1032.google.com with SMTP id o15so13889915pjh.1 for ; Fri, 08 Jul 2022 08:48: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=OYX/d+01tGy3cBxW/0xpcYjEwZc6/OMjB3i/YA7k0a4=; b=SQ593bbcqoAQar/qHavBiBV3rQAYb1ufwNzL/zbCJDVwDWa7Pg8sFk6tlrYxJWNemW UTYvPPYRzU1DwFFDy5Mfdvh0iFc19pl9yoY9pOQ/gabJH1IiU8/jH0QSTge4WjK7YU+j efasqkOi/QirKx/y4ab3YLpcwURnG5i1Dw3cAe/LxDOinwS0TVPkpYRt6yJPfYZ3ktx/ NO5mY/r6j160lMcpUiMb2N+D6kO/FkBx2blJiwEj8ncNcJSdPeujE6sBQlIFbPolda7A +hY3jvYVCrEjin/8ZrkdCQOkNZMdwUlo22GJSTJKA8Okr2U7dfozT/OLm4vQx/UM+lkh 7y5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OYX/d+01tGy3cBxW/0xpcYjEwZc6/OMjB3i/YA7k0a4=; b=auBsL2KvaflgFDNKuyxqsZ2R7/RIYh1gLSNHl/lGkYZOoCnTpmfksMmU7aGZc0oPqi +SP0WBX/atvcUqBBETdtNra1YqTlLuy7M8vzM4ov7st+E7qRLhL4ol1+gzK00dNMPitv u6pX15PCOQ5RuM66RzL0aZtATqLiqAI/2Kx6O38vX3LDjsHjClY1z5USTTsS7+7Ub4GV mDw25Nkfh7CDUji640OGgeKGuPQAMseMPDljn8NmK0G+K50zOZh7ISJ1oO6XJuP6lz3I a1u3Bv/Gw2JfIWw69TF89et4DysrdWGOYr19evexlYXeGxyrPc8MeNW8WMPw3CBW6xLA Dzog== X-Gm-Message-State: AJIora+u0hKtHu6fqb34+tycmkxp/78Qpjr2chQVUtdH3PLZNmMX7V2l 7jD04qJ/ri5V5rmvbDbVyG6pa4N6RLxBFD/M X-Received: by 2002:a17:90a:9d8a:b0:1ef:7a8d:1808 with SMTP id k10-20020a17090a9d8a00b001ef7a8d1808mr496746pjp.135.1657295296928; Fri, 08 Jul 2022 08:48:16 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 23/29] Standardize reginfo_dump_mismatch printing Date: Fri, 8 Jul 2022 21:16:54 +0530 Message-Id: <20220708154700.18682-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hoist the "master vs apprentice" label to apprentice(), since we will want different labels for dumping. Remove all of the "mismatch" text from reginfo_dump_mismatch -- just print "vs". Signed-off-by: Richard Henderson --- risu.h | 4 ++-- risu.c | 1 + risu_reginfo_aarch64.c | 12 +++++------- risu_reginfo_arm.c | 18 ++++++++--------- risu_reginfo_i386.c | 6 +----- risu_reginfo_m68k.c | 23 +++++++--------------- risu_reginfo_ppc64.c | 44 ++++++++++++++++++------------------------ 7 files changed, 44 insertions(+), 64 deletions(-) diff --git a/risu.h b/risu.h index bdb70c1..99f0d8e 100644 --- a/risu.h +++ b/risu.h @@ -123,8 +123,8 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2); /* print reginfo state to a stream, returns 1 on success, 0 on failure */ int reginfo_dump(struct reginfo *ri, FILE * f); -/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); +/* reginfo_dump_mismatch: print mismatch details to a stream */ +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); /* return size of reginfo */ int reginfo_size(struct reginfo *ri); diff --git a/risu.c b/risu.c index 1c096a8..f613fa9 100644 --- a/risu.c +++ b/risu.c @@ -449,6 +449,7 @@ static int apprentice(void) reginfo_dump(&ri[MASTER], stderr); fprintf(stderr, "apprentice reginfo:\n"); reginfo_dump(&ri[APPRENTICE], stderr); + fprintf(stderr, "mismatch detail (master : apprentice):\n"); reginfo_dump_mismatch(&ri[MASTER], &ri[APPRENTICE], stderr); return EXIT_FAILURE; diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index be47980..e0f80c0 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -275,15 +275,15 @@ int reginfo_dump(struct reginfo *ri, FILE * f) return !ferror(f); } -/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) { int i; - fprintf(f, "mismatch detail (master : apprentice):\n"); + if (m->faulting_insn != a->faulting_insn) { - fprintf(f, " faulting insn mismatch %08x vs %08x\n", + fprintf(f, " faulting insn: %08x vs %08x\n", m->faulting_insn, a->faulting_insn); } + for (i = 0; i < 31; i++) { if (m->regs[i] != a->regs[i]) { fprintf(f, " X%-2d : %016" PRIx64 " vs %016" PRIx64 "\n", @@ -342,7 +342,7 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) sve_dump_preg_diff(f, vq, pm, pa); } } - return !ferror(f); + return; } for (i = 0; i < 32; i++) { @@ -356,6 +356,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) i, mv[1], mv[0], av[1], av[0]); } } - - return !ferror(f); } diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 202120b..ba1035e 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -183,32 +183,33 @@ int reginfo_dump(struct reginfo *ri, FILE *f) return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { int i; - fprintf(f, "mismatch detail (master : apprentice):\n"); if (m->faulting_insn_size != a->faulting_insn_size) { - fprintf(f, " faulting insn size mismatch %d vs %d\n", + fprintf(f, " faulting insn size: %d vs %d\n", m->faulting_insn_size, a->faulting_insn_size); } else if (m->faulting_insn != a->faulting_insn) { if (m->faulting_insn_size == 2) { - fprintf(f, " faulting insn mismatch %04x vs %04x\n", + fprintf(f, " faulting insn: %04x vs %04x\n", m->faulting_insn, a->faulting_insn); } else { - fprintf(f, " faulting insn mismatch %08x vs %08x\n", + fprintf(f, " faulting insn: %08x vs %08x\n", m->faulting_insn, a->faulting_insn); } } + for (i = 0; i < 16; i++) { if (m->gpreg[i] != a->gpreg[i]) { - fprintf(f, " r%d: %08x vs %08x\n", i, m->gpreg[i], - a->gpreg[i]); + fprintf(f, " r%d: %08x vs %08x\n", i, m->gpreg[i], a->gpreg[i]); } } + if (m->cpsr != a->cpsr) { fprintf(f, " cpsr: %08x vs %08x\n", m->cpsr, a->cpsr); } + for (i = 0; i < 32; i++) { if (m->fpregs[i] != a->fpregs[i]) { fprintf(f, " d%d: %016llx vs %016llx\n", i, @@ -216,9 +217,8 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) (unsigned long long) a->fpregs[i]); } } + if (m->fpscr != a->fpscr) { fprintf(f, " fpscr: %08x vs %08x\n", m->fpscr, a->fpscr); } - - return !ferror(f); } diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index e9730be..57e4c00 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -349,14 +349,12 @@ int reginfo_dump(struct reginfo *ri, FILE *f) return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { int i, j, n, w; uint64_t features; char r; - fprintf(f, "Mismatch (master v apprentice):\n"); - for (i = 0; i < NGREG; i++) { if (m->gregs[i] != a->gregs[i]) { assert(regname[i]); @@ -399,6 +397,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) i, m->kregs[i], a->kregs[i]); } } - - return !ferror(f); } diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 4c25e77..29edce9 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -118,13 +118,12 @@ int reginfo_dump(struct reginfo *ri, FILE *f) return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { int i; if (m->gregs[R_PS] != a->gregs[R_PS]) { - fprintf(f, "Mismatch: Register PS\n"); - fprintf(f, "master: [%x] - apprentice: [%x]\n", + fprintf(f, " PS: %08x vs %08x\n", m->gregs[R_PS], a->gregs[R_PS]); } @@ -133,22 +132,18 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) continue; } if (m->gregs[i] != a->gregs[i]) { - fprintf(f, "Mismatch: Register %c%d\n", i < 8 ? 'D' : 'A', - i % 8); - fprintf(f, "master: [%x] - apprentice: [%x]\n", m->gregs[i], - a->gregs[i]); + fprintf(f, " %c%d: %08x vs %08x\n", + i < 8 ? 'D' : 'A', i % 8, m->gregs[i], a->gregs[i]); } } if (m->fpregs.f_pcr != a->fpregs.f_pcr) { - fprintf(f, "Mismatch: Register FPCR\n"); - fprintf(f, "m: [%04x] != a: [%04x]\n", + fprintf(f, " FPCR: %04x vs %04x\n", m->fpregs.f_pcr, a->fpregs.f_pcr); } if (m->fpregs.f_psr != a->fpregs.f_psr) { - fprintf(f, "Mismatch: Register FPSR\n"); - fprintf(f, "m: [%08x] != a: [%08x]\n", + fprintf(f, " FPSR: %04x vs %04x\n", m->fpregs.f_psr, a->fpregs.f_psr); } @@ -156,14 +151,10 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) if (m->fpregs.f_fpregs[i][0] != a->fpregs.f_fpregs[i][0] || m->fpregs.f_fpregs[i][1] != a->fpregs.f_fpregs[i][1] || m->fpregs.f_fpregs[i][2] != a->fpregs.f_fpregs[i][2]) { - fprintf(f, "Mismatch: Register FP%d\n", i); - fprintf(f, "m: [%08x %08x %08x] != a: [%08x %08x %08x]\n", + fprintf(f, " FP%d: %08x%08x%08x vs %08x%08x%08x\n", i, m->fpregs.f_fpregs[i][0], m->fpregs.f_fpregs[i][1], m->fpregs.f_fpregs[i][2], a->fpregs.f_fpregs[i][0], a->fpregs.f_fpregs[i][1], a->fpregs.f_fpregs[i][2]); } } - - - return !ferror(f); } diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 9899b36..e96dc48 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -27,6 +27,15 @@ const struct option * const arch_long_opts; const char * const arch_extra_help; +static const char * const greg_names[NGREG] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", + [XER] = "xer", + [CCR] = "ccr", +}; + void process_arch_opt(int opt, const char *arg) { abort(); @@ -147,35 +156,21 @@ int reginfo_dump(struct reginfo *ri, FILE * f) return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { int i; - for (i = 0; i < 32; i++) { - if (i == 1 || i == 13) { - continue; + + for (i = 0; i < NGREG; i++) { + if (greg_names[i] != NULL && m->gregs[i] != a->gregs[i]) { + fprintf(f, "%6s: %016lx vs %016lx\n", + greg_names[i], m->gregs[i], a->gregs[i]); } - - if (m->gregs[i] != a->gregs[i]) { - fprintf(f, "Mismatch: Register r%d\n", i); - fprintf(f, "master: [%lx] - apprentice: [%lx]\n", - m->gregs[i], a->gregs[i]); - } - } - - if (m->gregs[XER] != a->gregs[XER]) { - fprintf(f, "Mismatch: XER\n"); - fprintf(f, "m: [%lx] != a: [%lx]\n", m->gregs[XER], a->gregs[XER]); - } - - if (m->gregs[CCR] != a->gregs[CCR]) { - fprintf(f, "Mismatch: Cond. Register\n"); - fprintf(f, "m: [%lx] != a: [%lx]\n", m->gregs[CCR], a->gregs[CCR]); } for (i = 0; i < 32; i++) { if (m->fpregs[i] != a->fpregs[i]) { - fprintf(f, "Mismatch: Register f%d\n", i); - fprintf(f, "m: [%016lx] != a: [%016lx]\n", + fprintf(f, "%*s%d: %016lx vs %016lx\n", + 6 - (i < 10 ? 1 : 2), "f", i, m->fpregs[i], a->fpregs[i]); } } @@ -186,13 +181,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { - fprintf(f, "Mismatch: Register vr%d\n", i); - fprintf(f, "m: [%x, %x, %x, %x] != a: [%x, %x, %x, %x]\n", + fprintf(f, "%*s%d: %08x%08x%08x%08x vs %08x%08x%08x%08x\n", + 6 - (i < 10 ? 1 : 2), "vr", i, m->vrregs.vrregs[i][0], m->vrregs.vrregs[i][1], m->vrregs.vrregs[i][2], m->vrregs.vrregs[i][3], a->vrregs.vrregs[i][0], a->vrregs.vrregs[i][1], a->vrregs.vrregs[i][2], a->vrregs.vrregs[i][3]); } } - return !ferror(f); } From patchwork Fri Jul 8 15:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588581 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp828837mab; Fri, 8 Jul 2022 09:47:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6RCWPTEgKG9gmq8p0IIwfHhZKN/R0YxnRcWZxZzSiu76vsIoQbYtcd8lrPX4LOgBRjLTY X-Received: by 2002:a37:8904:0:b0:6af:199b:bcb with SMTP id l4-20020a378904000000b006af199b0bcbmr3123681qkd.462.1657298849195; Fri, 08 Jul 2022 09:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298849; cv=none; d=google.com; s=arc-20160816; b=F4kVnTM1dLZl00FQ2TMzuwGzuLDnvDcamfquWcksufGkxVFLpFj5kNdfVn74yfrXo/ lNMSUSEnF/lkaVE6VyWl+mB03XARc6j6MfViH7EwwlqhQAWIQ5dcgJ0BFlrm9l0PnlCC mq4dBCGEuLs8oH08kMTXLZi7Y54JNhEGedgKs2AebQglEudz9odCjBx0wzkP1HR+e40V cT0r4oSejavVB91ykDP//64R4OS5bwQ2N3Lr93M7OlaAEHd6DIC3l6ErizhtefQzcYf8 UFKtal+voVfmZjnvdQr5JBshzOcY05WAcVLZDSZY2bLu3N6Obve2HoHa9D136jRi1NO3 wpYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=0Z/3Dbr+/QrC8cn7TV42VKcjGJrg87Itb54NG8zLcNw=; b=GW6AS/dNDJzmFjgbCrvNDZajzWsGbHyyxAsEWyx/ydNyZ98xBMZ9SoE+BkqfMVM4fv G/u9AChPwLEJpyh1lOqYpQ69lUgguZcseYflMQGh29mTqlDw/C1Sv1gkSBJJWx6KIfsG YZoZNsCMvYDtGGw6iQH3JmKS0e8WsfFQ6TGCeXuE+lkjxpEjYRfUCefGnuCMIc+15KiY oWmONSHSldQkL7E6N79BQioWqJdVp/CgMvYjNe5ncC7cosbhLO/fWJ9u/MGr4wQhl3Rg HiB43oG8aul9F4hO9a6tBLqq2IFLqcvh2MqHMZExxVBqp0IUNfQWLbeVwx6kVKcxzKEH GxvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p4hQzLPI; 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 d7-20020ac85ac7000000b00317ccfa2fadsi28831656qtd.283.2022.07.08.09.47.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:47:29 -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=p4hQzLPI; 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]:37746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9r8W-0005lw-Gm for patch@linaro.org; Fri, 08 Jul 2022 12:47:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDO-0006Bq-6K for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:22 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:40715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDM-0002Y0-5W for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:21 -0400 Received: by mail-pl1-x62c.google.com with SMTP id b2so16657171plx.7 for ; Fri, 08 Jul 2022 08:48:19 -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=0Z/3Dbr+/QrC8cn7TV42VKcjGJrg87Itb54NG8zLcNw=; b=p4hQzLPICnUpOLOSIrooAeEV0I8IJaC4V251azmGcCkHvDgFr7/cH8NBU/8NW1uo9U +nq2VtFp5QVd5IW5+tc9s/+EqW0XwSRTsAo1kj+VlV4ixGQ5aXTH8P0ZPQyLrcRZ5Sht R+d8zn6hTwXOXcgdG68c+6gsZ/jsczH2dkGHQJ+WmqBaeHMruVuGBRt40/LoIBl9JFdm xy+RLOW98ztWgNt95dbKm2kv2v2cHRrG8a4rIwRwbrIs9HFwoGjxi8PQt7pxEqFcyXvr 8c1taC1xusBFFxSba6E4Yibj09WB7fLqIMdUI6f1/3iU2e0Nu9Xo9nqJu2BkwzXNNiWG MlFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Z/3Dbr+/QrC8cn7TV42VKcjGJrg87Itb54NG8zLcNw=; b=fmLAKr2jq/2d9swLL1itcrOsMk+OFMMso89PuoZa9SU8XEILSjCnIFUEDiWCWWgToV IyQJ5AX/lARx/hzRHcu+KIEQr0rI68/LxA74KRf6/iVDGYSQ2gcPc+/7x0LB2Hm2hWP2 ve92tXNC8C2+x5qAzPPgri0iaURDtH76bCfz4W282GYlYtZGLfQsQMDM9Xr31v9w5B8J z4HD0oxcv3WAc0tydieNZhS41qA3+90XPbe2Ygqqp1l05rKzS8KcFN6qGnnQdQnhlUNc xb/y4oct0kUNyNaUAeoYGDBONjXBYo/qv9FmuKKcnaDkqHt1HsI2cjdUDgkbtPYcWJE8 Kgfw== X-Gm-Message-State: AJIora/w0Y1iNSPTC0VXrytwaOpIyOBWsVmk1tnfunKmu/1Woam8V7L/ WneweKkXPtlq3+86VigobuRE7TzdPMjFMG5h X-Received: by 2002:a17:903:228b:b0:16b:ee10:b91 with SMTP id b11-20020a170903228b00b0016bee100b91mr4445375plh.27.1657295299400; Fri, 08 Jul 2022 08:48:19 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 24/29] Add --fulldump and --diffdup options Date: Fri, 8 Jul 2022 21:16:55 +0530 Message-Id: <20220708154700.18682-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These allow the inspection of the trace files. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/risu.c b/risu.c index f613fa9..8d907d9 100644 --- a/risu.c +++ b/risu.c @@ -484,23 +484,101 @@ static int apprentice(void) } } -static int ismaster; +static int dump_trace(bool isfull) +{ + RisuResult res; + int tick = 0; + + while (1) { + struct reginfo *this_ri; + + this_ri = &ri[tick & 1]; + res = recv_register_info(this_ri); + + switch (res) { + case RES_OK: + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + case OP_SIGILL: + printf("%s: (pc %#lx)\n", op_name(header.risu_op), + (unsigned long)header.pc); + + if (isfull || tick == 0) { + reginfo_dump(this_ri, stdout); + } else { + struct reginfo *prev_ri = &ri[(tick - 1) & 1]; + + if (reginfo_is_eq(prev_ri, this_ri)) { + /* + * ??? There should never be no change -- at minimum + * PC should have advanced. But for completeness... + */ + printf("change detail: none\n"); + } else { + printf("change detail (prev : next):\n"); + reginfo_dump_mismatch(prev_ri, this_ri, stdout); + } + } + putchar('\n'); + if (header.risu_op == OP_TESTEND) { + return EXIT_SUCCESS; + } + tick++; + break; + + case OP_COMPAREMEM: + /* TODO: Dump 8k of data? */ + /* fall through */ + default: + printf("%s\n", op_name(header.risu_op)); + break; + } + break; + + case RES_BAD_IO: + fprintf(stderr, "I/O error\n"); + return EXIT_FAILURE; + case RES_BAD_MAGIC: + fprintf(stderr, "Unexpected magic number: %#08x\n", header.magic); + return EXIT_FAILURE; + case RES_BAD_SIZE: + fprintf(stderr, "Unexpected payload size: %u\n", header.size); + return EXIT_FAILURE; + case RES_BAD_OP: + fprintf(stderr, "Unexpected opcode: %d\n", header.risu_op); + return EXIT_FAILURE; + default: + fprintf(stderr, "Unexpected recv result %d\n", res); + return EXIT_FAILURE; + } + } +} + +enum { + DO_APPRENTICE, + DO_MASTER, + DO_FULLDUMP, + DO_DIFFDUMP, +}; + +static int operation = DO_APPRENTICE; static void usage(void) { fprintf(stderr, - "Usage: risu [--master] [--host ] [--port ] " - "\n\n"); - fprintf(stderr, - "Run through the pattern file verifying each instruction\n"); - fprintf(stderr, "between master and apprentice risu processes.\n\n"); - fprintf(stderr, "Options:\n"); - fprintf(stderr, " --master Be the master (server)\n"); - fprintf(stderr, " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n"); - fprintf(stderr, - " -h, --host=HOST Specify master host machine (apprentice only)" - "\n"); - fprintf(stderr, + "Usage: risu [--master|--fulldump|--diffdump]\n" + " [--host ] [--port ] \n" + "\n" + "Run through the pattern file verifying each instruction\n" + "between master and apprentice risu processes.\n" + "\n" + "Options:\n" + " --master Be the master (server)\n" + " --fulldump Dump each record\n" + " --diffdump Dump difference between each record\n" + " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n" + " -h, --host=HOST Specify master host machine\n" " -p, --port=PORT Specify the port to connect to/listen on " "(default 9191)\n"); if (arch_extra_help) { @@ -512,7 +590,9 @@ static struct option * setup_options(char **short_opts) { static struct option default_longopts[] = { {"help", no_argument, 0, '?'}, - {"master", no_argument, &ismaster, 1}, + {"master", no_argument, &operation, DO_MASTER}, + {"fulldump", no_argument, &operation, DO_FULLDUMP}, + {"diffdump", no_argument, &operation, DO_DIFFDUMP}, {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"trace", required_argument, 0, 't'}, @@ -520,7 +600,7 @@ static struct option * setup_options(char **short_opts) }; 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); @@ -551,6 +631,7 @@ int main(int argc, char **argv) char *trace_fn = NULL; struct option *longopts; char *shortopts; + bool ismaster; longopts = setup_options(&shortopts); @@ -586,6 +667,8 @@ int main(int argc, char **argv) } } + ismaster = operation == DO_MASTER; + if (trace) { if (strcmp(trace_fn, "-") == 0) { comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; @@ -609,6 +692,10 @@ int main(int argc, char **argv) } } + if (operation == DO_FULLDUMP || operation == DO_DIFFDUMP) { + return dump_trace(operation == DO_FULLDUMP); + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); From patchwork Fri Jul 8 15:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588585 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp841268mab; Fri, 8 Jul 2022 10:02:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tXqZy08vOmcgXpgEXdjpVZ8DOtqSSDdwhAhi0kQrbFnCQ1ywfcCzqaRqU47baPbfJMhMn9 X-Received: by 2002:ac8:5b15:0:b0:31d:ab7e:a63d with SMTP id m21-20020ac85b15000000b0031dab7ea63dmr3882186qtw.164.1657299763193; Fri, 08 Jul 2022 10:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657299763; cv=none; d=google.com; s=arc-20160816; b=PkW137A0ZfTCCwnvjh80Kd0Edewt5E6xbWlypPXPZcwXNih8Gr6DEfGBCRSpTqLGy3 xTq74kt4x+yVMM0JILUKz7yW9lpOYyCUNSKFq+ystbyNyIN0/dhl4qiAafMOQ2iTM4Ze 9aNti6tk6I4ifVQ+MfEQ2Hrgi9oJBD+I5oh2bgbLIP8Kixp1YZfqgQ1x5qyaC4MEgCjv shRc/uEJmPzhRQ3szXYK87trwQkToGbfZB9CiQ5BRsckkFC01tqOr3eBSLmociAh/f2x Rpayo1NNG32KJP25ces9brglte/jicY6N4VBsTxgjdiP2D9+N7+67vdThxn1po1f4LjN J91A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=KHCjODk+vnGajKdN8rNYoLNgAJ6Sd7+uxGwpqklP/xM=; b=nU6MYH7KQvvHFUWv+JfqX6qzl5Y/8eKyvA/QKLCKLbS9X5rmeHcAkQzBfY/BdVYzjh 7y6kEnYIUaaLMVkqA/EXLL0T7H1GDifedkGyd+8UrSyaHpu6hC6whATyrsU8XGBLDbSJ 0Hz16VxejVUK3ffI+yRL4548tQ12b0egAc9fe4KudbeEV3uPOD+Ea9zF3AJ5mXK4jJOO tecXCHH5O8gsqaNLhkLMyiKPuiqGboVynObgi8f/cdseEIs2k0p9J/o3Ms1lk4n6/1G4 rBeOBM+/99XGrCUjKFdFsEonK+8GcCvLEAv88+jNAgoddiBCL3F1dSjAMWQdhTMIOTlg H8Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NMEfns2B; 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 t14-20020a37ea0e000000b006b263cd9f07si10972158qkj.735.2022.07.08.10.02.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 10:02:43 -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=NMEfns2B; 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]:52968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rNK-0000i8-Nr for patch@linaro.org; Fri, 08 Jul 2022 13:02:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDQ-0006MG-DM for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:24 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:35622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDO-0002XV-Lu for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:24 -0400 Received: by mail-pl1-x62c.google.com with SMTP id y18so8656098plb.2 for ; Fri, 08 Jul 2022 08:48:22 -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=KHCjODk+vnGajKdN8rNYoLNgAJ6Sd7+uxGwpqklP/xM=; b=NMEfns2BwCLb6OTZ9xSuMWVCZS6t/zVm7cN4YZ3Oqr8Hv6/XBGSA6h/dmCzS2cjtil 76WKGeB9oNxaW35tW10OgsV/Vcn8UVrkIG6vRmzmC2DkTHnS3vL32hnDxX4aaEH7riXU pHm1FQtgc927o+jITFmqg3Yk/J898pnJY0gR3yyTcpkhBBpE7lcFmSyKtGoJvhFcbqGP ahtLXhS+8wpXQJc8nUDvWC/ueOB5woZRb4IBokFk2+A5b+7GM3AVMz/GvJw2QW39yASL nU3DemIPREZauSulb4tnkYSh3RS1/snVkQBLAtA9DowmprN+3dTa7sFBiJI7gGjPo9V+ MwYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KHCjODk+vnGajKdN8rNYoLNgAJ6Sd7+uxGwpqklP/xM=; b=UIA/KrOS8ZSLt16UAzA5zZLDs9gf0KVNLmPF+lVHe4g5lNKvkKWrZbXLbAnQA9HSEk KLKC48rL3fhLM0Aj80OiMN7dW/w81wnrTsObeor5mgePw+39h7vxftLHeQOiDN9oorK4 XX4jY7hOf57YVYwMmNW4SoL3g1eJ123kYEW/EqSl0zuMFFenZ7KWxiX0Rqvu/cMe2jVH FEKOYEoMljakpTPtKnZoYhAWnV33FOuK/v+6FlyRNwzPd83pXE+wTWUlRCdwYjdrSIPl V2R6JOg2ybmCzI9bKEMUAEKgp9wS7dgQbHDpiueAvdJjx3Mk+EWCntuA9jdXVq2oD89h GKYQ== X-Gm-Message-State: AJIora/so5FGOBbFMRguZWBCEL9A9sPR5zkFmNicAyeShICehMqeSM2s CL5rrCLC7oLYKW3IzHaoVOuiy35H+FjKJwKz X-Received: by 2002:a17:90a:be0c:b0:1ef:accb:23a5 with SMTP id a12-20020a17090abe0c00b001efaccb23a5mr490128pjs.113.1657295301876; Fri, 08 Jul 2022 08:48:21 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 25/29] Remove return value from reginfo_dump Date: Fri, 8 Jul 2022 21:16:56 +0530 Message-Id: <20220708154700.18682-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" No uses actually checked the error indication. Even if we wanted to check ferror on the stream, we should do that generically rather than per arch. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.h | 4 ++-- risu_reginfo_aarch64.c | 8 +++----- risu_reginfo_arm.c | 6 ++---- risu_reginfo_i386.c | 6 ++---- risu_reginfo_m68k.c | 6 ++---- risu_reginfo_ppc64.c | 6 ++---- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/risu.h b/risu.h index 99f0d8e..6eceb9f 100644 --- a/risu.h +++ b/risu.h @@ -120,8 +120,8 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc); /* return 1 if structs are equal, 0 otherwise. */ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2); -/* print reginfo state to a stream, returns 1 on success, 0 on failure */ -int reginfo_dump(struct reginfo *ri, FILE * f); +/* print reginfo state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE *f); /* reginfo_dump_mismatch: print mismatch details to a stream */ void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index e0f80c0..b86864d 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -219,8 +219,8 @@ static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, } } -/* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE * f) +/* reginfo_dump: print state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE * f) { int i; fprintf(f, " faulting insn %08x\n", ri->faulting_insn); @@ -263,7 +263,7 @@ int reginfo_dump(struct reginfo *ri, FILE * f) sve_dump_preg(f, vq, p); fprintf(f, "\n"); } - return !ferror(f); + return; } for (i = 0; i < 32; i++) { @@ -271,8 +271,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", i, v[1], v[0]); } - - return !ferror(f); } void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index ba1035e..09813c4 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -161,8 +161,8 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) return memcmp(r1, r2, sizeof(*r1)) == 0; /* ok since we memset 0 */ } -/* reginfo_dump: print the state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE *f) +/* reginfo_dump: print the state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE *f) { int i; if (ri->faulting_insn_size == 2) { @@ -179,8 +179,6 @@ int reginfo_dump(struct reginfo *ri, FILE *f) i, (unsigned long long) ri->fpregs[i]); } fprintf(f, " fpscr: %08x\n", ri->fpscr); - - return !ferror(f); } void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 57e4c00..37506fa 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -310,8 +310,8 @@ static char get_vecletter(uint64_t features) } } -/* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE *f) +/* reginfo_dump: print state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE *f) { uint64_t features; int i, j, n, w; @@ -345,8 +345,6 @@ int reginfo_dump(struct reginfo *ri, FILE *f) fprintf(f, " k%-5d: %016" PRIx64 "\n", i, ri->kregs[i]); } } - - return !ferror(f); } void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 29edce9..38d7dd3 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -92,8 +92,8 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) return 1; } -/* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE *f) +/* reginfo_dump: print state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE *f) { int i; fprintf(f, " pc \e[1;101;37m0x%08x\e[0m\n", ri->pc); @@ -114,8 +114,6 @@ int reginfo_dump(struct reginfo *ri, FILE *f) } fprintf(f, "\n"); - - return !ferror(f); } void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index e96dc48..134a152 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -112,8 +112,8 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) return 1; } -/* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE * f) +/* reginfo_dump: print state to a stream */ +void reginfo_dump(struct reginfo *ri, FILE * f) { int i; @@ -152,8 +152,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f) ri->vrregs.vrregs[i][0], ri->vrregs.vrregs[i][1], ri->vrregs.vrregs[i][2], ri->vrregs.vrregs[i][3]); } - - return !ferror(f); } void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) From patchwork Fri Jul 8 15:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588562 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp798967mab; Fri, 8 Jul 2022 09:11:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMTVEs5KZTG0VvGiTza1ZC5E/FAtxL97Z9HOYPIrBaYUSAP9bZVcVPe/FBnFy3lsPrq6JI X-Received: by 2002:ac8:5884:0:b0:31d:36a9:b946 with SMTP id t4-20020ac85884000000b0031d36a9b946mr3607115qta.636.1657296668654; Fri, 08 Jul 2022 09:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657296668; cv=none; d=google.com; s=arc-20160816; b=Wluw4CQrJ5Nl6jn1Gh/uKo2NZb26xXNdERaO54P+UVFsklVMN8PajU+VaHLxpKh1ar pmrrMxlLAIzfNRpCZ4r4CkEdEScMj6eegvMNERrcdaWxdGNrVidOnCRWKLPprlfPHgQ1 BDp5k+5vc9nc00Zn4oK5IspL29QXiWob4dLqQe6e0aoBlCGxRCiuTmMB+EqjzccrAb0Z IApNdIudgS+ayErrt6m5gDvxPr27i0WHiGzJFi4Cs1R/q1520nEk3+YtbaxW9KYIpLU5 rwrDU4u9cb9yh1pgwsZGIGl/IJm7QGHrvDQyOvaG2kyzKvtmIzPKCXSsIdPc0Fro1Ic9 qYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Gkz60hItXrZkNCsstqfCphoprTGAep7xB2MfvanXt1s=; b=BwFe5HdE3TlOqAPyufvwhGZVfznHSvhwSRuNleZrR2UiEWqz7skHDFbhdVXkPiY2+8 tHPuh/4kp8dvtDh82TAnpxq19/bMA7WNDvhrcaf2AVhAVu03f0+zwhipjUZtwQgwMQVM 7xaq0JvtQ1Fgh77IykUVE3AL/4dr845B1RNDobfCpoFNRWlbvE0E+WLxV1oRIJYfxJXY af0N7aNALHcCN0jxywd+Q6DYaufgU5y8b7T5IsdZy07HmuZ4cQtYte+n3LIK9vHGM7xM 67D0DSC+Pu2tilaSrk5C5oigDlGdKk36oTh1PoDHvPoQrqM3ewcs7DiTcUrUJT4K6tET cCjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vQ0vn6lM; 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 iw10-20020a0562140f2a00b00473218812f7si4547968qvb.227.2022.07.08.09.11.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:11:08 -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=vQ0vn6lM; 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]:45752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qZQ-0000Zg-5z for patch@linaro.org; Fri, 08 Jul 2022 12:11:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDT-0006Xf-IH for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:27 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:37535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDR-0002bj-QT for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:27 -0400 Received: by mail-pj1-x1029.google.com with SMTP id y14-20020a17090a644e00b001ef775f7118so2311843pjm.2 for ; Fri, 08 Jul 2022 08:48:25 -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=Gkz60hItXrZkNCsstqfCphoprTGAep7xB2MfvanXt1s=; b=vQ0vn6lMzOSY8bE1bJ27YtqaxETWdngV19L7OhPVSGe8mwa8cEZXeI7o39TIrWQ1J4 HpSSn725Vlq5IBcFVmKp8B5mnBc+abHk2erfFzkhfZsIU3I9vOQkD3ADiddLRYVPEF94 RIde31578iVTd4gjlaoz6pmBZMVfM0ImVDf4U6X6SSMAwU8Wg4dx9pgAvWSJpFitOIhU bPWkRoKFpP/Fz502BvqNEZKjKz8r4gAufzTpSYIRqdKztEdtNbvBhv07msFHkfSul2H5 xDhvQykmfLJKHq49x7Kcn0upa4aXhchFXEYsfVP5r2u0HoJVGBJoLhPQd3sR6uqUGnMw yWcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gkz60hItXrZkNCsstqfCphoprTGAep7xB2MfvanXt1s=; b=jKVvSEGU7/hqFpopgyU0yDGHvOozlH+ekRSAgnLdCMthPJOW/Qk1bWxLNeWxRCTlxT kS/DTD6qzgxnBQz5ZcrttOhYJZqUmoE+AcreB+npaF3ddo5Z37KC4esabinmR7jNMa+8 7U0qQsrnJOqEnr1DiR4QwROgBmJak/CB9pMuaYUsDgftFitwjKvCb845cMNKkX3Cs5p6 zEg3E3ef6notrMFLVEdlacO3KWW+r+nmEVr8Gz2wgOQn8RgXFn4kkukqAWKt21e4HS9y y3R+3H3qDlC26IAhcfL06Sm4o4ejBVTvNicDqZ5w3Qo+DcCeBHFvLcuXkd2QgOdCIGLB fL5w== X-Gm-Message-State: AJIora9fxlrdilLsjCclqFvGqYTwSAwjqkP8mGb15byBG+U52Dy9FqpO HaldAY/eIUiFzuZzqDKBkXPcUERZayvz91ye X-Received: by 2002:a17:90a:dc01:b0:1ef:e3bd:a473 with SMTP id i1-20020a17090adc0100b001efe3bda473mr489405pjv.129.1657295304517; Fri, 08 Jul 2022 08:48:24 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 26/29] ppc64: Clean up reginfo handling Date: Fri, 8 Jul 2022 21:16:57 +0530 Message-Id: <20220708154700.18682-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Several of the gp_reg[] elements are not relevant -- e.g. orig r3, which is related to system calls. Omit those from the original reginfo_init(), so that any differences are automatically hidden. Do not only compare bit 4 of CCR -- this register is 32 bits wide with 8 cr subfields. We should compare all of them. Tidy reginfo_dump() output. Especially, do not dump the non- relevant fields. Signed-off-by: Richard Henderson --- risu_reginfo_ppc64.c | 114 +++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 70 deletions(-) diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 134a152..eeb0460 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -21,19 +21,30 @@ #include "risu.h" #include "risu_reginfo_ppc64.h" -#define XER 37 -#define CCR 38 +/* Names for indexes within gregset_t, ignoring those irrelevant here */ +enum { + NIP = 32, + MSR = 33, + CTR = 35, + LNK = 36, + XER = 37, + CCR = 38, +}; const struct option * const arch_long_opts; const char * const arch_extra_help; static const char * const greg_names[NGREG] = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", - [XER] = "xer", - [CCR] = "ccr", + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", + [NIP] = "nip", + [MSR] = "msr", + [CTR] = "ctr", + [LNK] = "lnk", + [XER] = "xer", + [CCR] = "ccr", }; void process_arch_opt(int opt, const char *arg) @@ -61,8 +72,13 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) ri->nip = uc->uc_mcontext.regs->nip - image_start_address; for (i = 0; i < NGREG; i++) { - ri->gregs[i] = uc->uc_mcontext.gp_regs[i]; + /* Do not copy gp_reg entries not relevant to the context. */ + if (greg_names[i]) { + ri->gregs[i] = uc->uc_mcontext.gp_regs[i]; + } } + ri->gregs[1] = 0xdeadbeef; /* sp */ + ri->gregs[13] = 0xdeadbeef; /* gp */ memcpy(ri->fpregs, uc->uc_mcontext.fp_regs, 32 * sizeof(double)); ri->fpscr = uc->uc_mcontext.fp_regs[32]; @@ -76,79 +92,37 @@ 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 *m, struct reginfo *a) { - int i; - for (i = 0; i < 32; i++) { - if (i == 1 || i == 13) { - continue; - } - - if (m->gregs[i] != a->gregs[i]) { - return 0; - } - } - - if (m->gregs[XER] != a->gregs[XER]) { - return 0; - } - - if ((m->gregs[CCR] & 0x10) != (a->gregs[CCR] & 0x10)) { - return 0; - } - - for (i = 0; i < 32; i++) { - if (m->fpregs[i] != a->fpregs[i]) { - return 0; - } - } - - for (i = 0; i < 32; i++) { - if (m->vrregs.vrregs[i][0] != a->vrregs.vrregs[i][0] || - m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] || - m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || - m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { - return 0; - } - } - return 1; + return memcmp(m, a, sizeof(*m)) == 0; } /* reginfo_dump: print state to a stream */ void reginfo_dump(struct reginfo *ri, FILE * f) { - int i; + const char *sep; + int i, j; - fprintf(f, " faulting insn 0x%x\n", ri->faulting_insn); - fprintf(f, " prev insn 0x%x\n", ri->prev_insn); - fprintf(f, " prev addr 0x%" PRIx64 "\n\n", ri->nip); + fprintf(f, "%6s: %08x\n", "insn", ri->faulting_insn); + fprintf(f, "%6s: %016lx\n", "pc", ri->nip); - for (i = 0; i < 16; i++) { - fprintf(f, "\tr%2d: %16lx\tr%2d: %16lx\n", i, ri->gregs[i], - i + 16, ri->gregs[i + 16]); + sep = ""; + for (i = j = 0; i < NGREG; i++) { + if (greg_names[i] != NULL) { + fprintf(f, "%s%6s: %016lx", sep, greg_names[i], ri->gregs[i]); + sep = (++j & 1 ? " " : "\n"); + } } - fprintf(f, "\n"); - fprintf(f, "\tnip : %16lx\n", ri->gregs[32]); - fprintf(f, "\tmsr : %16lx\n", ri->gregs[33]); - fprintf(f, "\torig r3: %16lx\n", ri->gregs[34]); - fprintf(f, "\tctr : %16lx\n", ri->gregs[35]); - fprintf(f, "\tlnk : %16lx\n", ri->gregs[36]); - fprintf(f, "\txer : %16lx\n", ri->gregs[37]); - fprintf(f, "\tccr : %16lx\n", ri->gregs[38]); - fprintf(f, "\tmq : %16lx\n", ri->gregs[39]); - fprintf(f, "\ttrap : %16lx\n", ri->gregs[40]); - fprintf(f, "\tdar : %16lx\n", ri->gregs[41]); - fprintf(f, "\tdsisr : %16lx\n", ri->gregs[42]); - fprintf(f, "\tresult : %16lx\n", ri->gregs[43]); - fprintf(f, "\tdscr : %16lx\n\n", ri->gregs[44]); - - for (i = 0; i < 16; i++) { - fprintf(f, "\tf%2d: %016lx\tf%2d: %016lx\n", i, ri->fpregs[i], - i + 16, ri->fpregs[i + 16]); + sep = "\n"; + for (i = j = 0; i < 32; i++) { + fprintf(f, "%s%*s%d: %016lx", + sep, 6 - (i < 10 ? 1 : 2), "f", i, ri->fpregs[i]); + sep = (++j & 1 ? " " : "\n"); } - fprintf(f, "\tfpscr: %016lx\n\n", ri->fpscr); + fprintf(f, "\n%6s: %016lx\n", "fpscr", ri->fpscr); for (i = 0; i < 32; i++) { - fprintf(f, "vr%02d: %8x, %8x, %8x, %8x\n", i, + fprintf(f, "%*s%d: %08x %08x %08x %08x\n", + 6 - (i < 10 ? 1 : 2), "vr", i, ri->vrregs.vrregs[i][0], ri->vrregs.vrregs[i][1], ri->vrregs.vrregs[i][2], ri->vrregs.vrregs[i][3]); } From patchwork Fri Jul 8 15:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588584 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp835476mab; Fri, 8 Jul 2022 09:56:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tr30PtCW6ula/jQE58h4QWEnG9+qaMUyLoXJ7U+QwHGExFNxHqHPNOlHuXMHKv/5HIA48b X-Received: by 2002:a05:620a:808a:b0:6b5:4d1b:c0f5 with SMTP id ef10-20020a05620a808a00b006b54d1bc0f5mr2999708qkb.713.1657299407085; Fri, 08 Jul 2022 09:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657299407; cv=none; d=google.com; s=arc-20160816; b=rFYNBB97iWmG89bPf7Fr4zZKLTx1LaZNDDw+mmMR9Lp/oMiEWZVWv4Y9dxv4/R2pHf 57nf1MmvH+O0nogFPCDuCQ3eJXp8RYttI+Fi5TwAAhcD+dVkXF+ux/MZxPGX1G34a21G Em9aWtnofbrGqfA+LY8dL8Vu8+jZAKaegLVo4CFdlukw4X+jy+/djS3PJRoSM+DiMJ+6 WCJdmGwzRK0k68C6Hsu+uUL8PUjX+4vIHzw/ZyI4odeWR7tNGKTkHDbdaapzgTcTbJ44 UeTjjs+pJRbA8M6bEyC4o6okTSK5kOaVRh/kSo61r/9yrx1GbJXqNRUhkDbPKvDWyD7A 0oLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=MRrXY542sxSC6HnNhvHgU6gcthc4iZQb6z5fd5sN5yQ=; b=gN5vSTypZ1pqyD9+D1uc4Z9nT4JqdFKJNvXecPIlq9bJax6zpNDYoAfHNh+4A3wly9 gdAdgnK22Os/sb22sd1SEvF3pbC0AYAKzWGKlZVUpW/1hu+UHU2NeFHnf/wNn95O8HcD wjfG9HWbENvhIT+zTlbVYhxj/oJkN7jZq9XrM8AUlQqIM0aPCxIBJHqMLYrWw3Pb1+XO BStwekhDzjj2ftZji8td4jL/rFztNt7pNKXRF0Vq1HhAgR0vGUKEaL/Jg5W5TKzXqL9B 8NAh+N3RFmkSHwOdFYroC68OhQNJ2KtMKiqUDKNNZJtqMFe0m8tlAomUGYlUXGk4jpkT Lo2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oy9P6QLJ; 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 do8-20020a05620a2b0800b006b557924406si3231367qkb.673.2022.07.08.09.56.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:56:47 -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=oy9P6QLJ; 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]:46392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rHa-0004P1-Me for patch@linaro.org; Fri, 08 Jul 2022 12:56:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDV-0006fG-JJ for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:29 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:38442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDT-0002Tp-Pv for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:29 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so2313991pjo.3 for ; Fri, 08 Jul 2022 08:48:27 -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=MRrXY542sxSC6HnNhvHgU6gcthc4iZQb6z5fd5sN5yQ=; b=oy9P6QLJFpVzQfPTl+1dkA12XPxWvQEkFRK3GHArgM+CAdseCpBg5wOuJY0x6Bnx8T Y+oejF7vkJAI7qVs6lbeMy94tEb2BbkHkZyZrzkqbJUzftPAdCRtAaOrhQ08IWjvxBf8 xS7Z/57NA0/q/HOF8b4N2qgtZVzy7ZZBPt9W8yfdQs2oQUVJ0pDzxtk+YBE7aOO5plWA Z0mrBhrBHb4MGxJJA3G7YpKoXc1sOZEtzT8GkdjhHfnJFcUI9+HaCKV+MjdnwRoJ9pmW FmKJgHAbfm35PN9ssYUFjoxo7s/Gj97QWbrLk1WuEGLK/1aKzglosxRN8IBYmEDcKU/H B95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MRrXY542sxSC6HnNhvHgU6gcthc4iZQb6z5fd5sN5yQ=; b=KdbkB7+n6t5f16jnr6TwezIE3pNfDW1Iu0h7qU0CUoP3AJ4BbjWLjXwsXIfdngZDjL aau/x2IqXH4fkAWzzF1OFpfGQtQnCLo7hSyATTsYJ9X6mqvepd+xfi8XtSV34iKpOzvj 8u+GzHrgWXUNKUCy8N8+ofSLajZZVKb/OvH185UlUc/Tt3Vn76Zyu+OC4M6t3A03cY9P n3w/37FutO53Gsd6tKFIq+O4/kVJ5XkSc1trU2l0tl0Wdx3JPNF7T9P1nUqTcMnzCYE2 mjp17ViCQbZ7xW9YYUqmfgAGkt17t0o3lUpF1sSnBPkL5ttUEPtShzv+/7mWPOi/P0z+ fR1A== X-Gm-Message-State: AJIora9lCPTSteKRTAFn7coXGtAB/K3ioXHq03dOf6hzgwAMQ3mGKPgP P+GppvIbXWuhdaudyl4WXYFwOYLXyzS05ava X-Received: by 2002:a17:90a:3e09:b0:1ef:8399:398b with SMTP id j9-20020a17090a3e0900b001ef8399398bmr487886pjc.39.1657295306991; Fri, 08 Jul 2022 08:48:26 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 27/29] aarch64: Tidy reginfo dumping ahead of ZA state Date: Fri, 8 Jul 2022 21:16:58 +0530 Message-Id: <20220708154700.18682-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A misalignment for sve_vl, plus add a bit more space on the left for the ZA[n] field name. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu_reginfo_aarch64.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index b86864d..9ea0acf 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -183,6 +183,18 @@ static int sve_preg_is_eq(int vq, const void *p1, const void *p2) return memcmp(p1, p2, vq * 2) == 0; } +static void sve_dump_zreg(FILE *f, int vq, const uint64_t *z) +{ + const char *pad = ""; + int q; + + for (q = 0; q < vq; q++) { + fprintf(f, "%s[%-2d] %016" PRIx64 "%016" PRIx64 "\n", + pad, q, z[2 * q + 1], z[2 * q]); + pad = " "; /* 11 spaces */ + } +} + static void sve_dump_preg(FILE *f, int vq, const uint16_t *p) { int q; @@ -211,10 +223,10 @@ static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, uint64_t zb0 = zb[2 * q], zb1 = zb[2 * q + 1]; if (za0 != zb0 || za1 != zb1) { - fprintf(f, "%sq%-2d: %016" PRIx64 "%016" PRIx64 + fprintf(f, "%s[%-2d]: %016" PRIx64 "%016" PRIx64 " vs %016" PRIx64 "%016" PRIx64"\n", pad, q, za1, za0, zb1, zb0); - pad = " "; + pad = " "; /* 11 spaces */ } } } @@ -237,19 +249,14 @@ void reginfo_dump(struct reginfo *ri, FILE * f) if (ri->sve_vl) { int vq = sve_vq_from_vl(ri->sve_vl); - int q; fprintf(f, " vl : %d\n", ri->sve_vl); 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, z[q * 2 + 1], z[q * 2]); - } + fprintf(f, " Z%-2d : ", i); + sve_dump_zreg(f, vq, z); } for (i = 0; i < SVE_NUM_PREGS + 1; i++) { @@ -312,7 +319,7 @@ void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } if (m->sve_vl != a->sve_vl) { - fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); } if (m->sve_vl) { @@ -323,7 +330,7 @@ void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) uint64_t *za = reginfo_zreg(a, vq, i); if (!sve_zreg_is_eq(vq, zm, za)) { - fprintf(f, " Z%-2d ", i); + fprintf(f, " Z%-2d : ", i); sve_dump_zreg_diff(f, vq, zm, za); } } From patchwork Fri Jul 8 15:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588586 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp847062mab; Fri, 8 Jul 2022 10:08:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sq2GCpT95k3liD6wHvqXatn/STeGMqF+GMwcSvAkJYeaviWz8DXjG9E+ZROHbtPpkX3iPR X-Received: by 2002:a05:622a:1701:b0:31e:9fb0:e0a0 with SMTP id h1-20020a05622a170100b0031e9fb0e0a0mr3867567qtk.27.1657300130425; Fri, 08 Jul 2022 10:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657300130; cv=none; d=google.com; s=arc-20160816; b=FGlQw+K5PILhEDfALfB2CGEJ0yiV0NmClOJJSwQYnd3bA8RJ97snopAceGJfjMUioH lNAlDVzdkaokx8l9v3ZQFeb40ab6gzuLaIa+JKCjMfHF7fXrPPxJeziYklB3LEJUa1Hp AeQqPCWEBrPbfxdHOxAPJDeatR/+Hz0QIIZZ2WexJlMDdWXa6k7HQEtyli8AITDHDdzz Y7IHgC5MqMMRiqgurSHmxz0JKK5CTrbdqQ/rE5dc+PdbIMvrXZZXEt66ph4n0Y5h3Sn1 iI+rS+v2I/yWcxmnHHP5QngYSp9XncJMKdSiBupSJwfY33Y9Ep7w6+NutXR16a8V9NCj qJig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=v0mp2fwMAm/3QWt6/khtoo1bYBedtATdI31SE5nBFNs=; b=uARjQTdctWYHTNUCf1UeAlCCP0TifvRcTP/bicSM1++W/zDa0AvmkZEUySy9Znexgu W+MZBiZ6bW5MDvUKWJIvbKtKBpB/rwxYnUDGWvPS/KqGRdftWwKvSzKJ80DWgE9IsgdA //MZJGPuxOc5JpfcQzua5ESrZTrFMWo0HSO/40qWGcmWLKanDdZ+6IyKvb9R866npdLg BgoU+1W/FWMKv2vKv4TjQ2m8VqoTuZQkt85oPSelF9B65/GL7TT+hx1TWtbjYL2Kv9k5 PP4240EmLVAFqhZ377wVJ4tjjBNTHO41rOtvyATIGtQ47Qil28qohPPaqTtxmREhaWgl dGZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DyveKn7n; 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 t15-20020a05620a450f00b006b25f42a307si17969362qkp.621.2022.07.08.10.08.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 10:08:50 -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=DyveKn7n; 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]:60164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rTF-0005oc-W3 for patch@linaro.org; Fri, 08 Jul 2022 13:08:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDb-0006yY-GN for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:35 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:33314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDY-0002cp-NC for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:35 -0400 Received: by mail-pl1-x632.google.com with SMTP id p16so1945965plo.0 for ; Fri, 08 Jul 2022 08:48:32 -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=v0mp2fwMAm/3QWt6/khtoo1bYBedtATdI31SE5nBFNs=; b=DyveKn7nHnlRo64TdMxrSezLt3U4Dqfw+SoJOH+Opg2LiBeRjKFVJsnsOx4/6dMef7 A9V9viJSMUcJm+690shHgQHsbnkonWiawop1aJVX+0dld5H7lO2wqBoHUtXbGt6a2ogh fJsvTNKKx0naRn/amePeZITQ6HEaXgCiZydRK3gtA4KhPFuhI8fR1LhZsi5cxyQ38TxO H6RhM5iL8pc3OBHfKtB/0eke9P6/8Iyi3j/5Hub2Qs7i+kHYj23RKTGFkoRwvSd5TBRa jgq+WtDzbRsIAJs+OYJUKc7R2jX4bNyQnC7Vy2e2W3WcHyQXNigV2xyKo/zS9do2EnUa Um1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v0mp2fwMAm/3QWt6/khtoo1bYBedtATdI31SE5nBFNs=; b=Kc8i9UlJ/hRFviKGnqPzKxy3wa0Zos+RJwtX30Vw0RwPeFBh4frhDUXrXhHlyU4WJm qBwmZ5MhWTQqL72K/epDjjSWJSX1i4+qHW/vVWnnNovp1tPb2ju+wE/HtrHWBH4sWSLy C53BY8O7VX4ebdqgQKFQ4Ujzg51lpWW6+AeW/tulUA4JelGCWqNFJ6zXHjOsZCFyKi+H PqNdHwZYD7KQaCoNzmbwua0iBNZhTQ4XDS9YCwSwLHo1UyMMwbfRfwWH7AdLJujhH5QV EtRk8+syrX9nnTWrKhFHHvIhdaLtJ6kLeFWxbLyXeXyNHrGJ3hV8XCQKfVM4j9N2fddN dzJw== X-Gm-Message-State: AJIora8E5SHcaccN5x9Q69o4nJVHtNnfFmlcQeFzBPLghtFogXRRaXdz 8vaKcFAP705UoimO6sTQyeDic+dYI4VFPe47 X-Received: by 2002:a17:902:f790:b0:16b:d796:3696 with SMTP id q16-20020a170902f79000b0016bd7963696mr4257201pln.97.1657295311415; Fri, 08 Jul 2022 08:48:31 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 28/29] aarch64: Add support for ZA storage Date: Fri, 8 Jul 2022 21:16:59 +0530 Message-Id: <20220708154700.18682-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Require NVL == SVL on startup, to make it easier to manage reginfo. Most of the time PSTATE.SM would be active with PSTATE.ZA anyway, for any non-trivial SME testing. Extend saved storage only when PSTATE.ZA is active. Use a carefully reserved uint16_t for saving SVCR. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu_reginfo_aarch64.h | 52 ++++++++++++- risu_reginfo_aarch64.c | 161 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 191 insertions(+), 22 deletions(-) diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index 536c12b..097b7ad 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -21,6 +21,43 @@ #define SVE_VQ_MAX 16 #define ROUND_UP(SIZE, POW2) (((SIZE) + (POW2) - 1) & -(POW2)) + +#ifdef ZA_MAGIC +/* System headers have all Streaming SVE definitions. */ +typedef struct sve_context risu_sve_context; +typedef struct za_context risu_za_context; +#else +#define ZA_MAGIC 0x54366345 +#define SVE_SIG_FLAG_SM 1 + +/* System headers missing flags field. */ +typedef struct { + struct _aarch64_ctx head; + uint16_t vl; + uint16_t flags; + uint16_t reserved[2]; +} risu_sve_context; + +typedef struct { + struct _aarch64_ctx head; + uint16_t vl; + uint16_t reserved[3]; +} risu_za_context; + +#define ZA_SIG_REGS_OFFSET \ + ROUND_UP(sizeof(risu_za_context), SVE_VQ_BYTES) + +#define ZA_SIG_REGS_SIZE(vq) \ + ((vq) * (vq) * SVE_VQ_BYTES * SVE_VQ_BYTES) + +#define ZA_SIG_ZAV_OFFSET(vq, n) \ + (ZA_SIG_REGS_OFFSET + (SVE_SIG_ZREG_SIZE(vq) * n)) + +#define ZA_SIG_CONTEXT_SIZE(vq) \ + (ZA_SIG_REGS_OFFSET + ZA_SIG_REGS_SIZE(vq)) + +#endif /* ZA_MAGIC */ + #define RISU_SVE_REGS_SIZE(VQ) ROUND_UP(SVE_SIG_REGS_SIZE(VQ), 16) #define RISU_SIMD_REGS_SIZE (32 * 16) @@ -36,12 +73,16 @@ struct reginfo { uint32_t fpsr; uint32_t fpcr; uint16_t sve_vl; - uint16_t reserved; + uint16_t svcr; - char extra[RISU_SVE_REGS_SIZE(SVE_VQ_MAX)] + char extra[RISU_SVE_REGS_SIZE(SVE_VQ_MAX) + + ZA_SIG_REGS_SIZE(SVE_VQ_MAX)] __attribute__((aligned(16))); }; +#define SVCR_SM 1 +#define SVCR_ZA 2 + static inline uint64_t *reginfo_vreg(struct reginfo *ri, int i) { return (uint64_t *)&ri->extra[i * 16]; @@ -59,4 +100,11 @@ static inline uint16_t *reginfo_preg(struct reginfo *ri, int vq, int i) SVE_SIG_REGS_OFFSET]; } +static inline uint64_t *reginfo_zav(struct reginfo *ri, int vq, int i) +{ + return (uint64_t *)&ri->extra[RISU_SVE_REGS_SIZE(vq) + + ZA_SIG_ZAV_OFFSET(vq, i) - + ZA_SIG_REGS_OFFSET]; +} + #endif /* RISU_REGINFO_AARCH64_H */ diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 9ea0acf..af620f3 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -25,25 +25,44 @@ #include "risu.h" #include "risu_reginfo_aarch64.h" +#ifndef PR_SME_SET_VL +#define PR_SME_SET_VL 63 +#endif + /* Should we test SVE register state */ static int test_sve; +static int test_za; static const struct option extra_opts[] = { {"test-sve", required_argument, NULL, FIRST_ARCH_OPT }, + {"test-za", required_argument, NULL, FIRST_ARCH_OPT + 1 }, {0, 0, 0, 0} }; const struct option * const arch_long_opts = &extra_opts[0]; const char * const arch_extra_help - = " --test-sve= Compare SVE registers with VQ\n"; + = " --test-sve= Compare SVE registers with VQ\n" + " --test-za= Compare ZA storage with VQ\n"; void process_arch_opt(int opt, const char *arg) { - assert(opt == FIRST_ARCH_OPT); - test_sve = strtol(arg, 0, 10); - - if (test_sve <= 0 || test_sve > SVE_VQ_MAX) { - fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); - exit(EXIT_FAILURE); + switch (opt) { + case FIRST_ARCH_OPT: + test_sve = strtol(arg, 0, 10); + if (test_sve <= 0 || test_sve > SVE_VQ_MAX) { + fprintf(stderr, "Invalid value for SVE VQ (1-%d)\n", SVE_VQ_MAX); + exit(EXIT_FAILURE); + } + break; + case FIRST_ARCH_OPT + 1: + test_za = strtol(arg, 0, 10); + if (test_za <= 0 || test_za > SVE_VQ_MAX + || (test_za & (test_za - 1))) { + fprintf(stderr, "Invalid value for ZA VQ (1-%d)\n", SVE_VQ_MAX); + exit(EXIT_FAILURE); + } + break; + default: + abort(); } } @@ -51,6 +70,31 @@ void arch_init(void) { long want, got; + if (test_za) { + /* + * For now, reginfo requires NVL == SVL. + * There doesn't seem to be much advantage to differing. + */ + if (test_sve && test_sve != test_za) { + fprintf(stderr, "Mismatched values for SVE and ZA VQ\n"); + exit(EXIT_FAILURE); + } + + want = sve_vl_from_vq(test_za); + got = prctl(PR_SME_SET_VL, want); + if (want != got) { + if (got >= 0) { + fprintf(stderr, "Unsupported VQ for ZA (%d != %d)\n", + test_za, (int)sve_vq_from_vl(got)); + } else if (errno == EINVAL) { + fprintf(stderr, "System does not support SME\n"); + } else { + perror("prctl PR_SME_SET_VL"); + } + exit(EXIT_FAILURE); + } + } + if (test_sve) { want = sve_vl_from_vq(test_sve); got = prctl(PR_SVE_SET_VL, want); @@ -75,6 +119,9 @@ int reginfo_size(struct reginfo *ri) if (ri->sve_vl) { int vq = sve_vq_from_vl(ri->sve_vl); size += RISU_SVE_REGS_SIZE(vq); + if (ri->svcr & SVCR_ZA) { + size += ZA_SIG_REGS_SIZE(vq); + } } else { size += RISU_SIMD_REGS_SIZE; } @@ -84,10 +131,11 @@ int reginfo_size(struct reginfo *ri) /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { - int i; + int i, vq; struct _aarch64_ctx *ctx, *extra = NULL; struct fpsimd_context *fp = NULL; - struct sve_context *sve = NULL; + risu_sve_context *sve = NULL; + risu_za_context *za = NULL; /* necessary to be able to compare with memcmp later */ memset(ri, 0, sizeof(*ri)); @@ -112,6 +160,9 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) case SVE_MAGIC: sve = (void *)ctx; break; + case ZA_MAGIC: + za = (void *)ctx; + break; case EXTRA_MAGIC: extra = (void *)((struct extra_context *)(ctx))->datap; break; @@ -134,21 +185,55 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) ri->fpsr = fp->fpsr; ri->fpcr = fp->fpcr; - if (test_sve) { - int vq = test_sve; + /* + * Note that arch_init required NVL==SVL, so test_sve and test_za + * are equal when non-zero. We will verify this matches below. + */ + vq = test_sve | test_za; + ri->sve_vl = sve_vl_from_vq(vq); - if (sve == NULL) { - fprintf(stderr, "risu_reginfo_aarch64: failed to get SVE state\n"); + if (test_za) { + if (za == NULL) { + /* ZA_MAGIC is supposed to be present, even if empty. */ + fprintf(stderr, "risu_reginfo_aarch64: missing ZA state\n"); return; } + assert(za->head.size >= ZA_SIG_CONTEXT_SIZE(0)); - if (sve->vl != sve_vl_from_vq(vq)) { + if (za->vl != ri->sve_vl) { fprintf(stderr, "risu_reginfo_aarch64: " - "unexpected SVE state: %d != %d\n", - sve->vl, sve_vl_from_vq(vq)); + "unexpected ZA VQ: %d != %d\n", + za->vl, ri->sve_vl); + return; + } + if (za->head.size == ZA_SIG_CONTEXT_SIZE(0)) { + /* ZA storage is disabled. */ + } else if (za->head.size < ZA_SIG_CONTEXT_SIZE(vq)) { + fprintf(stderr, "risu_reginfo_aarch64: " + "failed to get complete ZA state\n"); + return; + } else { + ri->svcr |= SVCR_ZA; + memcpy(reginfo_zav(ri, vq, 0), (char *)za + ZA_SIG_REGS_OFFSET, + ZA_SIG_CONTEXT_SIZE(vq) - ZA_SIG_REGS_OFFSET); + } + } + + if (test_sve) { + if (sve == NULL) { + /* SVE_MAGIC is supposed to be present, even if empty. */ + fprintf(stderr, "risu_reginfo_aarch64: missing SVE state\n"); return; } + if (sve->vl != ri->sve_vl) { + fprintf(stderr, "risu_reginfo_aarch64: " + "unexpected SVE VQ: %d != %d\n", + sve->vl, ri->sve_vl); + return; + } + + ri->svcr |= sve->flags & SVE_SIG_FLAG_SM; if (sve->head.size <= SVE_SIG_CONTEXT_SIZE(0)) { /* Only AdvSIMD state is present. */ } else if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { @@ -156,7 +241,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) "failed to get complete SVE state\n"); return; } else { - ri->sve_vl = sve->vl; memcpy(reginfo_zreg(ri, vq, 0), (char *)sve + SVE_SIG_REGS_OFFSET, SVE_SIG_REGS_SIZE(vq)); @@ -164,7 +248,18 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) } } - memcpy(reginfo_vreg(ri, 0), fp->vregs, RISU_SIMD_REGS_SIZE); + /* + * Be prepared for ZA state present but SVE state absent (VQ != 0). + * In which case, copy AdvSIMD vregs into the low portion of zregs; + * pregs remain all zero. + */ + if (vq == 0) { + memcpy(reginfo_vreg(ri, 0), fp->vregs, RISU_SIMD_REGS_SIZE); + } else { + for (i = 0; i < 32; ++i) { + memcpy(reginfo_zreg(ri, vq, i), &fp->vregs[i], 16); + } + } } /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ @@ -248,9 +343,11 @@ void reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpcr : %08x\n", ri->fpcr); if (ri->sve_vl) { - int vq = sve_vq_from_vl(ri->sve_vl); + int vl = ri->sve_vl; + int vq = sve_vq_from_vl(vl); - fprintf(f, " vl : %d\n", ri->sve_vl); + fprintf(f, " vl : %d\n", vl); + fprintf(f, " svcr : %d\n", ri->svcr); for (i = 0; i < SVE_NUM_ZREGS; i++) { uint64_t *z = reginfo_zreg(ri, vq, i); @@ -270,6 +367,14 @@ void reginfo_dump(struct reginfo *ri, FILE * f) sve_dump_preg(f, vq, p); fprintf(f, "\n"); } + + if (ri->svcr & SVCR_ZA) { + for (i = 0; i < vl; ++i) { + uint64_t *z = reginfo_zav(ri, vq, i); + fprintf(f, " ZA[%-3d]: ", i); + sve_dump_zreg(f, vq, z); + } + } return; } @@ -322,6 +427,10 @@ void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); } + if (m->svcr != a->svcr) { + fprintf(f, " svcr : %d vs %d\n", m->svcr, a->svcr); + } + if (m->sve_vl) { int vq = sve_vq_from_vl(m->sve_vl); @@ -347,6 +456,18 @@ void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) sve_dump_preg_diff(f, vq, pm, pa); } } + + if (m->svcr & a->svcr & SVCR_ZA) { + for (i = 0; i < vq * 16; i++) { + uint64_t *zm = reginfo_zav(m, vq, i); + uint64_t *za = reginfo_zav(a, vq, i); + + if (!sve_zreg_is_eq(vq, zm, za)) { + fprintf(f, " ZA[%-3d]: ", i); + sve_dump_zreg_diff(f, vq, zm, za); + } + } + } return; } From patchwork Fri Jul 8 15:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588587 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp851677mab; Fri, 8 Jul 2022 10:13:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uCDniwFgcfzCUcMy5VlAYCudWwV+Fs//2pELjX079e9Qht+MbGwz13QZRbpFAyNudrWM4a X-Received: by 2002:ac8:7f88:0:b0:31b:f70c:7b6e with SMTP id z8-20020ac87f88000000b0031bf70c7b6emr4039174qtj.561.1657300437360; Fri, 08 Jul 2022 10:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657300437; cv=none; d=google.com; s=arc-20160816; b=axkCTWhve4lHpB3fYvY7thnZW6ife/muZboofPW3XfQLTeeN0QOlnd72pixHFEbEeM UytTTK3r1SPdIOLItxjZUd/EotCSvO3c/q2LWDLNrJX8GOqU+ag7dZd5c85hl8v/j/0v u15Z2KvV7V804ksr2rPTTOJJMhMBDDhLYgp1PwMyvxJH8JcHL7meoWbLdD3TSnPs9ObB xh7ATkhJMCCqg5H7MFdrTA8edWDq8uGW+RxxzNZX4kzWxwWLwowDjT34VhXgHRKBo5IQ zxanQds4p/Tz12fwwciEISo+g/nbjI5yMScPu4AMzgAM6IiTcUtEde751S+9Pgtd4L3o RKPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=tDlq7Gwmx8RjkvitHJnXFST75wSJBtl/6C34V4BWgAA=; b=AbiAX0xfCLJBrAJWMSdGlWO7TL3ehI2pynV2eHUPQzQbbDYCghAbJVO4A6iizPqQ+J 2RmHS11hL62qD0AggrRNyK+gGmVUP6X7SFnYEfF9JD53Czs+d3G6YUMwaVfP1yvoIWUM kKE+0nMcLHI/lgchmzeXe/9FjHaWYyjh+CjGXmzDPPjHJifTF4WKCSjhWyt9MMBeA7/5 LKv1Ib1srOWpo1i37RYsx35zyuitrWlgs+2VjfD1CCafn1fzNeM60sVkreWnPBhhJnCu kczLsg2VZA6Mde3HhK4k9BlKK7GSqF4PkLb6Bzm9z4qsMStxkDYVzrd4kD1vO3jq3ROB UFyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7+mIjoX; 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 2-20020ad45b82000000b00470a898e4bdsi24078893qvp.226.2022.07.08.10.13.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 10:13:57 -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=G7+mIjoX; 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]:36186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rYC-0000Kn-PK for patch@linaro.org; Fri, 08 Jul 2022 13:13:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qDd-00072v-2Z for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:37 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:36520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qDb-0002d6-G7 for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:48:36 -0400 Received: by mail-pl1-x62a.google.com with SMTP id m2so16684030plx.3 for ; Fri, 08 Jul 2022 08:48:35 -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=tDlq7Gwmx8RjkvitHJnXFST75wSJBtl/6C34V4BWgAA=; b=G7+mIjoXub1NheYWmd06XLVXHaJz5wicH2cKKE3fyO49E2kltVlkfxZSk44pgDXa/u RFRwnmnPq2KB32DgvCx1bi4urniouKay2rqJCv77Kd/ILWff16d3subaDknaMjJM6o8q byJD6mrSIw1ZgXT4QsBG52TgIlqCHLWzmVOuaj4sYA0cod6/eh3h0CIh0JZRsX59q5jP oB5e7HPXjkk+vqnfs/hjmeZX7I4lnYkCyJJlGE5obU8HC4Gd6y4BTRJcENLqM1UHH+Oy hCkB5jgfCDXXMBxTiijzjecy66CdCguugfWL4jzxta5qgeUR9NZLnObMj2NJN/WMjblf ydQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tDlq7Gwmx8RjkvitHJnXFST75wSJBtl/6C34V4BWgAA=; b=PtBcDj2n4u2D3r7mezQ5SV9i431s70axVuYsNXTOrRYqh09lsRo7mFVbJDJh3kV5Zb 8/sfWceqWmbcghc8da24WHCC/3uSPG/hEvPz+2JzSzpy3VmYGycIzXTzgyRELyBxBGWj pL49rfmDg4SS9Jq34dB0Lx7YvydD/Njf78Xr/qJGCTiODrDszwIkK+TDMBgAebyREubV OpcdjGfqn2lg7E7TL6kZInNbITny7x4GPFf28ynBureOjYg+2cxN8D9XOreRaP71HQoe S4AiR+x5vOk0EBx5405y2pNyh4as8uFUrXd0KuN4Ubhel75QMXe5esM+QKVNgZ+HCC9c EbSQ== X-Gm-Message-State: AJIora8i8LFobKIT6rmdmfdj9PuUpynijdwOuZW4n4wNTP+B6uKwQpWQ WV4tUVYVPBaVJy6yn4OC0oBZm6lo6HnBMyIx X-Received: by 2002:a17:902:d707:b0:16b:e35e:abd4 with SMTP id w7-20020a170902d70700b0016be35eabd4mr4275451ply.111.1657295314262; Fri, 08 Jul 2022 08:48:34 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:48:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 29/29] aarch64: Trivial SME test Date: Fri, 8 Jul 2022 21:17:00 +0530 Message-Id: <20220708154700.18682-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- test_sme_aarch64.s | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test_sme_aarch64.s diff --git a/test_sme_aarch64.s b/test_sme_aarch64.s new file mode 100644 index 0000000..a5ef909 --- /dev/null +++ b/test_sme_aarch64.s @@ -0,0 +1,55 @@ + .arch_extension sme + + mov w0, #0 + mov w1, #0 + mov w2, #0 + mov w3, #0 + mov w4, #0 + mov w5, #0 + mov w6, #0 + mov w7, #0 + mov w8, #0 + mov w9, #0 + mov w10, #0 + mov w11, #0 + mov w12, #0 + mov w13, #0 + mov w14, #0 + mov w15, #0 + mov w16, #0 + mov w17, #0 + mov w18, #0 + mov w19, #0 + mov w20, #0 + mov w21, #0 + mov w22, #0 + mov w23, #0 + mov w24, #0 + mov w25, #0 + mov w26, #0 + mov w27, #0 + mov w28, #0 + mov w29, #0 + mov w30, #0 + + smstart + + ptrue p0.b + rdsvl x12, #1 + +0: subs w12, w12, #1 + lsl w13, w12, #4 + index z0.b, w13, #1 + mova za0h.b[w12, #0], p0/m, z0.b + b.ne 0b + + .inst 0x00005af0 /* compare */ + + rdsvl x12, #1 +0: subs w12, w12, #1 + lsl w13, w12, #4 + index z0.b, w13, #1 + mova za0v.b[w12, #0], p0/m, z0.b + b.ne 0b + + .inst 0x00005af1 /* exit */