From patchwork Wed May 13 18:09:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186685 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp684652ilb; Wed, 13 May 2020 11:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQqAqsDOAOzW/3cSZzkfe6vVcqXuLUD02Fmwwb4tDdbol1uZvwzsn3FKYJRn7OMFMhB++H X-Received: by 2002:a05:6214:70a:: with SMTP id b10mr920736qvz.186.1589393522967; Wed, 13 May 2020 11:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393522; cv=none; d=google.com; s=arc-20160816; b=YR1FOhIDilssYxfjF4+UQLP6XbN/n9ziedppvmtvD/3KzkRIWI24BeiIK/S88c23Wr Ox+98fKPeiGZ0Igw5iyqU/T9thgOQRlP2JjmlDUdpxz82vMXbLXEeNmoukpKNWTexFAR 9rGHY1Xorr6naJ2MD79svO1Tv3XZOMIypxU9vNjcQMwCLy+T/PEH4QrhJ6N7sq4glsTI oxGsVh5Ksk+gP1TU9M8vKi/yE9zKiqHTZGXmgNe+lI62OlrlBZLdqBRenyW9VLm8lFnS RExnzuXsxeMdllf1QEwAyy/vGv8mhlXXZ3n7U2VwjzsSbVMvdQ+QUnc23Mm1TvSJ8U23 JSBw== 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=ZgV2/q17x6H7Sn6RUMsv4Yoy4IHja1Ijjf8wQZe1BeM=; b=uLG7tRCDhUQAavHeKXwAe84/49OZgZXW/MLD91kwRzKf/sk67JxWTuikdki+rBDINV vJpLsFB6whW725gZxzXtb2JS5rCCCHn0HF9FWFf3aKQKCKk+Cnv1/3h23BmqH9TyB8pu tu5ZUFCTbIN+4mzgI6SSq8lQ14Cg5ptBYhRe/3WrR5V3kf0pc5uvGEIZ+g4Y6LG63CDu 7y8K8HD4ek27ME60VPZap85UC7nMLE/XI9bG55ESgkM63qaPeKw5XcybKcjuLsFQo96c wBucbAnFEpsL6y2SQ9q7slZvDetov4HzRXegLWvxY/sGFgLmeUBriaa5krGMMm6l5SsJ bXGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hJzWjm/P"; 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 u20si302692qtj.286.2020.05.13.11.12.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:12:02 -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="hJzWjm/P"; 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]:60320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvrO-0005ZM-Bi for patch@linaro.org; Wed, 13 May 2020 14:12:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpP-0003gI-5N for qemu-devel@nongnu.org; Wed, 13 May 2020 14:09:59 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:44302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpO-0000Ki-Ag for qemu-devel@nongnu.org; Wed, 13 May 2020 14:09:58 -0400 Received: by mail-pf1-x432.google.com with SMTP id x13so85146pfn.11 for ; Wed, 13 May 2020 11:09: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=ZgV2/q17x6H7Sn6RUMsv4Yoy4IHja1Ijjf8wQZe1BeM=; b=hJzWjm/Ppdu4ojt5uk9DhZXaiL2o1DLHMEPiJMtnDM4oyAVwviuFTUy+5enIa72Q4S qGYwo4XgeI4PIrCqPfTwaa2P1TYWMFjZNku0E0qNigNbIOmWr+Z+KGqZmWhUJRMnwK0W ANkSzqKY5ScNQZ3hL1x9JnWqL3ti8mp2yEzt8xMunPqEGFwgAjfnTOWdUVnyZTbrEHCU gEzguY0YUhTtk2WssiW2ffhA2zxSr2eNX0V+wF49jhWDeogaSVxm9AhErt8Ycvs5dWRw uD7rfqfOijhklUm8J/QVI4RYgKN3bsXaA4YME6qCx75sGhEPC4TrpfDTc4XAcTBXfxbG xhrw== 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=ZgV2/q17x6H7Sn6RUMsv4Yoy4IHja1Ijjf8wQZe1BeM=; b=J8YxVJG+B1fZ1tskhxtbn5zFEqbBi0WFep9+tcODWjOt6EzBI8PNtOx3Z5KC154foo f2VYSUK9DJWRV+KogiaC2rNoNnqWLtWLB1AYJG/X42+szeUkd0+feKgGhaDPYyR5dX/x TGYpihTaD2hPFQtMe5ZlMncGyxpI0JCl0FFoLY2FY2deoPECvZnkG61k0zVaXH3xcFO/ K0LrqieFHcSwNzL2SiKCR+K16EKZtYjY+6ag5vDtMH6E5bg8S5mVfbV55CutonEJcX6B gSBYvUchvG4PGW+cmiRCh72IZrSPKeC5cyHkMV+lQORupFP4h1V23HoWQLlF6D5ch1dc UUgA== X-Gm-Message-State: AOAM530+EZBL6fz27TSirzKyNrKYuKEb7FrYcz2gcplBGqB/9xuf1pL2 8Z4dZ1gVwG8I2errru/s6251Hp4sZgg= X-Received: by 2002:a63:150:: with SMTP id 77mr495647pgb.136.1589393396669; Wed, 13 May 2020 11:09: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 i185sm197361pfg.14.2020.05.13.11.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:09:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 1/9] Use bool for tracing variables Date: Wed, 13 May 2020 11:09:45 -0700 Message-Id: <20200513180953.20376-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- risu.h | 3 ++- reginfo.c | 2 +- risu.c | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell 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 Wed May 13 18:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186686 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp684664ilb; Wed, 13 May 2020 11:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8eoc5Ug0NRWCSB7b1Ng53rRpnr62m2hKSHU1WOct2JcmwyHvdQ9gfnuGZTVYlA1ZL7Gun X-Received: by 2002:ac8:38f2:: with SMTP id g47mr405260qtc.118.1589393523362; Wed, 13 May 2020 11:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393523; cv=none; d=google.com; s=arc-20160816; b=JToUTK6cP8izz4HfIpemtL2rIZOqOHzdEyQ5aNVhm5UbluFe/Lqa6AcRadRGfguSV8 mbvlbVxHMcJ62YYP4f9p4TUZqvLXe4K0hs5kE75XxPFkjVaZdBY8p/3C3Z4LB9WqH/AO F6Ki5/eYndPlxGXfpk9kjJwy8Op2yzWyuCBMjNJXXK54S0RArCpBKxIe6RU6tPn3Rg0X mv8OnBoetQ2LRwZOKFIrOQ47v2izDt1hiBWFE1xi+bG9KwooHPbzE5aKM/w86HzDYgRr 8iV1kmpGEzGOu40V6d/kXCxVuHbV4d6/7RBVFu8So81zzJy3lLheXNHsL7PRmSDERYIi +SyQ== 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=QFzU9EJ6IyuyhrhMiANrpQRCnZfFACVjoAb6ym/Zpjk=; b=Jt/wqtacIfNE4yqvpJy4BeSCOjcK6CBpzMo41RupBzbgvE3WnWI9HUKH1fYMuUM3Ht 0iNF8rXo5WW4NmoMgCNI+UkQJaoncExfLR/KqzaVs6LLHeg9sO0GdG9a8GOwzvFfKt4N yNTNoQcDFbEQ7nAazLHG1xEgFznEs72pXAu0nJQuE+QtKRXte8fez7tVWzqSV2QJU/3V y/4UAKFTLhZfslYqV99PQ3o26eMuEun8Sqd2my9ce3ORJjoKISZ2rJugF951qAnzqQWn +EfzTg/0fMpFEUyl5O1COeVYgS+mKOaV4BOCd4+XS5giStGb2Czs41yk0mUFBrwIcVyo nU7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r8FwMa94; 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 u188si129192qkb.100.2020.05.13.11.12.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:12:03 -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=r8FwMa94; 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]:60276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvrO-0005YQ-Pc for patch@linaro.org; Wed, 13 May 2020 14:12:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpS-0003kp-3f for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:02 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:55129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpQ-0000Kz-96 for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:01 -0400 Received: by mail-pj1-x1031.google.com with SMTP id s69so3155726pjb.4 for ; Wed, 13 May 2020 11:09: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=QFzU9EJ6IyuyhrhMiANrpQRCnZfFACVjoAb6ym/Zpjk=; b=r8FwMa94VsjeF2dEKwVrbAE75YVKx9F85MBWEmXZB73xGvmT0RaF76mesHjLbsIBL3 h2Qix5o72Jky34NNbxRHlYhRr90yPBjZnOBZWu1yGRh54bnbQVUcNVyYE3/tmdSelvRF WkYPDpGNeO1PO6PLs0RxRdZ82DFXCjLDc4SkrdvXehKSs0OxEJMxwLvmb51BuDdXm5Ut +4PrWB3oAlgf/xUWf0WyVmDVaHGEvQdgeB18H29v+hH6PtuC1jDzTMUXJud+14tM3+Ta VjcCMAt+SYNw9ioWkh6K6YI0PF6noz765PZ9nMmBOuXkTz3jWhiHmRIinpWLv8ShQBrs RjGw== 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=QFzU9EJ6IyuyhrhMiANrpQRCnZfFACVjoAb6ym/Zpjk=; b=JQ2CVG5YfTtizRmqcCQwtzUHwg9n+8+OwIshuKM/zEloBBkfQrKQSfKGzu5784p2Nm FYxiEWX7V8t8asyLRePRI+7ZcpmLG2K9YG2rTP9EplaHK/lxhhTsdPGL/O6DWN0nkWRV 8CkNdnQHgvOOACdG6DwxmgIuh/tO0sGnce6k61eXNMkP4nMXuTS0AYR9eQ6JRKCDLrFz zaxf9vFudqtB6g/s1q8Jo2X2cDi4riDRHNGi9Ym1vnZgdN05UxvA3TB8IHU4zKTEx/vM QPEdcw6husRIVD/DL+RZ1am8WloO2tisuFIkgIFb4E6xad2rUn4ZxUdwMIG0GRiwB7YY XiSQ== X-Gm-Message-State: AOAM530FhwmjwWJJsRWmKNrDpulfc+qkamW09yKZtKgsKqgTdR0UQKkG TI4xRXu943DpzdohDnNkKE4wPkTGFH0= X-Received: by 2002:a17:902:7885:: with SMTP id q5mr19434pll.320.1589393398207; Wed, 13 May 2020 11:09: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 i185sm197361pfg.14.2020.05.13.11.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:09:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 2/9] Unify master_fd and apprentice_fd to comm_fd Date: Wed, 13 May 2020 11:09:46 -0700 Message-Id: <20200513180953.20376-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Any one invocation cannot be both master and apprentice. Let's use only one variable for the file descriptor. Signed-off-by: Richard Henderson --- risu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell 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 Wed May 13 18:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186684 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp684623ilb; Wed, 13 May 2020 11:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFJabZwcL80TgJLV86XeoVFPk2nDQ7LF69jR31k49669juNnla4pL6h48xElnEDUsIcFLf X-Received: by 2002:a37:c04:: with SMTP id 4mr892415qkm.137.1589393521108; Wed, 13 May 2020 11:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393521; cv=none; d=google.com; s=arc-20160816; b=vBHFdwL77KsLFdEgi0SZU/lnv6mPMjS3NjQfvHS9EC4+x6uZhByRu7qnTA6sBCP6CQ OKxKcAENjRl5sSbr8CgfN+b2BlhrTzDywHwMxF3yLRrDlrKSV6Aq28fcnWXfCYYb9jr8 QTDrWpQZRr/LETf3MWtDPWG8VBMrAQDvoQgdhMHeQl5CwSqYPGyaA+rHXtxc4BSuOlxW dPu2NhR9wjDt7kKh7HZTdtiIj3Hjgoa0KLpRgZsQeHvLsl9AQ0fICCWedp0WG/N4DueO XkpNcsDYke/NLh+Efv0rInT74T5aBo7rGcWOFgJFFLcUU4gkTw5CSpGL7rlDHQnbCWpU p6FQ== 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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=wsCYL2zT6UVhgaK3HUKcwDQ8V6nGZ3FyjWtx0uHbR4tg31dA98gOsSOGfvCWhUCTkq kEdwSGs/pryWKAd0+bpiZ/OJ48fWDIcXEkkROLQ5kruIK1jS84j8GzEXxFnm0YuwEWVz RaEGtn5fs8Bf/fmedfdeMPVjrhlZnbYh1lPPBGDn5mDm0tKAH7vxVftylGZO1kC5S1yK eZqILnwnAunlGrZf/BEwI8W3rI+LsVXJAKDK0BTaqvKBCZ76dcf+zfI0S6yQ8JEfnEzP 8ZXr8eVQTlXqeZHKwBG6H+Xg/lsMdZR8FhvdOVas+AIKDpjDDX69mqUuDDmhjM+uPtpM 6bpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfi2Mcyh; 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 c26si151330qve.168.2020.05.13.11.12.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:12: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=nfi2Mcyh; 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]:60090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvrM-0005Sv-8l for patch@linaro.org; Wed, 13 May 2020 14:12:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpT-0003mj-FA for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:03 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:41358) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpR-0000L3-O5 for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:02 -0400 Received: by mail-pl1-x630.google.com with SMTP id u10so139814pls.8 for ; Wed, 13 May 2020 11:10: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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=nfi2McyhWp5KlLT7B06opOJr3FBtWlysLiXVLx64YHZNK5Zz5OuDvWRhL+PYRUJgrl Ye0EUEVdtFau36gY1+8+RpR5H/serJmfVatuu8ifL61DIl8mi1kzJP41Y9+X/WW0ulyL sqG5LV/EPGSKp+9zx7q5b5aUxVAMUdx+MK5drcN8MUMYvXSn0M6oVhFw8wGzZ7EzfxPS iWp3div9b23xgpNCy5y2ZIIprc4+2RomQw6NKNoLPzbsBylgXN9jv3lJx3JN9YXbaiIM teice8DetAKE2bClgZhTSzIpTtdEDEKY/yl42Bdx95EJ55or4yhr/QEyDeg6zR/bNum6 PutA== 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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=lLzR9BDHroooZcw2fXKqT+OJnkOS6Dy4bh35g2RL394LuQgH0BjixT6nEByEdnjVIY xVEKPqKGqMN7WAmnO1yum1UrqfQhN5A21poeyGTOWHLvD7DPIzoAKT2Nn5teVuuswukj OZNVr5HC29Kno0Z60xg0grJl5gv9+RPeQItOEWWUP9uJ0+/fYjUFbjo1GuoSEkUGpJ61 Rit8pC6TmxhXz8bO266+ab2ijn7a/I0kIWTzOI+B5MIAguM7si1MqcSwR/eWQjYzRaYS uSOAN7elyyL9p5UIMw5VpWe1+ScVQFxEf9XabDZjS0/l9thkyP4TjJG/biUfQ9ujxmNY V36A== X-Gm-Message-State: AOAM530Wsst7NDB4phl9YLCJG3POiQJRPDBGqFxoa9E0qasvm8p2zYk+ 8oX0dfvzTBo/EIso3Bn9+lYQQOFfPqo= X-Received: by 2002:a17:90a:df03:: with SMTP id gp3mr5378232pjb.50.1589393399401; Wed, 13 May 2020 11:09: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 i185sm197361pfg.14.2020.05.13.11.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:09:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 3/9] Hoist trace file opening Date: Wed, 13 May 2020 11:09:47 -0700 Message-Id: <20200513180953.20376-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- risu.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/risu.c b/risu.c index 059348f..1c66885 100644 --- a/risu.c +++ b/risu.c @@ -363,6 +363,21 @@ int main(int argc, char **argv) } } + if (trace) { + if (strcmp(trace_fn, "-") == 0) { + comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; + } else { + if (ismaster) { + comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + } else { + comm_fd = open(trace_fn, O_RDONLY); + } +#ifdef HAVE_ZLIB + gz_trace_file = gzdopen(comm_fd, ismaster ? "wb9" : "rb"); +#endif + } + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -373,31 +388,13 @@ int main(int argc, char **argv) load_image(imgfile); if (ismaster) { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDOUT_FILENO; - } else { - comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "wb9"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "master port %d\n", port); comm_fd = master_connect(port); } return master(); } else { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDIN_FILENO; - } else { - comm_fd = open(trace_fn, O_RDONLY); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "rb"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); comm_fd = apprentice_connect(hostname, port); } From patchwork Wed May 13 18:09:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186687 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp686818ilb; Wed, 13 May 2020 11:14:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyen+y1dB7RH8OR931xs06PbGk4JOtSPK/WmfbV5wzByAycWQEptY/MIcNak/LXwf/c0Rtu X-Received: by 2002:a05:620a:1479:: with SMTP id j25mr1043058qkl.110.1589393698186; Wed, 13 May 2020 11:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393698; cv=none; d=google.com; s=arc-20160816; b=Txbh0KznyevoJfJuq3Y1wnVjAqmDmx6ZqLahMU8S/7V3QXCSzLEypgKucld7Ls8MiV soRZYi1pyGwg+kxbO1Bb8gX/w3HEC/2LzF/xK88d3lywL5ONROjWWo4vjiY+0vRC9lWq gbNlNqOiid6jptI2ellNxsFSOQrFB/aNt0V/ADc3RMzl8Aq5y1MxNEuQNtxCgfN9IYC/ FGYOl4xKJ/SIoEP9dnT+WKoAGXIwbL8WcFIM8VBr2QSwsi5hNQDG3LEmXCSnzXeFwiOl eZxFSBwRWewVUscEBbtNXrCO7OzENyR1TaVkhX1/YOo0jXmuJncZHpW6yK1YPxLotZyn LyWA== 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=lLvKLW9QkwF6CYlMcG5jB8i9eNtam9qfgfh7941aYEI=; b=RpX4F5N3UwKXae5kECQO24uTaWNOSaXtuLFlKTdeKLCxNwZ2vbVWmLIBSxhDXR8Nz6 W7tqkFh/tye/BX3cvdoa/nq0r4ZZGQj2/XK/NEdW0f6lB8vcB++dO/B7XKOUNcfzx9fz H5RTkZ4Yu2eeTzUqZR/sJYlQS0sXLEmJnoEq/mq7/tlZLLvRGHSfnYZT46GDeo1Z3VYk wakdMkEsdovDPUCRtKqQCECsimrKZEqcSR2nafcg85jLvN35iIjwsX55Y/LArmL7Bu0O dTgw2yfd1QmUYTO9UVKxTpc/Q+ZdXEJEKTicxy7Y8OKkxwyBbd1bJEDJp7bxfCbpDfWD 9lOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qBexN1V5; 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 s53si302022qtb.71.2020.05.13.11.14.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:14:58 -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=qBexN1V5; 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]:40770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvuD-0002Fm-LN for patch@linaro.org; Wed, 13 May 2020 14:14:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpW-0003og-IF for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:08 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:40029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpT-0000ME-5z for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:03 -0400 Received: by mail-pl1-x644.google.com with SMTP id t16so141199plo.7 for ; Wed, 13 May 2020 11:10: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=lLvKLW9QkwF6CYlMcG5jB8i9eNtam9qfgfh7941aYEI=; b=qBexN1V5iAhi/Y3W2qYSdY2X2j5MqvO+VRrkXN+YKGMef35whPusMsSCg4I515AoAK ciN8FpFypbDlMvXFJV6hHr0WIBCNb1GNnXd1jFmsSXP2q1bQaoj9h7cr3g0PqGX1P6Om Vf16XHf2JvH6uq9pnIS0KFREPjpbRqRkfGYeWNoqXx6Xn2cdM/UuJMm41yAjIXTk+56H 8PabMse08+IKcxaT1BYeHY320jtPej62P88f98HKzT3zxyQMqIBhv7ClmuiP5h/zVGtC hBsj9ErF9pUKzcptWwKHFkLZwHG0nno4GIlxy5NK3fjIabnZIpHvFDbL4WbmdgJU5H7t kT+g== 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=lLvKLW9QkwF6CYlMcG5jB8i9eNtam9qfgfh7941aYEI=; b=W1HXQmS9nMl62zP7tH2//Gh763L/47NpmTzo65qtpnPzoLxTvpq3AY3MxoOrfE9JwQ GyYPEYO6FEQeWGSJ662ZZn/UMKTOOoe79bANHRdyhb3iS5+hPDrMq4tN/V+pD9mlcb9k SOU6eMMWucECFOItZEwaY7o8VPCwGQlgOjledeE60Vt0mQF30CJlt/BcHKBa/OaxBokL yzOE+yjTVJoc2R9ACcq7vlX6d2TKU+7t9d7h3+pjibVhYsom/AbzKAvaXH/yGzw3aQDi C+cvjcpl1kHUdJwPmb32LDsZS+kUe697IvRjPCI8E5GrBUWDcwb2TsYj/eHYyatyNnD8 n9iw== X-Gm-Message-State: AGi0PuZGZsg9P8RX+kzL5Fj8JambCpXW4+QiXxVynrUF/19n+DboaOXk dTSr1nCl5fvxwj31jVRr+HTlHGXesvQ= X-Received: by 2002:a17:90a:204b:: with SMTP id n69mr35084488pjc.176.1589393400875; Wed, 13 May 2020 11:10: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 i185sm197361pfg.14.2020.05.13.11.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 4/9] Adjust tracefile open for write Date: Wed, 13 May 2020 11:09:48 -0700 Message-Id: <20200513180953.20376-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Truncate the new output file. Rely on umask to remove group+other file permissions, if desired. Signed-off-by: Richard Henderson --- risu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/risu.c b/risu.c index 1c66885..f404d8f 100644 --- a/risu.c +++ b/risu.c @@ -368,7 +368,7 @@ int main(int argc, char **argv) comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; } else { if (ismaster) { - comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + comm_fd = open(trace_fn, O_WRONLY | O_CREAT | O_TRUNC, 0666); } else { comm_fd = open(trace_fn, O_RDONLY); } From patchwork Wed May 13 18:09:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186689 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp687320ilb; Wed, 13 May 2020 11:15:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmC39Xf9nm1hiH+A1ts5WTU7JrFq9+latdF6qAxfqEqMuvvFKyEgwKsGwhXd59LfjDI9IW X-Received: by 2002:aed:2ac4:: with SMTP id t62mr371954qtd.381.1589393735148; Wed, 13 May 2020 11:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393735; cv=none; d=google.com; s=arc-20160816; b=x01KO3m5UToDEAr5JpetbamQNQSuS6L8hi/hgP1XjguutFHCxQn+fhipAR6x2KLQF6 B80UOWrDh7tjQBRoAdPH+l/YcWajCKZNXcwBrcWM53jNxvVv6sEjix82ZZpfIh8+LiWF xEymGpYb3Wjk5Bv67NrQJ59lID80J3FCg9VtLBvwTpK6HyEJfCvfpEIq+wT0PPaDV2rm DAgHNvk1248pcPPse47e4httM7hJ0ouvvtAWFOLi26VMvUuPA64q/2cVE/lUh+SY0gTG H6SusYy51oP3KIsDTroobZS6AwthKcRp7f/3SvH2spFreNnSdKAiMHz3T7EGsxzYwbix +SwQ== 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=AMQUtdh7GLtHPDRn6Oq7V+4ssQorJyRBdGwREFAHbh4=; b=Qw8rCj8nQEu/WKZ1FTlMjgXEz3dKpewDTN4jlf/4WQeetTfevBeiXbbuIVznqJYx9v 4ewKOUM/Kl/WE7LedgIE6oOpsCB3vtAaMhdN9XAgASc6rnPgGBMy02LYZPR8QOPJqBnW UylZ9r598ki3FRFKsNL31gdYp2qsal+yhxhI282bY9YEuQrZlW87MF8HC94yVyB/YziW BEMv7aMLRLYYHPut95aeEXlI6GRsCuB8Uwe8E4FB9DFWyrOX4lGGfjxQm6HqcGEGQu/V W6Gxl5hJBdqnqDADya5/w+3D0uhEMnhVl8TLdehvJ5J7Jy388tu3+QXtjAkfUh0ItECl lOPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kymvCFFh; 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 s53si303043qtb.71.2020.05.13.11.15.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:15:35 -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=kymvCFFh; 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]:40664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvuo-0002Am-Gu for patch@linaro.org; Wed, 13 May 2020 14:15:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpY-0003pP-DW for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:09 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:44305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpW-0000MT-De for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:08 -0400 Received: by mail-pf1-x435.google.com with SMTP id x13so85235pfn.11 for ; Wed, 13 May 2020 11:10: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=AMQUtdh7GLtHPDRn6Oq7V+4ssQorJyRBdGwREFAHbh4=; b=kymvCFFhFOFLhJ4hFYNOMm3/3e3hmC5maCZsO3r0Usp++7HlaZ0iBISGndlnh243l7 bQvFecuDz3lGzcbpy7jbrFeJ+ZSmUZPrRZn20e7IllcuwVL4ZR8L24Vvn8J2fpTQQmAk U5eI5Oq/eYBKYSSHcGNy2GuQwkwxNb79kDU9B6zqy1S6fPhOgeRBJerOnAfg457cVctI ZiNB8SmXDFWFcQIuZMtfsCFQtb6x7oBmp8VPB1YoaqWw5Bj+oonN0FMiDogUOPCYkURM nytDtGjk4yblUJ2f/dSSlnigS5S0Bl0X1EN+37tAxWH2EhBG2T+bwEJWLLALWcBPGn7f osVA== 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=AMQUtdh7GLtHPDRn6Oq7V+4ssQorJyRBdGwREFAHbh4=; b=jESNxP/QkAJKdqRfrIOPGq0/PDMluxR/hECnlRQGRg8re1dm1ghN45Hna78gBlJ4Ki 8v9s4nyVvbtYiFioJI4VJ3B5QAsCl95HDHHsTFlAmrTVZQDV3yhZppKqaSmZthq5YBpa X9LM/jqxBCPp0bL6ihKHEyKDN01SUPyou6dJ8afUAFYZiNB+5mfrnrME5SUQrvtwAK5i 03ZcPr7YyY7mZiwNynD9FAZHeltcbOxhkljuKHApODRE0vyoUiwCZ3MsgampSw8ffMK8 sAMxOJ5+3rAh+bF+WL7yFdJihj473oLP1E2JmirFWbrVY6NfY5YzqRXK+LBgHyGUGBTg 2WTQ== X-Gm-Message-State: AOAM531qsTN+Vh9F092AqFShItGfS31fPcYfLoWbn65It+Y5cz2MA2uO XFXIycM5/ZfIWjxnoBwBP5MjCyYTGzs= X-Received: by 2002:a62:144b:: with SMTP id 72mr516753pfu.246.1589393402119; Wed, 13 May 2020 11:10: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 i185sm197361pfg.14.2020.05.13.11.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 5/9] Use EXIT_FAILURE, EXIT_SUCCESS Date: Wed, 13 May 2020 11:09:49 -0700 Message-Id: <20200513180953.20376-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Some of the time we exit via the return value from main. This can make it easier to tell what it is we're returning. Signed-off-by: Richard Henderson --- comms.c | 26 +++++++++++++------------- risu.c | 22 +++++++++++----------- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_i386.c | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/comms.c b/comms.c index 6946fd9..861e845 100644 --- a/comms.c +++ b/comms.c @@ -31,7 +31,7 @@ int apprentice_connect(const char *hostname, int port) sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); - exit(1); + exit(EXIT_FAILURE); } struct hostent *hostinfo; sa.sin_family = AF_INET; @@ -39,12 +39,12 @@ int apprentice_connect(const char *hostname, int port) hostinfo = gethostbyname(hostname); if (!hostinfo) { fprintf(stderr, "Unknown host %s\n", hostname); - exit(1); + exit(EXIT_FAILURE); } sa.sin_addr = *(struct in_addr *) hostinfo->h_addr; if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { perror("connect"); - exit(1); + exit(EXIT_FAILURE); } return sock; } @@ -56,13 +56,13 @@ int master_connect(int port) sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); - exit(1); + exit(EXIT_FAILURE); } int sora = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &sora, sizeof(sora)) != 0) { perror("setsockopt(SO_REUSEADDR)"); - exit(1); + exit(EXIT_FAILURE); } sa.sin_family = AF_INET; @@ -70,11 +70,11 @@ int master_connect(int port) sa.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { perror("bind"); - exit(1); + exit(EXIT_FAILURE); } if (listen(sock, 1) < 0) { perror("listen"); - exit(1); + exit(EXIT_FAILURE); } /* Just block until we get a connection */ fprintf(stderr, "master: waiting for connection on port %d...\n", @@ -84,7 +84,7 @@ int master_connect(int port) int nsock = accept(sock, (struct sockaddr *) &csa, &csasz); if (nsock < 0) { perror("accept"); - exit(1); + exit(EXIT_FAILURE); } /* We're done with the server socket now */ close(sock); @@ -104,7 +104,7 @@ static void recv_bytes(int sock, void *pkt, int pktlen) continue; } perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } pktlen -= i; p += i; @@ -127,7 +127,7 @@ static void recv_and_discard_bytes(int sock, int pktlen) continue; } perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } pktlen -= i; } @@ -186,12 +186,12 @@ int send_data_pkt(int sock, void *pkt, int pktlen) if (safe_writev(sock, iov, 2) == -1) { perror("writev failed"); - exit(1); + exit(EXIT_FAILURE); } if (read(sock, &resp, 1) != 1) { perror("read failed"); - exit(1); + exit(EXIT_FAILURE); } return resp; } @@ -217,6 +217,6 @@ void send_response_byte(int sock, int resp) unsigned char r = resp; if (write(sock, &r, 1) != 1) { perror("write failed"); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/risu.c b/risu.c index f404d8f..979341c 100644 --- a/risu.c +++ b/risu.c @@ -153,13 +153,13 @@ void apprentice_sigill(int sig, siginfo_t *si, void *uc) return; case 1: /* end of test */ - exit(0); + exit(EXIT_SUCCESS); default: /* mismatch */ if (trace) { siglongjmp(jmpbuf, 1); } - exit(1); + exit(EXIT_FAILURE); } } @@ -173,7 +173,7 @@ static void set_sigill_handler(void (*fn) (int, siginfo_t *, void *)) sigemptyset(&sa.sa_mask); if (sigaction(SIGILL, &sa, 0) != 0) { perror("sigaction"); - exit(1); + exit(EXIT_FAILURE); } } @@ -190,11 +190,11 @@ void load_image(const char *imgfile) int fd = open(imgfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "failed to open image file %s\n", imgfile); - exit(1); + exit(EXIT_FAILURE); } if (fstat(fd, &st) != 0) { perror("fstat"); - exit(1); + exit(EXIT_FAILURE); } size_t len = st.st_size; void *addr; @@ -207,7 +207,7 @@ void load_image(const char *imgfile) 0); if (!addr) { perror("mmap"); - exit(1); + exit(EXIT_FAILURE); } close(fd); image_start = addr; @@ -226,7 +226,7 @@ int master(void) if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); - return 0; + return EXIT_SUCCESS; } else { return report_match_status(false); } @@ -237,7 +237,7 @@ int master(void) fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + return EXIT_FAILURE; } int apprentice(void) @@ -258,7 +258,7 @@ int apprentice(void) fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + return EXIT_FAILURE; } int ismaster; @@ -355,7 +355,7 @@ int main(int argc, char **argv) break; case '?': usage(); - exit(1); + return EXIT_FAILURE; default: assert(c >= FIRST_ARCH_OPT); process_arch_opt(c, optarg); @@ -382,7 +382,7 @@ int main(int argc, char **argv) if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); usage(); - exit(1); + return EXIT_FAILURE; } load_image(imgfile); diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 00d1c8b..028c690 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -51,7 +51,7 @@ void process_arch_opt(int opt, const char *arg) if (test_sve <= 0 || test_sve > SVE_VQ_MAX) { fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); - exit(1); + exit(EXIT_FAILURE); } want = sve_vl_from_vq(test_sve); got = prctl(PR_SVE_SET_VL, want); @@ -62,7 +62,7 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", test_sve, (int)sve_vq_from_vl(got)); } - exit(1); + exit(EXIT_FAILURE); } #else abort(); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 194e0ad..60fc239 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Unable to parse '%s' in '%s' into an xfeatures integer mask\n", endptr, arg); - exit(1); + exit(EXIT_FAILURE); } } } From patchwork Wed May 13 18:09:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186691 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp689448ilb; Wed, 13 May 2020 11:18:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUYq3qPz8x3QJCXUW9SgX6IjfxA7NxLLDXj7dh/xeWKqS8bmtGj/c3Ib/eByn0icieJa4P X-Received: by 2002:ac8:6b19:: with SMTP id w25mr391829qts.147.1589393886178; Wed, 13 May 2020 11:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393886; cv=none; d=google.com; s=arc-20160816; b=B7Gg2xb60ugd5AOPrFkDErs/z1fWhq7FWx/1aiOfYIzrj/AhO+G4ecMsKzdmy4aA3b WCyw+u7XDxLM60KbIDFtQG0ZrJD/NbtcNCxRg2TifRP6nS1TCJReqfhWnevhtgJszP05 hQ8cicNh9YAM5NJkEc12wH8p9c0eFdzldyUGVVc9Fy7/77gBm5vGT/mQzyWi49yZ0aRl a2BcTWcX4qNWH0/6HUZTNZ+VJl79DtrwtxLHjf0aJ4AEzuPCmlwl+sQwTwj200lT52Fy NtAuKBMDj0WfHdj2Pu0YCwQdushqoN+5cPQid45MCISf2YmAkwUTDsvpME3ulpr5tZbk tZ5A== 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=JSmowOO+YiAA0eSN0s8xOlbrTguVMlQ6LjWvJ71pNA4=; b=u3U/LfxaEp2t2z/8kqam/lZJhlJUMMXfI6TP7+v0g9TM1E9pj0ex6wpUpQQTq7xKWl oKNZMN2iPjYlejNPmHzxp8r3Tb2gxXSiC2Tl9iDzYq212xzb5XAx1PdM7PGiGsFG4wVY WQgUK7nwzAvw5hvgbPSQ4GlyKPzmWft3iZRCdPeb9G/Ybgt/LUE53RCRIaS2Gjgp1Nrb 6sSzUFb2yiPdC+qSvhCYGwyB4BTPKnFMU50n4jbz0UZ12o5q7GZO6n6YkAdtRTqJkDoR 5zOqP+8/6pQQt+hoLx+JE4YXVULpqjzmXZ+dpV3MRc/dGW/mY/7RK+cxy1VEZYek2ger xItA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRuXKhan; 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 e22si178606qvf.81.2020.05.13.11.18.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:18:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRuXKhan; 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]:49218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvxF-0007Lj-J4 for patch@linaro.org; Wed, 13 May 2020 14:18:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpZ-0003qA-QU for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:09 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:42175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpW-0000Me-E1 for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:09 -0400 Received: by mail-pl1-x62a.google.com with SMTP id k19so136966pll.9 for ; Wed, 13 May 2020 11:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JSmowOO+YiAA0eSN0s8xOlbrTguVMlQ6LjWvJ71pNA4=; b=uRuXKhanODepsH+nLE0Bb8fz3ZKAZFQjhC1YneZy2V5DmXo9Afaj/r790teAy/xf4P qEX9WC/A+s00ibSqa2gk2EDgt3CJzKts3E1vXGhdTnqjlO4rVwKTC1lZp0EZrs31nDC9 YW6msOereGCOEgUxgkrQZssyah5L+Zd0XJRgmr/OHQ8S9JOtAmLVTtsrdvb2vyJNA8V9 QQy36j+xLsHIkeGZsYTED/iAj8U5rSKIQ9AUIsHOtj8yVDAzmVmVjnrKdR//scCYcJ9g eO9W8jodpSbuXG38j2sK4P1sM+TzNt/EgncxOCtQuIHPaFFAfOhIaU1LP/UBKaWjSHZ3 2ZlQ== 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=JSmowOO+YiAA0eSN0s8xOlbrTguVMlQ6LjWvJ71pNA4=; b=JvvGSQ94vva7VwMMK5vxRRk9RRrcW/f0OOKNqK2RciedXs7i6Ngtr6rqWA/rE1h+ZI gG3u+0QVxAm+JFTZCnFMJC5IqtiEmbL1s9lTbYE9Pb2XL3rO2V3wWHSjwqJAvnhCZB7W YZdF9KcTdUURENOSpaxdIevymAUDkS/OOMKgMV3fBKbBC6EAGqn9SibY0Sixowa4mplL O4qIu7eWJ2nvjtZWTPCEA7HO8KR29fxjDdLAtm2S+Jx4p89OyGa7dimmWUvYzUllJjed Sn4E3B3/8tMP0w1nIRQEKCBYMAphsmE217cVhRs6uWPK4Me4ZK05vkSQr2WJ0DGV/kiR 5EDQ== X-Gm-Message-State: AOAM531HSTl/sOSv8eOeE/sAoFvUcH0S/Fj8FL1BhXQrdZRM1FfutTkZ ALHYRJsU685Xmjp6SLYkIplPDPnC50o= X-Received: by 2002:a17:90a:be09:: with SMTP id a9mr2678962pjs.165.1589393403834; Wed, 13 May 2020 11:10: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 i185sm197361pfg.14.2020.05.13.11.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 6/9] Add magic and size to the trace header Date: Wed, 13 May 2020 11:09:50 -0700 Message-Id: <20200513180953.20376-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sanity check that we're not getting out of sync with the trace stream. This will be especially bad with the change in size of the sve save data. Signed-off-by: Richard Henderson --- risu.h | 6 +++++- reginfo.c | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index e2b4508..3fc198f 100644 --- a/risu.h +++ b/risu.h @@ -62,10 +62,14 @@ extern void *memblock; 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') + /* Functions operating on reginfo */ /* Function prototypes for read/write helper functions. diff --git a/reginfo.c b/reginfo.c index 1b2a821..a4f7da6 100644 --- a/reginfo.c +++ b/reginfo.c @@ -26,20 +26,45 @@ int send_register_info(write_fn write_fn, void *uc) struct reginfo ri; trace_header_t header; int op; + void *extra; reginfo_init(&ri, uc); op = get_risuop(&ri); /* Write a header with PC/op to keep in sync */ + header.magic = RISU_MAGIC; header.pc = get_pc(&ri); header.risu_op = op; + + switch (op) { + case OP_TESTEND: + case OP_COMPARE: + default: + header.size = reginfo_size(); + extra = &ri; + break; + + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + header.size = 0; + extra = NULL; + break; + + case OP_COMPAREMEM: + header.size = MEMBLOCKLEN; + extra = memblock; + break; + } + if (write_fn(&header, sizeof(header)) != 0) { return -1; } + if (extra && write_fn(extra, header.size) != 0) { + return -1; + } switch (op) { 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; @@ -51,14 +76,9 @@ int 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; 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()); + break; } return 0; } @@ -84,7 +104,7 @@ int recv_and_compare_register_info(read_fn read_fn, return -1; } - if (header.risu_op != op) { + if (header.magic != RISU_MAGIC || header.risu_op != op) { /* We are out of sync */ resp = 2; resp_fn(resp); @@ -101,7 +121,8 @@ int 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())) { + if (header.size != reginfo_size() || + read_fn(&apprentice_ri, header.size)) { packet_mismatch = 1; resp = 2; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -121,7 +142,8 @@ int recv_and_compare_register_info(read_fn read_fn, break; case OP_COMPAREMEM: mem_used = 1; - if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { + if (header.size != MEMBLOCKLEN || + read_fn(apprentice_memblock, MEMBLOCKLEN)) { packet_mismatch = 1; resp = 2; } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { From patchwork Wed May 13 18:09:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186690 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp688856ilb; Wed, 13 May 2020 11:17:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypySkiHf8Labunyqs5+m+PU1LXtkrs1B/BHeWv5A0mum+FNSrRbbx4XkFrYlIqNd2NsA/q X-Received: by 2002:ac8:2c44:: with SMTP id e4mr418465qta.13.1589393844188; Wed, 13 May 2020 11:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393844; cv=none; d=google.com; s=arc-20160816; b=T0126tRzEs5OLVTrfM7f5QziXYeKJ9nbPuoRDMbjqsPcpk4UlCm8G5eiwEPZeY5IYl xgsjq8jxeVS7+OWNrBiIe5fY88oE5VLqDQzIdYcFKT+I4VIvXjjk0+BgnHuZUiHZpoQu eQWDjy6SEmKv+MhrFGXGaLLXupFJ84lpnLeShvEvXZpz19kSun/383NiJSdCLzwcgLJf y3RuNEVTPACUrBrWDzAr//7fdj3KccNvpoP3/YAN/LqKCNesrI77dwzhXABlSaHSa14H c08ydzoIRW9euhnP1f/AOiQ0V9nTAc8G9wSTqmCrC/ji85qKkaEJyMheVWI2GfIVA2jv GhnQ== 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=jBzLmvDxBp3zJZsO6hz95Oe3IMjRgxYk/8WAQc4mszU=; b=Epm/ZDTFCcprOxpq4Y1nba7PWo3svrM7lcaV2BjvFVYoPiixhz+WwwrdD6nvgDjcvY 4w8RDJZU50fwx1oeooKznd1bOU5dSLVphYmo9O0NZX1fIh82zDfzqEdezUBImIg4DaV+ 7atBYniLhaWnUlYsVCmQybstlxSBzKJhVlGUi1wmXj19nkTABPHgmzmEF24xM6G03+3q Go2CIIxx/OpYiEZCfrwupAooICula3w9OLj7ycT3pWS5NiN1QhJjuU3vxlHkyZ4TRAD7 6BGvivjfiDuMFxP6rlD8MCU6Hq0Qf9vQmqlRJOfXbt4A5KBkSyn3jZSmBoDKDDXQWXL9 1wbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EXLhM5+F; 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 y5si169433qvp.74.2020.05.13.11.17.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:17:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EXLhM5+F; 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]:49178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvwZ-0007Kq-Kc for patch@linaro.org; Wed, 13 May 2020 14:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpa-0003ru-DX for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:10 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:35664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpW-0000Mm-V2 for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:10 -0400 Received: by mail-pg1-x52f.google.com with SMTP id t11so107747pgg.2 for ; Wed, 13 May 2020 11:10: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=jBzLmvDxBp3zJZsO6hz95Oe3IMjRgxYk/8WAQc4mszU=; b=EXLhM5+FN0DVD7utH5kdiS/DzOjhprxOe0DBdpU4t0U+5gHbDoYHTITvehckOLmg4T fUkuwe2Gr9ofhCVGDL8J6DQAKNdgd7UId6BErNWv4lZY/bEg1KeBotPOcoVw2m75t+73 kkyc7QrY2lUIJeugyECDsxuwX0Mx4y7m3cQ98M6snA2b0fppsOZbH4iP4uy8XGDAZbNG nZwiVJ3DvvIN6XX/An+mwYNCTqo6sllUs3a0qC5UmVnv7RYNm/418E1YPHfoK62TNXlu byifNPTmh/AR0grWWVLUMXhk+d3hRFh9vJWLiwM1QheDhWxpCXE9yrQIWhYY/A2qZPY0 GWjQ== 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=jBzLmvDxBp3zJZsO6hz95Oe3IMjRgxYk/8WAQc4mszU=; b=UpxSQZF3EQmZzYoYHMy57R65WApBJ03QX09XJtD/cjC152sNRC2gSI0oZ3jMmeHXU9 jATZZF2tFT0iGbzGxP/8XHnh/+bQKHgZ6ea/Xu2m39QJrrCxtkRfqiC54AhlcdpoyYnD ml2APnj82UloXIg+zv7NI8QF05ETnWKPFBRWqnTHq+SzA8lN4Wvl8vXrifaE9BttnDVQ /qLQmd9KrNBOp/LNVCRsNU+3q5FRdU0Y9zHeHbBtpNkNWZY0pm5QmlonfRKiYLSHCbAW RFWuu8BcM4bo83QosrR7rCc4v0wkLJd5W55BEygn0eed78mPrEyPuT/w6aQ1RYq2u7Cb 63Qw== X-Gm-Message-State: AOAM532oDoP2d7w9hmA5UvfphdU0EwJsbFaZzc1Dlcbc1bf4PqKvmUxk zVwS8kuzhfHBZTPnCzenN4bSBADHH70= X-Received: by 2002:a63:4911:: with SMTP id w17mr498675pga.13.1589393405167; Wed, 13 May 2020 11:10:05 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id i185sm197361pfg.14.2020.05.13.11.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 7/9] Compute reginfo_size based on the reginfo Date: Wed, 13 May 2020 11:09:51 -0700 Message-Id: <20200513180953.20376-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will allow dumping of SVE frames without having to know the SVE vector length beforehand. Signed-off-by: Richard Henderson --- risu.h | 2 +- reginfo.c | 7 ++++--- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_arm.c | 2 +- risu_reginfo_i386.c | 2 +- risu_reginfo_m68k.c | 2 +- risu_reginfo_ppc64.c | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index 3fc198f..0ae7fa9 100644 --- a/risu.h +++ b/risu.h @@ -139,6 +139,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f); int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); /* return size of reginfo */ -const int reginfo_size(void); +int reginfo_size(struct reginfo *ri); #endif /* RISU_H */ diff --git a/reginfo.c b/reginfo.c index a4f7da6..1727867 100644 --- a/reginfo.c +++ b/reginfo.c @@ -40,7 +40,7 @@ int send_register_info(write_fn write_fn, void *uc) case OP_TESTEND: case OP_COMPARE: default: - header.size = reginfo_size(); + header.size = reginfo_size(&ri); extra = &ri; break; @@ -121,8 +121,9 @@ int 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 (header.size != reginfo_size() || - read_fn(&apprentice_ri, header.size)) { + if (header.size > sizeof(struct reginfo) || + read_fn(&apprentice_ri, header.size) || + header.size != reginfo_size(&apprentice_ri)) { packet_mismatch = 1; resp = 2; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 028c690..7044648 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg) #endif } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { int size = offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC @@ -194,7 +194,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) { - return memcmp(r1, r2, reginfo_size()) == 0; + return memcmp(r1, r2, reginfo_size(r1)) == 0; } #ifdef SVE_MAGIC diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 3662f12..3832e27 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,7 +36,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 60fc239..902d33e 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,7 +74,7 @@ void process_arch_opt(int opt, const char *arg) } } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 32b28c8..361f172 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,7 +23,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 071c951..c86313c 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,7 +32,7 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); } From patchwork Wed May 13 18:09:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186692 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp689471ilb; Wed, 13 May 2020 11:18:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrQD4Ixre/9JZuSTclQ1ZskZP6ONROZEOUe0ORwmIfsFkFXBXeZTvjZ+TwLQdAXw0yCKmu X-Received: by 2002:ac8:555a:: with SMTP id o26mr429456qtr.190.1589393887714; Wed, 13 May 2020 11:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393887; cv=none; d=google.com; s=arc-20160816; b=BhELgYba/q9782jmj0Bao8/DP4DVssI3pJli4xY4Z/hOaywZBKqdGf7pKTGeEAHhTI MPFmNhVfGmSHGV1vrfaa9oRq9fdBrOAJhpK2I8/DgRb6VwCobecda7iq7hEu4VvkOeoZ LV/quxQHzaR59Wf7kEHCuTcH1s37G8SS8lnqRZHzADEgpgPE5KzDOORyJkDZTjaYuhXA V/n/oHKbTAkosYprt0FsALjyo5NWl7Yww2yXYm6Qxxc/zqjNm3sa4OzB0xphiUrBHpCr PN102Q8DQP8gph1HKSZ8rO8ILopF/8lFJeZcFg7+TKsvxI1bGn40D1RzrEPQ1qUWX1ry iwpA== 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=o0pcpm++ae0Vw3phpOxPtn3n/rDNTPNY1WDH3aco64eqW1P4TOyo4JDSnQrVnQk0h5 aS1nwBnqcRVCLKMBMWy7WrxI2M8d4Hz+YJwX8ld/g7vGKEiVxnRaNxB4Po0k6sCZlzsS 0KwQKgko9oQ/RgPA8LSaLOPsTd9JC0LDI2CqOs5Dlq/I8DRV+E5whFSrw+SzRhveeJnD DJANo2AI3QKCnKm18GgTeCsqxSpVN4UM8aH1z+GFR2V/H1100l5UGHJnbh3aPvaYH7vn ka17reRaWn0NdvM/sN1HZ1NNEP/ryDeickwBXLYry9YYRJRvJqEYEaFgRoCXzrLEVQJJ Ehfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PB7H4u21; 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 73si126386qkf.360.2020.05.13.11.18.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:18:07 -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=PB7H4u21; 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]:49400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvxH-0007QF-5p for patch@linaro.org; Wed, 13 May 2020 14:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpb-0003tO-1n for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:11 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:36626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpY-0000N3-7U for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:10 -0400 Received: by mail-pf1-x429.google.com with SMTP id z1so104434pfn.3 for ; Wed, 13 May 2020 11:10: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=PB7H4u210KUQ9tNmfJ2Pxvt+sxIe8i80ily4c7jkb+26Mt9DpTGIXOnKDZtixo6dzI abqEfS2BuXL/Owwgd+u+vqyp/nfp9DcMXAnYBK+ZqBBf2IFw8vrutJCySHRiHZ7zHEcF mL9Ywju1nDwLTW1oAPp7/sEaM/kSrzRJgereHnjPH2w1K24y4Ld8otpcUP/SkhShzWUC VIIK4XdRq7NrS6CBQcezh4eFQ0JlcQjAAbcQfKbVY5Oxjt5ZBp1/tr19Cs6k8qkt+QTC OhsC9QXrcjkN+l554N8Tk4IvwU4j2pO4Hv6cVdTdKQ7IluVk1OOWdo5f3N020pmEUGSN XuEg== 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=FIUJFCmoqCvECa2C/LtXgbmKSFe/gNr6o9WHL+YqbU/cbrLsDQGwfCXeQDH30q9Qil 6dAMwSQXk/YP9KA4LE9+v85i0h2bGfP3zcniM+/WQhZcBS/5cUzMFjmt1PsRmx5Yci0q jwbsy0ZI+Sfsc99r8AOOgJYhhhUP9do7VkHlLWUMszqeqD1I+ZPnu5y9IjZr0Atl9tjy tdpfli4ZJs2i0Vr3i5mEs7HsQWayGDGUPHPX3fztGHh2QWfF99HSEWDIydv8c2yjAmEQ t+Ynkc4O4Q/YmQUcD9s+1Iyu0LAxMPR5fggUzDHBecVcRZiZRKX4lDm2H0MuSEWo4wnv 5G7g== X-Gm-Message-State: AOAM532t9NL/rVkJ18nV2VeGAGLrWExL8NtuqCva+RDXGY4XmC9TM14P GjNkUcaVP2in9+mRq4FkmsF00qNMCQ8= X-Received: by 2002:aa7:8091:: with SMTP id v17mr497009pff.93.1589393406381; Wed, 13 May 2020 11:10: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 i185sm197361pfg.14.2020.05.13.11.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 8/9] aarch64: Reorg sve reginfo to save space Date: Wed, 13 May 2020 11:09:52 -0700 Message-Id: <20200513180953.20376-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mirror the signal frame by storing all of the registers as a lump. Use the signal macros to pull out the values. Signed-off-by: Richard Henderson --- risu_reginfo_aarch64.h | 16 +---- risu_reginfo_aarch64.c | 135 +++++++++++++++++++++-------------------- 2 files changed, 73 insertions(+), 78 deletions(-) -- 2.20.1 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 Wed May 13 18:09:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186693 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp690557ilb; Wed, 13 May 2020 11:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySTavVnJcmh0VdazMzoOBSpXckzBw87a7KdmrsABAClNWmW6k+BgwvpYyNmFNZboW+PIrK X-Received: by 2002:a37:7244:: with SMTP id n65mr944238qkc.483.1589393977977; Wed, 13 May 2020 11:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393977; cv=none; d=google.com; s=arc-20160816; b=v/4XLJ8D3saQIkPgEztkPzZZyentuXkZ/rjwMW7mVGe7Qw5LuGaqVp2gDY8K47m9YF GlFtoT9UiVzF93NpFyHSC9phakMUIEqUi8nsDArAuPnNea3bu6Xo6EcuvUe/It6E1hgX EEn8Oe5BpPfoec7EkgHll05z5LQCU4GxoEkO1RQBIEPEZPHEiT9xarT9nS8dw4JaA9sq x5blmWCkD1Imj+k/2mx+XVAE/yyiifnY0+Vd3NFEvixcE+5SNNH35ROI2F0Lw8Cib/yu hy68iX9u8k4WFKZjAMWOp/40u/UNJQdSLd42HOhWVFYVwGomEqA24RtaUgvviXSZVVgi O3aw== 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=NLyUmEZ5i6oZApVfDSFYVtzokpBFXsLQ3SNKAJFbA44=; b=ZRB91kRB/Mc0dNqB2NGByet8pSZsKHQCKcfKxYCQ2+1QlJg7dwvkp1F88ioiktsyJC iGRZhca2JLP/NG0zrxVfF3ltrcwBeK3qygVEXypnqWqq3WvMakFDC8o2Jdjpa8HnOD1K 3aKKh1WjRNlyOyeJRDJM1s9cgMwRVkUvC4fuGM18Lgi0zuy+PlJdeZ4zUykOW5VgPmdA 49ULa9mLe3nsHpX2RAobEDM4kHS3dCTVadxzqtjMfgxiXvizhbQzdz9jxefiwdCyLeEQ 9m68Tgxn8zp1o9clqv7HeZJSrRMDYEygvsoTPAliyI1wH1FM+cPvw1+jeU/MCdnLpSq+ dv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jVxX5j5L; 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 k54si352643qta.40.2020.05.13.11.19.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:19: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=jVxX5j5L; 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]:56262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvyi-0001yX-Tk for patch@linaro.org; Wed, 13 May 2020 14:19:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpc-0003vV-7P for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:12 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:36629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpZ-0000NC-Pv for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:11 -0400 Received: by mail-pf1-x42c.google.com with SMTP id z1so104466pfn.3 for ; Wed, 13 May 2020 11:10: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=NLyUmEZ5i6oZApVfDSFYVtzokpBFXsLQ3SNKAJFbA44=; b=jVxX5j5LyRLS0DrRPjvuhoE7z2M1L0tjIIJuQ64bdi7yqih7+KWZqf/t37HtF+5H/6 DBJLXN1rbhhtoDyj5CwrPd+SAFfh5kiled4mJmekfee1Iid07BNMluryy7VqIirSH49t jX9E8jL/iAarOnuj/R/wxrU1YU5tcWqvQBa6LE3P7zaxhIBsh2KTDnmCcedbnA5Q4ijX YiCr+uQxRXYrPXVEvueuGms8OdoF+VCkMmRRoG4yXOO/kG18I97mlUk3W1Dv8X3hq8EZ /nIiYff4oLIPX5Q/YJd+xj7dGJ6p6Uyitb9m0opDp5teBnQL1mdBLBcwsEE8y9M+DnER q1Iw== 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=NLyUmEZ5i6oZApVfDSFYVtzokpBFXsLQ3SNKAJFbA44=; b=RmMew+ipvmleTQBM9zQEsqEmVIe0p/X45VDCDwYhddcd1fbIk5IgwJYS5COzy5TCdr VwU7rRWvzJjhv7PoqXmAxRAsCnyH9IRxrzHBd9WQOMBmvP4K4jLWKJOPmWWfm/c11yoN lOwEwUZ2UMWYDiYLnShjK4Bx6L2S1qVepAcNuMG3OPt955ciPDb29dZ81UuCLi8grZ1A /rznhd3iOm981dXiO9DiRJceRz1VcKDPPyUFj26dp12SzUlqQdXePDdGL/ZyqKisQ9Yo L5xMIwigQmw1VuzhuvN7sqor0zwLhQP/VvuTJZ8OhnFSPgi+075Jx1E6MxPeoSJUYLCB tHEA== X-Gm-Message-State: AOAM531OC20bvQS4GAstSvuaiNY75frQUNAwBYfWhCXzLrZcOlh+A6iQ uFdbb6ao8UTm82Zk1jnJtjz7wIs77uQ= X-Received: by 2002:a63:5542:: with SMTP id f2mr489628pgm.384.1589393407686; Wed, 13 May 2020 11:10: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 i185sm197361pfg.14.2020.05.13.11.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:10:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 9/9] Add --dump option to inspect trace files Date: Wed, 13 May 2020 11:09:53 -0700 Message-Id: <20200513180953.20376-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 | 111 ++++++++++++++++++++++++++++++++++++++++- 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, 161 insertions(+), 22 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index 0ae7fa9..515e5c2 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 979341c..6410b2f 100644 --- a/risu.c +++ b/risu.c @@ -261,6 +261,94 @@ int apprentice(void) return EXIT_FAILURE; } +int dump_trace(void) +{ + trace_header_t header; + union { + struct reginfo ri; + unsigned char memblock[MEMBLOCKLEN]; + } u; + const char *op_name; + + while (1) { + if (read_trace(&header, sizeof(header))) { + fprintf(stderr, "Trace header read failed\n"); + return EXIT_FAILURE; + } + + if (header.magic != RISU_MAGIC) { + fprintf(stderr, "Unexpected header magic (%#x)\n", header.magic); + return EXIT_FAILURE; + } + + switch (header.risu_op) { + case OP_COMPARE: + op_name = "COMPARE"; + break; + case OP_TESTEND: + op_name = "TESTEND"; + break; + case OP_SETMEMBLOCK: + op_name = "SETMEMBLOCK"; + break; + case OP_GETMEMBLOCK: + op_name = "GETMEMBLOCK"; + break; + case OP_COMPAREMEM: + op_name = "COMPAREMEM"; + break; + case -1: + op_name = "FAULT"; + break; + default: + op_name = ""; + break; + } + + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + default: + if (header.size > sizeof(u.ri)) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + if (read_trace(&u.ri, header.size)) { + fprintf(stderr, "Reginfo read failed\n"); + return EXIT_FAILURE; + } + if (header.size != reginfo_size(&u.ri)) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + printf("%s: (pc %#lx)\n", op_name, (unsigned long)header.pc); + reginfo_dump(&u.ri, stdout); + putchar('\n'); + if (header.risu_op == OP_TESTEND) { + return EXIT_SUCCESS; + } + break; + + case OP_COMPAREMEM: + if (header.size != MEMBLOCKLEN) { + fprintf(stderr, "Unexpected trace size (%u)\n", header.size); + return EXIT_FAILURE; + } + if (read_trace(&u.memblock, MEMBLOCKLEN)) { + fprintf(stderr, "Memblock read failed\n"); + return EXIT_FAILURE; + } + /* TODO: Dump 8k of data? */ + /* fall through */ + + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + printf("%s\n", op_name); + break; + } + } +} + int ismaster; void usage(void) @@ -273,6 +361,7 @@ void usage(void) fprintf(stderr, "between master and apprentice risu processes.\n\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, " --master Be the master (server)\n"); + fprintf(stderr, " -d, --dump=FILE Dump " TRACE_TYPE " trace file\n"); fprintf(stderr, " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n"); fprintf(stderr, " -h, --host=HOST Specify master host machine (apprentice only)" @@ -293,11 +382,12 @@ static struct option * setup_options(char **short_opts) {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"trace", required_argument, 0, 't'}, + {"dump", required_argument, 0, 'd'}, {0, 0, 0, 0} }; struct option *lopts = &default_longopts[0]; - *short_opts = "h:p:t:"; + *short_opts = "d:h:p:t:"; if (arch_long_opts) { const size_t osize = sizeof(struct option); @@ -328,6 +418,7 @@ int main(int argc, char **argv) char *trace_fn = NULL; struct option *longopts; char *shortopts; + bool dump = false; longopts = setup_options(&shortopts); @@ -342,6 +433,10 @@ int main(int argc, char **argv) case 0: /* flag set by getopt_long, do nothing */ break; + case 'd': + trace_fn = optarg; + dump = true; + break; case 't': trace_fn = optarg; trace = true; @@ -363,7 +458,12 @@ int main(int argc, char **argv) } } - if (trace) { + if (dump && ismaster) { + usage(); + exit(1); + } + + if (trace || dump) { if (strcmp(trace_fn, "-") == 0) { comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; } else { @@ -378,6 +478,10 @@ int main(int argc, char **argv) } } + if (dump) { + return dump_trace(); + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -387,6 +491,9 @@ int main(int argc, char **argv) load_image(imgfile); + /* Select requested SVE vector length. */ + arch_init(); + if (ismaster) { if (!trace) { fprintf(stderr, "master port %d\n", port); diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index a1020ac..fb8e11a 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -44,8 +44,6 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { #ifdef SVE_MAGIC - long want, got; - assert(opt == FIRST_ARCH_OPT); test_sve = strtol(arg, 0, 10); @@ -53,22 +51,37 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); exit(EXIT_FAILURE); } - want = sve_vl_from_vq(test_sve); - got = prctl(PR_SVE_SET_VL, want); - if (want != got) { - if (got < 0) { - perror("prctl PR_SVE_SET_VL"); - } else { - fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", - test_sve, (int)sve_vq_from_vl(got)); - } - exit(EXIT_FAILURE); - } #else abort(); #endif } +void arch_init(void) +{ +#ifdef SVE_MAGIC + long want, got1, got2; + + if (test_sve == 0) { + return; + } + + want = sve_vl_from_vq(test_sve); + asm(".arch_extension sve\n\trdvl %0, #1" : "=r"(got1)); + if (want != got1) { + got2 = prctl(PR_SVE_SET_VL, want); + if (want != got2) { + if (got2 < 0) { + perror("prctl PR_SVE_SET_VL"); + got2 = got1; + } + fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", + test_sve, (int)sve_vq_from_vl(got1)); + exit(EXIT_FAILURE); + } + } +#endif +} + int reginfo_size(struct reginfo *ri) { #ifdef SVE_MAGIC @@ -170,6 +183,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ + goto do_simd; } else { fprintf(stderr, "risu_reginfo_aarch64: " "failed to get complete SVE state\n"); @@ -182,6 +196,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } + do_simd: #endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { @@ -260,8 +275,9 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpcr : %08x\n", ri->fpcr); #ifdef SVE_MAGIC - if (test_sve) { - int q, vq = test_sve; + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + int q; fprintf(f, " vl : %d\n", ri->sve_vl); @@ -339,13 +355,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } #ifdef SVE_MAGIC - if (test_sve) { + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); + } + if (m->sve_vl) { int vq = sve_vq_from_vl(m->sve_vl); - if (m->sve_vl != a->sve_vl) { - fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); - } - for (i = 0; i < SVE_NUM_ZREGS; i++) { uint64_t *zm = reginfo_zreg(m, vq, i); uint64_t *za = reginfo_zreg(a, vq, i); diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 3832e27..2982435 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,6 +36,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 902d33e..68f2323 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,6 +74,10 @@ void process_arch_opt(int opt, const char *arg) } } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 361f172..499fdc4 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,6 +23,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo); diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index c86313c..3b04747 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,6 +32,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(struct reginfo);