From patchwork Fri Jul 8 15:46:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588558 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp791820mab; Fri, 8 Jul 2022 09:03:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1shvgNFk2GJoGvJuTiaNsFKtFcUPRKeZmtKO5yXlrfhPpbit1ekCQCgsjkWQcWqrWFUrjMV X-Received: by 2002:a05:620a:2234:b0:6af:692:1fbf with SMTP id n20-20020a05620a223400b006af06921fbfmr2805643qkh.579.1657296239604; Fri, 08 Jul 2022 09:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657296239; cv=none; d=google.com; s=arc-20160816; b=xivMC3nKLtnYcl9hm0Q/yi8jzZpUTUX810aQV9vNJ4A2YpN7S8dcudyWozR+gIZYEo B49gdLip13tgzD5oMgZ7Un36L7uw0n7UFYxlE87YUjEksJVIeAAVordH+GgmbUF5n++d 9Q2MFJJtLufhAMC9rULBkgJ3gT1Rw3/a20sZEyGAsQWy4VRiRB25K7VAEbIVNZZxqgax R9SLhku/rmzcU6O6WzEVfL0zD8A2UH5d1QOtWVvTk1nmir3en9dKnlTpcrf59tf5NJYQ hwXrGSYHGmdCE/CUJKptYCVVLgd/ZFJAHssXWGqOOGNnvhY/ssPK8RziE1Byp07yClfW wytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=giE62K4N3abY45AouFUPnOIWPyjnV5qJ7GSggV1mLASq7B8CQC3q3kcZnXXoYEBHnW FH8Eq6M9r9qU5BoRdK22EkaAm2I3VbM4zuPdl0D2XMLg7vnyEd0vHhasrkp383xVbs6b zUPPrs6yfSbE0aKZsc5V4UCiJ4yNCwxlhsTGjS4iAqX5A5X9iA64jy17UThSaUmKokQY TzidE/kV3zwDzLg+PTBfKwUilZ6wpGGkHoJYhrVpHFAXheBrIOMwZb14o0CmeGGekoNv zNTOy353hggGW/P5E2pQRLs8xCeBm3Aj+3cYPqaz61M/SbxaxKN7GVylS1uXZK9s+VZz stqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DuagrhYq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bv15-20020a05622a0a0f00b0031d344f0955si14160209qtb.501.2022.07.08.09.03.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:03:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DuagrhYq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qSV-00077p-67 for patch@linaro.org; Fri, 08 Jul 2022 12:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD0-0005lf-1j for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:58 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:45670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCx-0002VZ-PX for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:57 -0400 Received: by mail-pg1-x534.google.com with SMTP id 145so22655318pga.12 for ; Fri, 08 Jul 2022 08:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=DuagrhYqV+ZRFMS7oGkdtwG2d+FTcHaYcxd38DHWg8s9b+f4kXIuZMHpoNhHQmntWY Z9l6I0THVH8+tfVSDX4QFZrLX4VD/DFnjIaj3/pwv8KlSO3gBISaXliUFm6B85hZ/cTc SpFbmwKU84mUDCeftWbADk8xhM7Sm1w59gpv5+pf+X3+sbDQaxGVXcQ2iijv2hxqM5FU JCTTjPMElmgc9A3xq8UiQANfcvfQUhUSZsUhUT8BTiInzDahu9UmImTH8K747X6AYyiY XLPPvoJrreIfZuTrm8X1R4Ugo4DSfkyQhoA21kxsqGqIbQxnGKXpAGrbyT1KcSEWnlJx xzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C50plgqGSIgO0dFS/L15QZFrfiVcGLB4PZLBa9Ht7hU=; b=s/MhwsYjzv3Ek9ADy1BXmOd9cdT1QhiroofU5WmoJdZAPgSL9YkB9aYUkEpZsoIg7+ R/HKlMjq5pUC7r9bMXfgiIWjXDRwK+1YOobX8ezLhFkFUHu7SDEoWIjTHeAmMEsXm6qp CefGDp2IsghrW0T4NU5JrsmH5V3m32H3+zUJg27WBeIKqzhUzBA57lEJXaZHnzRzY7d+ goPgQrXVr0DYVTVIIzWAipA1qGo138FwNZMGHIlFdHk1nDryb/erXtr9ykchVynof21r wssX9RlhuVel0z5rWyLuf2sAzCgj5ztL+6W0CYvaVqVD6KRLp3jIYez/4qQuRSSMbW8x zJgg== X-Gm-Message-State: AJIora+e5J74WCQAwC4o6f3Y84eN6oLc/9EkRJ0Mg+kkKBHn+QQvXpS6 S6Tqpmhu+tCBPO0+8n+n7z+cuDduhXSkrsNp X-Received: by 2002:a65:694a:0:b0:412:b98:4604 with SMTP id w10-20020a65694a000000b004120b984604mr4026000pgq.50.1657295274570; Fri, 08 Jul 2022 08:47:54 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 15/29] Rearrange reginfo and memblock buffers Date: Fri, 8 Jul 2022 21:16:46 +0530 Message-Id: <20220708154700.18682-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For send_register_info from master_sigill, do not keep a reginfo buffer on the stack. At the moment, this struct is quite large for aarch64. Put the two reginfo buffers into an array, for the benefit of future dumping. For recv_and_compare_register_info, index this array with constants, so it's a simple rename. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.c | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/risu.c b/risu.c index a0e20d5..b91ad38 100644 --- a/risu.c +++ b/risu.c @@ -28,10 +28,16 @@ #include "config.h" #include "risu.h" -static void *memblock; -static struct reginfo master_ri, apprentice_ri; -static uint8_t master_memblock[MEMBLOCKLEN]; +enum { + MASTER = 0, APPRENTICE = 1 +}; +static struct reginfo ri[2]; +static uint8_t other_memblock[MEMBLOCKLEN]; +static trace_header_t header; + +/* Memblock pointer into the execution image. */ +static void *memblock; static int comm_fd; static bool trace; @@ -102,16 +108,15 @@ static void respond(RisuResult r) static RisuResult send_register_info(void *uc) { - struct reginfo ri; - trace_header_t header; + uint64_t paramreg; RisuResult res; RisuOp op; - reginfo_init(&ri, uc); - op = get_risuop(&ri); + reginfo_init(&ri[MASTER], uc); + op = get_risuop(&ri[MASTER]); /* Write a header with PC/op to keep in sync */ - header.pc = get_pc(&ri); + header.pc = get_pc(&ri[MASTER]); header.risu_op = op; res = write_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -126,18 +131,19 @@ static RisuResult send_register_info(void *uc) * Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - res = write_buffer(&ri, reginfo_size()); + res = write_buffer(&ri[MASTER], reginfo_size()); /* For OP_TEST_END, force exit. */ if (res == RES_OK && op == OP_TESTEND) { res = RES_END; } break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); + paramreg = get_reginfo_paramreg(&ri[MASTER]); + memblock = (void *)(uintptr_t)paramreg; break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, - get_reginfo_paramreg(&ri) + (uintptr_t)memblock); + paramreg = get_reginfo_paramreg(&ri[MASTER]); + set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: return write_buffer(memblock, MEMBLOCKLEN); @@ -162,12 +168,12 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) static RisuResult recv_and_compare_register_info(void *uc) { + uint64_t paramreg; RisuResult res; - trace_header_t header; RisuOp op; - reginfo_init(&apprentice_ri, uc); - op = get_risuop(&apprentice_ri); + reginfo_init(&ri[APPRENTICE], uc); + op = get_risuop(&ri[APPRENTICE]); res = read_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -190,10 +196,10 @@ static RisuResult recv_and_compare_register_info(void *uc) /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - res = read_buffer(&master_ri, reginfo_size()); + res = read_buffer(&ri[MASTER], reginfo_size()); if (res != RES_OK) { /* fail */ - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + } else if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { /* register mismatch */ res = RES_MISMATCH_REG; } else if (op == OP_TESTEND) { @@ -202,17 +208,18 @@ static RisuResult recv_and_compare_register_info(void *uc) respond(res == RES_OK ? RES_OK : RES_END); break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); + paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); + memblock = (void *)(uintptr_t)paramreg; break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + - (uintptr_t)memblock); + paramreg = get_reginfo_paramreg(&ri[APPRENTICE]); + set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: - res = read_buffer(master_memblock, MEMBLOCKLEN); + res = read_buffer(other_memblock, MEMBLOCKLEN); if (res != RES_OK) { /* fail */ - } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { + } else if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH_MEM; } @@ -221,7 +228,6 @@ static RisuResult recv_and_compare_register_info(void *uc) default: abort(); } - return res; } @@ -342,10 +348,10 @@ static int apprentice(void) case RES_MISMATCH_REG: fprintf(stderr, "mismatch reg after %zd checkpoints\n", signal_count); fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); + reginfo_dump(&ri[MASTER], stderr); fprintf(stderr, "apprentice reginfo:\n"); - reginfo_dump(&apprentice_ri, stderr); - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); + reginfo_dump(&ri[APPRENTICE], stderr); + reginfo_dump_mismatch(&ri[MASTER], &ri[APPRENTICE], stderr); return EXIT_FAILURE; case RES_MISMATCH_MEM: