From patchwork Fri May 22 02:34:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187113 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102132ilb; Thu, 21 May 2020 19:34:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4c2Tgef5tt0feTjWHFyV4KeW48tr8W1hoAs6JfIxtPMQJoptcAvEtwBQlIfTHebkVVpUl X-Received: by 2002:a25:ba4c:: with SMTP id z12mr14904525ybj.164.1590114896730; Thu, 21 May 2020 19:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590114896; cv=none; d=google.com; s=arc-20160816; b=09mWXLppgb8W3Nx4yyDBruYHNktHRiHhAXSZTEW68HnxGLWRkH6+VG+CeoL22zYb6x XdVFgEP4fBoYCSCssWI9thi1idVhvdarCyvpUMKuGOj+8MaUygfJ38JcF7C9Ua8TnEgp LYoY63aOGZ3FV+SITbpkyuabYJDf7g9MPzVwv0KK2nMkAFX7F1ZW66ZS7SQLPsTkB5sN gsiHdo4ygO2+5scww0lrdADuQnvOpgKecEmKCC8RH1r89mP95lVa/DOwkB2SbM330V4V HeEGXFtUteDzZbtZ3GS2NoI1FuTYuIbVyvNXk0FnnOK3dBOtBtgbYuZrwtIm/SyriANV xXeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gkyAigBcxeB9sTmXF9GJufgbDs99qzgoeJAd1MWy3/8=; b=Zi6m5/QejAwHDkdUG2QD0JQyZ3/UJbGzmE0GmltOhG+l2hNbkcfvz+HeSh24M4oty7 WDfkDiO9daCTNajtgWZw+Yl2p16/IBm2GuYKamP3i3NIbz0vyKV9RQD3O986pjyNr0gC kMD1keCozwNSM/HJXLt7V2jE4e+2Cx0GipvRj5Qzp1du45tcTYBRlXAI3yStYL4Qcy6D IJKQj6JALb25mZhrHXzW3oPbYj1FUnP94tpMeRu7M6/KKUAdaoDyz4mGvBsFE/QFUncW Z1nfuP7HxIHywPokC4O2PcezAILuxLxOx3yNkhJBpSFj5jhzG2P3KsLIIHr29hWNaRVC T1Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="eYjy3/1M"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j133si2105923ybg.247.2020.05.21.19.34.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:34: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=fail header.i=@linaro.org header.s=google header.b="eYjy3/1M"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxWS-00023s-8b for patch@linaro.org; Thu, 21 May 2020 22:34:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWI-00023Z-AA for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:46 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWH-00055l-7N for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:45 -0400 Received: by mail-pl1-x631.google.com with SMTP id q16so3822656plr.2 for ; Thu, 21 May 2020 19:34: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=gkyAigBcxeB9sTmXF9GJufgbDs99qzgoeJAd1MWy3/8=; b=eYjy3/1MBhnXWugPc+CFxZeLIxiTC0jYd4kIUwzJV8T2KLpJ8jQYffGbx5qJFaY3j7 deRPgUhyPV4SE94sam6cWYBP5R2zj1LaKDSZJbJHQaKLsYczXCd2KbMk/7Zqiay2bWvV +da/AAj7xBe14iChYVnA7PoUzV5gu+daGIAmlZDyr+Zd613Wl5w8v1nq/loMNA5MG15P jF+EHWquY78+ZrfrTHq8Ps/oKuNUcoF8rMOPC9TjS+LGi40fnG9E1sWb6n/ORjmUXZ98 ANzbmk4z64vlH8Ztxw71oVjbC+0iN7hOE0FvO4je8HdOdIa676Yxho0+9cgrn2/FKmMM L59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gkyAigBcxeB9sTmXF9GJufgbDs99qzgoeJAd1MWy3/8=; b=NDPG1c44YcoTW6+U7vtrRj0GQAkHD0dBeVHor8IaT43CZKpY0IYip/eNWb+8A2Pax7 B/oYzAP80HpLXJLKdblkBOmZgwnKzYdOhu+7ySh8F/WqWygoY3MgdAZJMZeLDO5m3guo YU5lfiwFDjI3bSAlDJDEVQ03GONMVGXEixu7Csc3lUnC8W0GLRfJnhIl0IYPNybeCV5K 40b5z008XLJryrgEWtqiWnlR6ARQN8pLxm958FOkBAbukjvlMYFlW45W+QWaxjfs/nAL HZ81H6BkLZOrY1ZT3C1BenWbANuUBr1lAWj8UfIsvzghrCqNVQzP+6ag+DFeLosc68gB fiLQ== X-Gm-Message-State: AOAM5329gzG03tsbggdU42Bxf5hLFnFBr1zbdcI+XGz+oVAVWr5HEm92 1uJnA5wYSBn/T4rwHgr23r92FQEBIAo= X-Received: by 2002:a17:90b:3745:: with SMTP id ne5mr1822404pjb.68.1590114883474; Thu, 21 May 2020 19:34:43 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/25] Use bool for tracing variables Date: Thu, 21 May 2020 19:34:16 -0700 Message-Id: <20200522023440.26261-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alex.bennee@linaro.org 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(-) -- 2.20.1 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 May 22 02:34:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187119 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102997ilb; Thu, 21 May 2020 19:36:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYKG82Yy5IpVeLMR9waKktGCxSzPdkxOetcgqQupf9hV86JwOjIAsSaza1svEsctRJm7nU X-Received: by 2002:a37:e85:: with SMTP id 127mr12990912qko.178.1590115000748; Thu, 21 May 2020 19:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115000; cv=none; d=google.com; s=arc-20160816; b=W/3EG6n6V4FXkNq94g09jYcNYZ25BP4qwxYeCILK3ie4Cu1HdhGyeqFapNYQNSnEIP Ede8/4+dsRGgphsYMLpqiXqHFJ1dd+P8Ml2fwpcxuWMlBScYwzQ+xJl2INIKtiM36Sxs sChuolaInd/HyvHTRzcJ0cRI1D4xZ3So1FIb2ytNlzF54FSajRKFg6KG3+DDyhHdU1u0 abxwp6JhyNuhrPHyVnNfrn1V0SeqM56Mz8uFuqiIehIvLQPryGPMOPbGv3npwOZSXtl4 mqtksZrZOMUTgQKq9N1Di6Vu4c8jQOpOMiWbhlOL4gI/wax05rLgDjINgzxtp05ghOzr ZOKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=JQCGgvllP6/zU7ZDrHyu78GSFItc7dHunrM7u5X5NHY=; b=kPZ0hUCL4nvU/E4lYKV3zTVdH/lSP05WJbiprBrP5nYuS1Ge0S2Oo/vhXuUqDB8UCB 5cMqxgMNMUjxZ67WKKm0xlkqK15MMVEKl4bq0RBDrbs7FgAe8RpIqgglePO6vizlW5Fm 55n1Cn0paev+HnpkcYUBfS7gze5Hbtfsa4UjecyoD1+SLfWze4xmMxugqdJNtzBvkXkR r0r5dWeGJQC6atYNuw483igXChmmGSvPQIoaZnksfojduHC1JkzlsDwmib5A9Yk6VbDp 851Jo0MA6J3q/6NmzRaPgBhSJvYOSuURfB99jWcKGLjfTZW78+7jEI1ZNj1RKgc+7FGo F98Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yswuQWAA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cu18si4280662qvb.99.2020.05.21.19.36.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:36:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yswuQWAA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxY8-0006HM-8d for patch@linaro.org; Thu, 21 May 2020 22:36:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWJ-00023l-7I for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:47 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:40288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWI-00055p-Ai for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:46 -0400 Received: by mail-pj1-x1043.google.com with SMTP id ci23so4339821pjb.5 for ; Thu, 21 May 2020 19:34:45 -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=JQCGgvllP6/zU7ZDrHyu78GSFItc7dHunrM7u5X5NHY=; b=yswuQWAAOUpgZQ0p7M/vW8p9+vw1X2m4G5mfZdbfIurqVXZVw/ExYxvIWUwzmJN9X+ 34MJ6pLbTHePAfwHF8k1AuxfhY3D40HMcmVQfvCtotGimQPVqSUt80ueC61UHhXCyjPI h7uSddUVRDaYL2fWEthR6jWKNJTuLJ+HmnXJRw2+2l2+zGIued+XsjzpY9aBXRyM27KQ eRNOg+Z00DlV7x6IWIxJ1uF/k5dB1t3QAG0SBnkN0J1wUQO05Iah5Y/F0iucqmnHFsEc XZSs+nyvQFqPI9I+zeP8AIsNEIa8OdqmfrDMUmY7PzZOXCv7zsUi+vIlDVkqRT5OeLR+ PqhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JQCGgvllP6/zU7ZDrHyu78GSFItc7dHunrM7u5X5NHY=; b=SgaVYDm9LO7Ztg7P5ye7V3DGeiLCm0eCDfz0xcGdVrj3xuhsj6U8B+EtWTnW+2Zbp9 QArJWrz/pVIXPFVHDVOV8JyHkckiG08QvVAV0arq4gDP4K7HgaCaH/y25KF5kNn5U9b+ RSEYB4ICgI1S1w05eRjpneMDrwj85RNR1fIKN+943yelUsGxNlw/aDkCz3Mc8yg/rdkp KbIve9MYF+rKM4hZiGv+dRQ0QOmT8JCQ0RDbv3IkSyORwEb5lflUXvCzebugAGuVepmu 7wzSJ4nwUXj5/tYuLtwVxJ4R+GTEfJr2miqM6ZwKBtxrgTVSdCozi5/V98l1tPm4+6np VV6w== X-Gm-Message-State: AOAM531Xbhcv9Q9+WJP1jzuGz1Ie4UQMkCZgPEupZ9ka7Hdr6Owpxbv7 tzn3NWh2tudHbmCfox0BXywgNjEq/JE= X-Received: by 2002:a17:902:4b:: with SMTP id 69mr11442611pla.99.1590114884611; Thu, 21 May 2020 19:34:44 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/25] Unify master_fd and apprentice_fd to comm_fd Date: Thu, 21 May 2020 19:34:17 -0700 Message-Id: <20200522023440.26261-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1043.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Any one invocation cannot be both master and apprentice. Let's use only one variable for the file descriptor. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) -- 2.20.1 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 May 22 02:34:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187117 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102818ilb; Thu, 21 May 2020 19:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp+hSRPzi4MMATt2yCPxAMLt+FigQgK7To46WC/MdnEEQlaKDjK1JVAn3bNCAyiL7EAL/F X-Received: by 2002:a05:620a:201d:: with SMTP id c29mr11842133qka.263.1590114979513; Thu, 21 May 2020 19:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590114979; cv=none; d=google.com; s=arc-20160816; b=E2my50fvD0wccz8iDF+PV+8DrZJl6/6xsBeHXrYZmOx9/bmhVT3MBgOvW2J5e3k/O6 uwvHlIyoQdQx7uslRCa6y90zelNT9FqwBog+RtiHFpAEg4c8MRcPqo/ln7yd/tD9BE8f swmXUk8vhJuSTr0U+ej3Zzt3K1X2za/s26duoU75mCb07ADdMlZp8sSeyfLmWvoYNXfW Er74BYQYIj5adac74GTEKppXBSf/h+0jM5lc88nko04DZd0yL6dS4aV7uvWyDX3GNEDz 9at0hQZX2cuvJZruK4Xe+PwCu3crOcztBUiNDA97QCr11Ig+N3toCCdsoli2/k3MO/kq 0+IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qsogh1iVORSWncpn9Q6d07KHmeqCKiBimOSa205EF/o=; b=CHqa8B4oDM33heUcCs9gsSMud1IEQ0WIcZWn8dOW6S2swBQFapVGGOYgxPWvLb+MqK EwB5jIRtxal3nGeVKrVLg+UQXogMu2Vhwu6hd0U/d8xBc0epCXUmV9qyIwvHqQGjMiUO 15GR4vZW8YmXHSRbuCmFjryD6yg4LSG35d5KAVgET8pHlWaJZF5KO8B0C8yGVganmFTh aUTiu6aPaTMqQxomQ52lLhsSKgcomvHbuJAk/SKWoq0mXZyax1lgrW34VmyaeiQnWHcS ZvALjwSmXJqoiWHYGoaPy/K3R9EcVMcLDWAm+mu975q+sA+962o8JsH7gJJIDKe/6fYG juTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Yo7rGMXb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w22si4489398qkf.349.2020.05.21.19.36.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:36: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=fail header.i=@linaro.org header.s=google header.b=Yo7rGMXb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxXn-0006Mh-2k for patch@linaro.org; Thu, 21 May 2020 22:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWK-00025F-Bi for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:48 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:41737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWJ-00055z-I9 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:48 -0400 Received: by mail-pg1-x52d.google.com with SMTP id r10so4276232pgv.8 for ; Thu, 21 May 2020 19:34: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=qsogh1iVORSWncpn9Q6d07KHmeqCKiBimOSa205EF/o=; b=Yo7rGMXbypolOulo6jZnvutW+SAmxwEFHKRUQz1ULYq1OfBzpJkl6iw6WxsFlO/iCq K8aC7Tu+Ok6g2WlFkDZDGRgYNGJI1dV3rj+UMA1zjeRImM76sOwsO0ukAZv7LJ9FhJlU KS7ok2OdGGZldx6hs4H+YRjMWFu3e6uDbvINnnurPXyA/UtGfqVqLnvTZFMpHHwVd3w3 wqRmBIucoVLbYFm3hJ33WYcHsYdnPwefcyBEUKum5a1pHLRtQiN0r7QhjHyJyj2PM3kH TEFD4Xf7cAR0qIifdU0KoQEBoisgtrfwKiltpTqxRYylvyG9nzA0RlAl0nq+z1efS8XE l+Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qsogh1iVORSWncpn9Q6d07KHmeqCKiBimOSa205EF/o=; b=rKHn1qXnF/Np9sHhifGPll4UaOSOD7CXV6FkFWWmx/SUClZKcYeNq+T275/RTszK/i RtR08ynwnyUQgoMxtCnUuC3FzyzUmOtO/jUYIIut6u2eYdXZd4n0PUxPYj1J/6MPw4l+ 9VFxbWcpxXyv1RVejqK950CUO1z3csIfdjGpcCFKIxiVxOfsQr1Edea0auaGMVSat+q2 CzGp8p6yncpSZs3ludiomjvyfdzUIlbBe9tlErOvAJM0wzuYtl4WjUGU8NgQWH+qyee8 czZM75LmsmWkVE6hqHqUWRut0arjCG3tyjl6h8VS5LAihBN4bDcAMCuHTqaLZw0mAyQb KxkA== X-Gm-Message-State: AOAM5337QFTaNHK7BxVXVAQ2da4HktB6r+YEcqZFBSdyJMiv60MiHExk DuqTuVillDh2Ffkz6h7JxfoXPXJlx5Y= X-Received: by 2002:a63:d70b:: with SMTP id d11mr11840970pgg.372.1590114885833; Thu, 21 May 2020 19:34:45 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/25] Hoist trace file and socket opening Date: Thu, 21 May 2020 19:34:18 -0700 Message-Id: <20200522023440.26261-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code with --dump. Reviewed-by: 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(-) -- 2.20.1 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 May 22 02:34:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187116 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102603ilb; Thu, 21 May 2020 19:35:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkfd63+zaSN5ER1PR04g0X0FkdiUA+PB+LnCi+yNgsrOe5VLFfqJ59eKBnu/Ij6b8BBBYR X-Received: by 2002:a0c:8b99:: with SMTP id r25mr1614737qva.174.1590114952977; Thu, 21 May 2020 19:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590114952; cv=none; d=google.com; s=arc-20160816; b=tdcC9kf8KbwaXAzZ/Btx2gSrRs2fUZWWLJxmwGp/UwF3Rp5+66zzXkXSuUQo1IkbjI a8D7Ni8JH1w26IcDo5+4Aih6uAYPTUEagtgRYjU+wwgA+MRI7q83LjRIopjvm2ONP9tP iuuCjfCk6oD9UcLJuF528p/dg/78gcvS9ngO4r6+/MRM/Ez9Da7b+PC7C5h1pSgU5ojP NiXhN7AlROw8myE90yPB8ZQMJn32AotpvG6DvGBbI0NU4NaUEO/mi+qFMnxwft7ULRdl oxJUEwtD3GqChv9YuCDmjiYI4FTzg9dDoQYUMrZq4tTo2LrgKY0cSQXpJPJyK9eIvUH8 ZX+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=W1694WY6F055oZOFF3E5eWwK1wEHGNgMdmDWrbbBY/M=; b=MVh8CKaBmsdvUhBev1Jcd1ExQSxd97T3cAhCbNmIOqTGlMh3Vyq+TWvxa43E3kvoVr kkldc3ulwxORp7sqCB8dyWf0OJwnTxqqWmeotuGY1QYhdntJWbZfjehD+zF6BtSzZBOk Gg12jLeSKoDGY2C3qF08m0HrqzkNlBOlcEgtAgcKDKeJCbJxRO+k6pS+rCGn2KGiVFDu YgFvZh4pKMA44UM1GIjc0davFz/j+obthoV1Vti+TKi0/k8DG2Rsn0kWw5BImyxZHqCE OjYaLxXxWpxZb6UmrCkDOmz5HgK4mzyM42URv4pzbxxfwcxMrZ9trFurkDA39o49sjII b7HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GvVBlGh6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ba18si4503451qvb.150.2020.05.21.19.35.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:35:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GvVBlGh6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxXM-0003SW-GZ for patch@linaro.org; Thu, 21 May 2020 22:35:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWL-00027p-DJ for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:49 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:36957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWK-000568-Ke for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:49 -0400 Received: by mail-pj1-x1042.google.com with SMTP id q9so4346379pjm.2 for ; Thu, 21 May 2020 19:34:48 -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=W1694WY6F055oZOFF3E5eWwK1wEHGNgMdmDWrbbBY/M=; b=GvVBlGh6GZizFuyYHFIE3scoCKsIg/+Pinta/2iI0hpCwVAF9BlsEPmj5d8y+HwmXh p+43R11cG018wFQpJQ2nqBTpazUwJ6xdWAFSInINFG5e7iQkS5T7ZVDoqKEVK5RPXh0e X56Z5V2jXhd4Cz/WRhM1SVBY9leX/FvuX3r8GSf15MJ7QyDGmFtPCK4KpwW93MupSv5V 5B/gxKYA2PvfJGcLVRbjvLiqdlup5ShM6FRS9yB2kSJr74G5VlCdRpxWmhAmJMyXwSwX lA2SH2VRv/V3RFD6LUxRlBOXCPSL3taoUWqEzTLcaoxQb0FUvywYhxLEmSXQKCsE0GWP F2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W1694WY6F055oZOFF3E5eWwK1wEHGNgMdmDWrbbBY/M=; b=p6Xxer9PH51JQfpQ49xw1BR6rVUK1kpS9h3bpp5d6eXNGwHE9nenGsiicGQN5hBfLP fWYFTcs7O0CjOAVNs5b1ii3m5E8yo7bhqpm19AyM1t7jCRUtVUFywJX0YlMNgjiRwAOo FfcGKKxU9GYQRni7WLKBIAugJ2kP4wEt7hU1XPqRDoa3e3Fts7pgO23PPkHmCsNQuS96 F6EKnKv9yyEXw3KL8K9FCqStBuMx222b4UoeamKTvG0COjf2Y1m9yKsZs+z3BiZsnbw+ tRYfEtCBKtRbmlhuLFST1Kl64SPZQhNXuwoF7faaSIUxS6RBirSZR4WBx78kLZmSNSaY k4fg== X-Gm-Message-State: AOAM531dIXZnAJCmnlHGq446a6qMJgL7iToMBNPvhafmIcCFkRK5MJW8 J8BD2sGWmttgleIhSf23HtrDt1HLjSU= X-Received: by 2002:a17:902:6bcb:: with SMTP id m11mr12262424plt.264.1590114886994; Thu, 21 May 2020 19:34:46 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/25] Adjust tracefile open for write Date: Thu, 21 May 2020 19:34:19 -0700 Message-Id: <20200522023440.26261-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Truncate the new output file. Rely on umask to remove group+other file permissions, if desired. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 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 May 22 02:34:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187120 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2103039ilb; Thu, 21 May 2020 19:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0CG9bZWHpda0D6IKxVoRa7MIr1FO/7ZcPQBmh/UptfIRRDGA8RswRfENSy41vXTu/cX22 X-Received: by 2002:ac8:3fa4:: with SMTP id d33mr13969661qtk.376.1590115004687; Thu, 21 May 2020 19:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115004; cv=none; d=google.com; s=arc-20160816; b=KDEKHsJj8yV4RyjpDFZRTH3qvnkDvPYZxRB1LwQnb5zJE75ubMH3Y2DatiwTy7Q8r6 t7aY/Z+G6AnX8aoyiVVUeMDEe04bMYMPQb4c/G4VVUl1keXpsieaxMLPnuy0AkaVkHAT +8OjMisW7UyZdTt0qpwP38tZ2RqWUdMuxcKSlmUoh7njk6KwZbHIgW6GB6whGDeijHpx fQ/ms03kOoIItcXPOtdhJyBDuhqBD9l0kvigXuE5TSupoRnqkit462Tk8yhVCMba8COf 64WrUvEYt5OZv+2gp9f1Q/TOW7NtHFgCLlCyAMB31w86s51qrsRfkU3TI6VeA6/T5HaK Rtuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GXIVgvEnDLOXwbTNGEBPAbiNIboC/MDu6a6Hd36/44g=; b=feH/xx+uLbYytCr+LlWz0AkKDylmeBZD3VMETT/uUUPcnaAgmqKCkhkHGGxLCZLeR1 s/692Zmy+V7/8DiscnKWznwCIqPyMZ4ScQXZE/DbSVTbnnZZN3K4xhXNeDgw8NGHIVqu /bDI9wMVc6rs/9eFYu52rL+ohkvngHTlvStG5PkrlZfLPbIXDM87X6Y8VkBkF9B/6+Qi ND00g2dOVHsaTS2u8TJWfmJUMUKnZFC+hdJiZn3pMxd9wD3pvcuMrNENcBSkcSnPo0w2 n2WLXJL/5BgyfXPb/93yigqIzAUP8tffHxwtdnwqy4QZD/fZyAeNHMAGJl2rrpofvfRx AMfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=V8tLQwiE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o6si4480471qkg.15.2020.05.21.19.36.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:36: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=fail header.i=@linaro.org header.s=google header.b=V8tLQwiE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxYC-0007hX-4b for patch@linaro.org; Thu, 21 May 2020 22:36:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWN-0002Cf-8F for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:51 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWM-00056I-48 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:50 -0400 Received: by mail-pl1-x641.google.com with SMTP id w19so3802058ply.11 for ; Thu, 21 May 2020 19:34:49 -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=GXIVgvEnDLOXwbTNGEBPAbiNIboC/MDu6a6Hd36/44g=; b=V8tLQwiEW2fdgwc9KX0ulOVxEB703BehXNuNF5+zJawretRjIBIDv6UEnsaK09E0lH 6tSpvdJzl1VqIv9W3owno1kKB7iOxaUCneb2qFrTSW1CH7/LNgPf2KrMGS6dqSgqGCk0 /l8b5VHaxy+nrojrwL4tCjjkBFp1ynWap0tb+xjTzmLlbKClwB+gi3C0MNThPwFqE58S IfTfZL5BHWSlCWb65vzUk+jq2RuP8M24Dy1LOL4LrtE9DYAJEXtKsVKixTiIEWUIH59j 2h2z+sQuH+mGBgCjs/5iM9MpmHn7OMREoRH5FA8qtBlkClkZsme24uNipWEELj4uqklt E32w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GXIVgvEnDLOXwbTNGEBPAbiNIboC/MDu6a6Hd36/44g=; b=qgkp3+/mRTeKCxWtEcvScaiK6WjnbhiIX1niyVAqahV5ecVUSCqMM+79Yvna7Xrn2C NQ4fMu7Z867pkKAJZx9rxriaHYwU74JUN4Ls8yYs6voqWg3e0Ui/aUW24rsL5U8S8qyz 6Pb8WTEztyZ2vwG5oi0ApRXJtLioTDYuJAKEfC50ucE9mwcMFnGzUF1a38KxiWtPDyik YpZWbNT3mNPq8lZWeNxep+sW5vRubqzHAyciw30T4L4qU1EIArorSBKqKTdmEE52zFPf qVnJjETAckSZwQeWprT9DDxF9lvo7h99PfFMe5boshvTYzBe8ysPWX9nleWwiAWWaCDs bz6g== X-Gm-Message-State: AOAM532YDPwvtkYCRISpjZTaRVivgyASqwLDgaHUkgF4PPL32mJFn6Mh ufRotq4XDCbGwuMbCeR7rBnleAJbEC4= X-Received: by 2002:a17:902:23:: with SMTP id 32mr12514073pla.40.1590114888259; Thu, 21 May 2020 19:34:48 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/25] Use EXIT_FAILURE, EXIT_SUCCESS Date: Thu, 21 May 2020 19:34:20 -0700 Message-Id: <20200522023440.26261-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Some of the time we exit via the return value from main. This can make it easier to tell what it is we're returning. Reviewed-by: 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(-) -- 2.20.1 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 May 22 02:34:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187122 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2103662ilb; Thu, 21 May 2020 19:38:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx73jcgce8b+wFGiH/chviz4PEqxhbpzZTn5kdUt04zr17dR0I/d1mJkHI0mRzxBmp0vWy5 X-Received: by 2002:a37:7086:: with SMTP id l128mr12583374qkc.61.1590115089976; Thu, 21 May 2020 19:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115089; cv=none; d=google.com; s=arc-20160816; b=mAR5yTCkMzGRfhJRUfZoFcZDSq7gz1f0FcfG8kyLp+uHhUFJpoPTzrejqzkwqKqTxt y1DKTuFcC2QGE8gK454sNzb/ZkF+ulgEvhpLj4wpNODbNWQ0FMMGco6DoME/pPu3lQjz naGaPx++iXBCv4X5yqtXQ66OmnVms5KMBfN6GA4UtOkhWRdcmTZtSiWpGbOKk4g7xHhy jM43ku8DBdj4JHLFfEAscLQmDNPN6FlDodbIKhIGEKJ722GDBAVA9ImH0ZJZQQS1+pLj 0REM5Lrwc+mNMq7XKf9gYQFDMxz9/PJBhR7BFFeEd5PoypdyALHIlhGZtuOuLyqCHWsV 4LNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CpTMXKHcoiytZRid5gwjf0q94Tx9HJK5chSS8lZYa0c=; b=DI7Y/X55yhxXFAR2ijzWucGwxqXlPG63B47gTj+cBSgCzj/pW5vRPvS6Z566ZTGKwi KujRi49sneRLHWOkZNCTqUw2f3NP6uKAx4AKfKJ26ydqY0EgsJByAO/2tijtfhUUVq5Y lyX+06O4Oj2iKphstkuVQFROpteOfArG87D8HM1Fao+AKf2HRRup/4JYSQgb8ozoT+no vg+VMyTSZ1CVRj2gEbeIM/aVnHCDrEqyMNn6itOqnPXfTuUF9SEuFSCPAGce4a9obuv0 llti67q4gf68oFibPmCymaz6PI8csewiusttoVDrS4qv3YwiJ60ZA/V02pXLG1TmoXik StNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GeKIMm9L; 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 j17si358837qki.243.2020.05.21.19.38.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:38:09 -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=GeKIMm9L; 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]:59652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxZZ-0002IZ-FL for patch@linaro.org; Thu, 21 May 2020 22:38:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWO-0002F3-4N for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:52 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:45078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWN-00056N-A6 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:51 -0400 Received: by mail-pl1-x644.google.com with SMTP id u22so3800078plq.12 for ; Thu, 21 May 2020 19:34: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=CpTMXKHcoiytZRid5gwjf0q94Tx9HJK5chSS8lZYa0c=; b=GeKIMm9LF31aLach7PhMa4JuTyVQ84YVnwA6UrIdpVF4hJCo3uo8D2tmNJG/AG6YNq 2QxTq8MfklRNjSYR8+Z4KwqbHTcBDi4dQOBJ9LLfs4m7kwai/Kpn4FaQtx0xJZkj73L7 hVFJKdkPE5d5nxtYIWauEHlhKhlU9UCN4efgC97wrWI0W5iZTdlLJK1q0pb6aMYjsAxU wqW3fBGpuJFohfytqvhxS4wjqDhNN+Ytb2DwzwrhHVrvQ46y2RYHSW0LGumBsyySz/t+ Q9MsLO+Q1VLj90bUlYqGoqFFP8N1IFotq7etyfQod3OAavYuB9Kf66AncMwfRRlD/9kn 9Uyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CpTMXKHcoiytZRid5gwjf0q94Tx9HJK5chSS8lZYa0c=; b=UdOUX4K50eusC1sLJsy5MM7SlGbYJV7xYS/pjfzvBq7wFIhU0SqoMg7ghLxqeulb3w cs/MF/wO+snqsJCjN3gAhevTu+/ZW1/ElS/sDNk7xz457p593sqtfxtdiuPdwEkVU32A 3VZ6X8oy7lkqZdxqWZVoeAl6F4rBokNn0cSqAf24M0TFzeSIXbRfQXNIZ9Il87/hXnyL /gnw3RePT4TIWAq2z3TwMpHk6pps4xBD+s5jWusGwtMUt4hXWFhvv21Qxqo71dDXU9qK 5FNa7TGOtOPJxGuduWK2YxSz3UdBqAp3/mofuOCG87evOYSzJD0MP0tPFbp8A2o8T61T z5Gg== X-Gm-Message-State: AOAM5311f6m0a1pzW5BkBH3aVrjw/aPo1VBwl36R0edRL30Db8zWAmqc 7EN48WzbJerul/jK1O5hO1GbEaN7RD4= X-Received: by 2002:a17:90a:fc8b:: with SMTP id ci11mr1786607pjb.40.1590114889697; Thu, 21 May 2020 19:34:49 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/25] Make some risu.c symbols static Date: Thu, 21 May 2020 19:34:21 -0700 Message-Id: <20200522023440.26261-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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(-) -- 2.20.1 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 May 22 02:34:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187121 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2103650ilb; Thu, 21 May 2020 19:38:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRPqmt+w7hZqCo6ZLVdQyf2r5mnF90KWssQJgCBYYF8TOYnhe/+LvJJnEM0Y16kRh6fHRZ X-Received: by 2002:a0c:e947:: with SMTP id n7mr1759725qvo.165.1590115089039; Thu, 21 May 2020 19:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115089; cv=none; d=google.com; s=arc-20160816; b=AOysQ13Cz9IvtEs51PGZe4qJ+XEK7ds8Ihqy2yYiuYwjlIBTKHZm97FbiQW79/0F2D vTCYrPq2nSjzzHoPnxlBRJCl7P64whkQXgIMJWfhRJieWsDHa5vOAB/OmuA1akeVyvWy v5KV6WRnhSwE+l9tYsVRaHZSuUOqoz6U7BH/XDt8LYBng1Pvi52VOQ1fXbxCaafsHZhy MpKjtMk4M4zJnEf3RrQVmZ/EEer7q1LBxsdyhJzDjT8mLyRMfX+JcC0+6GxHKOb66+Oq 43kUQJ+VO/nd1GrKooOCZVdLh+vMj6H0xa3BG6xa2QyeZEjqQdJ2np/7uC5GzahkV+0C 6oxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pUDhKq2QDEDanz0bWwiGRznNEu5AkBEdSOmZLuPk6MM=; b=X2rkCjnq5dG66wb6O7iJ0fk2NU2GUJME/QUoZayL53Qqw8akho0RvGWIRvt/avGGlY QLjwAVNIZgoBl8NiROtgTS+BclNme0H2fezGgKTg5upXzdXDJmZQq0nbaYcFB/5rFCun CgRMa+YGrDHZz38hnI15ZNE096KE4FwYVUi41yEqWfsFhN2gEUsRNB8pDT71unjPnxSW SHFwh2O2ERjXPC6NdK1thlpDSOv7ma6Y0k7E+PA+6B6lCVHmDeOx1QNd/4+UV6ziZv4C igGOlJATk2wSVvm8EU1n6e8IqB+5P7dqw3/65/dnqN7UyJQ003iaR3LvZoQExMyT7IlL ElpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kAhNLlZz; 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 r4si3975071qtm.294.2020.05.21.19.38.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:38:09 -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=kAhNLlZz; 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]:59508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxZY-0002FI-Iv for patch@linaro.org; Thu, 21 May 2020 22:38:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWP-0002J8-Ot for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:53 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:42280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWO-00056U-LC for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:53 -0400 Received: by mail-pl1-x634.google.com with SMTP id x11so2823481plv.9 for ; Thu, 21 May 2020 19:34:52 -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=pUDhKq2QDEDanz0bWwiGRznNEu5AkBEdSOmZLuPk6MM=; b=kAhNLlZzg2GBWJw+ycBl3L6CRTnj/U9QsqOlpiX/UYaf5Ujo/5+D6ILOgKr+5SMmY5 xG96qiAGbapeuTLSl5gA66pwQ7fPVqeqE+Jx5a8jLgme/nyy7dZc8niVvptL6oOKdGcS N/Vaj75ePGXGmlLG/usRefmMcbMnKRyqvsJsFLQSyy+rWaIju3Qiki677TvLDt+kzb3B 6Lfji/PYU57qxaBTUfWkDXEYsGsue0EKXJaIul60QhT+NUdecdbA4ERKOl8XIjETf5pA yFvu40r/NGeEY4u2qKjz+QsHVudMpemUF0QHUGJDqiBT7A4E3Rbp6MpHSPqjr23zRYFR lRbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pUDhKq2QDEDanz0bWwiGRznNEu5AkBEdSOmZLuPk6MM=; b=RwvBXF8b6AownatS+4SIKVm3Ynh/Z+h02XYRCciD0zGhHxLCyXh+BkaBDHF+LfBd1e o8zJcS584xaIhmcexBzoTvkbqFhom6enafwgm3fYCv1/DeKQm7IW7x6ZLybqSbzUu7zy iHuwiZObLDOjDcjSDNkb8XAJFQTXNJcw4a2Ba86Ke/7lcfE6TyEnCoZ9EAZnB8ZFJ4bL scvjBEP/wVBh5Ubf8uGVShOaIs3QIeJtMieWzBljhMof6mVHAgF3/MxzuOhzi3TOAbpu 7bYmePoNSFparnfdy0Xdll/pCGK3i2l9MFKLmJiJuGjuZx7MRyjCF96XF90bqsO0A222 JXFQ== X-Gm-Message-State: AOAM532JkYsUmVn5QbkqwsvGL5lalFVikr5t4K/DowV5/UUh8U8mwiEX TOsTMbQehwmec/qdFWD1v62pUEqXORs= X-Received: by 2002:a17:902:a513:: with SMTP id s19mr9034196plq.168.1590114890804; Thu, 21 May 2020 19:34:50 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/25] Add enum RisuOp Date: Thu, 21 May 2020 19:34:22 -0700 Message-Id: <20200522023440.26261-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Formalize the set of defines, plus -1, into an enum. 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(-) -- 2.20.1 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 May 22 02:34:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187125 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104478ilb; Thu, 21 May 2020 19:39:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX4Hc7trLV/p7DXvMfekU8vGdZgN+oFVSwSVQfpk67bDulaJwgA/n7b32L7qwvFl849Obz X-Received: by 2002:a25:ba8f:: with SMTP id s15mr20122217ybg.34.1590115197156; Thu, 21 May 2020 19:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115197; cv=none; d=google.com; s=arc-20160816; b=siFneVIyVI6yzP+faM1XII5wQnN5l6jPUxccop+0N2mPayV4JTlSMa+FtS+XbNCfDB nZWnS6QtYtiI7rBoCP5aZ7D69GboybxitudG5DLgtXZxKfu8S4bgl+ITQFtievvBVMNv 2AtY9+0iWTd8xIC9pxTD67R+5CybGAtqL2uxtwH1TIu5sxk2OP0+UeF6z/6QdreLDj3H F1UgoJR4bkJTkX9KVZTjANZaVBhLbUZ3VpXmksJ/fGnUyfARF1IH375950AGqhgIXk2N bAUGc4Lq+EYGFwSpj8pU1hQaBFVQcxqk3NO62PQirn1ZPuEkC6f8Eli1QVYq/txtDajD V41A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3G4PJj+ygy8yy6dNKzxkyDjb06D6oXBdXQgauyjKNKc=; b=aB/PO1wHpyNEX7vQP7C++hb6p83MUD6buLipcML8qRW6ZnXAej3/RgbTmA7a98rgca uMWo0VQgVtpvicZBGQk86L57s9EUSPdGfmy1CmZw6PA4k1GAd5umm8uDsU87IbWaDxhX eEhYvyz+++J46nHN8kTQ9BRghctr1cDK68aPOH9rGx6TGxZn2333xfv7idSSfz9O0xyK V5o67+79iEQbZ5PzkyWT/ZQrlq0BvdrXSdDtit/gtTXipSDK2PEZ+5mJbpcNdxFWupQt hpKsxPpR2DCoV661uxktIWrJj+0z/3fh0NVAGmjCcUMfR9hPatJdLOt1Mm3jRbPogy5H 3uPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYzFDTzE; 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 g18si6670460ybd.194.2020.05.21.19.39.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:39: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=VYzFDTzE; 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]:38490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxbI-00056G-L5 for patch@linaro.org; Thu, 21 May 2020 22:39:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWQ-0002ML-Vz for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:55 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:45078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWP-00056d-U2 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:54 -0400 Received: by mail-pl1-x643.google.com with SMTP id u22so3800107plq.12 for ; Thu, 21 May 2020 19:34: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=3G4PJj+ygy8yy6dNKzxkyDjb06D6oXBdXQgauyjKNKc=; b=VYzFDTzEPy0A2kxWMWYkLaRVXsZ//5tFKncxAGUD2ZuPjx+xpuwaOLVyCAtQXz4x6R GU5gN9YV3x7Ps2RlJHECsvuN6s0hzf6vVXOwRm0XV3Vy6tmfCD3TJ4sYc6b0auV3SXmB ltNs1MVKO6EasxaMRKzr+V6LTB0WX2hjEbgj+ceE81l2QHJ5gaqogLB72a6mIzXKZLg5 rb+KG98p+9mZaU9mYK2iyQpyl3wIEZEi1O6Ef4CU6CS6df2Ht59HT2WWzrwsY4zhIq/T NLQ3+0z67jT76lybRHgvsYegfVVyIjeLzLYTpeoF1Hg/p9qdPjKuSMVSqEVufgVuAS2R +bWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3G4PJj+ygy8yy6dNKzxkyDjb06D6oXBdXQgauyjKNKc=; b=O8ZM50MJvry9y/uG6xWrUBL0uIBM4y9Og6/lC29SI6OgTAI8duhCjhnAmyjlEh7orw J+OCgWisl6hLET2KbdoleF0KiBOvjVxnUDYu+ISE7osof75zg8NwvxheZR0xefDlgM5G xtRxiPU5n6Zuq1Suit2Iq9ZIS3Wxns04IHWyoN2cAQkLh/u8liuz7LILI+8ONZbxlJpb VvfqfrFeWakC7seCI5dyuffzCnRbwXK3/Q7lvbnMublxB2EO0DXrRgAlYVqFnUvILhtE H7N8wB2d4fnL+UrtEeF+bEWS5cDMFHhE26FROhoRxr0DiFdsILEWomJZCecAXzRKnJRo hK3Q== X-Gm-Message-State: AOAM530lY357J8keqYCkTxkzCJKbJJUxWeiBuHRgEoCOyMWMzfBAkFz0 Y6heWq2z43Jzp9MhgjewXvpGt6talPU= X-Received: by 2002:a17:90a:7087:: with SMTP id g7mr1902831pjk.70.1590114892095; Thu, 21 May 2020 19:34:52 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/25] Add enum RisuResult Date: Thu, 21 May 2020 19:34:23 -0700 Message-Id: <20200522023440.26261-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Formalize the random set of numbers into an enum. Doing this makes it easy to see that one of the responses in recv_and_compare_register_info was inconsistent. 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(-) -- 2.20.1 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 May 22 02:34:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187129 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2105141ilb; Thu, 21 May 2020 19:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk2uLLy3Aj+3P/SwSACQIVaP9badg5wvVAVUevxz1ctGvj9q+/cpAQ82xQ1ORbJNeApyjC X-Received: by 2002:a25:a567:: with SMTP id h94mr20528354ybi.95.1590115285134; Thu, 21 May 2020 19:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115285; cv=none; d=google.com; s=arc-20160816; b=r513Fz1NyFadpsqNvRIREPls5kyT0dlmELxe+AYKZPX3e4VSC2l8WUdeTjVco1srP7 9EAo9TMOdGqEyss982F0yigdKzl8DW6DTbkLfQyPRXpjFXg2XeeNRoQSmLxGT0vxtgAs w+7jiAIZWRM+7r2XQVrrF2cfVUJRtFPlxAWgU26/ZXGlY+8/eiSmSWmYKsWM64iAfTvC h1Wj3Q0J+e5BY51SCelGicu28TYthUwCP6/Fz7+5UjNP4xQ+/Q0jdnTzzegW+DzO9rJF F+nI5mLQtp3Te+UKluFt00NESQlU9U9mTQRV2BVaum17Ua2QNuIS9WG0nZN/8VN3r1vj /gdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hXiDJogXpOZ8s/dlpDZsG+PYSCUe+WH+1ZPNXE4fyIc=; b=r1xwb1OQ3R7WQRLiW8hF2LH81oJBDu/6DGn1OVPI8Y174PgQjVK2A5wU2kkZC244xt qBoHbJONrFqEm5U+4pk/h9CNfdrmHx60xPUylfm9BPuLrCwTo3zoR4xERrUXJHdzDjTO ssZwHPmf2pjwN+PIQpB0KrBAGl1+EoH4HhxzSZlKTxahdGO8t+8wrdpETW7yTLPhpUoC vARzeeZa4+yabXjVPO9/9PTPg3a/2w/xKbZY/a7F3rFjqCfZryUgjfdLoiF355mJdUVT Io8CelIHYF5lm74sJqBHCJ6+pHKzI4IZTZpbxeX1nqOEZXy2VzZIO7lCPA2/Jk7u97zJ VEJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y8oq2nft; 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 o185si6671422yba.260.2020.05.21.19.41.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y8oq2nft; 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]:44922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxci-0007k2-Lb for patch@linaro.org; Thu, 21 May 2020 22:41:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWS-0002Pp-Gb for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:56 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:41330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWR-00056m-6y for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:56 -0400 Received: by mail-pl1-x636.google.com with SMTP id a13so3818050pls.8 for ; Thu, 21 May 2020 19:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hXiDJogXpOZ8s/dlpDZsG+PYSCUe+WH+1ZPNXE4fyIc=; b=y8oq2nftNUkDv7Z2gNTLbZATHAmWJH/x/kF1QBHHzAzZBMEUmX1crqzdmdBk3Qcr/K 5K4TA5o/UnBMxhowtYzwILfpvLB/Mz2RtepAvwNW9tw4NnaoU87rE10GI5pWfWfgPOYl xg01RVrJ4hrNZX1EZy9aJAY47yh/hEAOGF+SPZrFuXZYP9ueQNcMpj8QvUhzmWMagZFg iTboUdcVpRdEye8u7XvbTEp9dUmD9Hbu1KPLzfaDThCMFuqeTyhWCB0ADkra1gBFPgdY 2I9UITnAf7/w2y0WqEvlIOKhpY5DinzbwBsRfBnpoSB1NzFd807iJBaArymPxtBGgITV F0sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hXiDJogXpOZ8s/dlpDZsG+PYSCUe+WH+1ZPNXE4fyIc=; b=C/KnhE0XqQkmsXRUjpJ/Pi8R47+TEvb08pzeoHjHjpz9/sYssGKWbDHZz8Emc/D8a0 VeuI5DpxV9NkQXG/AvQkTnJaHBYq22rf6pjTHw1GET+WDU7sznhQLqWKvEmE5M6lJ+fE 7t5Akt9hBde4wK2a6QXU8RUv/GXSuC5MjC7waO7wxpiNfYVGPQxOG7Nywj+TS+3FraAi LT3ogihlho968PrInY0TJ1NIzBrdB+RSun+CxCpY/XXLjP2F6vN+z2MbOA8ZmyqD6ndX D7CgVHgMgIZgHRHgT1lDEOk4RCzepF7iUoq2EjduPHInfzp3RKL48iDBhuJuaKDGP5PZ OikQ== X-Gm-Message-State: AOAM5312/7g0nREDKvidFMXxHbd/xrnXs/sRTJqMTThA5E5W2U/fAf8B BZbeMiiu7pBsT2sOGGLUJJT3441Evfc= X-Received: by 2002:a17:90b:344d:: with SMTP id lj13mr1869879pjb.160.1590114893353; Thu, 21 May 2020 19:34:53 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/25] Unify i/o functions and use RisuResult Date: Thu, 21 May 2020 19:34:24 -0700 Message-Id: <20200522023440.26261-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Push the trace check down from the function calling the reginfo function down into the i/o function. This means we don't have to pass a function pointer. Return a RisuResult from the i/o functions. This fixes a minor bug in send_register_info (even before the conversion to RisuResult), which returned the write_fn result directly. 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(-) -- 2.20.1 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 May 22 02:34:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187124 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104331ilb; Thu, 21 May 2020 19:39:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrKtQXmSd+d7g84gTv8TkXptIZxZzwyCaRpoWjtKMa1T/7zl7aCiwYwfhfGid28/u5Lr1X X-Received: by 2002:a25:aa4f:: with SMTP id s73mr20161625ybi.156.1590115176858; Thu, 21 May 2020 19:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115176; cv=none; d=google.com; s=arc-20160816; b=r+kmAxfXhGc8BlqM2y5xNKBYTNRgXX65d9ilYkOLLahc7XoOkkURtqRdFrlhSc5bHN fJvqcTYHBUa1n2ytNoiJXp1lIX0XTYHUKLwjdqjS0gBJoz/rUEQ/g+XCO5VzJLeT73N8 rQk/votqQllpaKHg8nHGslINWt4z1eyCHzpuKS5qP3mQ6Y7oPwaCNiBYzzFCpVk80F3O Ie9lkUSrQiA+nwLAprNiniPz+SlXgcBoiAo+7LdAf7NO77YcaoTHCEri5yRTPLPu5Whd H2tpYKcq4yBItFnBLB6QE45Xd9FW/FRXsbIwln1S8DSf52mnDYk02/s5CC1ChQ10izV+ qLAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=Qqt6c/+iuoKyIH3TB+8Wso5+t4q9OcDR/WG/4hWUxqeirdJUOKQkDaQoEd+P1FcgVY aU00z/i1HN3PqgreYwuBkwnvHWKy9NwqhoGUL24ET+a1eTnCSBVgLIq6vtS0xAoykAe2 4BDdXIuwMJ8hNmFmEgJWV094qxRnTT3okXS/Wz7+SKarkFRFb7huOLqXg/ST8CpK+RwF FAP+o0P75Kk8LS+DXMT7qCsbc766YB5qQ30BLFINKAE5p/Kz1/zOYVOanAH4VaopBoeD 7Begj6kLILj12yyVxd2CHYBxqQupHgcvMMP5DrGNBPaa6kNZU+9znSZT12SXGpTjXn8g or+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WuQZV024; 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 y123si6898986ybf.94.2020.05.21.19.39.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WuQZV024; 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]:38476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxay-000563-99 for patch@linaro.org; Thu, 21 May 2020 22:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWT-0002RP-EL for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:57 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWS-00056x-GX for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:57 -0400 Received: by mail-pg1-x543.google.com with SMTP id f21so1284011pgg.12 for ; Thu, 21 May 2020 19:34:56 -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=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=WuQZV024ez9Hv4PfFJq+w6udDFdwJhqjrR+DfehK0/yV/87MVeYs8eQRxqZpxnhoGE rtFuyCG4Oo+6yxMOyCxXXUVmq93EfR+QoRxNGu4ArljYAkvJd0SQMap8IaMsqjRrm3AE mrbcWFA52Mu6hLRQCp0Gp7qTVp7QfgphD8X+jePZ+AQ+QZJ+lc3kgb9SoMKK4Uhhnm1h RJFgD3wPysfehwxkP1EZERi3immiYYQFClAFEGga44NElH8/6qkb4Z3kJrOEnomP4QzJ 6f7pGI57m/slKYSvyc5fh8D39+jcVCgsBV2k45pTuAlJgIBXlFd/NT8+k2Q0vmqYlSAp LJNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=IeMeWjljLmYjWwein7QaJByHlixJpW+LelwYIfz52OmokqL8Tq5dFv+YIu3jgjW5iw 61wQYx8nXhxFmPfXyJr6BJ/BDo0z+MEpvXUbqyNCv3ZxWUV+RgrS1YmIWcVEWlEzgHzm 3H4yuc9YeTa9Oowx1ieRs2JCwoFi0X/LPwQoIWGEYU1wzJAwWzQUUhX9wYqH4GEf2o2y 9i82RuiPHP8C0Fb7zQi4g8d2tPKd+tymxtJqg3xjKeU8l2Lp+AxWTUEDUSYPUnpUZVi9 2G1ScyXLi+X4ibJ5LSQ3FnyeMDAGTZ1eU+RqdaVHZVzUhRY3noUXjTiTR2C70pLVUoOC RC4A== X-Gm-Message-State: AOAM531mO07SN97HDFIC3OkrujyKyVMcdohpPvQVqDlyrgLPh0SnE+YJ MEbnVJubBYREMOjM4pbZOBKh3HGRaQw= X-Received: by 2002:a62:3383:: with SMTP id z125mr1684956pfz.271.1590114894796; Thu, 21 May 2020 19:34:54 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/25] Pass non-OK result back through siglongjmp Date: Thu, 21 May 2020 19:34:25 -0700 Message-Id: <20200522023440.26261-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than doing some work in the signal handler and some work outside, move all of the non-resume work outside. This works because we arranged for RES_OK to be 0, which is the normal return from sigsetjmp. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) -- 2.20.1 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 May 22 02:34:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187127 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104898ilb; Thu, 21 May 2020 19:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiMT5tf1HUI1N47BWltSBJXGxlVoE5W41V4sCDhcZV/AiioFHpUgYTyz/bolSggiwxucXJ X-Received: by 2002:a25:3044:: with SMTP id w65mr20604182ybw.207.1590115252575; Thu, 21 May 2020 19:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115252; cv=none; d=google.com; s=arc-20160816; b=yhwmIfHG2qE4/6g1n/ihELikAyOp3mkig3ftWQdK4oDkjeakgSm7CeUB1poUFjo5hy IQppd6JaTyqM+EnqNh1wOlOrc/2LC+n0a1iNSaknfoTKqTNSFR5N+dxBAXdP5v+YYdak 3Drl/g2f4EzbTY9nF7hz1kFnRAekL6pyXtbgtyRTINgFZtKuBsMURRun0JN0san65i54 jpUOsdQgqIQRn6zKj0ttyMDCL38H/evHGbhDZVCbvRIEl6yDXgnl1p0gQipgrC6fKliv XCHwgulAc2sQlkrdQsT+bNowDfMPIbzxfd0QX0fXCkbMntGSOxtfBoiiijRoRven7Ar8 JgNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=eTv8XWbEWzRSTmnzzPXdqnO3RaGyZr04Q6UotRmePOCe5x4nwxYshRknG0JCpazGPd yJbDEG1rUIcKXHQP3M+GDDQ9EQEEdZLuE6yTW6qjs/6D48nNkaPaHMvTzFskPCH85pXm jcs3Gw+QIK5LKy41ige7bEAfI7e48syyQEg+IJDPB0Ul/HPTZu8mpxMl8KA6Yqd5siMD NkWCWIHsWl5N9QnyujJecZVzK12VKabUr+GhI2fV7FhOLHqbsZv4T1NFHqLPd/XLvypQ Rzz1LUSi8Im+rjr6OK+hJFubiaIvCHezv7ay/vvqoY9OorzCaBUGRxgXVfnCQQAGm4ez 3GtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kjg0V1fa; 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 z66si6526527ybc.286.2020.05.21.19.40.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:40:52 -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=Kjg0V1fa; 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]:44824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxcC-0007hp-2K for patch@linaro.org; Thu, 21 May 2020 22:40:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWV-0002VI-0h for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:59 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:37881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWT-000574-RG for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:58 -0400 Received: by mail-pg1-x541.google.com with SMTP id d10so4292409pgn.4 for ; Thu, 21 May 2020 19:34: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=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=Kjg0V1faLSnT5254nz637RsvJ73jyNX4cA0CjlrSQFZqAgYF4dv5WVl/Ak+fV7Z9DN PEFMynQjcqS8Pn8jgw9BxRweI0b8szlERetMze1/WxlPXc90Jvym79uO0h6gi8WU7PuR tkVRZCHxFPTPoIZOLwX5YTPsqLA9EyXT00LohDOZf63dPZTj3F6wYe/VgGZGtrWV9Qxr fjOOcQA8VjZ+xxxg54blahtEuopQYVe4iSv2Eb48FCsbax98kmNj4GM1zWpBXKyYSPI7 JW0Fr/n47EorY1YM6KcUo9mjWEyYyVRkkafaVuMLE14ObXMkG4+Wcjtx0/1BLEk8ozQz v36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=kE21hhyNZZYzbM4gZJ+rk687Zz2np6huNvcmEs5ukcKkuqHwMRDBXtF7EPtxzxMZr2 it+kbWFm875htyiGKlheZd+uYNhe8CwN2mwIMTUO+RK4/lKHeOj897ShwYjPEdPfeEnz P0QVBnNPwya9IAjn0foYSLp+YXvtcR3+nb4l/vAuNVaoi/7i89BzYXhi28CROB7W+ikh zjZdE8WvIM6GvTHLesBjrgqCbCBoYX0qztlXz9oczjJfHzGFR+ck1nL79IFn+nHG06ut u1I1NKpwGc8YLmGBMExy+1b6jyBumqcaDwZLRaLkQsVJimcGJr8M/l1LEh0lxtYQHToC PnhA== X-Gm-Message-State: AOAM531MyszpnhTobbmfe2c/em7Jx8nlCTPeMX1BbQxmFp3S5ubqImCI 4nDtye1ic6rfjUA/Osduun4Bag7Ry+A= X-Received: by 2002:a63:3814:: with SMTP id f20mr11520301pga.266.1590114896004; Thu, 21 May 2020 19:34:56 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/25] Always write for --master Date: Thu, 21 May 2020 19:34:26 -0700 Message-Id: <20200522023440.26261-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For trace, master of course must write to the file we create. For sockets, we can report mismatches from either end. At present, we are reporting mismatches from master. Reverse that so that we report mismatches from the apprentice, just as we do for trace. 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(-) -- 2.20.1 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 May 22 02:34:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187131 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2105632ilb; Thu, 21 May 2020 19:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhVSJSJW0wLeF3Rl1cJ27yoONE365k+1hLGadFmLz3Qw9GEYxOlYs7QNQ2ESv8L/wX+xwy X-Received: by 2002:a37:7643:: with SMTP id r64mr5929916qkc.137.1590115353831; Thu, 21 May 2020 19:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115353; cv=none; d=google.com; s=arc-20160816; b=jRC3DB43de0B6D9zDI3PTNuwcK2C/9krqWCF9uzpeZos22nFVvp67goYgrm8ZVSSTv 0y3OuvIv1iwg0fuLqfGba6qvyBgFSxxKetgEWl25RhSm+RgFwDnQpwfUEoh2wlRN+oT2 2bLxND/WlIPL5zkEDq4HXnLdD9YZIg5lvc5n6n8phljUP+9fFaayk2+tx1YQIlvfOKiR 9IBnJFGRE3PoNz599NW9tQ6F1apw7vCMskZ5zvc7Tgm2PEudUXTAdxMBVELus2WFTD8K bvbIoksajoVeqUYyCo3PA7vywuqXWxXYdH7nmQYGYcXUNs3J/2SvBZgauGtzXC3ujo2B Gatw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rJUczCRf7dBt8YUhUpO1kHr1QrkMw5NPc8UGt9HIenA=; b=W1Wh6H/MEauBcdMcOLEjxX4eWN6ogL9b7DFIO+VC74xMrzhOQmvy6ZkyN9VuydUsOo oZQUeMhlkP+TJsRCbeRIlF/ClA5yey7Kp8CZPnJt1LkPNFaOKHD+E3Tt75MbR2snzLEn JixK7TDC/8OUp53RAFMTnS4B3+WQhrxdeBq8SUrinBnkqekl4KTJeg4be4GshxYJZ09t FhrKMvUO1SbdcDkIJhFBJsEjX625Q4fPuK8/frDwJQ6Kec1YCttQeg3ievUwTyZ3HwOs jrJ7eJNaeE+OD+JhXgJMyeZ+1I5KxgQEsp6PXCQ53mJZ2kq/IUkxMGHq7KDWP0gHKoYK DgBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JlwNv7+8; 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 s24si4560182qkg.129.2020.05.21.19.42.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:42:33 -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=JlwNv7+8; 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]:51188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxdp-0002Tq-Ce for patch@linaro.org; Thu, 21 May 2020 22:42:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWV-0002Wu-Oj for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:59 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:38309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWU-00057B-Rm for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:59 -0400 Received: by mail-pg1-x542.google.com with SMTP id u5so4284365pgn.5 for ; Thu, 21 May 2020 19:34:58 -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=rJUczCRf7dBt8YUhUpO1kHr1QrkMw5NPc8UGt9HIenA=; b=JlwNv7+8T85n3ZlQvSqBuJS4qU6VYzQ/2w7aqL5AkZIqVR27L5i58mKqvi0CCNE18Q DcEaAkxdJDcu+yiekfXr8zCahz22KXdSo6GsG1hWRlTjVlk2+B05tQfFYtfadPdW359f WHmBIbt2ZQhYjYR3D0HNgpICN/Pt7MDsn+TPv6j51CIcmKc5D3hZ9Dpl9IRhJ0aCsRMQ TgZ2q/wOfmsXcCcB3cD50w4xme1jdOdkNNZfKp3Yqd4EV+BFo2yS9wggcXneTcD3+1xB 0O3mA1YujsBXm83+DiQIz7wgDkNCo5n7DlMw1n6jtVZ+tpuM7EYWIlByh+g+KDsCPDQ8 xEjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rJUczCRf7dBt8YUhUpO1kHr1QrkMw5NPc8UGt9HIenA=; b=OmuhLYF3EPbqXvepDL5U+fGo+PvLTz2rwHhqNGmzVpLMottTNRjHJNfNM/u02EK6x9 s3RN65F86Mg87PUaB5SaE6IUMFu/mat785ggOdv+1rW0UK2fwXL1MCcziGESYte+vwdL l4BsqFw49fEoAMM0lCrNrq+rvtDSmoFt+pNKNeO90DhZYKGLIbWXNBun97Dfqzt392qd pNOY/pSVvXGKsLMHuvtxivAGUri3/NfJfha7fVKMXGQqxndsci6UWw6CZQb2Sia1KQ09 oS8kNazLNMNTjolgrYWa+FK8zE1Bj10C1WjwCujLU528Y53Ms4aHBONjCoHATxKdtCAe QQrQ== X-Gm-Message-State: AOAM532SztddE1ZmUC9/rc+1JeOQDohPIcmzRt1atZfKx15UE0DysG5r 9LrHwODFigwN0P7Wl/zmCfgXzo4mKBM= X-Received: by 2002:a63:f709:: with SMTP id x9mr11658477pgh.330.1590114897162; Thu, 21 May 2020 19:34:57 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/25] Simplify syncing with master Date: Thu, 21 May 2020 19:34:27 -0700 Message-Id: <20200522023440.26261-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not pass status like RES_BAD_IO from apprentice to master. This means that when master reports i/o error that we know it came from master; the apprentice will report its own i/o error. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- reginfo.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) -- 2.20.1 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 May 22 02:34:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187130 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2105501ilb; Thu, 21 May 2020 19:42:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw46wMtDOmSVx0JmNKGP5aAsxmlCFI+ZgaA2zW73CNKMnGPhROXM6EEqpQvud26tim2YSH4 X-Received: by 2002:a05:620a:526:: with SMTP id h6mr12450005qkh.395.1590115336137; Thu, 21 May 2020 19:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115336; cv=none; d=google.com; s=arc-20160816; b=arlC0JulM9eqUFqpf32wzZcNGaaZLS+64OZucSrxk7IhQT1ud+5YoULvcjug+LHFXK BeuYtagNgU9hoPYPblPF1s5nf4NO88cUwyS+Yyi7jdlvEaPThqZ8I/rnip6e/dz6/jwz YDwdUovZlHyIqvpTOIJnRwbUmkGFf7qeumy5nzqeNrhcqi7nPVKL/LtiHqy/32an/eYU RgvtjHWp5iEqdgvhdhsTnTbyAI5IJeXjth3PwVGXCWSPIRwFWfac3MCiYGm+zk/sCEBf G45Y7ldCgg173oCGhDeIPaptd8G22K01z43eYM6qJ6vXG1zdtWMvftYpoWUeGX2wkFqS KPFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=47X0nDkNnDfoYJURE/fAwmOiKXa0tA0+uH16JNzJ4Lc=; b=Z3QeI64RGqduBLD44u85/WxtTDlvnN+EWEDTE2usL0b3ZFkbrUpa0kkDNjMzJ8QHlR tQzYMAc/MVFZDfSpl7xfQM3PKddfxXwwqoOoXnkQk3WHfPFrX3wolaEbWJYAFN/3V8gF q8RhT70141YsuY0xgq9jE+zdG9+j1FicpSYw1qDye7eoopnpvMvXGSN7MBXT0AUioxAT laTgFf1zQ1EnnXjG/6Sjnh/8j+36nRg0o/tDIjroz3TXN/p4hI+OBdBALMIHGLNQ6xmW P42jrwnsCCHr8NouHD9lKmKhf5yBOyDvuFKa9m2StQt1yrsHhoDc2plshdlAL4Dpy8v/ Ssmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mWA2ChL7; 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 n21si4220686qkg.60.2020.05.21.19.42.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:42:16 -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=mWA2ChL7; 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]:51428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxdX-0002ZZ-Lw for patch@linaro.org; Thu, 21 May 2020 22:42:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWX-0002Zs-29 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:01 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWW-00057I-22 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:00 -0400 Received: by mail-pf1-x442.google.com with SMTP id n18so4481515pfa.2 for ; Thu, 21 May 2020 19:34:59 -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=47X0nDkNnDfoYJURE/fAwmOiKXa0tA0+uH16JNzJ4Lc=; b=mWA2ChL7cbSgsA8g2nvgitxTW1oZxOYAEYKR5OH/gT3gDT9P6+HySeBugg1Jlk1XSX 3JmkJBJFbWTbnI954Dtuwe4kib7HQH+QvZLFlCxqS+BRVMIvmftrv7t9yTn+uejcX5T6 kPjCxmWDDks49igwOipyI44uu9eEZY1SX9OY2pEREQyVR+5/dWFawqCS2UAy35ofmN1v so00RI4y7wyEbONjKQsC+IkOtin4wiroO/bKOR5dkGDmfMt90YTeBWbsUfY8AXMDzElQ UyJvaFIuz7CJOkjCfxTGFx32BvDPnyRdqpl9WjH6YWYoF3Ntt2D9wmLlkUoc6AMz/lJU lt3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=47X0nDkNnDfoYJURE/fAwmOiKXa0tA0+uH16JNzJ4Lc=; b=a3UF3HcZzyeH7Sbrtis/T80WMJMmIh44LsgeQoh529Ar6G7dhT/39cQytuad+3qwNm y0mtP9auOqc8lbErTEF+4yDtpO70qQZboCbr1BrBjpr+yE32trC1uWRY51uCk5m1efKT JXAxWkJZO+eRCUdWSUAz4KaUhHbOf4oknrNFI9UeVEeNYf9UdmmGGOrhGN5LG6+xWhpH CsvXbyVN7+EEIRQycayDIOwYmLdoFEuOx3pAh1IN71mJRQe19sRpCjY1SOUXRu0LuAFv N4XGwBIBDWKy1hYrGDQSRjDa1T9K2lktT4870AisxFsn6FV3qRAhhlCqKZMLneTHerQx UJfw== X-Gm-Message-State: AOAM532xobtVXrZMj5+acySeY09BJBPHzK9oykSKwJ+SdmvghQnvNtXc C0bKsgIOvsWaG9OPIFWMq6Kx9pytfcY= X-Received: by 2002:a63:3ec3:: with SMTP id l186mr11489052pga.228.1590114898319; Thu, 21 May 2020 19:34:58 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/25] Split RES_MISMATCH for registers and memory Date: Thu, 21 May 2020 19:34:28 -0700 Message-Id: <20200522023440.26261-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" By remembering the specific comparison that failed, we do not have to try again when it comes time to report. This makes the mem_used flag redundant. Also, packet_mismatch is now redundant with RES_BAD_IO. This means that the only thing that report_match_status does is to report on register status, so rename to report_mismatch_reg. Also, we know there is a failure, so don't return a status from the report. 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(-) -- 2.20.1 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 May 22 02:34:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187115 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102546ilb; Thu, 21 May 2020 19:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDeugxhDJCoNXN1dTNVc0dLa3wPtBsx7CiPXTGX7WCbHE8ezvnJLaHJdkJHrT+vtUVEeWr X-Received: by 2002:a25:845:: with SMTP id 66mr19658444ybi.7.1590114944200; Thu, 21 May 2020 19:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590114944; cv=none; d=google.com; s=arc-20160816; b=Ls2s4uGBbGGidIhn+gLahxocnxGnOfo78RR/yKQSfGbaiTRcL9d6BrUi3M9/pf9pFb Amzw6m1whQRwtUcnt28Oc+lYngk3vNvIT5IcMVC+dz7hUVNTz9MNCFhytsF0gMOYRZDy lNnMj79Bs9/JdKYJQMv1tt9Ggi2FrwH/pG1EZaChu7Aeys+5Mw6F1aWO/7kBGlWzM42M P8Nl2qe2Jryhhoye3tFBsbO084NwoTMgumsn6ftEl4mNfXNPg7IWJxOj7GghyyuZbQTH LtheHV4euh2JAKLuciB32HQL1vupQpcLNrNmAH/7YltH/cAcDspQeLOmeGk2lqrqowQe 3ikg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TXAASNAhxxCZnrmhR/019xFA1WSxX4Hf5mCh0xMRPmU=; b=zQxk2QavBLHdify8FdfB6wIE9cvRqFslz8jNFrWcrnm3/GSykOcPMC7q6c/V1DJkor MImEqKeZ6nCgnlivUOIR4vC1AsJAvknlkiAX2T6cDYGbODD2MPDypdqXSvKOull4MeHd KS/AOYnrtqQoAZo2dj1GCEE/iGLry2h7XRCZB6qXjLyolYeg3sKpMnllMA5sUsQrR3U1 xVAJWtoQtk+REYPcOq8ljFLtnbb17uLeI7PpYwjV0yJeEJw+nSzS7OR2g/s4/71r3451 kjnbVwf4T0m9Q8mTmdyloIewOhougZhSm6Hs5hl24k2nv7hdXGfUo+QjtY7AsB9vapCi tl2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AUtufOGf; 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 q7si6516728ybk.391.2020.05.21.19.35.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19: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=AUtufOGf; 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]:44418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxXD-0002kz-LF for patch@linaro.org; Thu, 21 May 2020 22:35:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWZ-0002el-Sl for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:03 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:40785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWX-00057X-Dg for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:02 -0400 Received: by mail-pg1-x541.google.com with SMTP id j21so4275588pgb.7 for ; Thu, 21 May 2020 19:35: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=TXAASNAhxxCZnrmhR/019xFA1WSxX4Hf5mCh0xMRPmU=; b=AUtufOGfzGkjlfkqqxb794wZpat78KRsybJft61LmYhClncza5WibhmGMSUo0t5KF2 0fk1SW80/fxljjgayPa757/OA0kpTohm2lcfsuZrVEI3EtCGHkuLU41Z06jX1ITQDEfj Ir05GmGj7sdNcFzLu006gwS9tVN/Oa7fHj4sfiM1yVQW9CO0zSt8jxgMC0Is8sxfmjPw iVYt+Hjo/rwmUwf5IRXTjEsrYrUfiEQnxgjP2V+Ip7quBTke6gVPsuC4RNNVRcX1bTz3 w/cEQnHAaWd+D0UYvoPET5wzT/XvNiJ48HdEvGeqTqDQl9DEDnTB/DKLjYzidLa3qF0/ leRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TXAASNAhxxCZnrmhR/019xFA1WSxX4Hf5mCh0xMRPmU=; b=keaUoLu6tJ7zK+eUKekKqvyzHVzBrXBIPCYoZCskn3C5+qtWYo1j/ergASjjDeolY+ fpw2NnMLLrj82H3It9+Nx4BXbIWZbTjE7ZQ1Xdqjl0pJdrKpbIGGB7xv4GHZzhGheKq1 muiwbxaQU61eni/TU57aS+lg0nRwu0Pb+qoLdznHD80NCaEPhRvGnnl/QeQngHmzzEjU MaqlgJ/7iwXFuhCxtS9dC94MUz0IyAbRTra31jjpgRB/m284GOKq6fQwF6FmAqQ0kr60 i+9+YctJ78k3Je7aBChq5lhxWRRThHQ+LZq71P3HRJ7DIKoRKL4AS9RLdMrtNYxwmt37 7SRw== X-Gm-Message-State: AOAM533JxcRkMCqnlXRHIxV2OtCnxWcC4lhkVvU72pEwf4ArraOjCZIV lzYkW5/22LVtowwdVvh0BtIYFvYLnxk= X-Received: by 2002:a63:6e8a:: with SMTP id j132mr10248319pgc.301.1590114899535; Thu, 21 May 2020 19:34:59 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/25] Merge reginfo.c into risu.c Date: Thu, 21 May 2020 19:34:29 -0700 Message-Id: <20200522023440.26261-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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: Alex Bennée --- Makefile | 2 +- risu.h | 28 +--------- reginfo.c | 151 ------------------------------------------------------ risu.c | 129 ++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 126 insertions(+), 184 deletions(-) delete mode 100644 reginfo.c -- 2.20.1 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 May 22 02:34:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187132 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106016ilb; Thu, 21 May 2020 19:43:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySNyGgQq5gIXBhrZ3DW+9/IjFbt4NBTB97X+mZ2fSVtzwMUiLcc/t0wb7zS0LHK5Qk1EPN X-Received: by 2002:a25:bb42:: with SMTP id b2mr19682527ybk.383.1590115403678; Thu, 21 May 2020 19:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115403; cv=none; d=google.com; s=arc-20160816; b=QofUqIrn31nsLk2rITf15Kmm96q6Fod+cYvTXZofoRgW1VHmdoOa4s19V8Tdxtw+Gj m2Qs0xrTLNQ0pcVbtDaKCoN0v3/evAOrBrHPgZMCa+hZdP4N6IPm+jE7+mXINzorsVKe BLbGusJDKxEzREy6Mb5+QMW3psJAM+otXz181kPmo+N681zepj1+ep84wwmEsGGbeM7h 3Q+b6bb21vmMq2KAia35m0IMBmdHlLQSfp4y3b57s7w1Xomk5a5DSitz0Egbuj0BzPZj D98uEXvmo6NkaHLUUX9VsI1PqoMEC9m9536SseBvjzELDF4Twca1VRYDX+mgKyO0EQ/v 4d6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=B4k4BKg+4kQ/VDRH4oFHB0FxFiaeSR3tTozfgNRDGtM=; b=M1qEvgKKQED3PI373Rc1r+3arHv6ZsTY9hFgK/kOh1Jwfz0B2wl3YaXFjjqj1CMJyU OdP1cpNLJG5b+XI3PcQni5WnaOEPKtPooYAuBcMI9si1vmyliWh67K1w9CsloDzYj5gs s5uClKHhX0yPbepS8/sSOjrmCE/DL+TJ4Bbg6Q2phu4srm008pCl6I6iX5ZVY2B+znei DlzofrQmdQzLKONt3eKLsvegUz3nMulLw9T89HccWklqQe62f8Us8zSRCflydUjcIeDX vbgW4IlsLPqfHMkxSTe4NMBWY1wBE4aNgn/VQiMuZ9K7Vf0EX3lx7yKgOADb/hS6x7FJ t2GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hnU+TE2v; 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 k8si6976495ybm.423.2020.05.21.19.43.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:43:23 -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=hnU+TE2v; 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]:57592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxed-00050z-4v for patch@linaro.org; Thu, 21 May 2020 22:43:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWZ-0002eL-FW for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:03 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWY-00057e-GD for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:03 -0400 Received: by mail-pg1-x543.google.com with SMTP id r10so4276458pgv.8 for ; Thu, 21 May 2020 19:35:02 -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=B4k4BKg+4kQ/VDRH4oFHB0FxFiaeSR3tTozfgNRDGtM=; b=hnU+TE2v4VAx0UyvUVtYx6ZQZiJtFXRSjvf/pQnGPK9BCEfmzw639GBMShVNsq5oQv OutNvyMPe3qwsC5X6ci08u5IBsfwq4Qab3ejcVBN28tK5wgMyV2CoZPexNwjt2rArITV E0dpBowl0bW7SQSw7jWnpngHWK1oXX7GomPGoNpA5hjrtMOMFxDOD81+ob1DwtfzLwVE JYMJJ0+RxleW+dx2FBLtFOy9HHQI1S1mITz9mHvb97I2PNixv9zNcJvARsetrV72qcHw gs++JIyYT2wheE6xIqXZPDsfxufzfNzrFsoP5qMqY/tR/BxBOTQRR31nGKQGjwNElOci wl1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B4k4BKg+4kQ/VDRH4oFHB0FxFiaeSR3tTozfgNRDGtM=; b=Cl+mHTEF3fH38z7r3uovayvJO4WSvJVHBniYo9ylXCYfL+bSpPlXC/cL8O2lS6cCfr CLtHunWR8+FYEnxN6A3SWBuB4GYiYMgSlywz0O46hgff8EuKz7rtOLs7+lsqD0TIi1oj RklhDwI11zhtR/ykjqoL+CmgkNC7GA8Z25rRJec+1W5WC0qGIRDXPXlDg2wzKueVLFY3 uRJOHyBgPg+Wk81ZOT9ECGTxYkMbEHH8GqOdN7dNcoddD2vpcbA6BxdFEAlcYD++nUON fiXgRNc1TbsJcsmJGg5z0m0MN45GxPMKCwQKSj0ITgVxcIKamakLEP69WCcyxHW3LG/F ghAQ== X-Gm-Message-State: AOAM530U3J1DtQv80ap6qgDyZyE9jtpR9VzLXS9LurzXAG6bV0VZzf2e agY3t2nnBJjG1GLf1RKVlRGdd+mo5lQ= X-Received: by 2002:a63:ab0b:: with SMTP id p11mr1527746pgf.278.1590114900853; Thu, 21 May 2020 19:35:00 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/25] Rearrange reginfo and memblock buffers Date: Thu, 21 May 2020 19:34:30 -0700 Message-Id: <20200522023440.26261-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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: Alex Bennée --- risu.c | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) -- 2.20.1 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 May 22 02:34:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187118 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2102980ilb; Thu, 21 May 2020 19:36:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcQSfGcNZKmYXF+7l195s9O0HcJoQYWGiTuJ/erRQ48ADvsBfvinhoUerptidnkcrCNbr6 X-Received: by 2002:ac8:2c38:: with SMTP id d53mr13907192qta.162.1590114997573; Thu, 21 May 2020 19:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590114997; cv=none; d=google.com; s=arc-20160816; b=X5qbXYQ2ad8VnJsLd6Y2/HqkD4YNv+73buQmIy4ROQY820KBsjLQGl3dMM5JIYz4Vo NRFAgRUcHqy/fCk/xAmXsMl8Wp4VMaKQFGi5R67IVwiQhTjTTRH2tBCZqBVTFHcWUjvz JwwSm3ls1bZHhDETmIvfHIEJtLDTBRlTiSVo4EJtBTwP7ZIsHESG2dN23+p6sLNp5S7O 2NdgHTvt3QEpYTspS/C0I3ZvSDBbB1ox/iueMUjoTHgO/CeqLhCVOIdivU7xtph6YSVR vbK7/uWK7HiczKjEy8X2Bb/m/bSbVGXUuWxY4SeU6725fJUo/3f3uaWYUVbI6dngJsQx sVDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QZjvdmBYYHmi+JAXhLPT2G2PqWOdLYnmeKZkQvZb7ek=; b=TbmI7LqYwd5rxgMehr9RL2B6UgEoJpqieRd682E7OS8nB242R2NKK/CkW6wtcO7ok9 qtWYgNFHH4GrjM48PZk62DzNdx53huscOr8kM8okf9PNnkkfdyQo3NUJq2/LXMDvI3Jv RlHWZpQD98cY+qfvTmJ4SpWnVYH6VqonzDMqqRwKKqqlC2ZU11TyaR351vN/IJHq9MCh oqYdEHJdP8q4Z2Avwa7WpFm+ccB9LeWlf72Gwc1+0QVBuPpjNHJVNh86sK/BaDC+NWO+ /xAr8WQD9U34Rj4CCUZPmCqGN7zmVIaFAi4LOojX66/cnOV+mQn3uJ+SvRZlW51/i2NR TM6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDxptqFJ; 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 v45si4222649qtb.306.2020.05.21.19.36.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:36:37 -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=FDxptqFJ; 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]:53180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxY4-0007Ns-W0 for patch@linaro.org; Thu, 21 May 2020 22:36:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWb-0002j3-2v for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:05 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWa-00057t-3a for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:04 -0400 Received: by mail-pl1-x644.google.com with SMTP id q16so3822938plr.2 for ; Thu, 21 May 2020 19:35: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=QZjvdmBYYHmi+JAXhLPT2G2PqWOdLYnmeKZkQvZb7ek=; b=FDxptqFJysnUoaUeN8EOXWdN82ANKTymZV4rhaBjDEs/EPCoMSjOAsKYEi08MoYxct spNydnPRl7fyu00l2oaXoV0oqqOFUMm85/Kong5rpMFE7YHKabRjdRypzAe8zV/eJUxy U+r20sb/JMyiOaFpgNkDX5vGnsKx/zkawXm++GfMlT/GnV5uYX6SaFPVnxNnyz2DeWxk h2miMfzALhCnozsGDDjw3+7poOvBONA2R73uhF2VUZTlq+37Sg+upAYO60RD9Mnh3Jjq OuDFxex89P9+vJSaKjW/UOdAYCdbVTi3wVFmI4us4VsT9XAYP6iA3Y0dZIucMN4QYJrY eTag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QZjvdmBYYHmi+JAXhLPT2G2PqWOdLYnmeKZkQvZb7ek=; b=WSVauLiTJkwV+t2tbKtKixg9SmoXdbXOulIyg3/vEt8yYiWgSyV6/oByfhHvrDs31g bDZSRcLgfjzwwtnCkC7phDJBuzZHhkq8gTHDjxo4YDDoMqxVX7pFcYV0jX9dKgZXYS1J /nvEkQoYUwzC72DeQG6uBEsT7dXLbi+ZXaW7bBUIHWuXlNWzV8ZNhmNSuU8kjbn/LDMe 9zMU0vVeeOFs9e9P1hFr8VMxg9u7esFfA2i8VFq6Mm3kVMrsGyiGH95rcqNV5CMdFQty yYHKYyPeWXO+eCpSLRTvcKCDyA23I4zgvbYUvl9yKg+BEtdx7lgABepFou94pwFKVKDO kk/Q== X-Gm-Message-State: AOAM5335q/0HurI4u3NFH74NJUU4EzTI2boUAkDWNA4F2BP1AZniRmQt tTS3TN1H6pyl6blIpV1I4pArXGT6fdc= X-Received: by 2002:a17:902:b206:: with SMTP id t6mr12690295plr.248.1590114902429; Thu, 21 May 2020 19:35:02 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/25] Split out recv_register_info Date: Thu, 21 May 2020 19:34:31 -0700 Message-Id: <20200522023440.26261-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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: Alex Bennée --- risu.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) -- 2.20.1 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 May 22 02:34:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187133 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106383ilb; Thu, 21 May 2020 19:44:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysdMe26b4udYYMlV8Pt+6r3xePo7tTLbBz2Dp51959ub+ezQlVWHIw7jiinqDc8BVv16iL X-Received: by 2002:a25:e08d:: with SMTP id x135mr19549525ybg.360.1590115441044; Thu, 21 May 2020 19:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115441; cv=none; d=google.com; s=arc-20160816; b=Q508XiJ/Y56zUSx2yr4zFLil92ruePFQ3flpcrey2VtN0ZTZfy5qzMkTpTUZ967cHf Kd6rvA0jA+yrhEBy1F/9bn6FoWjq0cCLVpUe7uNWp0xs387LbxPA/G/4klWJek9J9/t6 TyOv884MSVLRZYEINteo023p8QfD0VrDRoiAx/+gcWUg3uCUnLQHuk5N0vWUbkdZp3uI Wh/rTJNSEuDI/MRbyUh5SrP4DeL2/SsLv2XIia8iZP01Thux+H0Er3ylNIZMZjqu+Px0 KDpdBIBQNcsAPHc+34Zk6h6bXhOH+ZBRuL5ZN80J8Lbt3M59h2mVI+Rt6hKIz3keZ3Hm OKcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Q/LihqsBffCSl3YlGCBIwjGGFgT5Kwzo71qJstw4oL4=; b=l24dfx84LLQAEvyLYhkjXaFOu6xnPM9//cb2CB5wz2F7nHd+ntJxwc3FXDemSHy/W3 L4xVX1FKQ2S+nkx4XdJ2kSosUA6n6kK3+JhW3xG5wBbeEISeALWPn1jQflJhVba8MzoK q1PR3+moPqG2EcFI2PAqHObZCPrV5APMjmn8OUj5auRCw9LizLgDl68cMMkIBCVjZOHv 8ynczmhtW/2ydFeXd5fj0zzR4QeJbmMDOOi+Phv/KDBVTpzur+fdyzIplMJaKsAjEXiF 01/Dnshocg6RH2iEk4xoHbV5hZtwMzRDzFcH1A3q0hl2if1dgLhaNPapriYh9PaQskdl aVtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qjRPDEFu; 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 x67si6897102ybg.183.2020.05.21.19.44.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:44: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=qjRPDEFu; 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]:59868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxfE-0006ex-IO for patch@linaro.org; Thu, 21 May 2020 22:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWc-0002p5-Ne for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:06 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWb-000587-Cq for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:06 -0400 Received: by mail-pf1-x442.google.com with SMTP id x2so4471664pfx.7 for ; Thu, 21 May 2020 19:35: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=Q/LihqsBffCSl3YlGCBIwjGGFgT5Kwzo71qJstw4oL4=; b=qjRPDEFul5/Adm96hM0EHUYCOuBjT9SZ691NHvNBVSKhOsvqdR5Uoxoikm/8H3FsFp crqDo8OL+xzK7o3gqMvKl8aQd/F8aG4N1X6ukgrvagK3nTcwsKf4vEh4SSC804cKK6J/ h5TC6KsR8Rzr6vSnaFd1bTr88jCYiA9xU5ySMHLKS8lofG0dInuse1SHwdezzengmRpM +Bxr3SMO+hSeiA28wQBiLDTUb3GTnVwU5rjF8XwMEQ8O3PLIctRtdgaZMExxepw8+4pG stFTb9fHAGQ70/u0EedrcO/XgyHv5Th20EH9mpHLd1S8sGSbzOITq8L1B7J0gtCRpJmb cYSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q/LihqsBffCSl3YlGCBIwjGGFgT5Kwzo71qJstw4oL4=; b=YwkyWdUegwgyAms1rtAK1v98YAAx9jXODf1v+QXKZxkR8wg7NBlIoTcnetVLpyK4u1 /jhtcf2SqWaq7GJvvivxjfTbQ5jIaEi6zBmhxVcmrTiyCjZGRKVvnqrlKgc1vZrcR7gF RIMDdDvsp6cNJvrQFunmp2+KdYs1yYcJXOqttZrygmGoXeJvJWiwyqKk6dhWOPUewzwg 5PaDpIOtLkEhSX+hEtLJ+ziZLYkexPP2Wh0ydsJrgzi5rn2Jb5dpgTH5N2YjKp5FG+gw mfTvMGzZPSjDnEkyptnSImPRQivhLDsUu2tzNmRGtAUacARbbBSAOXA6N+vZ9dxbJpZT LX1g== X-Gm-Message-State: AOAM530O/GsbmOyqXzgBBk6jMd8l0LyHjjZIVM9nEE6JdiyuAxcSKN15 HYX8IdTH5Ow16LXavqA4/oZA3Y4vWUo= X-Received: by 2002:a63:8f03:: with SMTP id n3mr11461146pgd.352.1590114903508; Thu, 21 May 2020 19:35:03 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/25] Add magic and size to the trace header Date: Thu, 21 May 2020 19:34:32 -0700 Message-Id: <20200522023440.26261-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sanity check that we're not getting out of sync with the trace stream. This will be especially bad with the change in size of the sve save data. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- risu.h | 10 +++- risu.c | 162 ++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 136 insertions(+), 36 deletions(-) -- 2.20.1 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 May 22 02:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187135 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106991ilb; Thu, 21 May 2020 19:45:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKnykSheLgpTM4OJ8OQX1+8zHXu04ulpO5cKt0+sQdcmBi8FM09+eC3ppk8KoOeKHhGpQX X-Received: by 2002:a37:b743:: with SMTP id h64mr12498514qkf.460.1590115508222; Thu, 21 May 2020 19:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115508; cv=none; d=google.com; s=arc-20160816; b=HyIqTWn6d1u/grvIDLgK51TzrL0pYjZFNd3vP2Y+QVJ9dH78CMY2Ev+oHfa9E0X+eJ 7kOD9Ivtswsv2hNBttQbadh9zPI9CcNEXdlrcruO/3OmjHxpJjIXrGWu2vldhKieQsWW 8bDDN5VvX/Jr6PbsHHyrEWLnw0hIP4TxLD155zs1kmfK/5shhA7zLWjhqzfkL7CB4aga dnxvzpWZdmRGpAeFiJUeGEjb/2POq7dZZWZlOuDyKRZHdyyHdtmRzpr0Mf/XmDAbslej 0Lo6aOw+TlSaHRJShUb5lpCXSCBdQSPv/ABmqD6qnqvY4gZ2eTnIT4EhgmtSxGkpbi/f LS7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=XW5PiRLM8QB2t4Bz1jgnvCSf25XRZtwrOymC3pF1Gq7IR5GnGfGIP0Pv94mhKfBwq9 TmiotovVSQGoAFAvV9bf9imhzI/4xSrZddGJ0ceb5qtZEvSmY+5re/Fn5XTw48Dl77ED fBqH1MmOoyPj3CAVD+4vIKkXq06nVXoAphfDhDO3SYAc3kTt25AeBhyXtfQHtwGQ56f6 8b6cPCYwrLvv7H40wjxueKKgoEPnJjJhjQbdpNhXjoOHSqojdVxVvAo+eP9tG83xpa89 JoW5uPQhnREPNdEOPQ8JCWjHYZHdw2YaMNs9bWqLjMtLWSfwc2JBqg15dsnlt3knt3zY EceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aY/6jD3E"; 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 q56si4337076qtb.347.2020.05.21.19.45.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:45: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="aY/6jD3E"; 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]:35922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxgJ-000180-Q7 for patch@linaro.org; Thu, 21 May 2020 22:45:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWd-0002t4-Qn for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:07 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:36961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWc-00058I-Mn for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:07 -0400 Received: by mail-pj1-x1044.google.com with SMTP id q9so4346658pjm.2 for ; Thu, 21 May 2020 19:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=aY/6jD3EsjlwEoRTgPmICL0MkRiVyaBx8KayP38X/AVAvNkC69XW+F7RuVcnTTMmw3 nMB7SnSE309lKgASpqSA+X4+4PL9FnA6scLJh9W5qsve8DRmPnQsetyiQU/lSrgBik5y Pe4/oLrV8QbyprXhcut6piyNDC6fudenaVMw2LrRoJuUnE+799HvfSWR6kjYpe29qHtM gIBCim8u4NYBZ5tHyQsSfbUI+rTLO3uK2JJ7pyHGMD/VeVSgbGDLQ2M8B+hRAGTGgLUF P6HhpBZJYuBjC7PEFuZ3jiFjJQOjiMeEKQ8OBcXOA9Q64puvt5KU8QH9HDrxpt6Bkxpa 8obg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=JA8lpo4ZvIT/YLVTdchEZ5CL6l/ONK1y/tvfRXxXtdwwyoK5IzMkKn7kmPmcoOCAor uDF2XWfm52hgKwxD4o4XmoPKBMZH5BhoZM8BOB1OIUNCAgaat5TzKkv+wHgV7sYoA7JT XbTpGe8HECS5yG7ArV4TQwpUfU721jzAR9B4zH2yqwCEduEE4jNwAKPvsRtUwcJDtUnq D6SrvxFcpURD50qZswRKmJtyLr8NDDxfqUcXILofTBpLCYKDv+MxjTP4UdWcZznNFld8 LiMAw8lezW5Yl5iblcWp6lFaiOStrW7T0R2D0L4DCzNBrpuQJw0pa+WcYRQtFbuJy3YV yjfQ== X-Gm-Message-State: AOAM5313b2moQtkn6dfPvPIUuf0rbovpo4AEoUiwkuVSUctKX0jZGi9e L+LXiM0DGZgkE3O0GhxvgCb7mTRt5/0= X-Received: by 2002:a17:902:7045:: with SMTP id h5mr12695977plt.108.1590114904835; Thu, 21 May 2020 19:35:04 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/25] Compute reginfo_size based on the reginfo Date: Thu, 21 May 2020 19:34:33 -0700 Message-Id: <20200522023440.26261-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will allow dumping of SVE frames without having to know the SVE vector length beforehand. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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(-) -- 2.20.1 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 May 22 02:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187123 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2103864ilb; Thu, 21 May 2020 19:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAqcdYVegUB2wimkO1Zqlx1iN6y42s+ze9cVuURKfwRyyu7+H20m8Ewy+1mJBziHZKOTJD X-Received: by 2002:ac8:6b03:: with SMTP id w3mr14049921qts.275.1590115116578; Thu, 21 May 2020 19:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115116; cv=none; d=google.com; s=arc-20160816; b=LO3y4LahrLHK7ggO3ODvGNG81ogergTtmigKDoH1nlRWnx/vWAIpOOQ0Sl2KYundfU P9afOT8WTlNgk2MXHMAuA7ylQRg2KbmFt/4/78PAv0Ogd/qslXVNaVdTszGrIycf+IA0 eresfCkDu6o4bxYCpIfci8a8Hlytxh/vIWHiBjO+ezTtuMGnVwycYjySEJf32b0ZCVDq UctFedZlLWHp/m9UlTpUb3C8mXYszSBMO6Nc7ThkoYDqwbzn8d9AQesk8f11Z4wug/FK peHg6aPkdZPvl093II4Kw1Iqb+cw/dyHrcmN8ri4RBZkkRj/xITPQrs6Y7V0XuOHAi36 VAuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=lIWWSOIGb2z8T249F4jMG6rK+8+fGfqR4NfqT9RdvAnSsarfJKatnw1W+g509bufWG 3/q1QhbgSfGmldimNCjiyslvceh22Yjs2PZPWhMgNeV0MvipyvhShTABpM5j1fi6FVMR rJ10qqtyd4fGts40MbGqlC7u4zs8aEygcAWwRLckKIFBqxeQ+1Syb2Q2K+MPa2scVRtq Zvz4Ey1/wDx1LiCXqac0iJFh6ENPibCPDHILYvGW1aMys8mCqEzb3FAYrtvI6knOJPcW Z6u5jRNmY9e8fqsn7/WQoBUBPRWK1HpRbAgUxB2qpxlXWRIo51j2p+kgn7xTHkkdbNw6 yOvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ugYrlGz6; 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 w5si4399598qtk.87.2020.05.21.19.38.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ugYrlGz6; 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]:33386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxa0-00034o-4C for patch@linaro.org; Thu, 21 May 2020 22:38:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWf-0002zI-H3 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:09 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:35002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWd-00058T-W8 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:09 -0400 Received: by mail-pj1-x1041.google.com with SMTP id 5so4348059pjd.0 for ; Thu, 21 May 2020 19:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=ugYrlGz6ltuiNsbxkqPk9u7b4CZHviOZ4LKmlv//2Vh6NjQcHiyuCLGAlBH5DNp6Fi NF7QciY/bd21G/0PkCIeNnFKldeBJ62KxghAkKOMUjgQLHqPDM4I+PFFli7ap2+M+lHh 1Jsvhv476z9mK8rqQ+frFuTusUi/6abGlEepqWHvZY1ew6fg26sCnfM2M/CMz0Lqi3ia zASSjCqb/gZzggqGfYaH5LGWoPo/EzirIqg62PpAnG9b3eJUDK0cC2Te3mS+jkCaNm8x 8C5MoQmo2tgRDDfwQo2cRMiI1tDW3SNhlKuOfRTokojPZqLiWasdVnEUnBQrNzoCNGcq 2BAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=Vs0xJcbxELfNol3dtmaYeHn9Va7p5YQp/szhw4+7AUl0i0on0MNaNDXDdgsqnnSJgI 5FtW4ZsQXt5iq2riodxNaFxRtISTh3ofinEAnes7Ek1B2FHD5rV0g5qdPFQHM1BnHVM9 oTdKj8fYdUuIdaUMeOQZx5FWxMnNipq/I8ufduSUNRnQGuxJxv0lYOZd9u4NuebxWCM4 NOtux3sK3WQbAchhNrgBCKjsSa/0Tu+Ehs2HmI9r+Bq8B7q76tEQA8UlA9gQGp1QO1HS +sQfxP8IOmcaO6tJ1yMrJ/mBgJTKW21VKiUUcA8XBg/dv1cqXutpV3p+fbaJQ/5FJZ5D /WCw== X-Gm-Message-State: AOAM530psQ3TUWQ04GIVVIZoJD9KWeo3+sQ0WJP+XP2y+txArdobkvHr TwshWXnOCV/aQVPfI1K+SxW+uiZ8kG4= X-Received: by 2002:a17:902:dc86:: with SMTP id n6mr12400066pld.17.1590114906123; Thu, 21 May 2020 19:35:06 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/25] aarch64: Reorg sve reginfo to save space Date: Thu, 21 May 2020 19:34:34 -0700 Message-Id: <20200522023440.26261-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mirror the signal frame by storing all of the registers as a lump. Use the signal macros to pull out the values. Signed-off-by: Richard Henderson --- risu_reginfo_aarch64.h | 16 +---- risu_reginfo_aarch64.c | 135 +++++++++++++++++++++-------------------- 2 files changed, 73 insertions(+), 78 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index c33b86f..01076b4 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -17,20 +17,8 @@ struct simd_reginfo { __uint128_t vregs[32]; - char end[0]; }; -#ifdef SVE_MAGIC -struct sve_reginfo { - /* SVE */ - uint16_t vl; /* current VL */ - __uint128_t zregs[SVE_NUM_ZREGS][SVE_VQ_MAX]; - uint16_t pregs[SVE_NUM_PREGS][SVE_VQ_MAX]; - uint16_t ffr[SVE_VQ_MAX]; - char end[0]; -}; -#endif - /* The kernel headers set this based on future arch extensions. The current arch maximum is 16. Save space below. */ #undef SVE_VQ_MAX @@ -47,11 +35,13 @@ struct reginfo { /* FP/SIMD */ uint32_t fpsr; uint32_t fpcr; + uint32_t sve_vl; union { struct simd_reginfo simd; #ifdef SVE_MAGIC - struct sve_reginfo sve; + char sve[SVE_SIG_CONTEXT_SIZE(16) - SVE_SIG_REGS_OFFSET] + __attribute__((aligned(16))); #endif }; }; diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 7044648..a1020ac 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -71,15 +71,30 @@ void process_arch_opt(int opt, const char *arg) int reginfo_size(struct reginfo *ri) { - int size = offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC - if (test_sve) { - size = offsetof(struct reginfo, sve.end); + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + return (offsetof(struct reginfo, sve) + + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); } #endif - return size; + return offsetof(struct reginfo, simd) + sizeof(ri->simd); } +#ifdef SVE_MAGIC +static uint64_t *reginfo_zreg(struct reginfo *ri, int vq, int i) +{ + return (uint64_t *)(ri->sve + SVE_SIG_ZREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} + +static uint16_t *reginfo_preg(struct reginfo *ri, int vq, int i) +{ + return (uint16_t *)(ri->sve + SVE_SIG_PREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} +#endif + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { @@ -152,8 +167,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } - ri->sve.vl = sve->vl; - if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ @@ -164,24 +177,9 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } - /* Copy ZREG's one at a time */ - for (i = 0; i < SVE_NUM_ZREGS; i++) { - memcpy(&ri->sve.zregs[i], - (void *)sve + SVE_SIG_ZREG_OFFSET(vq, i), - SVE_SIG_ZREG_SIZE(vq)); - } - - /* Copy PREG's one at a time */ - for (i = 0; i < SVE_NUM_PREGS; i++) { - memcpy(&ri->sve.pregs[i], - (void *)sve + SVE_SIG_PREG_OFFSET(vq, i), - SVE_SIG_PREG_SIZE(vq)); - } - - /* Finally the FFR */ - memcpy(&ri->sve.ffr, (void *)sve + SVE_SIG_FFR_OFFSET(vq), - SVE_SIG_FFR_SIZE(vq)); - + ri->sve_vl = sve->vl; + memcpy(ri->sve, (char *)sve + SVE_SIG_REGS_OFFSET, + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } #endif /* SVE_MAGIC */ @@ -225,18 +223,20 @@ static void sve_dump_preg_diff(FILE *f, int vq, const uint16_t *p1, fprintf(f, "\n"); } -static void sve_dump_zreg_diff(FILE *f, int vq, const __uint128_t *z1, - const __uint128_t *z2) +static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, + const uint64_t *zb) { const char *pad = ""; int q; for (q = 0; q < vq; ++q) { - if (z1[q] != z2[q]) { + uint64_t za0 = za[2 * q], za1 = za[2 * q + 1]; + uint64_t zb0 = zb[2 * q], zb1 = zb[2 * q + 1]; + + if (za0 != zb0 || za1 != zb1) { fprintf(f, "%sq%-2d: %016" PRIx64 "%016" PRIx64 - " vs %016" PRIx64 "%016" PRIx64"\n", pad, q, - (uint64_t)(z1[q] >> 64), (uint64_t)z1[q], - (uint64_t)(z2[q] >> 64), (uint64_t)z2[q]); + " vs %016" PRIx64 "%016" PRIx64"\n", + pad, q, za1, za0, zb1, zb0); pad = " "; } } @@ -263,28 +263,30 @@ int reginfo_dump(struct reginfo *ri, FILE * f) if (test_sve) { int q, vq = test_sve; - fprintf(f, " vl : %d\n", ri->sve.vl); + fprintf(f, " vl : %d\n", ri->sve_vl); - for (i = 0; i < 32; i++) { - fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", i, 0, - (uint64_t)(ri->sve.zregs[i][0] >> 64), - (uint64_t)ri->sve.zregs[i][0]); + for (i = 0; i < SVE_NUM_ZREGS; i++) { + uint64_t *z = reginfo_zreg(ri, vq, i); + + fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + i, 0, z[1], z[0]); for (q = 1; q < vq; ++q) { - fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", q, - (uint64_t)(ri->sve.zregs[i][q] >> 64), - (uint64_t)ri->sve.zregs[i][q]); + fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + q, z[q * 2 + 1], z[q * 2]); } } - for (i = 0; i < 16; i++) { - fprintf(f, " P%-2d : ", i); - sve_dump_preg(f, vq, &ri->sve.pregs[i][0]); + for (i = 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *p = reginfo_preg(ri, vq, i); + + if (i == SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg(f, vq, p); fprintf(f, "\n"); } - fprintf(f, " FFR : "); - sve_dump_preg(f, vq, &ri->sve.ffr[0]); - fprintf(f, "\n"); - return !ferror(f); } #endif @@ -338,31 +340,34 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) #ifdef SVE_MAGIC if (test_sve) { - int vq = sve_vq_from_vl(m->sve.vl); + int vq = sve_vq_from_vl(m->sve_vl); - if (m->sve.vl != a->sve.vl) { - fprintf(f, " vl : %d vs %d\n", m->sve.vl, a->sve.vl); + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); } for (i = 0; i < SVE_NUM_ZREGS; i++) { - if (!sve_zreg_is_eq(vq, &m->sve.zregs[i], &a->sve.zregs[i])) { - fprintf(f, " Z%-2d ", i); - sve_dump_zreg_diff(f, vq, &m->sve.zregs[i][0], - &a->sve.zregs[i][0]); - } - } - for (i = 0; i < SVE_NUM_PREGS; i++) { - if (!sve_preg_is_eq(vq, &m->sve.pregs[i], &a->sve.pregs[i])) { - fprintf(f, " P%-2d : ", i); - sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], - &a->sve.pregs[i][0]); - } - } - if (!sve_preg_is_eq(vq, &m->sve.ffr, &a->sve.ffr)) { - fprintf(f, " FFR : "); - sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], &a->sve.pregs[i][0]); - } + uint64_t *zm = reginfo_zreg(m, vq, i); + uint64_t *za = reginfo_zreg(a, vq, i); + if (!sve_zreg_is_eq(vq, zm, za)) { + fprintf(f, " Z%-2d ", i); + sve_dump_zreg_diff(f, vq, zm, za); + } + } + for (i = 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *pm = reginfo_preg(m, vq, i); + uint16_t *pa = reginfo_preg(a, vq, i); + + if (!sve_preg_is_eq(vq, pm, pa)) { + if (i == SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg_diff(f, vq, pm, pa); + } + } return !ferror(f); } #endif From patchwork Fri May 22 02:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187134 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106785ilb; Thu, 21 May 2020 19:44:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZxqFKCino2uHQvf5BxhAanassvfH6dPy4vwu8lcR05MBko494jw3tjWfa/nyarCh3Js6V X-Received: by 2002:ac8:6118:: with SMTP id a24mr13807716qtm.30.1590115482318; Thu, 21 May 2020 19:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115482; cv=none; d=google.com; s=arc-20160816; b=Donw1A1X8MmBLmhXmIP4Tuf39MiR+0IHOT530ha1uS5IUF16gQDUj2zayCsULX07bi o63z6bzkrmaE2l5XoHzUimvHQf/kHbtVnikfJX2xKlHWZxJXLU/healNSK+zLrSvNCar Jyy6lOJ1Qy1f4jEiCSHuwGZFk4RiAnecAjWDJA2VMhi9UwIUqwYyZkObX544qSaFSwGp d5ueTlsPxxpa2dEqKuynQons2z8/x/37tNzkuvnDgQ0lSQTgn6PcYXaU9wljH59qVCol dnNANzHqCs9I9kQGNL/wd257XKmV5ktm2p2kVtUCXYlhdKYzzdSwwGeZ2eI053XzoyL+ UQ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=o5FDYbWZkHaKCqy9EzQf8vhuRnge92qP2vqpYFSfPmL6dgar0VoIfENxLvT+vkJ7f/ FzS/SZv7cJ8rR0roFUG1P6vBKIQCe69mYcee9q6jV928jfXoJMkHD4JL5Xutrp1jgF+i sHqQiwDTEUkjrj+yZg4LF92v1x8UmfgXnKJEr6kZsg7baAoDownKBQRrhPz2m59UL6il iv26LAMe0zwsH2g5i5OKyvhFYKD+CvUt8YsCd+0Dyq3277zKP32ah7YfphHWfgGWWv8b v6NhhkmtwQA32C8ChCvJO7FT3YXgNWCki9ZHktf0EMqD9Q2HK1i9sn5UlzBGvnBE+3RY WXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbQNc8jm; 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 i17si10359qtp.102.2020.05.21.19.44.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:44:42 -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=jbQNc8jm; 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]:34104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxft-0008Vz-SB for patch@linaro.org; Thu, 21 May 2020 22:44:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWg-00033N-KL for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:10 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:53751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWf-00058i-CG for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:10 -0400 Received: by mail-pj1-x102c.google.com with SMTP id ci21so4301989pjb.3 for ; Thu, 21 May 2020 19:35: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=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=jbQNc8jmS6QsogwRXB6jiRqzwhYNSaoVNMotTMIk4pxg0AowvCR/GNpofFlPtGCkGh LEoC/59q5a2k8KPNdmnH4sQGCAz1ZqxutLuhGO2BWecKWos7Nhiw2yOIdu9UxkXEbK8F RqC1QtFoRzaQJf1KHI/WM7ixkP0zKXp12OYBEjdFyPYTjRjEQcYd3Dlo8X4jeMLyAi9s 3NNBA/vP3QO/FitdSI/VkIAp8Njgn0DHkd2F64Adl1FViF93J7T+pcfnK63ZNWTNhC7y lSgQxJYYvDLjxLTVYuQa2XHOlwKvKTFCWb6NULs6tORLJj9faa5dkrJ9kbv58kXAQV5K F1bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=pEf+HjaqmGjfnMzjCZkXGhh/QnJT9c9WXKru+C0cHP+vWn2uMT3Q5oQD0IhZeye1tG fLRq23QtM6Acf4do9YSUx6PsNHTEM3rv1acwf0ypHoue2stfN4E4+yEBuldsMpvp2N7R beDvq+IZzQrNYB9XRLUYU5XZZ4CyePS60U9FaKogh7plu6lAB4gUcxW5kbsLZAk2dTwp CPrhsaiS7czuMtuJ9gMALJ/n0ZTCybsLoOg1kO1ikSLcpBZZkrAgpJfYtrj8Nisi41GR ydOmHSCdDB3R5of+gOxbabNvdjEf7Rjf2fnP1A5Z7VN2KsDdxs+67emdLCP7gu5lZLwy I/mg== X-Gm-Message-State: AOAM531ffd0fvJjElrJECf6w73nxV1hrusZ3uHz0g0VX5b8r7AqHTKOi TX3Fp/ae50jYJEkVnrtCtN1fm9Kij90= X-Received: by 2002:a17:90a:17ed:: with SMTP id q100mr1677697pja.80.1590114907295; Thu, 21 May 2020 19:35:07 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/25] aarch64: Use arch_init to configure sve Date: Thu, 21 May 2020 19:34:35 -0700 Message-Id: <20200522023440.26261-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adjust some of the aarch64 code to look at the reginfo struct instead of looking at test_sve, so that we do not need to pass the --test-sve option in order to dump sve trace files. Signed-off-by: Richard Henderson --- risu.h | 1 + risu.c | 3 +++ risu_reginfo_aarch64.c | 55 +++++++++++++++++++++++++++--------------- risu_reginfo_arm.c | 4 +++ risu_reginfo_i386.c | 4 +++ risu_reginfo_m68k.c | 4 +++ risu_reginfo_ppc64.c | 4 +++ 7 files changed, 55 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée 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 a1020ac..fb8e11a 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -44,8 +44,6 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { #ifdef SVE_MAGIC - long want, got; - assert(opt == FIRST_ARCH_OPT); test_sve = strtol(arg, 0, 10); @@ -53,22 +51,37 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); exit(EXIT_FAILURE); } - want = sve_vl_from_vq(test_sve); - got = prctl(PR_SVE_SET_VL, want); - if (want != got) { - if (got < 0) { - perror("prctl PR_SVE_SET_VL"); - } else { - fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", - test_sve, (int)sve_vq_from_vl(got)); - } - exit(EXIT_FAILURE); - } #else abort(); #endif } +void arch_init(void) +{ +#ifdef SVE_MAGIC + long want, got1, got2; + + if (test_sve == 0) { + return; + } + + want = sve_vl_from_vq(test_sve); + asm(".arch_extension sve\n\trdvl %0, #1" : "=r"(got1)); + if (want != got1) { + got2 = prctl(PR_SVE_SET_VL, want); + if (want != got2) { + if (got2 < 0) { + perror("prctl PR_SVE_SET_VL"); + got2 = got1; + } + fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", + test_sve, (int)sve_vq_from_vl(got1)); + exit(EXIT_FAILURE); + } + } +#endif +} + int reginfo_size(struct reginfo *ri) { #ifdef SVE_MAGIC @@ -170,6 +183,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ + goto do_simd; } else { fprintf(stderr, "risu_reginfo_aarch64: " "failed to get complete SVE state\n"); @@ -182,6 +196,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } + do_simd: #endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { @@ -260,8 +275,9 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpcr : %08x\n", ri->fpcr); #ifdef SVE_MAGIC - if (test_sve) { - int q, vq = test_sve; + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + int q; fprintf(f, " vl : %d\n", ri->sve_vl); @@ -339,13 +355,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } #ifdef SVE_MAGIC - if (test_sve) { + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); + } + if (m->sve_vl) { int vq = sve_vq_from_vl(m->sve_vl); - if (m->sve_vl != a->sve_vl) { - fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); - } - for (i = 0; i < SVE_NUM_ZREGS; i++) { uint64_t *zm = reginfo_zreg(m, vq, i); uint64_t *za = reginfo_zreg(a, vq, i); diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 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 May 22 02:34:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187137 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2107670ilb; Thu, 21 May 2020 19:46:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydSpyzBcRo1vNC7FX1c5xMr3uddr81MP8ugMXeKhd3XS0Q2yO7442XxsnLZTQ/a67+7Oal X-Received: by 2002:aed:2d02:: with SMTP id h2mr12865493qtd.83.1590115571637; Thu, 21 May 2020 19:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115571; cv=none; d=google.com; s=arc-20160816; b=x+CAGAD5VxNwvV03bFy9E8tvb5VUk6FtgaeSFX+NmQ8k9ecgPaMXVq6841vcJUS+ol wIsnZqtsSBbNdtgPgapx/Ls55oyOb4iVmH/hucQqcrolKawV4SpyDt3xXBi89uQlDA8l PsOsY4gvu7CbKW1Fb0ZGAGlu3rA5dA1ONAwJGVPQr7togxy6leWaZTUsD24KommAMfjN j5NSBoyh3rUf3D+cEaXmvz21OhR7IrutNRNWbKsTVe9Vouamur2RViBqvhNJIzGVF0kE AZulQ0LpKRkPhdKWyqr9Rh4QVs2lUQGq+w3VSUJVFuhD6w1kVQBUBMErTOE7eBBQZ4+1 OrZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Y21KcsvLFJXq/u9VH9lik1swR2hgaP1jOrA8QoTE+F4=; b=nhUZpvq6rkyDVtxQOCmMGjXdH7aqDcsy//+MizHiB1rvRFjQbW6BCeV7I4JAUaRJy8 3FXGjNWM1UuFaTz4VGce8PpvoUIHF/Vj/mRUUgDqNoxVXv1/U4mCw4Ad2cGJBGgiNAej 5VVSBW2AQnFP/UnxYeQpmc1RBQIB7LyaOpGnEGi/N1eYcsPXZxlfILe7CFJ9aVxi4IKv fKBbCSWZwCUNZqEotY3Iy3nT29Wth282aPeJPj+vhBWc0hihYqLUAtHqhtuhDwFAJ+wW gWH7m1TLcisS8biurbFTETpEauDT8GSMlm4UkxmoYsmufx+vWv1XIWiVhxO8PbEOiXPx 5N3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ECNuVEcZ; 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 p10si4322066qkm.267.2020.05.21.19.46.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:46: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=ECNuVEcZ; 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]:40190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxhL-00041X-6H for patch@linaro.org; Thu, 21 May 2020 22:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWh-00036W-IH for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:11 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:55378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWg-00058u-FP for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:11 -0400 Received: by mail-pj1-x1041.google.com with SMTP id k7so4289771pjs.5 for ; Thu, 21 May 2020 19:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y21KcsvLFJXq/u9VH9lik1swR2hgaP1jOrA8QoTE+F4=; b=ECNuVEcZAbPQPZxEjgGYqmY1EOgyTcS2pmNAfs8ZJcMHP/ftK0gbYbPgPPCps1PfE1 eLCzVaAcxyzXmswqa0IQNKeXMKdbERkhegKD6Uqmm8Hl1/fr8F4UfHqVIJp+lSS9xrLL DLKVYDamgUw2k2Tb1pvRsN9i/ikTMT9OXfxnYFn4wyeVaUq+dhFEOMTqgBqA0p69szpg 4hFl1488GrsZkojtEUBgv7lBQe1HZtUMMT1BfUndkL+qZwo02RjpwaSBf4OCeVyOY2o0 PImxTHMXHkVVBXgIKbG1v91iYbGrSHOq3HlI3kNAcMa5SPM9NOax3coU7J/vK4XAhtCg 2zCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y21KcsvLFJXq/u9VH9lik1swR2hgaP1jOrA8QoTE+F4=; b=KV5WvMw6uMHxCAR/m59s9zrFGgONBK3y53jzdcw4Fae7i0B3c0x9zczTHgh0V1VMFk t2XseKAYbYFjmIs4ajuIHGOjefrsEc3LNSw0o/0+G0ZOqV9qCFLywOuElBZ6cslZXWhf oYsIrcsK++d9ZlOsH/egrBUIuUlxJ8+1PJi41MACpCjWtVR3vFJ8IUtQ2YOE/pG5JMdC Ct6agPSUqz9HPo3BNKCR2jUeBcf7Qqi4GHHMmCmaUwfihvaZzzZ9E7HwLKxoU6teLeWa nma7acZV3mdGluzhe5GIQIwK8ODyVDD4xqOXJofpjN5avoEt7cd5BBoKREBF1OZsEwdY 4QWg== X-Gm-Message-State: AOAM531h+Eg9YMDoUTFP37ELdd9Xk49rVEbrd+kiHfIK4MBYuACELIn8 BikHV1780PvYtiZK5JbFcOcoGm7f5I0= X-Received: by 2002:a17:902:328:: with SMTP id 37mr13148955pld.35.1590114908766; Thu, 21 May 2020 19:35:08 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/25] ppc64: Use uint64_t to represent double Date: Thu, 21 May 2020 19:34:36 -0700 Message-Id: <20200522023440.26261-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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: Alex Bennée --- risu_reginfo_ppc64.h | 3 ++- risu_reginfo_ppc64.c | 29 +++++++++-------------------- 2 files changed, 11 insertions(+), 21 deletions(-) -- 2.20.1 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 May 22 02:34:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187126 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104616ilb; Thu, 21 May 2020 19:40:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYLHbQ2C5UXxW9rLOHlxLjD440pF6cRlx3zbo8muQrYdnElv2hpjxgYgdtGKv45L/KIS0j X-Received: by 2002:a25:dd7:: with SMTP id 206mr23501083ybn.63.1590115215085; Thu, 21 May 2020 19:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115215; cv=none; d=google.com; s=arc-20160816; b=DWDe571lcJ9TIU7pjNLf5k7aUvvp3JT3RrR8sKh6KERwdGoXNFT+LFhe/bBeBsErZ2 qNpVuWcUU2yAAIBGMGIpJJu+qLPbizTWTscCQW38XtZhHi0RmIRYmnZXx0cQyDpRIvyP X7iSH6i9PUEyfAnk00mKZED7HmYwVUCeEgPeU0tdhrEzYCmaHvKyBWMQTTuiStJp1aKl 3RDxBrAI8wMhvrqbVNs43XJ2pyum7Iljb632XLBVkE9c1OoNGReRQqm/yYmn0C8fJ7nN btuZvT6xAWpxcrP3QyaprAbEYcuswPWHxrXZc0rf7xbI7X3uJlzICIY0MLixDJhTEUdj lf+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8z6nXPR7A7x3OYVICMe1JtjXlF4OZnzlzqVhe7En9iU=; b=Jp9kYBxH/SjXmRPG7l3rfqSiQkMwibGmuuPEy8m7kBOCZDjYQnz9hvOKGqEZQqB30v 0ICuqCubxmHRfwIwdJOKRWTrLLWV/NFgw7QH+CyxkwZgdzH4VydjIkoQXhxoajr+QrXr RIbzu2+tlI9PMWsvRrnoDaY/aRu7CGM7N57tdSVteFkj2O3jj8U6TjGwRdiOcjksvOxC x6SzHAQnt11rtXPyq+0s9UKyNH+EHAJf2UC668EEtCM9iMsFPN327PxrkWYb+n/lR2wT G9sukREWlKoci+klHBxYbRtFfviuxkqS/T8Gcs8g2GyPRfM8NgDL59NvAiLGSi532xX2 gH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kf45REac; 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 m11si6515290ybm.322.2020.05.21.19.40.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:40: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=Kf45REac; 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]:40072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxba-0005kE-GJ for patch@linaro.org; Thu, 21 May 2020 22:40:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWj-0003DT-M8 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:13 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWi-000596-5R for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:13 -0400 Received: by mail-pl1-x642.google.com with SMTP id k22so3809188pls.10 for ; Thu, 21 May 2020 19:35: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=8z6nXPR7A7x3OYVICMe1JtjXlF4OZnzlzqVhe7En9iU=; b=Kf45REacJKvbRslyMaI32TXHGeHT3x3QSle1TsHlTUfNL1UhF9ECVA0X8Yf/CR00tC TZFITRRCE5XiDELUD1wK465OUGCl5vJaeXa3erJFXADPwdhEXIRqj4fgHYmvpCUTY6lQ uNw/lC2KcvjFf2v8k7OsD+cu2hcFyv3VOQmsSFQToZPgpcLQCRVhg+ZkPFG2hoTQVbbE V30kK7D/Cg7DQxBMMJjkRFtbOdFErepHdfniO7JuysVrdwWiYz9stK8ngF5aAC0kdZgO wPhMzbq1dt7DtJw/YsoAz8Kgrj9hlL0eZC264mvrYMHXJcZxC2ZX+1JP3OlWL2+Ad4Jd lrqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8z6nXPR7A7x3OYVICMe1JtjXlF4OZnzlzqVhe7En9iU=; b=n5AMX3TtouZVQCTzVSaDAuqbk0GYjmZrcpKCemlRuqbP0p3a35AF/RUEr+utNymjYk tSMt9loxgvRIwXlzxvrwY+i/sB2sDNChMrLG505Fnn9ikKQ8XewHITyboxb7W0AQwQp/ 0XR/5fFuP+jiuJjerVzKw41ZZbWPin7L6HbhCMoxwb5fP6ZRTQwiufTnd0yvlodbeCxR dIFQYs7juwQYGchGJiD1UYRoRV5/Z5APfr28BMnZtVj4pT+0A4UaexTbEUZBEg73rbLx Ly2TN9RRHBrNSxjKjCWeLL5czfdfByXPgW6C9yg7ueJAYdC/PpU6wdrNE+tDYOcNU0ex gtqQ== X-Gm-Message-State: AOAM531z55WaE6/3/mEAbqN225VAQzRuo6w4leMc87B7HUBOnCJxpSZg kKzJnYNHg6I5U4GwhX1GkD/UO72GVRw= X-Received: by 2002:a17:902:82c9:: with SMTP id u9mr12390775plz.179.1590114909988; Thu, 21 May 2020 19:35:09 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/25] Standardize reginfo_dump_mismatch printing Date: Thu, 21 May 2020 19:34:37 -0700 Message-Id: <20200522023440.26261-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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 Reviewed-by: Alex Bennée --- 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(-) -- 2.20.1 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 fb8e11a..b443745 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -316,15 +316,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", @@ -383,7 +383,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; } #endif @@ -398,6 +398,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) (uint64_t) a->simd.vregs[i]); } } - - 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 May 22 02:34:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187128 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2105088ilb; Thu, 21 May 2020 19:41:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJCvKZIyCZZWoWMf+Fh2U2xV56RgrYnM6D6mhvwiWiYDBG7tjvqu1B93iVLGkuBsD9x1ai X-Received: by 2002:a25:8b83:: with SMTP id j3mr19192737ybl.450.1590115278161; Thu, 21 May 2020 19:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115278; cv=none; d=google.com; s=arc-20160816; b=PKTy8BfWQgZkT0AQCxE7jl0RohM8t0FS32E12guL9R5FPycapcF9sAS8B47yIMkuiM Mz4VhXmGAlCm5nF/FOO5osMwMMHjHkVXcRqPoNr2b3qJw5UqjC/40sEm82O8vGP2iMq7 Z2VnNmK+ZQ1KnhI9h5K86TVJzJaAvie53fK2KX5VBrjFoLeMsA5dMWoAXUg1AnvEuJjB fxuvGjd5ruYvoATyTgwvufUJzYrm2M+jAZNeROLFA/kKacTyDqYs4SUwn5M9beGuIIDT EKcFIW3BAh7E57g2nUxdj2XvpsI7ar6cd6QOP0hnI59QUztzxlPncUBiw6v94d5doIrM /TzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=tw6kaS7cgnv9ojaevwAQsz7Pzb9OgphIdJHXfmoaatWXfMu5GLM57Cxf1uu8DAg5w9 JslphnYRogcwuO9HPL0V1k4202zaJzxqseyMHawSExdiZvqurBTUO+RC4eSV36N6lF2M SLuVWFYgsIsERpeCeVX6YjGqmd5F1uSVN5P3xZ0Usk65qibXjPYqMgMHubZ/TI84/D+p fgZope10ngJMCymfktHxaDv+somCZccPv1aCzGNO5IgNiQKHJl5IOIk3BLnVubvu3TCo m4GRicwduAIo6rt66MdD2l0h9DQhV3vQKjw5NbTgEu7/Umil5hgtJsOz6xtvxdcyeFVz fTfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d+o7d75w; 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 n190si6727241ybf.130.2020.05.21.19.41.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:41:18 -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=d+o7d75w; 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]:46524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxcb-0000J9-MO for patch@linaro.org; Thu, 21 May 2020 22:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWk-0003FK-8o for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:14 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:55060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWi-00059D-ST for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:13 -0400 Received: by mail-pj1-x1042.google.com with SMTP id s69so4293967pjb.4 for ; Thu, 21 May 2020 19:35:12 -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=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=d+o7d75w1dlN4N2FIq8e4q06qpBJmNEHlzIZHEEsXlgvTpu/1E3VoqzuVXTJlqRk7r Q1dohYUTIFDY7W/ugezO08NFd8RXBhXZj8yVQhFOzhXy494BR8HjI3GBrjPkzQjrfgfp Ky0Z+CaWObUzM6P0ZIoJMiSwKPneobr5q8+v7ENzoKCdoevuYUWCEKfvqoMp1sMJcJ74 Fj70aNxhBWy5wJcnFeuABxs+bWflcgMla8v2SxVmU0Q2CAVWX6B3ssi/ardvAdaEIv4j PIWIg7vJgPw19zmrOIR1fDANVl9ZW1bu69e7qsfz+IQKJQvxP7QnD2JVolqbq1iVHrhj N0lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=SfvVHAsVl2Fc/B+UgR2aKN2+qdk59JYDYEHwuAfxfUm41KplCLUDxZYke4O1mwOV14 y7dWFv85ENnTO7t05I7A9E+jOmyAhN+c0ylO/WTpJY1n35x1LBNY+FdF+WIT6OeC5qtL 2Yq0tMvH9AXKBU1dTulYUjiGITOpCjV5g17Sk1cap3CKarCB1vYtbwjYroeliI6JNwvB sJ9F/ZtnwU3fWeyE1ixpM1/72QdTu/X1C/k6dc3SX08WcNL5ywRKrzONqNvVgb1iYGSZ /91FVKC8i95BwzTX2Hb9EJ6nl+W5vv7YIjvLXeQck2xu4N9AbDC1Ezp4ODacipwJlXiK D/wQ== X-Gm-Message-State: AOAM532WW8FBHP9cBtdrJyqn2UiUBTCDT6+C9bscFRwGxhYjEFI+yn7U cGbEvud770FZiYRww7P0aSEStfACx/4= X-Received: by 2002:a17:902:bccc:: with SMTP id o12mr11723535pls.162.1590114911034; Thu, 21 May 2020 19:35:11 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/25] Add --fulldump and --diffdup options Date: Thu, 21 May 2020 19:34:38 -0700 Message-Id: <20200522023440.26261-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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 --- risu.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 15 deletions(-) -- 2.20.1 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 May 22 02:34:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187136 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2107373ilb; Thu, 21 May 2020 19:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyucbDy5BMS7a9TV5pcVQ/WCQ6zJP3wUZoyxK4yUQa3ov+vd18YEKn5j4qjV8Yl2gKsPLdg X-Received: by 2002:a25:4c04:: with SMTP id z4mr20295714yba.466.1590115544737; Thu, 21 May 2020 19:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115544; cv=none; d=google.com; s=arc-20160816; b=np+PNxk4Vmt8BNoBqcbGC+bN1LC/MpyMtHaWv9itcKevsdWZWS6NUY4xyo2hRSutfP jk6L28RCTh5Jdp3QBIf/jc2pgPycgk26xNioWUdsb/6RDaVY6wM+H+Ly4q2ZSnAOuO+/ 2cfd/SSiEQg/qQeh/+oa1RvgrSmRQrwtWZASQEzXtBLLdr9NCf7X2wOx2bFHfZlEH1H1 mqxz9TNoGTGRzTyDc3vcD/YqZsCcITNNETWFvyJz4UtfbU/kqHpHIrBNjjRj3sp4+KRQ Mbn2CiJoRhmLj4EgSOQQzggpCNXeo7QdUUVjLc9Jyd2HEBPirCZUFDaNv3+1ZySetK2n 0MSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=d+UUwp78+6taEfLoHDVuHhWwS3335HTdwAKjJ5tb8QA=; b=zEf7rcOrEc5vcGABEs581tQQIHDRGcUTE7uyED5PaMRRZaAp8PCp1vt/18pHDKCkCZ RXEL479I6L5r5xfUjoAZ0tnI0lR0mLrOa7q1xk+cIDg9KkPDDXFGPO+WR0Ng6YoiQMT+ AXUTyTRx8dpQYWzkVZHydL5qwGdiiwjh4z1cOk53A5ugpMLdsv+2HB+8IRvKfwDDH9m8 nDRblButMXlyToLgMkKRP9xacEz9jxcnf8le5PyPRrKRXPTQCAQXB27NlKgb9SeMIcT5 TS21QDVZnPADobtCSd4ZskR+XWWWulakWSnBBl5wZSDdz5Bl2skcdlNwxQm5zJFvbp0L 01rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r0XxkTEb; 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 n6si7086926ybn.223.2020.05.21.19.45.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:45: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=r0XxkTEb; 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]:38390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxgu-0002ke-7x for patch@linaro.org; Thu, 21 May 2020 22:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWl-0003I1-07 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:15 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:55379) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWj-00059p-TP for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:14 -0400 Received: by mail-pj1-x1042.google.com with SMTP id k7so4289825pjs.5 for ; Thu, 21 May 2020 19:35: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=d+UUwp78+6taEfLoHDVuHhWwS3335HTdwAKjJ5tb8QA=; b=r0XxkTEbcMCW0ZnPa0sMlqDv9tHIfFEg8RqPdRx1jDj5ttWO7sBThKtDd9vKrt2Whv isJ0v/9eZlZddUq4p5VIbz1APqMGJFsuZWepg29Iyxgdn/JB5hOoNhWAndrn0T2dHdky T66ifuDKiSKFXTGyEVk8ck1mTqOcbluWLJ7eN2PceTC31OxEHECLexmQePRHyXQlgFmh A4zze19ove2EDi5eFs8bwnuSr8rlkTo+3V1y1D4gPvBFW6rwIzu84McYiutmh+3sfGNX 7hRCN2iIaui+Ljzkh4C56B2EH0JPRxiJswCfzl8UCg+GyQvxMJHRld6IOMZ5DCpiIG4F yYEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+UUwp78+6taEfLoHDVuHhWwS3335HTdwAKjJ5tb8QA=; b=gSHPa+7VjzfLCeX7Jy+1utzkpGm6opHdXoZBQksdSGBTPD9F4wtp7hf+DT9qFCFwUK zsXGGEgJnJ7mO4YCxRSed7p2gfx5j6pegE3I99pfmbE1eu3Vp72i0DM7ocP+oZ6BSv52 LkTzXr73OpS23rGo8eB3LZEYQUI/LdhF4birALFVEEgf3AjmzNP/DoWTFNOMOwvWHrXf YCqeYL6r9h+CESGg4GZffih8UjdFKaMBjlO6wCROCJtzp9wii3P/vhuYcKhXQ4Yxfe85 jL69iQHWWC+OJQUMHk7hnxAzCDUnPcNhqyERxDUglK4Ye4whsXH4719pMGqRBH7Cvpz8 OJpg== X-Gm-Message-State: AOAM531DP2GR59WR1iOiW0lBThibijXaLv4IyNYPnzYzW0CyYr2DqFFU yhBcbpA205zfFV0VyIM2AnNKaMBKYUQ= X-Received: by 2002:a17:902:8303:: with SMTP id bd3mr12775649plb.217.1590114912196; Thu, 21 May 2020 19:35:12 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/25] Remove return value from reginfo_dump Date: Thu, 21 May 2020 19:34:39 -0700 Message-Id: <20200522023440.26261-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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: Alex Bennée --- 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(-) -- 2.20.1 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 b443745..64e0e8b 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -258,8 +258,8 @@ static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, } #endif -/* 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); @@ -303,7 +303,7 @@ int reginfo_dump(struct reginfo *ri, FILE * f) sve_dump_preg(f, vq, p); fprintf(f, "\n"); } - return !ferror(f); + return; } #endif @@ -312,8 +312,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f) (uint64_t) (ri->simd.vregs[i] >> 64), (uint64_t) (ri->simd.vregs[i])); } - - 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 May 22 02:34:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187138 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2108383ilb; Thu, 21 May 2020 19:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzOXVZnvM0qJThM/B4Fw8WSEXG9PY2pzmqV4CyrgAkLv1mvsnm3DoClRJR6J3sNUOLbMOX X-Received: by 2002:a37:d245:: with SMTP id f66mr12263861qkj.452.1590115648173; Thu, 21 May 2020 19:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115648; cv=none; d=google.com; s=arc-20160816; b=MGGlN/TH0i1h3dQGHEftVJr6LZjMO0EqnOfR0cFnn1YXDHz3Xo3mBCxBFhP5FzpcJm DW/ciLEUTjLm3nZdB0MrQDprYuLrq79v/htEtLJPbEqzlSUhO4/uXzxuaEbgSe4cR7rZ NGlNCKG4wdwUa1J2s5TrP1XPtYzMdaJMBna5xg5UMN4YF3ojeFHe5sv/mEZ6SJbGIDkW YeVgtpHaZFJG97+7YAvPdEaQaPUF7RixFozSDY3rsFx/5NF+R6gBJ0lte+HCAwtF9HBJ TkJXfPSU6ZV8gylpPRGPg2VP0t2ayD6+j0sacj3fA9e+7P9AwG+m2/bwIGs8YG3OFfaD wA5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Jg8schz/DdjNAa/Xi5ymKEIjRDrXBwYH1uhacJEJtGY=; b=DVbIKI+SMxIdRFifD6rtEBoQGjIFcK2yILQtDV87qbrLEP5m5UbMocxoXNsQBDeAaP uVkXPhCwBlpU8RGLAAAMEzHtiqnpcU0QBkqi2a9GctIFZTJPJ/NCBXW7Ah1nlJmG2WDo /AqRQtdCl1uz7PSzwehk2bYEstrJOW7wgHx7LYWugbend7AKJvMQKoNQJM+kSDbngie1 o6aAAD4S31HwOqZ6Or5Jmf9JiKk1MxNzy3z8jquXyu4DFpjfNTYiiTry+x+gpzWNZwUN cis8v+dWddteg+0QaF3dwLveqdP2d80u8MD4m5vrAqCamgRLf4KscTXpDuAo8gq/S7k7 1QiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KrgStOtu; 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 c12si4440037qtk.81.2020.05.21.19.47.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:47:28 -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=KrgStOtu; 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]:43594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxiZ-0005VV-NF for patch@linaro.org; Thu, 21 May 2020 22:47:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWm-0003Np-E6 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:16 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:45081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWl-0005Ai-7H for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:16 -0400 Received: by mail-pl1-x644.google.com with SMTP id u22so3800403plq.12 for ; Thu, 21 May 2020 19:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jg8schz/DdjNAa/Xi5ymKEIjRDrXBwYH1uhacJEJtGY=; b=KrgStOtuLFuUuccfNSJf3bvzggv4IzMOsiMnsu1lOSHJPyO82fXmbck+BOECxTUXav OvqzloYXGQKdj4/UVCQK4OPA5KB+PyAAJuhK3mHHOiY4ugvuiBiuDp1H7h/qI1BwNLqU lRoXkLY+HxcR0TFiYI6+CR1acSdFIYyU+lJfcX2sVkhgkD7M8pLc5OnxwA3bAF4fsjRl m0rKFLeDAAiNQyy+s8yTxcQO1RiFc3T+JgLuBrTHGQKCXVekUvIxHQHqODp/j60XBun9 nrcfeq8r737LKYihPA035i7Cg/lsYIy2kSDTOItWcr5j/Bl2sVQu2jc6oFxaLeqWanGQ A9Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jg8schz/DdjNAa/Xi5ymKEIjRDrXBwYH1uhacJEJtGY=; b=koZc9wo6VcxE7juVAVngwLy/9RgBD3eIxSVrmpe72d0haAopjsunADoUgLDrl4/ivS yT6Lqcey9V/kChNZ1M+0R3ivxvTrK0ftnrro2RFtvHeiRlyiGrxgFS6Yc3ONwSzNf/91 xb7ZmklxOrtmeOpTMHQLSVkPbkSym7gAaTVcov0fLGzhkwNWP2pT916xxCKtC4KnRh6J 8nIW8v8VdQSRUpidf0PPX+g4+PDkqmhZjmbuhF8cs+2D/LUdXjy99URNwOTIkZx1fzrG VRWP+9Sr6HZs7d/4UoNrDPj524POJ0n75WMjpaQ5KyYewco410BHkJbuFoyU+nEtbEtx h9pg== X-Gm-Message-State: AOAM532kHxqfo3hdR4m/XXBXKE05x4OifI+xA1NyleMvaA5AmxVHQ1el 9tuslO9/jcro9uvXCbCDvwbkBLGj+QE= X-Received: by 2002:a17:90a:8a08:: with SMTP id w8mr1825913pjn.53.1590114913512; Thu, 21 May 2020 19:35:13 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/25] ppc64: Clean up reginfo handling Date: Thu, 21 May 2020 19:34:40 -0700 Message-Id: <20200522023440.26261-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org 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 Reviewed-by: Alex Bennée --- risu_reginfo_ppc64.c | 114 +++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 70 deletions(-) -- 2.20.1 diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 134a152..62d7ff2 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)); } /* 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]); }