From patchwork Fri May 22 02:34:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187124 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2104331ilb; Thu, 21 May 2020 19:39:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrKtQXmSd+d7g84gTv8TkXptIZxZzwyCaRpoWjtKMa1T/7zl7aCiwYwfhfGid28/u5Lr1X X-Received: by 2002:a25:aa4f:: with SMTP id s73mr20161625ybi.156.1590115176858; Thu, 21 May 2020 19:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115176; cv=none; d=google.com; s=arc-20160816; b=r+kmAxfXhGc8BlqM2y5xNKBYTNRgXX65d9ilYkOLLahc7XoOkkURtqRdFrlhSc5bHN fJvqcTYHBUa1n2ytNoiJXp1lIX0XTYHUKLwjdqjS0gBJoz/rUEQ/g+XCO5VzJLeT73N8 rQk/votqQllpaKHg8nHGslINWt4z1eyCHzpuKS5qP3mQ6Y7oPwaCNiBYzzFCpVk80F3O Ie9lkUSrQiA+nwLAprNiniPz+SlXgcBoiAo+7LdAf7NO77YcaoTHCEri5yRTPLPu5Whd H2tpYKcq4yBItFnBLB6QE45Xd9FW/FRXsbIwln1S8DSf52mnDYk02/s5CC1ChQ10izV+ qLAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=Qqt6c/+iuoKyIH3TB+8Wso5+t4q9OcDR/WG/4hWUxqeirdJUOKQkDaQoEd+P1FcgVY aU00z/i1HN3PqgreYwuBkwnvHWKy9NwqhoGUL24ET+a1eTnCSBVgLIq6vtS0xAoykAe2 4BDdXIuwMJ8hNmFmEgJWV094qxRnTT3okXS/Wz7+SKarkFRFb7huOLqXg/ST8CpK+RwF FAP+o0P75Kk8LS+DXMT7qCsbc766YB5qQ30BLFINKAE5p/Kz1/zOYVOanAH4VaopBoeD 7Begj6kLILj12yyVxd2CHYBxqQupHgcvMMP5DrGNBPaa6kNZU+9znSZT12SXGpTjXn8g or+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WuQZV024; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y123si6898986ybf.94.2020.05.21.19.39.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WuQZV024; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxay-000563-99 for patch@linaro.org; Thu, 21 May 2020 22:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWT-0002RP-EL for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:57 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWS-00056x-GX for qemu-devel@nongnu.org; Thu, 21 May 2020 22:34:57 -0400 Received: by mail-pg1-x543.google.com with SMTP id f21so1284011pgg.12 for ; Thu, 21 May 2020 19:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=WuQZV024ez9Hv4PfFJq+w6udDFdwJhqjrR+DfehK0/yV/87MVeYs8eQRxqZpxnhoGE rtFuyCG4Oo+6yxMOyCxXXUVmq93EfR+QoRxNGu4ArljYAkvJd0SQMap8IaMsqjRrm3AE mrbcWFA52Mu6hLRQCp0Gp7qTVp7QfgphD8X+jePZ+AQ+QZJ+lc3kgb9SoMKK4Uhhnm1h RJFgD3wPysfehwxkP1EZERi3immiYYQFClAFEGga44NElH8/6qkb4Z3kJrOEnomP4QzJ 6f7pGI57m/slKYSvyc5fh8D39+jcVCgsBV2k45pTuAlJgIBXlFd/NT8+k2Q0vmqYlSAp LJNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=08GYkLDINQo3JCs7twtHmTIyHJC0TnW/vsw/vZ50A4I=; b=IeMeWjljLmYjWwein7QaJByHlixJpW+LelwYIfz52OmokqL8Tq5dFv+YIu3jgjW5iw 61wQYx8nXhxFmPfXyJr6BJ/BDo0z+MEpvXUbqyNCv3ZxWUV+RgrS1YmIWcVEWlEzgHzm 3H4yuc9YeTa9Oowx1ieRs2JCwoFi0X/LPwQoIWGEYU1wzJAwWzQUUhX9wYqH4GEf2o2y 9i82RuiPHP8C0Fb7zQi4g8d2tPKd+tymxtJqg3xjKeU8l2Lp+AxWTUEDUSYPUnpUZVi9 2G1ScyXLi+X4ibJ5LSQ3FnyeMDAGTZ1eU+RqdaVHZVzUhRY3noUXjTiTR2C70pLVUoOC RC4A== X-Gm-Message-State: AOAM531mO07SN97HDFIC3OkrujyKyVMcdohpPvQVqDlyrgLPh0SnE+YJ MEbnVJubBYREMOjM4pbZOBKh3HGRaQw= X-Received: by 2002:a62:3383:: with SMTP id z125mr1684956pfz.271.1590114894796; Thu, 21 May 2020 19:34:54 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:34:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/25] Pass non-OK result back through siglongjmp Date: Thu, 21 May 2020 19:34:25 -0700 Message-Id: <20200522023440.26261-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than doing some work in the signal handler and some work outside, move all of the non-resume work outside. This works because we arranged for RES_OK to be 0, which is the normal return from sigsetjmp. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- risu.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) -- 2.20.1 diff --git a/risu.c b/risu.c index 1917311..f238117 100644 --- a/risu.c +++ b/risu.c @@ -107,15 +107,10 @@ static void master_sigill(int sig, siginfo_t *si, void *uc) } else { r = recv_and_compare_register_info(uc); } - - switch (r) { - case RES_OK: - /* match OK */ + if (r == RES_OK) { advance_pc(uc); - return; - default: - /* mismatch, or end of test */ - siglongjmp(jmpbuf, 1); + } else { + siglongjmp(jmpbuf, r); } } @@ -129,21 +124,10 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc) } else { r = send_register_info(uc); } - - switch (r) { - case RES_OK: - /* match OK */ + if (r == RES_OK) { advance_pc(uc); - return; - case RES_END: - /* end of test */ - exit(EXIT_SUCCESS); - default: - /* mismatch */ - if (trace) { - siglongjmp(jmpbuf, 1); - } - exit(EXIT_FAILURE); + } else { + siglongjmp(jmpbuf, r); } } @@ -200,7 +184,9 @@ static void load_image(const char *imgfile) static int master(void) { - if (sigsetjmp(jmpbuf, 1)) { + RisuResult res = sigsetjmp(jmpbuf, 1); + + if (res != RES_OK) { #ifdef HAVE_ZLIB if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); @@ -226,15 +212,27 @@ static int master(void) static int apprentice(void) { - if (sigsetjmp(jmpbuf, 1)) { + RisuResult res = sigsetjmp(jmpbuf, 1); + + if (res != RES_OK) { #ifdef HAVE_ZLIB if (trace && comm_fd != STDIN_FILENO) { gzclose(gz_trace_file); } #endif close(comm_fd); - fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); - return report_match_status(true); + + switch (res) { + case RES_END: + return EXIT_SUCCESS; + default: + if (!trace) { + return EXIT_FAILURE; + } + fprintf(stderr, "finished early after %zd checkpoints\n", + signal_count); + return report_match_status(true); + } } set_sigill_handler(&apprentice_sigill); fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n",