From patchwork Fri Jul 8 15:46:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588575 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp819484mab; Fri, 8 Jul 2022 09:35:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slF0peFYbEgTLE7aCz2GnZqC9eBZIwWhGAdW8vTCYIqRb9qijGf7U0XLCZy0lU4450K5Hg X-Received: by 2002:a05:620a:2556:b0:6a7:9f07:602 with SMTP id s22-20020a05620a255600b006a79f070602mr2915733qko.207.1657298144679; Fri, 08 Jul 2022 09:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657298144; cv=none; d=google.com; s=arc-20160816; b=G3QBGyoxCz2ygAsdoRw+oE5p+bphoohz9RMSPfz226gmraXb8Si99vwrvGwUaS1zPJ bteRBQ2QqlCENbIkcTK2cKNnX5DBeA5zHZLNCRG/ZMi3kEPnmCr/f+WJCjm6FfW20ygO wbSACxAucipYXq8Myv3rhz8O3Vj4MzEstyt3qUqEDwP+KnifNyZGWvuF3NdxstVxmb1b +2uyzBhC8dePz5GgQTIglnFAjQl4cIuYPZAxcSL8oATOI87mEQjCL3IdSd7LXP1AoAE7 B2lmkcECck4p3CDMDl5ms6fSjmJsfbgKL3Uv6z1pugr51kI4yK5YZoH9CIGPsqnoJUPc 9rfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=v19iYVQqyPYqii6GOgeAb6KeSVjO7ZLU6D0RHily+Q/bLDs31nAfQAX7holQCPmMOF BKNapjW8lG6yWcpd6zwA05dJD8dDwTJ+KfkLOr36XfCtaDNYZCppasLygLkt7ej4wuaV 86A24G9fMR6VgUe1y08QJcuizH2IMiMZpDNTB9WRFmoadtOJpBSDeOp2tZX/zqcTGeLl 1CH1zI4mA/y+rtlPjZGwUFoEr8u5QnF7MYhKO1Gqh1LyESOlKvkATRbbUBCsiEVjGsNf W3xWfmG3wT27H3O+xy8OovOU4hB1yAfZJW8uHIeHKATlOrtbnnG8CMlbWsi3IO/rDFh3 d+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDdTgLPq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bl11-20020a05622a244b00b0031cc5db5aeasi9910729qtb.713.2022.07.08.09.35.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDdTgLPq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qxE-0006Dl-9t for patch@linaro.org; Fri, 08 Jul 2022 12:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qD1-0005qn-Bs for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:59 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:37643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCz-0002Ux-PM for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:59 -0400 Received: by mail-pl1-x630.google.com with SMTP id f11so4115351plr.4 for ; Fri, 08 Jul 2022 08:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=bDdTgLPqjoJsQLTGlQpoH2VllST0upphtnER5sE74xLt8M0k8GiIbBk6DoQReqsOxh D8fWlxZRYBzi+YAW66mq1XnNRURgbE9uts8JuApSsVlPb6B5Qb9YaSJljEfjC5kuHQ/n MD4F8OL9qOKbBAxPq/X0P5yJFQeCcN6JngRk1VIFMXQJNWc/SIkQhjq5jlXZView9o0H 3jGofyxe3IcHDuKf+seMGFMB1VLIAdKkVB8DcfXexBPwqZb0YX7DpxIEJa2hH35vGWiI +LKx+WjWPf7LLRIFneW9E/3h/5rFW2S9i1saERHLoKAaIAeI24eQsUIIMxOS5ZrUenCl nxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n2pj04eKwIIwfWxKRy+OpUcFUnQWI9QGoADis3HM7QI=; b=KUcFRKlH9QyCitfGdJq9Mk6bZvP1PzLur3aAzgV2TNfv/CemeBdBQVTSrJrPrPR9UQ o9nGFjTCdYQ4P48IV03JHYERAT04T1tC0nEEwYiXL3PlTFNWyEZG1kCQqI0EnaTL8eA5 Hdgi2jHweeiveGEFEOYfOv9cdp4aZG1Vr9ytGvqS9tl9ROJhV3jaFFz7pl3FPkJ+3kvh vD5ZmAuX/x12nkGC40kInceh1e6ZzJNGb67od4JC/6oDW8ah3pFtc29uNrCzd8m0b5Dz 58ld97pQxgc8XisYsQA47oqCzjKCVHgvawGyhXP4WehWVUx5OeNyKWXcTZutze7iWz4q ZYGg== X-Gm-Message-State: AJIora8LPFj/C7y2og71wDnZGzl0xlX3JUSBXAV2XQ3Tgspd7UMrx2wf hxEg2H17dKOT0hGjfP+x1C7q3iLB8QJvhflM X-Received: by 2002:a17:90a:e391:b0:1ef:83c2:2527 with SMTP id b17-20020a17090ae39100b001ef83c22527mr541978pjz.94.1657295276984; Fri, 08 Jul 2022 08:47:56 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [RISU PATCH v4 16/29] Split out recv_register_info Date: Fri, 8 Jul 2022 21:16:47 +0530 Message-Id: <20220708154700.18682-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code when dumping. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- risu.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/risu.c b/risu.c index b91ad38..80bc3b1 100644 --- a/risu.c +++ b/risu.c @@ -166,6 +166,34 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } } +static RisuResult recv_register_info(struct reginfo *ri) +{ + RisuResult res; + + res = read_buffer(&header, sizeof(header)); + if (res != RES_OK) { + return res; + } + + /* send OK for the header */ + respond(RES_OK); + + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + case OP_SIGILL: + return read_buffer(ri, reginfo_size()); + case OP_COMPAREMEM: + return read_buffer(other_memblock, MEMBLOCKLEN); + case OP_SETMEMBLOCK: + case OP_GETMEMBLOCK: + return RES_OK; + default: + /* TODO: Create a better error message. */ + return RES_BAD_IO; + } +} + static RisuResult recv_and_compare_register_info(void *uc) { uint64_t paramreg; @@ -173,33 +201,26 @@ static RisuResult recv_and_compare_register_info(void *uc) RisuOp op; reginfo_init(&ri[APPRENTICE], uc); - op = get_risuop(&ri[APPRENTICE]); - res = read_buffer(&header, sizeof(header)); + res = recv_register_info(&ri[MASTER]); if (res != RES_OK) { + /* I/O error. Tell master to exit. */ + respond(RES_END); return res; } + op = get_risuop(&ri[APPRENTICE]); if (header.risu_op != op) { /* We are out of sync. Tell master to exit. */ respond(RES_END); return RES_BAD_IO; } - /* send OK for the header */ - respond(RES_OK); - switch (op) { case OP_COMPARE: case OP_TESTEND: case OP_SIGILL: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - res = read_buffer(&ri[MASTER], reginfo_size()); - if (res != RES_OK) { - /* fail */ - } else if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { + if (!reginfo_is_eq(&ri[MASTER], &ri[APPRENTICE])) { /* register mismatch */ res = RES_MISMATCH_REG; } else if (op == OP_TESTEND) { @@ -216,10 +237,7 @@ static RisuResult recv_and_compare_register_info(void *uc) set_ucontext_paramreg(uc, paramreg + (uintptr_t)memblock); break; case OP_COMPAREMEM: - res = read_buffer(other_memblock, MEMBLOCKLEN); - if (res != RES_OK) { - /* fail */ - } else if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { + if (memcmp(memblock, other_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH_MEM; }