From patchwork Fri Apr 22 16:51:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564842 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp658076map; Fri, 22 Apr 2022 09:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzfvtGKnOJxQJW5kIJ+4QEn60vcSOa3r6UMiJkJ21WS0X3IQBdTSxXhhugLFBCRgvRG0tu X-Received: by 2002:a05:620a:219d:b0:69e:8ab0:dd22 with SMTP id g29-20020a05620a219d00b0069e8ab0dd22mr3349243qka.33.1650646688148; Fri, 22 Apr 2022 09:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650646688; cv=none; d=google.com; s=arc-20160816; b=IkSuC9H8MTMbDfwOnFMHYpU+zBWJ4RuyWCBthN/8zwzVLqlBSMAbHzLThm2VO1deSZ hxcCDa4LwKNIo2RT61M0uX7ONuwb7lTMlutK87aMWk1qGMjPj8iT76ehKTmm9+Ky5fxt +mrAgReTAwwoHXaq8WYhiP+XqSM/NDAyHVEe3QcgQ8jeVcjZeY+Bc/VkgU1XhfKBrwDR XnwBLp7misnd2qxJUPUKbvaNhVB+1Eo2VpOrHt+SRPaRxuE7guJuzib9D/G2XIdJALzt xdxcCNJCFe+K0y+U86JFrifg8AfAe3R90+k0UCOkegM7nA+ESX3dtDqjNk5k664UOX/1 M4jQ== 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=meOXfrn2PD5m0Qh1cBNLkWBSrBP+MRPsiz/DUB3aYZo=; b=Ut33l7sUJM5qcQ+r8A4O5qLVttspkyyafi6CFPpyrF5dlGGSXGXmX+ecT5YdGuLMzo mgKYjFt/cw4kXvpcCyifgW0Ci00uVSXFAFyLLe9n5zziILiBxtr2Z8WiIGDpmCuSCJ1S 3Jsil3n23C432DPDiWsdXNxT1TDTZ10mBbyWy4HzREHGQoiwbtxbGU9b/NSxciqV6dFw ahlJkx0+8gv5oTWqdsHyuSUZG32bpyPbk+FBRGxbAzYDihyQAFuSoZuQTlWJr0hRZobO rL2TPTdq4DHt3SDG3+u+XgYJ3mDsI7mHhN8BkSPIpvysfEj3PXi4Wla9VjjGA1DSZfiS spjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tbqVPiUI; 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 s8-20020a05620a0bc800b0067e4be23aa3si2543894qki.744.2022.04.22.09.58.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 09:58:08 -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=tbqVPiUI; 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]:58074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhwbf-0007fy-Nv for patch@linaro.org; Fri, 22 Apr 2022 12:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwWW-0008Sl-Pg for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:52:48 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:40787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwWV-0007Cw-5w for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:52:48 -0400 Received: by mail-pl1-x62c.google.com with SMTP id k4so544507plk.7 for ; Fri, 22 Apr 2022 09:52:45 -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=meOXfrn2PD5m0Qh1cBNLkWBSrBP+MRPsiz/DUB3aYZo=; b=tbqVPiUImFnthQK0yo86Pwsk9/imCz2d90C1cP3trX1+76OjpzqOerbEx5INy91u3p ywqaQzbIG2d+dXdLWY6ZAKitIAvFrB/rUInmYG+Xr7b1PjYJPw+MvTLKMuMXtlN9Rk5m 3+Ya7e3bGnTRiO2FlLi7/diAZYklHsUhLigu6XnKEiWIWkni88SJxlqeyykrcvAhkpqu /PoBv9RC7D9k69pS9AtcR20/7HRAlumI4OyGAw72Jg19ZoK3vpTgMdfcvLNvHmhkFKvc Fp+iz7CUumVIv0w2B7opNMf8h7eZAev8lxZuYJDzAS3eCPKOfSPuQqLuVcjRHl5Xq4JU 9q6A== 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=meOXfrn2PD5m0Qh1cBNLkWBSrBP+MRPsiz/DUB3aYZo=; b=5iJDQAAxiL1Prtlwsd1HFMQyif85wzjm9H2xHyAsM3dmYAnI3CFJK8aAxhAp/u4VaX pC9A7iK0Ni0pmQBLRElOSObAoNqNzOUM8ZictjjwpN+WW2ebxt/5uJlwB0U1OjzhW8oP mQqnIc7sI3c50Seu1x4plj8DJYPQHZLT2G1E5GjB8+mw8eVeNrFgkdXwCM8j9feP2Wsn K0VXH0PCH5soqyv+mBjGURFNRf4qsIozCBXIafLN41FVeS8ukmHAyTSacmuMAG3w4FKa h1z+lYKB0gwVoo6Z/NYP4pAoDDZfWdzjVun+OVjG9LAqvBMKs1zbYcDvYye1eXyEx/Mi ytXg== X-Gm-Message-State: AOAM533sIGacSIq4YuLFn3kgDmkA5Elonl4KO+svFitvfw5wzNpLbUXD +YHBY2bzeBHwjN7G9Ix+cyD0g4Oq8waUtxfX X-Received: by 2002:a17:90b:3b8f:b0:1d2:86e1:6e4d with SMTP id pc15-20020a17090b3b8f00b001d286e16e4dmr16965403pjb.186.1650646364241; Fri, 22 Apr 2022 09:52:44 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id 6-20020a17090a030600b001cd4989ff5fsm6835904pje.38.2022.04.22.09.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:52:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 01/68] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP Date: Fri, 22 Apr 2022 09:51:31 -0700 Message-Id: <20220422165238.1971496-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220422165238.1971496-1-richard.henderson@linaro.org> References: <20220422165238.1971496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that this advance *should* be done by the translator, as that's the pc value that's supposed to be generated by hardware. However, that's a much larger change across sysemu as well. In the meantime, produce the correct PC for any signals raised by the trap instruction. Note the special case of TRAP_BRKPT, which itself is special cased within the kernel. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20220421151735.31996-2-richard.henderson@linaro.org> --- linux-user/nios2/cpu_loop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 1e93ef34e6..2e9296750d 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -40,6 +40,12 @@ void cpu_loop(CPUNios2State *env) break; case EXCP_TRAP: + /* + * TODO: This advance should be done in the translator, as + * hardware produces an advanced pc as part of all exceptions. + */ + env->regs[R_PC] += 4; + switch (env->error_code) { case 0: qemu_log_mask(CPU_LOG_INT, "\nSyscall\n"); @@ -56,7 +62,6 @@ void cpu_loop(CPUNios2State *env) env->regs[2] = abs(ret); /* Return value is 0..4096 */ env->regs[7] = ret > 0xfffff000u; - env->regs[R_PC] += 4; break; case 1: @@ -69,6 +74,8 @@ void cpu_loop(CPUNios2State *env) break; case 31: qemu_log_mask(CPU_LOG_INT, "\nTrap 31\n"); + /* Match kernel's breakpoint_c(). */ + env->regs[R_PC] -= 4; force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[R_PC]); break; default: @@ -99,7 +106,6 @@ void cpu_loop(CPUNios2State *env) o = env->regs[5]; n = env->regs[6]; env->regs[2] = qatomic_cmpxchg(h, o, n) - o; - env->regs[R_PC] += 4; } break; }