From patchwork Sun Aug 22 03:55:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501416 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp1064797jab; Sat, 21 Aug 2021 21:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOcM5Lzg18bxGTbzFb3xa6dY3AbGNPqpO8O2rmZGZJ/Dq5NYGfzAqkqb1sMjrKp5+EeArh X-Received: by 2002:a25:2007:: with SMTP id g7mr17403735ybg.434.1629605481103; Sat, 21 Aug 2021 21:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629605481; cv=none; d=google.com; s=arc-20160816; b=KwUbVIr/L5wEK0txFOQnjOQ5gM73fE2lgBcex4OmnM79EIUKtwQ/BjpZ7vlF5usJEI ABth++Q7UqgNdJLC3CYLjh7ziRrx5It5xhuRu/nwISm9gc91uw1ysqfUS+6P1utMOxAT aF4/cZC8+P+rpzTpbhzbIbKfCD5BsI6e9U63QBuO7iwirR2zshkQ3nhl+LYPmAJieJZz 6D9/n8FX2yRR/vSS7khQwPpg0O1jrUAxfg3FV+JhgrrRWib/2/iwlfG/7XjN7SaHJBFt /ESK0iufzIy+2MfsRHiCRxXAXIK8cBIlHLk+rm/u0bUhb8Y/w6G53rX15P3+OA0nPu/c xbZQ== 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=nExu9rWHCS7f7+CKti5VQfpmql22KtPSQqzBYFW5vis=; b=uWoqy1M4d/T6bRYekBK+Lujb2mLWHNVamiXmrFJAhcuKj9IA+zs7gq5ueI2l6bJDM2 kGUZXtincKSOMvVSiqnotnvN1IzW1d6NyPXcWr2XBeAartTE/LxuRvlNf7PXqsO4TUN8 Ds5h7Vft0d4iDDSLyKnRAT5sVNa3nvNBHsKH61AhEcbe2PYVEkRnfhfLWVinLq7hmwS9 dFvow4P28/oMg9QhyStDl516zoYqUOUTam+bnB3EzGCtbEtE+fQ0z59x7kpKFSep9HLy LPshjm/pY8vHDtCvoLVxryXjy/HXyHQVqJc9RSOn6PnZyPib+9aswpKwbHkxWVSFGCfN /WqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRlVtLkD; 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 l32si5591676ybj.206.2021.08.21.21.11.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Aug 2021 21:11:21 -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=vRlVtLkD; 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]:51798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHepM-0002VX-HQ for patch@linaro.org; Sun, 22 Aug 2021 00:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0007u0-U0 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:56198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaQ-0000jz-DE for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:55 -0400 Received: by mail-pj1-x102a.google.com with SMTP id mq3so9789198pjb.5 for ; Sat, 21 Aug 2021 20:55: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=nExu9rWHCS7f7+CKti5VQfpmql22KtPSQqzBYFW5vis=; b=vRlVtLkDQeuUGXNOwTJq9XxLxmc85rhdmXv+WPiq95+z9Iinopw2EkRLV/CudT6+Ak 8cb+LW7qJ2TNEogxyg6p+YA4+RUAw8QYaEZzwS4j7mNiBL0B0wzdSY+V/1FsS9G9w3JX 6fLb0O3a7rPwL7ST/O0ZyGpzeCEZ117+kGUNCncWxL+2CjTRWcXqv6Ya2Dcvqn3PWVat xBfbClHekNWiivLTrUFQQotIFNGlqjdvWalukBdZwAHnwR7qtab4tPml1VaIvQobnPUT DkodglcctHweytH5/U4lLbKnQkaF8bWadq5wIibjFrscaJlFl3GwND/lNgC1etc5mTrn xBMQ== 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=nExu9rWHCS7f7+CKti5VQfpmql22KtPSQqzBYFW5vis=; b=PKgtg/nlk+vCqWEEyzJP2qZLmVKHihgHQcdSrEVU9Id1ZQ1P9tsGhwrMr3JbbB4AaI rnIoyqRuoFxa6aWUzm5z65D+UBkfydVNivrtZwr9C2a53uW8LpyteNfAlMyQ541gKKSr ny3rhcWsYtpnzuM2dQmsjOapZU+bWtv+qC7J3AlDo9GT8x5VkAhT7tMjbfbFL2kGh93B JNAvGYCBCYf8s+wpRcdcKF6qONFJpbAEbXELB6UHtvLmwMdChvmpUoWmulRKdpgerk25 cX5TphQQu7G2tlxRtPQw4yrbAJB/ECX4V/ikZWZSbzqhIDBVxzGJT4XaR035Ca1uYgjw jbcw== X-Gm-Message-State: AOAM533v5PFz2a/8ECvBBhT4618cpYNFINRw77AIMOo2AQ9fTPaTODgY nqVeosHKkalnwV08l4h6zitzHD8pxfZgmQ== X-Received: by 2002:a17:90a:86cc:: with SMTP id y12mr1572317pjv.127.1629604553213; Sat, 21 Aug 2021 20:55:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/30] linux-user/mips: Improve do_break Date: Sat, 21 Aug 2021 20:55:29 -0700 Message-Id: <20210822035537.283193-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822035537.283193-1-richard.henderson@linaro.org> References: <20210822035537.283193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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 autolearn=ham autolearn_force=no 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: peter.maydell@linaro.org, laurent@vivier.eu 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. Signed-off-by: Richard Henderson --- linux-user/mips/cpu_loop.c | 47 ++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 9d813ece4e..797b6bf659 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "elf.h" #include "internal.h" #include "fpu_helper.h" @@ -38,29 +39,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) @@ -214,6 +211,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 */ @@ -266,9 +270,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, false); } break; case EXCP_TRAP: @@ -276,6 +278,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]; @@ -302,9 +311,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, true); } break; case EXCP_ATOMIC: