From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F4170C433EF for ; Thu, 21 Apr 2022 15:29:01 +0000 (UTC) Received: from localhost ([::1]:44292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhYjt-0002vM-4Y for qemu-devel@archiver.kernel.org; Thu, 21 Apr 2022 11:29:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhYYx-0006cc-Vu for qemu-devel@nongnu.org; Thu, 21 Apr 2022 11:17:44 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:54008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhYYw-0006C7-68 for qemu-devel@nongnu.org; Thu, 21 Apr 2022 11:17:43 -0400 Received: by mail-pj1-x1031.google.com with SMTP id bx5so5228895pjb.3 for ; Thu, 21 Apr 2022 08:17:41 -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=tcIID1Tauhkhysj1gC2xGpQ5XH6/Yfy4VHCAd2/0IIg=; b=b5Raj597Subkv0gQafl1D/UBkwAjtXzJQnETL91WVeUVHdUoNfeQhpA0DBb7LcCQiD WmwVyLLPrVI5SQ9DUhBbiLXKIJ/8HmuonXa2FxLCZrmiXSF/wGuwJv0rXaS4e+joV1zW PS5XqYAIOWtx+w8Y6CTb1dsSXdYzopZwE+wxdQ/Jq+Hb2cOakATtc4siX7Q4P4+fsQVV dCViJ1PKny9GkrBuPQxQ+aa8dnOtTqPWtxJrIKovjMaS5QKFZEaC3w353XycSPAlNQFh A/asdEvJs51sVxnc83btmWeQV8pH+SVZTCZZRejIavnwsVdSLFJRvvw85ewF+f+gUgkx NJcw== 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=tcIID1Tauhkhysj1gC2xGpQ5XH6/Yfy4VHCAd2/0IIg=; b=4Ks6uu4f0fRTn1h07u9yExE0Sbj+ADZhAVm5WLZLXQbB26JnWoYybYwlreV9zBdLx3 Ak/TvuOE4wgol6n0TskjFcdTYznjdq3vVGt08iwonXId3ZDQWHmADVphYYagzTmcvWC2 mYtj8U5K40qfM5B52w3gldyJiKb9wOSj0rfNTtNoJEST2sLSYOv30gsqDhq58YdBZUKk QBSnFOha5nTqVEvY70Z4eUGNwmqAet8EgutQaO9TWnY/ftnZAKYDdlqH+mPjNX97IUp8 Zp41Xl1FDsHTzwh7d1ZPDI8oeoS+F+RvWEo7WQOQRrcVK68ARmR6+ksvBXblQ33RRntL r23A== X-Gm-Message-State: AOAM533eoa5ItrRG2pNO5aKmlPuPNznAAT0cd1xhnNjhCjRgcbHsChso Ue8eUjoP0X6aF1q8JYA905N35E793mjnAA== X-Google-Smtp-Source: ABdhPJz9U5fWxxun/g6XKqy+k4ntPnTCCNIG7Js6y2eY6VAMfLuNgWap/J978DbkSlguHwhdXw5EVQ== X-Received: by 2002:a17:90b:100d:b0:1d2:d49a:c341 with SMTP id gm13-20020a17090b100d00b001d2d49ac341mr173632pjb.130.1650554260783; Thu, 21 Apr 2022 08:17:40 -0700 (PDT) Received: from stoup.. ([2607:fb90:80c8:6cf3:a91a:4957:ba18:ac18]) by smtp.gmail.com with ESMTPSA id z16-20020a056a00241000b004f3a647ae89sm24616248pfh.174.2022.04.21.08.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 08:17:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 01/64] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP Date: Thu, 21 Apr 2022 08:16:32 -0700 Message-Id: <20220421151735.31996-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220421151735.31996-1-richard.henderson@linaro.org> References: <20220421151735.31996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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+qemu-devel=archiver.kernel.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 --- 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; } -- 2.34.1