From patchwork Mon Dec 20 21:05:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526084 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4457620imb; Mon, 20 Dec 2021 13:17:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7ZSh7kt9e0mL6ucV6yd3nyLw4FVC+5WS2qCZf0Mwt90jy3ppi5kEd+UtpDUBNypF4wVLt X-Received: by 2002:a02:a382:: with SMTP id y2mr30039jak.101.1640035057004; Mon, 20 Dec 2021 13:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640035057; cv=none; d=google.com; s=arc-20160816; b=JDemyEypE6+XtE8JRyw3DcGR+ss2ja25SsJc4/FhYxhh24wR2WiiHxdOyI740eUaWH tljrvRc2sZCjWgTOriZ98n1/g+kolqj/L7Mp5IqbH+ieXxibemgPUNyBAzI3y94uTyR2 GsiepOW45hbTGQuDrqM0Q9MpOkPyMz0lUWXmUyqPXCBT4GkxWU6x/YGSyvfuxc7Vapq2 /AiBGah78go3iIXjS0WfbCZ/e1ocmryRcwZz1r80JXfbq8965VvZAZpQp6mp0ueW3+FD YiJdMaQSUJCh+CcH5m/xmYPlu3I6ErujgzI9odbpFVV9TEy4a2rp9y+Dsg7wb64hilV4 nvNQ== 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=JNhSgXJTgMGZWBsS+vqzx7SqW7s/rfAY63sPF+SkLf0=; b=WlgANSnFOPUzQvx3t3PogNPdcplygSlIO3szQt5HrOU2foReD3caCmQJVFcT5+gmjH FDXCkHi+RSnYBClGM3/Dt6Jm7/F7+n4Q6ZLIl8gWPD67WCmqw3PHD1Wm32Q9GAinyXkM T2m2FkqSE5SxzxCyi228whFfNXg1sSDYXcrS19WYKQF5h+gF/R+czSOiZlCM2f00TI7Z fMG3YRjX9RFjTvnoMI30REA0BNI+c6dyIlMxuTkKCq1fh7TIgIWTLG1dWXaItHnsFLtN cCiCnNxFNrHl4eGkUz21+WzWa4gazw9Nik45r6LfTwXj59nhjjMohpMGbUXwhRPjoaGh nb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b3IobSou; 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 b6si14644839jat.81.2021.12.20.13.17.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Dec 2021 13:17:36 -0800 (PST) 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=b3IobSou; 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]:59028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzQ2K-0006jS-G1 for patch@linaro.org; Mon, 20 Dec 2021 16:17:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzPqr-0000X7-2U for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:05:45 -0500 Received: from [2607:f8b0:4864:20::531] (port=37679 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzPqp-0005uz-7E for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:05:44 -0500 Received: by mail-pg1-x531.google.com with SMTP id a23so10430930pgm.4 for ; Mon, 20 Dec 2021 13:05:42 -0800 (PST) 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=JNhSgXJTgMGZWBsS+vqzx7SqW7s/rfAY63sPF+SkLf0=; b=b3IobSoulVxdx8q8motxIs1S/KgIVN7CoVFQXrsydHbsm7hq+yZ+WueIRNFY6Aqi5Y ZK5OHA4vAxedHMoEgv5ZqRrVu8G0z6Y7mlvOJJ+E5KrvA3NCXavmkyfRdFkgl0QJOOXU KkOH+MMjhHNG8P11WnL4degAzD6Y3Tp3sS8Uv9XtHtjCkrVmGWnR4idEvHeul+BvT+LS HhALkopZRrMnZqi7mJeaRplgG9Rr6/X7YkE9QJ+O13zJqKXll4mfpTitVQlHvKBdXVGb jIzBlgk1h7Zq0sQ25QXkBtk/PAG0l3zynXJftRfRYvE8fth9ov6Xbr32KuXwQc9GTgHF HFMg== 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=JNhSgXJTgMGZWBsS+vqzx7SqW7s/rfAY63sPF+SkLf0=; b=i3Oae6Z1BuapFaV6Pz90DptRLPaZz/AEUmvueJoqxC4YbkDJZzWfuS1HcgDEL7MBj8 cbymsjfyiEERZtKoOSSlkF3fqJeTgmJJN1rxsruaTcLe60qS2Axtgvg9uFUVzmnGLYPE Q3e3y2sy+599vUm7kDo8ObcSyTLMkYX0Ctr1a2IFRsfCTapRA9Sd2rAMSKR/dPoiIqbE aKqSs/gkPP9PB6xFB679R1tYTXp8bSj6W7gFRyZGV6CtKmApn1zv0rVjdXYZo8HVHzGW nG6A5CouVmt405ExsEthoxwqwQXzVxvXKe1jysIXEswyw4tUxqTBfuPNOG9olxHblSra sgfA== X-Gm-Message-State: AOAM531lMPIf5KDDCs/N2f4H4y2d6mP32kpFZBJxyG+nycDlV8pR7zUg lRletPGRxA80+KYXXAIdS9fJ7xn789ynsw== X-Received: by 2002:a05:6a00:ad0:b0:4a3:1056:e2ae with SMTP id c16-20020a056a000ad000b004a31056e2aemr18226957pfl.2.1640034341881; Mon, 20 Dec 2021 13:05:41 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id d13sm20091021pfu.213.2021.12.20.13.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 13:05:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 14/24] linux-user/mips: Improve do_break Date: Mon, 20 Dec 2021 13:05:18 -0800 Message-Id: <20211220210529.150423-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211220210529.150423-1-richard.henderson@linaro.org> References: <20211220210529.150423-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to do_tr_or_bp, as per the kernel function. Add a 'trap' argument, akin to the kernel's si_code, but clearer. The return value is always 0, so change the return value to void. Use force_sig and force_sig_fault. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mips/cpu_loop.c | 46 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index b735c99a24..7317194cc3 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -40,29 +40,25 @@ enum { BRK_DIVZERO = 7 }; -static int do_break(CPUMIPSState *env, target_siginfo_t *info, - unsigned int code) +static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap) { - int ret = -1; + target_ulong pc = env->active_tc.PC; switch (code) { case BRK_OVERFLOW: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, pc); + break; case BRK_DIVZERO: - info->si_signo = TARGET_SIGFPE; - info->si_errno = 0; - info->si_code = (code == BRK_OVERFLOW) ? FPE_INTOVF : FPE_INTDIV; - queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info); - ret = 0; + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, pc); break; default: - info->si_signo = TARGET_SIGTRAP; - info->si_errno = 0; - queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info); - ret = 0; + if (trap) { + force_sig(TARGET_SIGTRAP); + } else { + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, pc); + } break; } - - return ret; } void cpu_loop(CPUMIPSState *env) @@ -205,6 +201,13 @@ done_syscall: abi_ulong trap_instr; unsigned int code; + /* + * FIXME: It would be better to decode the trap number + * during translate, and store it in error_code while + * raising the exception. We should not be re-reading + * the opcode here. + */ + if (env->hflags & MIPS_HFLAG_M16) { if (env->insn_flags & ASE_MICROMIPS) { /* microMIPS mode */ @@ -257,9 +260,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, false); } break; case EXCP_TRAP: @@ -267,6 +268,13 @@ done_syscall: abi_ulong trap_instr; unsigned int code = 0; + /* + * FIXME: It would be better to decode the trap number + * during translate, and store it in error_code while + * raising the exception. We should not be re-reading + * the opcode here. + */ + if (env->hflags & MIPS_HFLAG_M16) { /* microMIPS mode */ abi_ulong instr[2]; @@ -293,9 +301,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, true); } break; case EXCP_ATOMIC: