From patchwork Wed Jun 8 05:19:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579811 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5796061max; Tue, 7 Jun 2022 22:25:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKt24qbq5FeotfIamk+4Qnq1Fz7xx1yLMITyuXGs2/oahneevOQ8vqHDirEX8X6Kng2JdX X-Received: by 2002:ad4:5fcd:0:b0:46a:a0f8:db51 with SMTP id jq13-20020ad45fcd000000b0046aa0f8db51mr15237472qvb.11.1654665900172; Tue, 07 Jun 2022 22:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665900; cv=none; d=google.com; s=arc-20160816; b=pLYg+HODn8PP9hHEF0/OhnEWhCOCfLuDfLSrKddD6suW+NifKt1M5GvZqk2WJndAuK qCYWO3DcuLuu1Ne1rX1GexzdaZXW7KANk5zZyEd0i0tfrX07u48A2LV0Osg+QJFDk8v4 DwyBDz9IFTpdHTW/SjNTPJEtZyYZmOLm5CUiFcLnhGAEo99CRzIPlBnrZyNAr/meYPJH Ls7SvLwra0Ju9DlHUYcC9lBEC53T4ES6ifxFlbEIImS2vkPzFvSpAkLwaCFChpu3gp60 I16dt2m+EPOHOfKlvPNmlgwQvM2d3pTGXVd21XZ1r3XUIgFMq5YWOgIMuBbngK4E2GP9 tdGg== 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=snMin+Ep7/5LPe8TvWggacov1u+bV2I7wwYniTN2Z4lKUxJi3DkxCAwYIFkWvr/KIu Hd2Ju7hdEOIF/HLFY+wxsBgOfbM/rpfVuCTW3ox3TP69509Jx2qM/ZifWavJTxripAqW 43RBAAXbzn5AgCZZ7VvkmX9c7jp3SSPN2cAJ1VJx7Pq1JF+PRY8EnveOaTcKEq3uPuuy n5EyJ6uSpA1XTN6UD7WVXxfB08Q40An701WpHl8jsLkb3u0jvqMUNecLWMHtg8Yl6pJg HQj+2DaXXsXk0mViOiwr74f0GCxtXX/AYf27oNxY5hl9sn3KQqC7W296sDsOEDWTBKsf g6QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRsQuzcS; 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 u17-20020ac858d1000000b002fc26474292si11467272qta.244.2022.06.07.22.25.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:25:00 -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=dRsQuzcS; 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]:39186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoBf-00030M-OE for patch@linaro.org; Wed, 08 Jun 2022 01:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6o-0006wc-8l for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:58 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:34673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6l-00023M-Hq for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: by mail-pg1-x535.google.com with SMTP id g186so9023917pgc.1 for ; Tue, 07 Jun 2022 22:19:54 -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=dRsQuzcSmi2ALA61dgmw9YNkB/KU2DY3wZ+ycRfkqzaLNS52pMxxk4fkl4yMAKQu4C 76FMAJZGHYTmPkxa3l5s4FLFJk7//rDnuuR8KpXC1b4InpVP1gav1re1C0/gjE24EVt/ gb7aDmMhALtbOWI/2TUpKDMFwvjpflek2X9BhA/cxq28LjBptVUsSgu5qJqYAndh1u1U PF7pxRhyJ26tGgudtSA+XEKJbkukPm2MD41yJjs1byS/9Gq2l9LBq6PaM0jbdNzJFLiD Izb5MmRj87p0rYnVfsKd6K+mySJXj9YbBLdumFUfkMT0gTrk8Ry15EIevvzG0t4806b8 vVbQ== 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=owOL48bq5915nj5qClpOto2a71OWilPZINbBvvkNbTqAXKxCUoJ+dkzMuB8zpxV02R grMpfprzmfMh9ezEzoc4NbdlLsVjqgpPdJVBI0wYtKlShWXHmLabZScHG6FNh09I7POd bkaaSumuJ7QkupMZvseMgcUp/r3JT46JAdBufAjUfhn1Vh+CQk78FtsWJdIU1gXfLZdi FUMQ74AYrkqvaWHxV8HRrowx0cDN84wIIH2Y5PomaZU+Sr0BST0kKqADq8q6tx+Uukor 1kYOyTm2t4iTh68dVkL1Lxu44Q4H5wBByxNXsy/2RgylXxh2vpj3SJscc9iW8PGuzhRj vmBg== X-Gm-Message-State: AOAM5308AHqVSlgOu/+4/kWjqdANrQ2DlAHZP+Pvilr5bqMGG3sk2/mC xoazBXbMUYznMf2UsPsd3Ma7OPxH9YZ7ZA== X-Received: by 2002:a62:8702:0:b0:51b:c452:33cf with SMTP id i2-20020a628702000000b0051bc45233cfmr25358364pfe.72.1654665593769; Tue, 07 Jun 2022 22:19:53 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 08/11] target/mips: Use error_report for UHI_assert Date: Tue, 7 Jun 2022 22:19:42 -0700 Message-Id: <20220608051945.802339-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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();