From patchwork Tue May 3 19:48:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 569025 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp9819268map; Tue, 3 May 2022 14:07:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxds/jxlBKrAQjNKdetES5+0vwh+nmCZrimWFbFCfNOEe2NIIAnvMkmSXmnB9/4dhu4+47r X-Received: by 2002:a05:622a:c4:b0:2e1:cb5b:9b5c with SMTP id p4-20020a05622a00c400b002e1cb5b9b5cmr16785704qtw.69.1651612055202; Tue, 03 May 2022 14:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651612055; cv=none; d=google.com; s=arc-20160816; b=KR9vu1Xqwv8MwOgLNwvh3cnuoEWAuxIPwVX6Hxvw+Q6XXtV8q7qz7f3t5ICYRwnp4J aeJWSEWRNyZ+k60nfoB4HZC4VPt7vNYkps0UejYxnMaQXeV58DrzLswo4j1ASpqqEigJ UMqQpyEHgTcCQs1AixROKiAvTpw75KWxI0O2k6fTtzjyPKJ7yl3QnSd1crm6QME4pKDS leZrc7bt+NKc5e+vIJAPBxBqG1nynITyeGqQmlrZ459mKpsKYuIxn2T816iESNbIsA82 XpLdcOgTyvJcOtRR0kIvkXDUFMXCJnck+ZS3Whwwa5JleOZHO52D74MQQXetG7uUq++J c+Vg== 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:to:from :dkim-signature; bh=0KmR0I9MQL8sMij82tj+TGbywtXC8SOF01Vq62VNOXc=; b=DehN7MoUoOT5Leh0Lust7VGug3pN/N4nOAa763JVnk1dTc1BMpqLydx5Q8iwq1E2vr vKJM9x4S3hweEiSUsufpm6lZhQfmLvJwkIJ4V6hvbtoG5/uZsBvMOQhe1UJl0EIVxKby p4kay/uXfrf8oqpjtKSMSokDfMsc1yu32AtYjgTRVjunys3YVn2eDbV8XMv/gIhoKsFM bItHmZyDe1kYX32Luet9Qzst1yEf2T5oYIN9WRolmSZ930TjVUkBmP+61zaHCSP21Ny2 6J0MNALgZ1H6sm47MT/VmjVBx3AMHFsCkVnP7KFmLzjt1SkxyDN3wZq1rPg9s1M+0VVE K0Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bj978LCY; 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 bi36-20020a05620a31a400b0069f8a2bcdc5si6318287qkb.94.2022.05.03.14.07.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 14:07:35 -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=bj978LCY; 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]:57468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlzk6-0004dL-NC for patch@linaro.org; Tue, 03 May 2022 17:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyZm-0000Xo-6M for qemu-devel@nongnu.org; Tue, 03 May 2022 15:52:50 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:41905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlyZk-0006Mt-Ic for qemu-devel@nongnu.org; Tue, 03 May 2022 15:52:49 -0400 Received: by mail-pj1-x1034.google.com with SMTP id z5-20020a17090a468500b001d2bc2743c4so2917140pjf.0 for ; Tue, 03 May 2022 12:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0KmR0I9MQL8sMij82tj+TGbywtXC8SOF01Vq62VNOXc=; b=bj978LCYcEKh12QBdn3r1wS7KagW1xp0uHsYD9BxBUJLXw83ImhdoDrGcndFTpFRaD VLIRHpU5DB9ImBOWN8yjes7VW/fYNDxR/toHvgiPNA79G3U0o9dyilUZTixnY2Ln8KZN p/Z9e/drfrwh8YGIbIuQMk4M7NYZVhfgBcCL0pCgcEpaQW5Zwpbt/MMfCdBfTCw6IJuS sQS02IjtvUeOGyYO5aBvZd8ygljdQWuERD7KPsvzaAgq9zduBheW7W16Edg0IBpAjB49 BIEjEegpmzWwiIA1k+/8E75NI3XMRp7wkw0seJY6KU3Dmh71lMO2QoEx1m3c8hALWL6J 9D7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0KmR0I9MQL8sMij82tj+TGbywtXC8SOF01Vq62VNOXc=; b=lBgWhiKwu0OlpmkV0qVSvR5TRYC3+RvnWxgGONAExV90eyir1lgCeb/b0GiytIjy3I 8/byjARGg7Z1BueBCFUcjNNdeSLOORkUTfcXbImQxe/6y+ms2NftMBh4nQB0QFoQKFCq Qg/uTNt9jcHuchXpH4ZzDsaelzLKQGb+AxUT+1REC5xEJFHkmreBo5bWj0i/PMq2Q8XR yRD2FzisukcW2PYqhheJsga4t3QLfeWLOYcSjvCeREZbloCEBeGt5AinKGoXiptjLI8H UM526Qy/6sp6KBVBTOfKUcDDsOBGg9LlURhzg5mo3dkxhzKQvWyfkqanIaE0KGxEeQnV 5uMQ== X-Gm-Message-State: AOAM531m+pft/DquVNw8y0jcG9LD3PFgHILLR55WsOLlcxeH7oyHrkUD xYwqISd/5USB6nMc//z7s1HYyVSzdRYq/Q== X-Received: by 2002:a17:90b:704:b0:1d7:367a:f16b with SMTP id s4-20020a17090b070400b001d7367af16bmr6541124pjz.197.1651607567332; Tue, 03 May 2022 12:52:47 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id fz16-20020a17090b025000b001dbe11be891sm1692286pjb.44.2022.05.03.12.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 12:52:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 61/74] target/mips: Use error_report for UHI_assert Date: Tue, 3 May 2022 12:48:30 -0700 Message-Id: <20220503194843.1379101-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503194843.1379101-1-richard.henderson@linaro.org> References: <20220503194843.1379101-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 --- 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 d8c9be5e9f..df1747aafe 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();