From patchwork Fri May 22 02:34:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187127 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104898ilb; Thu, 21 May 2020 19:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiMT5tf1HUI1N47BWltSBJXGxlVoE5W41V4sCDhcZV/AiioFHpUgYTyz/bolSggiwxucXJ X-Received: by 2002:a25:3044:: with SMTP id w65mr20604182ybw.207.1590115252575; Thu, 21 May 2020 19:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115252; cv=none; d=google.com; s=arc-20160816; b=yhwmIfHG2qE4/6g1n/ihELikAyOp3mkig3ftWQdK4oDkjeakgSm7CeUB1poUFjo5hy IQppd6JaTyqM+EnqNh1wOlOrc/2LC+n0a1iNSaknfoTKqTNSFR5N+dxBAXdP5v+YYdak 3Drl/g2f4EzbTY9nF7hz1kFnRAekL6pyXtbgtyRTINgFZtKuBsMURRun0JN0san65i54 jpUOsdQgqIQRn6zKj0ttyMDCL38H/evHGbhDZVCbvRIEl6yDXgnl1p0gQipgrC6fKliv XCHwgulAc2sQlkrdQsT+bNowDfMPIbzxfd0QX0fXCkbMntGSOxtfBoiiijRoRven7Ar8 JgNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=eTv8XWbEWzRSTmnzzPXdqnO3RaGyZr04Q6UotRmePOCe5x4nwxYshRknG0JCpazGPd yJbDEG1rUIcKXHQP3M+GDDQ9EQEEdZLuE6yTW6qjs/6D48nNkaPaHMvTzFskPCH85pXm jcs3Gw+QIK5LKy41ige7bEAfI7e48syyQEg+IJDPB0Ul/HPTZu8mpxMl8KA6Yqd5siMD NkWCWIHsWl5N9QnyujJecZVzK12VKabUr+GhI2fV7FhOLHqbsZv4T1NFHqLPd/XLvypQ Rzz1LUSi8Im+rjr6OK+hJFubiaIvCHezv7ay/vvqoY9OorzCaBUGRxgXVfnCQQAGm4ez 3GtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kjg0V1fa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z66si6526527ybc.286.2020.05.21.19.40.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:40:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kjg0V1fa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxcC-0007hp-2K for patch@linaro.org; Thu, 21 May 2020 22:40:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWV-0002VI-0h for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:59 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:37881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWT-000574-RG for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:58 -0400 Received: by mail-pg1-x541.google.com with SMTP id d10so4292409pgn.4 for ; Thu, 21 May 2020 19:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=Kjg0V1faLSnT5254nz637RsvJ73jyNX4cA0CjlrSQFZqAgYF4dv5WVl/Ak+fV7Z9DN PEFMynQjcqS8Pn8jgw9BxRweI0b8szlERetMze1/WxlPXc90Jvym79uO0h6gi8WU7PuR tkVRZCHxFPTPoIZOLwX5YTPsqLA9EyXT00LohDOZf63dPZTj3F6wYe/VgGZGtrWV9Qxr fjOOcQA8VjZ+xxxg54blahtEuopQYVe4iSv2Eb48FCsbax98kmNj4GM1zWpBXKyYSPI7 JW0Fr/n47EorY1YM6KcUo9mjWEyYyVRkkafaVuMLE14ObXMkG4+Wcjtx0/1BLEk8ozQz v36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mjhuvlUCpOP50NjRcK3iFgBHX3wIurn+3a+Fa5MAOOk=; b=kE21hhyNZZYzbM4gZJ+rk687Zz2np6huNvcmEs5ukcKkuqHwMRDBXtF7EPtxzxMZr2 it+kbWFm875htyiGKlheZd+uYNhe8CwN2mwIMTUO+RK4/lKHeOj897ShwYjPEdPfeEnz P0QVBnNPwya9IAjn0foYSLp+YXvtcR3+nb4l/vAuNVaoi/7i89BzYXhi28CROB7W+ikh zjZdE8WvIM6GvTHLesBjrgqCbCBoYX0qztlXz9oczjJfHzGFR+ck1nL79IFn+nHG06ut u1I1NKpwGc8YLmGBMExy+1b6jyBumqcaDwZLRaLkQsVJimcGJr8M/l1LEh0lxtYQHToC PnhA== X-Gm-Message-State: AOAM531MyszpnhTobbmfe2c/em7Jx8nlCTPeMX1BbQxmFp3S5ubqImCI 4nDtye1ic6rfjUA/Osduun4Bag7Ry+A= X-Received: by 2002:a63:3814:: with SMTP id f20mr11520301pga.266.1590114896004; Thu, 21 May 2020 19:34:56 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/25] Always write for --master Date: Thu, 21 May 2020 19:34:26 -0700 Message-Id: <20200522023440.26261-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For trace, master of course must write to the file we create. For sockets, we can report mismatches from either end. At present, we are reporting mismatches from master. Reverse that so that we report mismatches from the apprentice, just as we do for trace. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.h | 2 +- reginfo.c | 38 ++++++++-------------- risu.c | 96 ++++++++++++++++++++++++++----------------------------- 3 files changed, 61 insertions(+), 75 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index c83b803..f383b64 100644 --- a/risu.h +++ b/risu.h @@ -106,7 +106,7 @@ RisuResult recv_and_compare_register_info(void *uc); * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(bool trace); +int report_match_status(void); /* Interface provided by CPU-specific code: */ diff --git a/reginfo.c b/reginfo.c index fee025e..c37c5df 100644 --- a/reginfo.c +++ b/reginfo.c @@ -14,9 +14,8 @@ #include #include "risu.h" -struct reginfo master_ri, apprentice_ri; - -uint8_t apprentice_memblock[MEMBLOCKLEN]; +static struct reginfo master_ri, apprentice_ri; +static uint8_t master_memblock[MEMBLOCKLEN]; static int mem_used; static int packet_mismatch; @@ -82,8 +81,8 @@ RisuResult recv_and_compare_register_info(void *uc) trace_header_t header; RisuOp op; - reginfo_init(&master_ri, uc); - op = get_risuop(&master_ri); + reginfo_init(&apprentice_ri, uc); + op = get_risuop(&apprentice_ri); res = read_buffer(&header, sizeof(header)); if (res != RES_OK) { @@ -107,7 +106,7 @@ RisuResult recv_and_compare_register_info(void *uc) /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - res = read_buffer(&apprentice_ri, reginfo_size()); + res = read_buffer(&master_ri, reginfo_size()); if (res != RES_OK) { packet_mismatch = 1; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -119,18 +118,18 @@ RisuResult recv_and_compare_register_info(void *uc) respond(res); break; case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&apprentice_ri); break; case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + + set_ucontext_paramreg(uc, get_reginfo_paramreg(&apprentice_ri) + (uintptr_t)memblock); break; case OP_COMPAREMEM: mem_used = 1; - res = read_buffer(apprentice_memblock, MEMBLOCKLEN); + res = read_buffer(master_memblock, MEMBLOCKLEN); if (res != RES_OK) { packet_mismatch = 1; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { + } else if (memcmp(memblock, master_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ res = RES_MISMATCH; } @@ -149,18 +148,13 @@ RisuResult recv_and_compare_register_info(void *uc) * Should return 0 if it was a good match (ie end of test) * and 1 for a mismatch. */ -int report_match_status(bool trace) +int report_match_status(void) { int resp = 0; fprintf(stderr, "match status...\n"); if (packet_mismatch) { fprintf(stderr, "packet mismatch (probably disagreement " "about UNDEF on load/store)\n"); - /* We don't have valid reginfo from the apprentice side - * so stop now rather than printing anything about it. - */ - fprintf(stderr, "%s reginfo:\n", trace ? "this" : "master"); - reginfo_dump(&master_ri, stderr); return 1; } if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { @@ -168,7 +162,7 @@ int report_match_status(bool trace) resp = 1; } if (mem_used - && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) { + && memcmp(memblock, &master_memblock, MEMBLOCKLEN) != 0) { fprintf(stderr, "mismatch on memory!\n"); resp = 1; } @@ -177,15 +171,11 @@ int report_match_status(bool trace) return 0; } - fprintf(stderr, "%s reginfo:\n", trace ? "this" : "master"); + fprintf(stderr, "master reginfo:\n"); reginfo_dump(&master_ri, stderr); - fprintf(stderr, "%s reginfo:\n", trace ? "trace" : "apprentice"); + fprintf(stderr, "apprentice reginfo:\n"); reginfo_dump(&apprentice_ri, stderr); - if (trace) { - reginfo_dump_mismatch(&apprentice_ri, &master_ri, stderr); - } else { - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); - } + reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); return resp; } diff --git a/risu.c b/risu.c index f238117..199f697 100644 --- a/risu.c +++ b/risu.c @@ -102,11 +102,7 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) RisuResult r; signal_count++; - if (trace) { - r = send_register_info(uc); - } else { - r = recv_and_compare_register_info(uc); - } + r = send_register_info(uc); if (r == RES_OK) { advance_pc(uc); } else { @@ -119,11 +115,7 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) RisuResult r; signal_count++; - if (trace) { - r = recv_and_compare_register_info(uc); - } else { - r = send_register_info(uc); - } + r = recv_and_compare_register_info(uc); if (r == RES_OK) { advance_pc(uc); } else { @@ -186,61 +178,65 @@ static int master(void) { RisuResult res = sigsetjmp(jmpbuf, 1); - if (res != RES_OK) { + switch (res) { + case RES_OK: + set_sigill_handler(&master_sigill); + fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", + image_start_address); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + return EXIT_FAILURE; + + case RES_END: #ifdef HAVE_ZLIB if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); } #endif close(comm_fd); - if (trace) { - fprintf(stderr, "trace complete after %zd checkpoints\n", - signal_count); - return EXIT_SUCCESS; - } else { - return report_match_status(false); - } + return EXIT_SUCCESS; + + case RES_BAD_IO: + fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); + return EXIT_FAILURE; + + default: + fprintf(stderr, "unexpected result %d\n", res); + return EXIT_FAILURE; } - set_sigill_handler(&master_sigill); - fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", - image_start_address); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - return EXIT_FAILURE; } static int apprentice(void) { RisuResult res = sigsetjmp(jmpbuf, 1); - if (res != RES_OK) { -#ifdef HAVE_ZLIB - if (trace && comm_fd != STDIN_FILENO) { - gzclose(gz_trace_file); - } -#endif - close(comm_fd); + switch (res) { + case RES_OK: + set_sigill_handler(&apprentice_sigill); + fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", + image_start_address); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + return EXIT_FAILURE; - switch (res) { - case RES_END: - return EXIT_SUCCESS; - default: - if (!trace) { - return EXIT_FAILURE; - } - fprintf(stderr, "finished early after %zd checkpoints\n", - signal_count); - return report_match_status(true); - } + case RES_END: + return EXIT_SUCCESS; + + case RES_MISMATCH: + fprintf(stderr, "mismatch after %zd checkpoints\n", signal_count); + report_match_status(); + return EXIT_FAILURE; + + case RES_BAD_IO: + fprintf(stderr, "i/o error after %zd checkpoints\n", signal_count); + return EXIT_FAILURE; + + default: + fprintf(stderr, "unexpected result %d\n", res); + return EXIT_FAILURE; } - set_sigill_handler(&apprentice_sigill); - fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", - image_start_address); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - return EXIT_FAILURE; } static int ismaster;