From patchwork Tue Jun 28 11:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585569 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp664403mab; Tue, 28 Jun 2022 04:21:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjPAJfWqwe2M95tcHlauiFVxE33F22zC6LP7ruI3oUwa6T31ecLFTJ1QMzK4i5oZC6PvKN X-Received: by 2002:a05:620a:190a:b0:69c:3ee7:7c8d with SMTP id bj10-20020a05620a190a00b0069c3ee77c8dmr11028884qkb.743.1656415280445; Tue, 28 Jun 2022 04:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415280; cv=none; d=google.com; s=arc-20160816; b=Kp58JUvZuBRkW2e63Mw8rHPS43UzcvoCW2dWHHnonkQ/OL8ev7XRky4OwP8mEmakuc 3/s/Rb1XM5gWlsanYKQKz1SjbwBFq1bi4VO0xnALb09Bs/55ZFZl5SDNPJ8EQQI0k9wt ng7Xv4+62Vn862qhfzPg9QgdpfuTbj3kFkBilVP23zKd1MRuWQprN/QaOKAIF8E4yxhH uMKY9g8YCzWWp49Wwq+WECvD2cJTPdFmjZF/o2RYBoJ9BK4M6ZpEEPpOXdLabsDIGGk5 /TtoT5LFFjKqtxfq1VMoDeHkBy+nfEnKUC+6+mHK52vA/6/p0w6pjTp2wlnzXD4ZbKeH A4wg== 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=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=LFzaJNJXTIIe5c8uD3JaCb4KWvKWxqk5jcFyIIF3XfMwYfgB3IUC62Yt6y/m9f7GkT IYaw4teKuRSTRbD3UjFcl3lSl7Ie2OM4m1rxu9RTV/hhHkVITH7gCu4iRZ5nFtSDncQw 51rBqb6JZBqpcJtWJaohZZKI/d7B31UEV8+nCRaxXF2572cAq1MAQ5DJUqPB0AavbQCm x2Z215xyAQOeuDTNLG8kL5eyDzzmXQwAymTB5QJ/J9lDnnmEqstEY6TlZnzl326FAj/s p9A7KIDjwJxJ+wSTSv7jCcGGddq6FW6PIfcyFjAGVL6PkSQ1tLnuTloOpfXjLgWEH0J5 DQtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cU0PyAXU; 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 e5-20020ac80105000000b003175be6b95csi5964133qtg.315.2022.06.28.04.21.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:21:20 -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=cU0PyAXU; 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]:41420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69HU-0007e5-0v for patch@linaro.org; Tue, 28 Jun 2022 07:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dj-0003y5-Ah for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:27 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:37403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Dh-0003Bm-NB for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:27 -0400 Received: by mail-pj1-x102e.google.com with SMTP id w19-20020a17090a8a1300b001ec79064d8dso15537511pjn.2 for ; Tue, 28 Jun 2022 04:17:25 -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=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=cU0PyAXUIoTGSUk7MjTJZ4mp1Q4jyymWRtcVPJXvfmLXnSHpX4oId/WQUjM7C3sRUD W3OglN1oNE7/0EPIm+JRVOialsvm3myc3l9zD/bLT0X/NFW3uyN9tSCYpMNptZ/Jd+aP OV3HrzGjYSjbhxWbtqQpK9gTDLiNIp3OS2n9oUmlYEhVzCXdroTpzjCWvWIniwDUba4E 89So3XA1R6cYMkYKcWPYtEl6QuIWM/vWYNyA72qDYviHdgy/uQ+CSU7RivMD0f0nOWOE bjqDN/taODhyruZUMeZkbcvufeoKnJmajcyK6GKnvvcFGdP9lPeFuMN9cWrHTzQ0sGJV Tqew== 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=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=OdJ6Ixs/Y3iPQzgrkGUVg1s6S5sBTbRe8uNrJy2nOSW1wUfg5/5dAbEk2cmghnLzWj eQeULa2qPcu6Xs7w6Do4/30lc2bq+0IddvXlzA4LhyjGEmdFqNpTdr82Uu7HL4ldekTt IY/8GLFyWwp3siCx64ItWWvimMtueZLtt0/Ywat3kleC34TZbtjts8b5RTT1BE479R7v MKHsS0IQiygPEx0df0O7KUy/OcWrCzujVBph5puTe/Prwx0FUgYAE90A4pSVhKECV25q BvPnToK7p01+1xDsE5jmfAlzOyidKXOSc6BO/ADAi/vUPge3JVkSQfJH7ra4uUY2qi/m hf6A== X-Gm-Message-State: AJIora9PpdwJaUqS290X+p2stl6ng4IuR1WCg5CDJmNEfrWVbX48lnvk UbzIYA7Tz5vU+LlogMmammQtDi0j7t6MZQ== X-Received: by 2002:a17:902:f34a:b0:16a:e2d:3e9 with SMTP id q10-20020a170902f34a00b0016a0e2d03e9mr3251665ple.95.1656415044423; Tue, 28 Jun 2022 04:17:24 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 5/8] target/mips: Use error_report for UHI_assert Date: Tue, 28 Jun 2022 16:46:58 +0530 Message-Id: <20220628111701.677216-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" Always log the assert locally. Do not report_fault, but instead include the fact of the fault in the assertion. Don't bother freeing allocated strings before the abort(). Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 39 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index ad11a46820..ae4b8849b1 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -221,18 +221,6 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, } \ } while (0) -#define GET_TARGET_STRINGS_2(p, addr, p2, addr2) \ - do { \ - p = lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - p2 = lock_user_string(addr2); \ - if (!p2) { \ - report_fault(env); \ - } \ - } while (0) - #define FREE_TARGET_STRING(p, gpr) \ do { \ unlock_user(p, gpr, 0); \ @@ -243,7 +231,7 @@ void mips_semihosting(CPUMIPSState *env) CPUState *cs = env_cpu(env); target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; - char *p, *p2; + char *p; switch (op) { case UHI_exit: @@ -355,14 +343,23 @@ void mips_semihosting(CPUMIPSState *env) break; case UHI_assert: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - printf("assertion '"); - printf("\"%s\"", p); - printf("': file \"%s\", line %d\n", p2, (int)gpr[6]); - FREE_TARGET_STRING(p2, gpr[5]); - FREE_TARGET_STRING(p, gpr[4]); - abort(); - break; + { + const char *msg, *file; + + msg = lock_user_string(gpr[4]); + if (!msg) { + msg = ""; + } + file = lock_user_string(gpr[5]); + if (!file) { + file = ""; + } + + error_report("UHI assertion \"%s\": file \"%s\", line %d", + msg, file, (int)gpr[6]); + abort(); + } + default: error_report("Unknown UHI operation %d", op); abort();