From patchwork Tue Apr 26 18:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 566064 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3837122map; Tue, 26 Apr 2022 11:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmglE7I1x3kB64KLwgraBV43JyiHjU0rYkXSndlE2G2hOg2wKqVv/g1f8gwpjvm2NrNEPB X-Received: by 2002:a5b:cc6:0:b0:648:aae2:db82 with SMTP id e6-20020a5b0cc6000000b00648aae2db82mr3680789ybr.488.1650997567189; Tue, 26 Apr 2022 11:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650997567; cv=none; d=google.com; s=arc-20160816; b=IyreOKVc6LJoEyakNEfG0owa7lNcOgkbGBh9y/wJrhy1sLuomik55JaoRel+XGsibj 6XsXBrzbaXaF0ZqTYVgzb/MpxsS5r3Y1sNh3ENxFye/CFUuYLPKSaz7c8/j7KrtGkSP2 zhCbYH47f5pfclg7Zhwibt6OwN8Y4bc8iiJONHxakUZ7EDcwMJODvJC3fOLvEAlzFXpP FJ9hlOXgR0Uz94hxQMhGvW8AgNK2iE85uT2UDVEotxE7pRXz04fTC1vP4aHOMcjuYV6Q BEMRN1Iie9Ei7nSpwNzieBmiZBirb6RGBx/RCbjQgO4a2KNWi+ubnN8B1SGzZgzRZV12 7PLQ== 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=eHvPohlOKUQnSmyCNe75TWvOoBODy/hIoVtxKqN8gxrf/mkQuhf7atdCRXXk8jbojl tW/dyG6gH6neUcVsJhI+NlKUWAoiJA4WKr2SzcKAWYB9cL9YstJ9LFsaBWIMWz7drXMf 17ETpBCQe94j9mzii8YGgCRDXLIym9+sXHt0JhuVYkvFMTFKScb6Rn5XPd5LSOLmfyKz 4RSwvu4OCTiPPyK//N9I/4DebO4iX17k4iFMmPxjIpIym6vxtDkl2KOdg7ZbouRtmSIz EQtPXjlvuVnEudmiyF+CT+2ii3Ra9AOOOl/Ohbr7y/BJ8DHozJU5SqAFQ3b3ZSLgStno q5lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=loCFcVUO; 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 t11-20020a812d0b000000b002f4d370e0a2si13931320ywt.440.2022.04.26.11.26.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Apr 2022 11:26:07 -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=loCFcVUO; 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]:56824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njPt0-0003BI-Nh for patch@linaro.org; Tue, 26 Apr 2022 14:26:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njPmR-0002St-QU for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:19:21 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:56259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njPmI-0004JH-PE for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:19:12 -0400 Received: by mail-pj1-x102c.google.com with SMTP id r9so2157632pjo.5 for ; Tue, 26 Apr 2022 11:19:10 -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=loCFcVUOP72i9/F3g/GaoW09E7nfR/V6rEGLs6ufEqTp0S/B5pDYBUQKpgjj0XGEir JYOxMkWyUCJQrTOA7W1cfXgf3Ztk5firwe743j/bM6PxiNUoxRATM1/ksiS0kwq6XKce QGLNIo7WFb2yqTqCmgS1yzZzMwlmgW3RWmD4rBbT52wmvgl3j8t613kdi6NqGBmGfI4Z 9F3AT5Zf9zOgbXqH67860g5sT8AHAtrCe3x30jOS3wfyYc9xKCGih8curP/1sr1xN1g+ vgTz5VIP8YUIkXVISSeVjLxdBok4a2wnJ3CnPayeP/LwxsoVlSerarWtUhenM8GPnFaU kEdw== 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=Db/pnwXTckz9ugC5xMhDHKV6ZE0RSh1CviRaHKutfjVT/8zOYlIYSEeOwiy7SwPzkU zkwBq4zgxbnpqFVe+cppEdUzvUgqygHs95sgq5YwoVlJWa/zyXxvkUTihz+DOhrF+Cct yFfem1/wXZ9c9gpB+d7yl8z7t3l9pgnksyENgeOVaFbYBYyEraKqcG9m/THY9JXjhXzO IM9Gge5n6cIEurVnzOlNLUpZfJPUpwUwnPL5cxPAy5Xl2ODJ1bnP0lQ/bz3Qv5xZ6AGJ qSlOrj9RlaSV9RBltGHuxm8A2jKYNfObAIacdIxVHXv7JdNqLLqTM+FZo+FdqEAFH9SF 2mZQ== X-Gm-Message-State: AOAM532CLBKMqGulGK1j0AIMosX3+p1DMEQUfNESMkhkI1bJfRDfKqsP KF0Iv3mcyU5WAbKvKVSiTX/MWuzC+Yt5Xg== X-Received: by 2002:a17:902:f789:b0:14e:ebbc:264b with SMTP id q9-20020a170902f78900b0014eebbc264bmr24158710pln.169.1650997149433; Tue, 26 Apr 2022 11:19:09 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id j7-20020a056a00130700b004b9f7cd94a4sm16482827pfu.56.2022.04.26.11.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 11:19:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/68] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP Date: Tue, 26 Apr 2022 11:18:00 -0700 Message-Id: <20220426181907.103691-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220426181907.103691-1-richard.henderson@linaro.org> References: <20220426181907.103691-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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; }