From patchwork Fri Oct 2 07:50:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315238 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=DIYuJAQO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGbz5b7Mz1yFp for ; Sat, 03 Oct 2026 03:53:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChPe-0003l7-47; Fri, 02 Oct 2026 13:51:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChPV-0003gU-P3 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:07 -0400 Received: from mail-dy1-x1333.google.com ([2607:f8b0:4864:20::1333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChPS-0007Hc-JS for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:05 -0400 Received: by mail-dy1-x1333.google.com with SMTP id 5a478bee46e88-34bb8b31647so242633eec.0 for ; Fri, 02 Oct 2026 10:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963458; x=1791568258; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=D+6+qn+yh1OD1CvirI1XQx+kYJP3uEKSWNOVrm/1f1s=; b=DIYuJAQOtA5cbT8MtlSYXuKjmHVmeW3gXJJLeFZNVwBPNaQOeZe9feYkivA3Icbd5/ DmV+RDDKWo1fJ4ll41Mh5yx2uj0oVfWy7goy0TsbLZcQ+udutz/eMzS33DkOvEOcHhhx SDrU1ih9kDv3uw7KCwvybJth5ijzhHvR2rHMOjz07p+MnxKU/yt8jUIqUV2tNPzFT3Ba hVWd0rbgZ7j/VmJZtoQ0HcEMVMjp3kKzZdnqfC7f/O4kFw87NKgcsGTzC1Idk5qAnErb /ECmYjbJmrpGKRICi68PjTO6jRzSWFaJm7k7QQJE5TfcHRgraIq22J5wevL7CQefkR2y xXTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963458; x=1791568258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=D+6+qn+yh1OD1CvirI1XQx+kYJP3uEKSWNOVrm/1f1s=; b=0pxnR+P/+creLoK9FZElDsNhZjgK9KKsjIeKIEqVMyRmuEuQYkhYdiQtZZ6ouFoBdR 6ycpvfOgkDOInvgHA3bCy/0NWcSR/xnr2vB5H9hbdC4qPEI77GMpSc1lOddgvUy9+dZD Be2/lYLSoJbfnsmnmNmb13q7Ia+i2fnrxTBKQzLL3cCLts6YkQ766OKicQF7F2CEHba/ QMQsj7vrS7r65Lqn0l8sZm5FfDrLyttxxbbhDqppzV3imHwbAkQjYupf0Q11k+g4tme5 QhyeJ8LOHaWEeJ5m7hTIBr4ZX4WD71HsKNkXwHtWs6aN7R0gteghD2AkaPbBdv48cfn5 wVyQ== X-Forwarded-Encrypted: i=1; AKwUvBxm+NbteONrhw7b5JLXZZNkM9wG4v3kNXf7yCYzF2Q7P2t4gD1q6TpmTOPbRDudWFTAohMCKiDHVQ==@nongnu.org X-Gm-Message-State: AFq9FYLhdxVUWjsMB8yAr1k4sWn8iOI1plXJwEdBqUvFYBh4kzXsS1af IyxfkBS3RgNRpogqnTz4/y4kDT/Lb1N98zbGYvM8hh+IreVT/WV/Scwz X-Gm-Gg: AYBFou093bwQpU5qXN84jVX5pFKxwj0zzCkTwGTxqDowyP+hRVUbTVZ3uJZTQbr1nV5 8ugdD7ceGOtUKMKjtHkjLKgCFWtp9+vq+g6LB/5cUtFm1x4tUgV0DGsYZnDtP1mq5wYKmfoXw8e fyxtHGrCRs+aq0mjXWaetDNoiP9lBMvJ3nk3z03kqr3hCTWX0TG7Ck33+MA/z6DrrvxQdn+l2lF 18FeDiq+QUMZID+sjT+JKtpAasJ11mCdjP4SQ52oO6uXOivKBXkTNtc9ShEoEbKKQphypykiXAN jkijhgfjB9IWc7fzP57+QpVnzqgMZnH5ypi+NvN5r8cNRkQStRU37AAIi5VVt4L49whKq73VfO5 Rg5OFkDaVg79FhOxpH3GqASnCRUPmgIT7bdRSqjNTzwJd0HvKnEs1bX+5eJj4r0DPoJ1IaiXqNl qBCRPnot2uaF8iha21f84NEBloCpKNMTov+nuUgxMUHz/I70CimMXv8iStnnc8oL3fQp0YzBj2T bU4KyMXN69Sr8GFl1KJ4Oq1mIW+gO4= X-Received: by 2002:a05:7300:8248:b0:34b:f031:be93 with SMTP id 5a478bee46e88-35111502821mr391268eec.31.1790963457884; Fri, 02 Oct 2026 10:50:57 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:50:56 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 01/27] accel/tcg: move helper_exit_atomic next to cpu_loop_exit_atomic Date: Sat, 3 Oct 2026 01:50:09 +0800 Message-ID: <20261002175037.1747-2-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1333; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x1333.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org helper_exit_atomic only forwards to cpu_loop_exit_atomic. Define it in cpu-exec-common.c with that function, and move its DEF_HELPER line to cpu-exec-common.h. That file emits helper_info_exit_atomic. tcg-runtime.c keeps the integer helpers. Signed-off-by: Yonggang Luo --- accel/tcg/cpu-exec-common.c | 10 ++++++++++ accel/tcg/cpu-exec-common.h | 2 ++ accel/tcg/tcg-runtime.c | 8 -------- accel/tcg/tcg-runtime.h | 2 -- include/exec/helper-gen-common.h | 4 ++++ include/exec/helper-proto-common.h | 4 ++++ 6 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 accel/tcg/cpu-exec-common.h diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 68077c8fd9d..d20cece1c5f 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -23,8 +23,13 @@ #include "qemu/plugin.h" #include "qemu/main-loop.h" #include "accel/tcg/cpu-loop.h" +#include "exec/helper-proto-common.h" #include "internal-common.h" +#define HELPER_H "accel/tcg/cpu-exec-common.h" +#include "exec/helper-info.c.inc" +#undef HELPER_H + bool tcg_allowed; /* @@ -120,3 +125,8 @@ void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) cpu->exception_index = EXCP_ATOMIC; cpu_loop_exit_restore(cpu, pc); } + +void HELPER(exit_atomic)(CPUArchState *env) +{ + cpu_loop_exit_atomic(env_cpu(env), GETPC()); +} diff --git a/accel/tcg/cpu-exec-common.h b/accel/tcg/cpu-exec-common.h new file mode 100644 index 00000000000..19359a97bae --- /dev/null +++ b/accel/tcg/cpu-exec-common.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index 7c0aab98a80..764c62c684d 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -23,10 +23,7 @@ */ #include "qemu/osdep.h" #include "qemu/host-utils.h" -#include "exec/cpu-common.h" #include "exec/helper-proto-common.h" -#include "accel/tcg/cpu-loop.h" -#include "accel/tcg/getpc.h" #define HELPER_H "accel/tcg/tcg-runtime.h" #include "exec/helper-info.c.inc" @@ -129,8 +126,3 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg) { return ctpop64(arg); } - -void HELPER(exit_atomic)(CPUArchState *env) -{ - cpu_loop_exit_atomic(env_cpu(env), GETPC()); -} diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 0b832176b33..9b4c1c24916 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -22,8 +22,6 @@ DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env) -DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) - #ifndef IN_HELPER_PROTO /* * Pass calls to memset directly to libc, without a thunk in qemu. diff --git a/include/exec/helper-gen-common.h b/include/exec/helper-gen-common.h index 834590dc4e5..ed5521ad881 100644 --- a/include/exec/helper-gen-common.h +++ b/include/exec/helper-gen-common.h @@ -7,6 +7,10 @@ #ifndef HELPER_GEN_COMMON_H #define HELPER_GEN_COMMON_H +#define HELPER_H "accel/tcg/cpu-exec-common.h" +#include "exec/helper-gen.h.inc" +#undef HELPER_H + #define HELPER_H "accel/tcg/tcg-runtime.h" #include "exec/helper-gen.h.inc" #undef HELPER_H diff --git a/include/exec/helper-proto-common.h b/include/exec/helper-proto-common.h index 76e6c25becb..28afa7782d0 100644 --- a/include/exec/helper-proto-common.h +++ b/include/exec/helper-proto-common.h @@ -9,6 +9,10 @@ #include "qemu/atomic128.h" /* for HAVE_CMPXCHG128 */ +#define HELPER_H "accel/tcg/cpu-exec-common.h" +#include "exec/helper-proto.h.inc" +#undef HELPER_H + #define HELPER_H "accel/tcg/tcg-runtime.h" #include "exec/helper-proto.h.inc" #undef HELPER_H From patchwork Fri Oct 2 07:50:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=bOVnEl2t; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGZr3Bb6z1yFw for ; Sat, 03 Oct 2026 03:52:36 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChPg-0003n9-JS; Fri, 02 Oct 2026 13:51:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChPY-0003h1-MY for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:08 -0400 Received: from mail-dy2-x0f.google.com ([2607:f8b0:4864:36::f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChPX-0007Ii-1X for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:08 -0400 Received: by mail-dy2-x0f.google.com with SMTP id 5a478bee46e88-33e46a15703so7334780eec.0 for ; Fri, 02 Oct 2026 10:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963465; x=1791568265; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oEyujAwpsRaAxwTHH646nyJUYrC5y703ZAv6Bnw+1fA=; b=bOVnEl2txH0efrZPUoRziRjUAWG+AK1niWwZdXztHT53TZP4bfw0RUDDHLBpYp3/Ud noCSUB0yfAro2NbI5ANjp5m5HCO733mj3FCd2HAi4fMf7VRusmmnloNXWghrt5mUFYWc +hr3XHsf/Ni1DN9xEGyYo44bv32Y95gtlpXH6msATbD820o62nBaje7B6VXCdy+5Tw6H m1NQhx+iOI3tTfHFw4hPGc6hg4QlOu+5zDXz7qRudCzwYPP0JE1jDnhBKZ5AmNXlSFzu YlPvVkE4B6XjjlUardtLhEENQqDxxdTw2FMGUt+ALNDQfj5fp1lBfsV+fsDjEt6+wMlY 2PXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963465; x=1791568265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oEyujAwpsRaAxwTHH646nyJUYrC5y703ZAv6Bnw+1fA=; b=j5bmZK6HKbqeqQE639e9yyujXnMLmxHfVXZZ7RA0RK3kv/ooZl0Uip6Y80y/7sPakH tlfPSeYO1zGOe0/vdwEe6lhD9jetBaMku3DzObUJ2FrOWPlYdS0Nn0n+goS1ofPUnlyP K04HZY0c/h0ideDXqBpcEjA53YUkVUSAc+IcyHdQy5N4nJBmRv+P5a4oJJ0R7oDISMta Udm2GqnGIzXeD4gRX2X4/NMCsawdpaBfsONOKhKdAZrOEqFHRw7tdQGf7WVYxyNd5AVl UdhiJhpp4C3Elwk5aUfwhVmW6DEF9fpmpIF+17dZe2l7BRPlxuLK1DayWwU7DkY72Q19 g9OA== X-Forwarded-Encrypted: i=1; AKwUvBx7TEQB0YSrcpEjnEK7PWFqrAlxoJb9wvJQEC346iz3G82hEpMUTBhFs4ObBo8CrV1ZcPjyfQoUlQ==@nongnu.org X-Gm-Message-State: AFq9FYIPP+uMDEexvWrQ7j+CJ3mzVfSvRkkVOI8/59LD+iLD/EkB50In yDHTIvHbLW6+inun83XWqjlYSkbb3mBC1466pvxdIONXfbv9yXm7DbqN X-Gm-Gg: AYBFou2I2qampZfpVUkI1YPXSLjDMwxYoRp3F+IpKh/UMOrkTVm7ZZEostFEn0CQORJ VnQ/Mi37NB/E/IkqgKJjkyYPKL4DO0TpvQxrmV/cPxM8I1Fq4SBGY2S/fj5PfTXlC0u0cFYQKqX izpoFmBXYGoRsBmu468Pzzk4OnWtd4q+O0Nt5sE+J/lg9Bkaxwp1cYca+ssk7bhGVyc4cY+4m6H sl9I7DTfyHBruCAnSqkS7isrndZp4RthAm3ADDY79IzkYrHPu6sryJdrmoTpCwe5iH7hkdFYXqX qkg7kKxvJF/1tFxbZNJyI8iekPkkd0rMEe6zbJaVu2rqOexf/Cj8+TXUj8y+9BAJpL8IB5sn6ZC kGqOgDB0a8w9j7SVQbMfFLhnLlM4Llwr1Xh6gfg5Q0dKkQi9I4ZNe+L6edP/RyuP11TpXfKuDC4 R8TsH+E8H0qIEzSxiRvYdBeESslrf95Nm9ROJ5iADGi5A4jfVuMguzxMnYZMELLJyVmUhjsP4YJ L9p28b3v3cZzav1rX6rjEWMKTBOSfk= X-Received: by 2002:a05:7301:707:b0:34a:e4f6:4a4b with SMTP id 5a478bee46e88-34f150c3c64mr3357679eec.21.1790963465441; Fri, 02 Oct 2026 10:51:05 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:04 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 02/27] accel/tcg: add cpu_raise_excp and cpu_raise_excp_restore helpers Date: Sat, 3 Oct 2026 01:50:10 +0800 Message-ID: <20261002175037.1747-3-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::f; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0f.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, FREEMAIL_FROM=0.001, 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-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add cpu_raise_excp without host state restoration and cpu_raise_excp_restore with explicit state restoration. Signed-off-by: Yonggang Luo --- accel/tcg/cpu-exec-common.c | 13 +++++++++++++ include/accel/tcg/cpu-loop.h | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index d20cece1c5f..b551c1439ec 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -118,6 +118,19 @@ void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) cpu_loop_exit(cpu); } +void cpu_raise_excp(CPUState *cpu, int exception_index) +{ + cpu->exception_index = exception_index; + cpu_loop_exit(cpu); +} + +void cpu_raise_excp_restore(CPUState *cpu, int exception_index, + uintptr_t retaddr) +{ + cpu->exception_index = exception_index; + cpu_loop_exit_restore(cpu, retaddr); +} + void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) { /* Prevent looping if already executing in a serial context. */ diff --git a/include/accel/tcg/cpu-loop.h b/include/accel/tcg/cpu-loop.h index f4d38bc2bca..5282c70d5e4 100644 --- a/include/accel/tcg/cpu-loop.h +++ b/include/accel/tcg/cpu-loop.h @@ -65,6 +65,28 @@ G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t host_pc); G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t host_pc); +/** + * cpu_raise_excp: + * @cpu: the cpu context + * @exception_index: EXCP_* or target trap number + * + * Raise @exception_index and exit the current TB without restoring guest + * state. + */ +G_NORETURN void cpu_raise_excp(CPUState *cpu, int exception_index); + +/** + * cpu_raise_excp_restore: + * @cpu: the cpu context + * @exception_index: EXCP_* or target trap number + * @retaddr: the host pc within the translation + * + * Raise @exception_index and exit the current TB. Restore guest state from + * @retaddr when nonzero; otherwise, behave like cpu_raise_excp(). + */ +G_NORETURN void cpu_raise_excp_restore(CPUState *cpu, int exception_index, + uintptr_t retaddr); + /** * cpu_loop_exit: * @cpu: the cpu context From patchwork Fri Oct 2 07:50:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ET9WTKKN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGfQ3mq9z1xxW for ; Sat, 03 Oct 2026 03:55:42 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChQ8-00044w-87; Fri, 02 Oct 2026 13:51:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChPh-0003ne-Cl for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:17 -0400 Received: from mail-dy2-x0e.google.com ([2607:f8b0:4864:36::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChPe-0007Jg-MB for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:17 -0400 Received: by mail-dy2-x0e.google.com with SMTP id 5a478bee46e88-3510b42f4e3so597901eec.2 for ; Fri, 02 Oct 2026 10:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963473; x=1791568273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kLOBJyItJ1+wNCmx4Q5Z29VyAFIZnj6HoQfSvPthpZk=; b=ET9WTKKNOsAYEA+HuRudT08kUE8vVbVJxBXLVf6gzjoFDQ1XhmkZU1rA9wbIzvrmnV H0CCu0KJfSewgJOr1D/OUU5qTHHY0PRD6sScrNFnTYCkGTBSp3GjX+QfoE8ROETVM75E PDXxCXBglB3NimuXAjIMRLCoQTzdGxWRFSO98Mf2ns9Tuy6iCq3l2AQAWoC2ji4vOFp5 T45McXq1mqe8spVRN0NqXcnxtNTo1VtiJxm+Fa5xx6CkeWfQ8Ya5p22afIuIgnpqsYu0 g1YKQtiJUBgudC9jbOcQ5ea8+2GydZzrij5murSKr7v6xr4wXGDXxizsLftUCLIKVfnJ qhzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963473; x=1791568273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kLOBJyItJ1+wNCmx4Q5Z29VyAFIZnj6HoQfSvPthpZk=; b=nDvdVgyuFzOl0s0ls/EkGMM6sSW/e0eqOUQxo+So24CMvN0VvnJZRcUV8XtV9CRbHC bdHuLlKmYWKXtn4TrMo0o5IG5vE7zfBKTIAOdQas0/wmQFhNcGNAURM8BF7lnbMXb4SK f9MF2UVWPT7hqSJ+WEwH8rDZgdqgX5kZuAmybl2fvf3LUCSVoZdUGEO54xEgBwDx1X/S wbIJ38kppLus0xNBf5V15WOEd8EEvP5Vcn41y0j/lp0nxwpxQfr3tMUIIT9bGxTVB2NT cf9Vg2dv83d5wqXLxhSKKogC9Ncvms5TAh6N7xCq5rFYdLcb+wnuBqoaL9Q8ZdBezOUj RWjQ== X-Forwarded-Encrypted: i=1; AKwUvBx0E6UMpulmplG8JMvn4VQf2G5mdhYkcs3IxPufAzxofIk8fTLXv0pKSg0FWUkwXTiLcuWO2jDNCA==@nongnu.org X-Gm-Message-State: AFq9FYLOM424Gyvxs0lH9nDZQ1P/Z2yAx5fht7PJDBmJWjwlccCoidy7 3Vlnljw6vm0DjO3Qo0quk+IA81DOK0p0ike+rozrOCYqHEJwz1RI3f4w X-Gm-Gg: AYBFou1Cxjts2tH5tumlVRTE5hqUGsFaRbBWNrMK0PDS0Sp2H99F5KDrMEYHO8w7EJB TKCOABFk7L2N/2OafRsa69IqOHddlqOvQ1Z/Wph8YvVMECSg9jZvsEnAYv27Fi4w0bgz8j9Xg5F hnxQ9XHQtrNvwKBu17CDNPsNYYm5zfFwCn1OdNpXD/qE18yvluDYk5ckYDrgjCERq1mM+HfNqYk F2ynaZIsP5aTmahvkEnJVQdJQ3wSMJFTwU0GiiL/WbLGzNFLvYeWrIOMlCFvAp9RAe24MczPSms JxLI97I72qZNTMCUDLJ2NCVOcBEm7RxQN0pS6L0tHGZ4JSC9JKMATqHJkJd6o4CiBajSLui8c9M xXJ4JSP1HgRIkOxQ74Y1zGIwHuuVCgZq6R3FoNjq21UQ09vPHcXXrefTw8+nZNNigy9XW8urGUU 688xOkIMPvqd43nvH01Z4tudVSM2usOiWSIzWd5sDb2hMxkfUL++q/EBAv8Q9IM0bIFn7N5IfOF TK6vJA+4pQxVzcSGJXx8LjZYPyFkzk= X-Received: by 2002:a05:7301:b0a:b0:344:1bd9:1f0d with SMTP id 5a478bee46e88-34f150d42e6mr3480798eec.21.1790963473082; Fri, 02 Oct 2026 10:51:13 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:12 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 03/27] accel/tcg: add raise_excp and raise_excp_restore generator helpers Date: Sat, 3 Oct 2026 01:50:11 +0800 Message-ID: <20261002175037.1747-4-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::e; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0e.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Yonggang Luo --- accel/tcg/cpu-exec-common.c | 12 ++++++++++++ accel/tcg/cpu-exec-common.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index b551c1439ec..715e3cb327c 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -131,6 +131,18 @@ void cpu_raise_excp_restore(CPUState *cpu, int exception_index, cpu_loop_exit_restore(cpu, retaddr); } +/* Raise exception and exit the TB without restoring guest state. */ +void HELPER(raise_excp)(CPUArchState *env, uint32_t exception) +{ + cpu_raise_excp(env_cpu(env), exception); +} + +/* Raise exception and exit the TB, restoring state from GETPC(). */ +void HELPER(raise_excp_restore)(CPUArchState *env, uint32_t exception) +{ + cpu_raise_excp_restore(env_cpu(env), exception, GETPC()); +} + void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) { /* Prevent looping if already executing in a serial context. */ diff --git a/accel/tcg/cpu-exec-common.h b/accel/tcg/cpu-exec-common.h index 19359a97bae..1e82f3b14d3 100644 --- a/accel/tcg/cpu-exec-common.h +++ b/accel/tcg/cpu-exec-common.h @@ -1,2 +1,4 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) +DEF_HELPER_FLAGS_2(raise_excp, TCG_CALL_NO_WG, noreturn, env, i32) +DEF_HELPER_FLAGS_2(raise_excp_restore, TCG_CALL_NO_WG, noreturn, env, i32) From patchwork Fri Oct 2 07:50:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315236 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=dlxvVWh5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGbq0Y9wz1yFp for ; Sat, 03 Oct 2026 03:53:27 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChQj-0004ZD-Af; Fri, 02 Oct 2026 13:52:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChPs-0003sd-8u for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:30 -0400 Received: from mail-dy1-x132f.google.com ([2607:f8b0:4864:20::132f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChPo-0007Ka-Pe for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:28 -0400 Received: by mail-dy1-x132f.google.com with SMTP id 5a478bee46e88-3282db206d3so6430129eec.0 for ; Fri, 02 Oct 2026 10:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963481; x=1791568281; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=NztR+mMu/kxVkbQISDdOFa5VSRkwOwOsIq56cZDD+0s=; b=dlxvVWh5HxWkzqPDJMZFreb2z4rwm+4neF8E0k6xYL36ZZhplD+WONvNnBly8gCPi9 kuG1wp1bcAR/1HKTo4gjgGQlBmT9k9L+dJACH8Ia3/tWXmw6GZPSbXL7Nbxui8OIrxIL OB4mk72qlHa7ZjGt4sfCH8lEqnmX/4bagK1WkggX+37iMMerLbBPkEG4S2WcOJvqT7s5 TWgEWUUdCJVZtcuq1MyppDlKoWQIPQPFhFfen1uvQe+axL09Vf/T/fMLb+VdG/+Cvdcb sNUTKtEv4dYQEC1lB+CD8yjayixFXlScbHTJxm0Qd7ARVvszzmYRAL0/ZTq+rLLL0Cd+ 549w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963481; x=1791568281; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NztR+mMu/kxVkbQISDdOFa5VSRkwOwOsIq56cZDD+0s=; b=mzxG2o+ySM1f/cNe7WIgQNDL5XIKoXT5t4ArSfo2YXJPMCldlCYd43O+BmndneZQr1 wCdNNg6kpRrT/WnLuNdcRV1Mu85nazmZU7iMjRDmkHdcRhFW6bZ8FBoexxmZyv11IDki C2RekX3h/YpEr0nvXXkhAmyRess03u5AnkvhOT9K9wDCz/IWWA5TtcAmxbANbb9PCD3z iDNPzYUGoAZFYV6q5Dqd3o1+VryCeQ2zPcjb/WSHKiWaZAAFOZ8G060MoLK/Or5AygCx TJBDe8eURiFhcxFAXOpL8a0Nb145LxhFN+WPFXz6k4wJRbk5qHUVtS1begjnAhu2AqEi 45lw== X-Forwarded-Encrypted: i=1; AKwUvBwH8jFXTBJzOWZlRVZJwOR/YVbLoQ1DohxBvM63ubZoeoiFdHQjGp8m8XMX3Ass57pwGljY3nM4UA==@nongnu.org X-Gm-Message-State: AFq9FYLG9tK32XeqENXHdnSLoJ1ZK3xKbi0MczLEFjwx1KbRsSJHfnoE QV7LAT864IGZEBAK06GTqS3MbGsWAIzbVuwk9VoCjNthlVesMv7xJR5w X-Gm-Gg: AYBFou1RYGP4xbPwdiorSvurBI9ECmmTruNdQ8Z17ZJQ3N+cakLGxbfkEV73tnSDSbe sWFFZBX3tsneVzGIAYluvSeg3WQgfIJs9LcDLqd32FhQJI8uUFblSGFh+8ucJF4lYb/lpcO4+rw 9N0P4+epk6rqkJYufSJh/DdiZblm9Od8UmWr8CsFhQt+BwHU0HxE4MerSXGLQludg/1i66LPLih TVqyA6wWpVFMghcdF5bEfb426ssNuhTG8sX+Zasu9s4YSfwgnCgkN3dS+mo0r8iKJuSr9+jd19j F5Yf06LusubVqpxz7AaUJyF9lTvTo96PdRkLUY0nocjV/r2sgxicH9SwySnEkisBp6KHjJOzC/s 7kKbdJwstQtNgZlE84XhJuASpn00yjryZ9Ervb5EtG1VAVkkZxsW6ANmRRihPAYwSKJCxe0Tnyk cC5FofsLfQmKkTcq4nOL//lbqgFrRPq3yzshdwp11hLOyycXNq6RyBHS8BC5ehf1fCg1K+MmtqS VGo6KruZE9srYtUGBoxlIGWdfO2C6c= X-Received: by 2002:a05:693c:88cd:20b0:342:d7a0:2f40 with SMTP id 5a478bee46e88-3511162fa7emr336824eec.7.1790963480670; Fri, 02 Oct 2026 10:51:20 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:20 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 04/27] target/rx: Unify BRK and INT trap handling Date: Sat, 3 Oct 2026 01:50:12 +0800 Message-ID: <20261002175037.1747-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::132f; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x132f.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Philippe Mathieu-Daudé BRK is equivalent to INT #0, so route both instructions through the same trap helper. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- target/rx/helper.h | 3 +-- target/rx/op_helper.c | 7 +------ target/rx/translate.c | 19 +++++++++---------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/target/rx/helper.h b/target/rx/helper.h index 8cc38b0cb71..f3897ce7619 100644 --- a/target/rx/helper.h +++ b/target/rx/helper.h @@ -2,8 +2,7 @@ DEF_HELPER_1(raise_illegal_instruction, noreturn, env) DEF_HELPER_1(raise_access_fault, noreturn, env) DEF_HELPER_1(raise_privilege_violation, noreturn, env) DEF_HELPER_1(wait, noreturn, env) -DEF_HELPER_2(rxint, noreturn, env, i32) -DEF_HELPER_1(rxbrk, noreturn, env) +DEF_HELPER_2(trap, noreturn, env, i32) DEF_HELPER_3(fadd, f32, env, f32, f32) DEF_HELPER_3(fsub, f32, env, f32, f32) DEF_HELPER_3(fmul, f32, env, f32, f32) diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c index 36df7d377e5..6782912247e 100644 --- a/target/rx/op_helper.c +++ b/target/rx/op_helper.c @@ -455,12 +455,7 @@ G_NORETURN void helper_wait(CPURXState *env) raise_exception(env, EXCP_HLT, 0); } -G_NORETURN void helper_rxint(CPURXState *env, uint32_t vec) +G_NORETURN void helper_trap(CPURXState *env, uint32_t vec) { raise_exception(env, 0x100 + vec, 0); } - -G_NORETURN void helper_rxbrk(CPURXState *env) -{ - raise_exception(env, 0x100, 0); -} diff --git a/target/rx/translate.c b/target/rx/translate.c index 132d495710c..d0910fbf8e7 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2170,26 +2170,25 @@ static bool trans_RTE(DisasContext *ctx, arg_RTE *a) return true; } -/* brk */ -static bool trans_BRK(DisasContext *ctx, arg_BRK *a) +static bool do_trap(DisasContext *ctx, uint8_t vec) { tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next); - gen_helper_rxbrk(tcg_env); + gen_helper_trap(tcg_env, tcg_constant_i32(vec)); ctx->base.is_jmp = DISAS_NORETURN; return true; } +/* brk */ +static bool trans_BRK(DisasContext *ctx, arg_BRK *a) +{ + return do_trap(ctx, 0); +} + /* int #imm */ static bool trans_INT(DisasContext *ctx, arg_INT *a) { - TCGv_i32 vec; - tcg_debug_assert(a->imm < 0x100); - vec = tcg_constant_i32(a->imm); - tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next); - gen_helper_rxint(tcg_env, vec); - ctx->base.is_jmp = DISAS_NORETURN; - return true; + return do_trap(ctx, a->imm); } /* wait */ From patchwork Fri Oct 2 07:50:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=SHu+hQ+g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGZr1KC6z1yFp for ; Sat, 03 Oct 2026 03:52:36 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChQU-0004Lt-Hx; Fri, 02 Oct 2026 13:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQ0-0003wK-2w for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:37 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChPu-0007Lr-Jq for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:34 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34c0b552ccfso2208359eec.3 for ; Fri, 02 Oct 2026 10:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963489; x=1791568289; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=KOKjr5kL2cfyDpx78RWp9rg/JdrEjZ2P/SgqMSLCZd0=; b=SHu+hQ+gnMhMAsqexM13e18PtrGNi1aepcus1+Q3ILwZjTi02NzA8Bqzh6OJJRxV5p 8DCsY4gQhnGcmFRmDSWw62zYS6DNfcN26cEFw8P3nV8lmjr76LzGFEQxFVexyWkAzLuJ RiPgBCmmHn4bYH5Gvp2Rr7dXMcLfyEDzlOQ9qF/jL4I1euJykJC0BXUT2gz2GJl3vs0g QwRDPndVBC3L2d156UW/D/VoQHT1KFr8AAuIl1S3yhSE+sAPHfq6Q4DneX+QTzgNrK88 LP/iUZ1X47rSD2Zge+bl9nzCV22qtayoQ8MNOsnguXnjvDkFAtU3cuMRib5MHl1LYPXB ZIMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963489; x=1791568289; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KOKjr5kL2cfyDpx78RWp9rg/JdrEjZ2P/SgqMSLCZd0=; b=hHKcTaBrrDHMc3SPjlq1+TJyVTSGPwWuy1xQEVtDxVGETPABGoOuLPzhOPqcQu5bX0 Bj3fc0d6NeRTA5XJwDqWzgh6BXG5l44QeyfzE+Jh1GiVAZslLlFyvA4iqw/QREzMTpap U0VANo4elGoTY+HzC9C3ucy/Rv3hBv1EoPLtAqd6RDox7VIYILKWOUbZSnGkOgcxIRr9 R6i4hbks5FCgIGOtBA6TCY5zFKcnvr5opqH0VJKEZX/VSVj9tpf0MmIXouaF13eL/Erw qxlWOj7wX07B/HpVyKK1Jrgwqtus3CbQZI+s3Lbx2029bvNPhSMyzZZ0ccMMYVUTssxi rtgQ== X-Forwarded-Encrypted: i=1; AKwUvBy4vrK3CcCUxV2fL7Cmd2Vpggep0Zl3xEeZVbVCfHiq32C87tDzmKdK8ScfhogrFUxRNXcuO/1qlQ==@nongnu.org X-Gm-Message-State: AFq9FYLEZtXajME9TIh66dHu/xNw7AwW+wrCjrezOdJKjp23Uef9cg1l FJeeI2hDvWAbww863GWZlfNGcLBD9wrdSlwgRI2g5OkpipE1SOY0wBNo X-Gm-Gg: AYBFou2SRgDxd6CHRLJgdY1l5gJAqvLufi3IgT5+KJPGKZ3qOc7B6YgZFZitfm9VgG0 Y/wRwwTtETRQ5Lu8jxEwsyGF8BoFcDlYozhNX5tXXbkrxClGsxBYAS4Wqvn9/WZe3279mMZkyA6 6YDoyrrYB7ojaHF5cdIpzPfcipmrRws9PQE6xAgGOuwIn5KVpMqO8IY6tgZfjibnKivG/KxCvGd wcuoL+epQlrlHiKs0S8Siw9P8V4am1vtx1AIkcMY9u5796rJ/cqJk5YfrvXP5BVSIx1NHnqmzIZ uhgC4NyZANQCPfiISjAjd5FI2v5iTmLZpqOqex6a1aTt6aChucmEf2nHxkFyO8iCBecNheCoWke hhNQyLPd5gHSWhLpeVGeNxl5wmUill6fwkeXAndBYvT4q4+AzWyuuw38aY+L2aaU3s+oOhlVxCU 8WeYPrd/jPIvvxPOoZy4wSf3wnBC69LoXnN6lMQZhw98CeUp8qZXUtQnoFfSSDEPZ+MYDE0ptyP fH/XNjHNSkkT2IdvZrr6VkFoAkM+Nk= X-Received: by 2002:a05:7301:4547:b0:33b:e75b:cc42 with SMTP id 5a478bee46e88-34f150c2f6amr3123645eec.19.1790963488833; Fri, 02 Oct 2026 10:51:28 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:27 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 05/27] target/rx: Define exception vector constants Date: Sat, 3 Oct 2026 01:50:13 +0800 Message-ID: <20261002175037.1747-6-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Name RX exception vectors and trap ranges, and use the definitions throughout exception handling and exception raising. Assert that exception indexes remain within the defined range before accessing their vector tables. Signed-off-by: Yonggang Luo Co-developed-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- target/rx/cpu.h | 13 +++++++++++++ target/rx/helper.c | 21 +++++++++++---------- target/rx/op_helper.c | 10 +++++----- target/rx/translate.c | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/target/rx/cpu.h b/target/rx/cpu.h index 64ba48a7329..0d9f4898a26 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -71,6 +71,19 @@ enum { NUM_REGS = 16, }; +#define RX_EXCP_TRAP_COUNT 0x100 + +enum { + RX_EXCP_PRIVILEGE_VIOLATION = 20, + RX_EXCP_ACCESS = 21, + RX_EXCP_ILLEGAL_INSTRUCTION = 23, + RX_EXCP_FPU = 25, + RX_EXCP_NMI = 30, + RX_EXCP_TRAP_BASE = 0x100, /* Up to RX_EXCP_TRAP_COUNT */ +}; + +#define RX_EXCP_COUNT (RX_EXCP_TRAP_BASE + RX_EXCP_TRAP_COUNT) + typedef struct CPUArchState { /* CPU registers */ uint32_t regs[NUM_REGS]; /* general registers */ diff --git a/target/rx/helper.c b/target/rx/helper.c index 0f99279bbaa..bc76dd28ab3 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -86,13 +86,14 @@ void rx_cpu_do_interrupt(CPUState *cs) env->isp -= 4; cpu_stl_le_data(env, env->isp, env->pc); - if (vec < 0x100) { - env->pc = cpu_ldl_le_data(env, 0xffffff80 + vec * 4); - } else { + assert(vec < RX_EXCP_COUNT); + if (vec >= RX_EXCP_TRAP_BASE) { env->pc = cpu_ldl_le_data(env, env->intb + (vec & 0xff) * 4); + } else { + env->pc = cpu_ldl_le_data(env, 0xffffff80 + vec * 4); } - if (vec == 30) { + if (vec == RX_EXCP_NMI) { /* Non-maskable interrupt */ qemu_plugin_vcpu_interrupt_cb(cs, last_pc); } else { @@ -100,22 +101,22 @@ void rx_cpu_do_interrupt(CPUState *cs) } switch (vec) { - case 20: + case RX_EXCP_PRIVILEGE_VIOLATION: expname = "privilege violation"; break; - case 21: + case RX_EXCP_ACCESS: expname = "access exception"; break; - case 23: + case RX_EXCP_ILLEGAL_INSTRUCTION: expname = "illegal instruction"; break; - case 25: + case RX_EXCP_FPU: expname = "fpu exception"; break; - case 30: + case RX_EXCP_NMI: expname = "non-maskable interrupt"; break; - case 0x100 ... 0x1ff: + case RX_EXCP_TRAP_BASE ... RX_EXCP_TRAP_BASE + RX_EXCP_TRAP_COUNT - 1: expname = "unconditional trap"; } qemu_log_mask(CPU_LOG_INT, "exception 0x%02x [%s] raised\n", diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c index 6782912247e..d4e9ac2f192 100644 --- a/target/rx/op_helper.c +++ b/target/rx/op_helper.c @@ -115,7 +115,7 @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr) enable = FIELD_EX32(env->fpsw, FPSW, ENABLE); enable |= 1 << 5; /* CE always enabled */ if (cause & enable) { - raise_exception(env, 21, retaddr); + raise_exception(env, RX_EXCP_ACCESS, retaddr); } } } @@ -432,17 +432,17 @@ void raise_exception(CPURXState *env, int index, G_NORETURN void helper_raise_privilege_violation(CPURXState *env) { - raise_exception(env, 20, GETPC()); + raise_exception(env, RX_EXCP_PRIVILEGE_VIOLATION, GETPC()); } G_NORETURN void helper_raise_access_fault(CPURXState *env) { - raise_exception(env, 21, GETPC()); + raise_exception(env, RX_EXCP_ACCESS, GETPC()); } G_NORETURN void helper_raise_illegal_instruction(CPURXState *env) { - raise_exception(env, 23, GETPC()); + raise_exception(env, RX_EXCP_ILLEGAL_INSTRUCTION, GETPC()); } G_NORETURN void helper_wait(CPURXState *env) @@ -457,5 +457,5 @@ G_NORETURN void helper_wait(CPURXState *env) G_NORETURN void helper_trap(CPURXState *env, uint32_t vec) { - raise_exception(env, 0x100 + vec, 0); + raise_exception(env, RX_EXCP_TRAP_BASE + vec, 0); } diff --git a/target/rx/translate.c b/target/rx/translate.c index d0910fbf8e7..1bacc7adf92 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2187,7 +2187,7 @@ static bool trans_BRK(DisasContext *ctx, arg_BRK *a) /* int #imm */ static bool trans_INT(DisasContext *ctx, arg_INT *a) { - tcg_debug_assert(a->imm < 0x100); + tcg_debug_assert(a->imm < RX_EXCP_TRAP_COUNT); return do_trap(ctx, a->imm); } From patchwork Fri Oct 2 07:50:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=dXE3gDjw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGZR20bFz1yFp for ; Sat, 03 Oct 2026 03:52:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChQR-0004Hi-CG; Fri, 02 Oct 2026 13:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQ8-00045x-JL for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:44 -0400 Received: from mail-dl2-x0d.google.com ([2607:f8b0:4864:38::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQ3-0007Mt-HX for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:44 -0400 Received: by mail-dl2-x0d.google.com with SMTP id a92af1059eb24-148b5c829e8so6497515c88.0 for ; Fri, 02 Oct 2026 10:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963497; x=1791568297; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PgJUSeNzfpTZJWKv8Z1tYcQOVnoJ00PGHXu3FD5a7b8=; b=dXE3gDjwglvbxZojROo4YO5XvTL+xG9kpwiReBCG9umaibigFGmI0vmgjCdMFg5NTw zBAyTaVkAEnzgszigIjchjsSKRCRLxCQsbQo8NNNPD7KWXDIKQZkgbBCpwxBwaNKxuI2 i0PjQgF6ytyb9Ppe8+Sx7I7fyjTjFMpl9xDj3Vb2sAWcEnH6JN5cpgGsjT+VW23w1Ufz xkQYQ/h5jbTe81aEtkPQv0bmiQAnwCO8HV1/qfdHGAKYBLwfFJ9HpBXNblIPMEGD2bNA HKxHWFHqFSe2rMCN6Jox/NLv3TY0MeQTio2I5cfY+8v5VNQLVmhMKHAcG0wpt9h9+Wdj dX/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963497; x=1791568297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PgJUSeNzfpTZJWKv8Z1tYcQOVnoJ00PGHXu3FD5a7b8=; b=ymJXL3LkccES+8aus7XdmKn0nHVi4HdRT4WoNVVbUBx8Ct3c5ibK9hUxWHblrAJ3Qb LQgR+/qT94C3OG8Ucpy7ttrdY5YGKr80/1C9GfgTTNrbcjVi5Oy/7u0ddU4Obmv5dFG4 Alj7MR24WGWYEM7dIom/1huq4PLzTT6WWK4Yv5jE4W2pmhQKW8CyahYFlVA0uy/SflpJ jiKMz/5wfB42ijHIezsjcH9wQ70SvA/WDbontqfa+TxJs1yrC7gKAlwvbUoSguqtrRcS LzfH7YeCM6nSYjB8TTdj5L2PrizDL5PT+9Le7cxgrD3Gq8GnlSWYqmFktY7JQpCJ3QmY AzPQ== X-Forwarded-Encrypted: i=1; AKwUvBxrpwhHt+7Gp5Y9PhW9yo7q38BYOABdPwHZIeq1h0J9Vxn1Ggbbkvbm6I7+rLN7RxYXnIvzpJ0SkQ==@nongnu.org X-Gm-Message-State: AFuF++l3/0Y9TRW6zIvXEMTZFE1+0puAm9YsPIp2xHrqgZ03vY110kg5 wlkvJrKHG+kIrn6Nn49RkB/BgH20VJPCtWTOeTlhVf3cvSPPCejsih0M X-Gm-Gg: AYBFou2GbJ5onNTxtqahrq8WXvSvJqTyYt3TbPR+0an5XDbuGgvWwbQ7zSucpJafxuH nVJixVoHx8uPRLz+FHjAjHGAC6O2EBWRoo9tayQmsvU0D4R9gsrytJl1yxKYk18iVD1UphirSMF COxADXL5bkVwh85ilZ6fG7bapR446pD7c4kejP1ZojezUwuZwElKRBuHCjHepypw8UBe/a9CNBI py19Ulqf9IhNTzKDOWAEgiwGgt44xlnGwmvNgbAs8oL+zjmEyc9hrXhigltcilKRta8b5KfbxCi rQ+kduzOZMvE0H4nVQyl/gyXG/833dudEXZkRMlFaQw87WOFRXsr/whoEPdpdBukmE6bF6U4nRg o4CebZI403omBqOalnOcE8cpPoCd4zEAc/xMUW7oZcnNKpzO+9R+SBDpXeAdRDR62TgvamxPZnP gq3TEiOV2jnJ3JvsBIaaXkAJd9KKKDI94xQVxy1HkYbA8nhTNVxyPd8lhZ6I+cIjFZFUcq5titu peq4xbaWps0s4+7qNQMYAnSzLS5aCr9eTOvvBtxQw== X-Received: by 2002:a05:7022:f90b:b0:14c:be8e:69f2 with SMTP id a92af1059eb24-14f5c2ee7bfmr4546424c88.21.1790963497059; Fri, 02 Oct 2026 10:51:37 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:35 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 06/27] target/sh4: Define exception vector constants Date: Sat, 3 Oct 2026 01:50:14 +0800 Message-ID: <20261002175037.1747-7-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:38::d; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Name SH4 exception vectors and use the definitions throughout exception handling and exception raising. Signed-off-by: Yonggang Luo Reviewed-by: Philippe Mathieu-Daudé --- target/sh4/cpu.h | 21 +++++++++++++++ target/sh4/helper.c | 60 +++++++++++++++++++++--------------------- target/sh4/op_helper.c | 16 +++++------ 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 6984bb462fb..a1e9049b7be 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -135,6 +135,27 @@ typedef struct memory_content { struct memory_content *next; } memory_content; +/* Guest trap numbers. */ +enum { + SH4_EXCP_RESET = 0x000, + SH4_EXCP_MANUAL_RESET = 0x020, + SH4_EXCP_TLB_MISS = 0x040, + SH4_EXCP_DTLB_MISS_WRITE = 0x060, + SH4_EXCP_INITIAL_PAGE_WRITE = 0x080, + SH4_EXCP_TLB_VIOLATION = 0x0a0, + SH4_EXCP_DTLB_VIOLATION_WRITE = 0x0c0, + SH4_EXCP_ADDR_ERROR = 0x0e0, + SH4_EXCP_DATA_WRITE = 0x100, + SH4_EXCP_FPU = 0x120, + SH4_EXCP_TLB_MULTIPLE = 0x140, + SH4_EXCP_TRAPA = 0x160, + SH4_EXCP_ILLEGAL_INSTRUCTION = 0x180, + SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION = 0x1a0, + SH4_EXCP_USER_BREAK = 0x1e0, + SH4_EXCP_FPU_DISABLE = 0x800, + SH4_EXCP_SLOT_FPU_DISABLE = 0x820, +}; + typedef struct CPUArchState { uint32_t flags; /* general execution flags */ uint32_t gregs[24]; /* general registers */ diff --git a/target/sh4/helper.c b/target/sh4/helper.c index b6b057f104b..0fbd613f333 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -70,7 +70,7 @@ void superh_cpu_do_interrupt(CPUState *cs) do_irq = do_irq && (cs->exception_index == -1); if (env->sr & (1u << SR_BL)) { - if (do_exp && cs->exception_index != 0x1e0) { + if (do_exp && cs->exception_index != SH4_EXCP_USER_BREAK) { /* In theory a masked exception generates a reset exception, which in turn jumps to the reset vector. However this only works when using a bootloader. When using a kernel and an @@ -97,43 +97,43 @@ void superh_cpu_do_interrupt(CPUState *cs) if (qemu_loglevel_mask(CPU_LOG_INT)) { const char *expname; switch (cs->exception_index) { - case 0x0e0: + case SH4_EXCP_ADDR_ERROR: expname = "addr_error"; break; - case 0x040: + case SH4_EXCP_TLB_MISS: expname = "tlb_miss"; break; - case 0x0a0: + case SH4_EXCP_TLB_VIOLATION: expname = "tlb_violation"; break; - case 0x180: + case SH4_EXCP_ILLEGAL_INSTRUCTION: expname = "illegal_instruction"; break; - case 0x1a0: + case SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION: expname = "slot_illegal_instruction"; break; - case 0x800: + case SH4_EXCP_FPU_DISABLE: expname = "fpu_disable"; break; - case 0x820: + case SH4_EXCP_SLOT_FPU_DISABLE: expname = "slot_fpu"; break; - case 0x100: + case SH4_EXCP_DATA_WRITE: expname = "data_write"; break; - case 0x060: + case SH4_EXCP_DTLB_MISS_WRITE: expname = "dtlb_miss_write"; break; - case 0x0c0: + case SH4_EXCP_DTLB_VIOLATION_WRITE: expname = "dtlb_violation_write"; break; - case 0x120: + case SH4_EXCP_FPU: expname = "fpu_exception"; break; - case 0x080: + case SH4_EXCP_INITIAL_PAGE_WRITE: expname = "initial_page_write"; break; - case 0x160: + case SH4_EXCP_TRAPA: expname = "trapa"; break; default: @@ -161,18 +161,18 @@ void superh_cpu_do_interrupt(CPUState *cs) if (do_exp) { env->expevt = cs->exception_index; switch (cs->exception_index) { - case 0x000: - case 0x020: - case 0x140: + case SH4_EXCP_RESET: + case SH4_EXCP_MANUAL_RESET: + case SH4_EXCP_TLB_MULTIPLE: env->sr &= ~(1u << SR_FD); env->sr |= 0xf << 4; /* IMASK */ env->pc = 0xa0000000; break; - case 0x040: - case 0x060: + case SH4_EXCP_TLB_MISS: + case SH4_EXCP_DTLB_MISS_WRITE: env->pc = env->vbr + 0x400; break; - case 0x160: + case SH4_EXCP_TRAPA: env->spc += 2; /* special case for TRAPA */ /* fall through */ default: @@ -632,7 +632,7 @@ void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, hwaddr addr, CPUState *cs = env_cpu(s); /* Multiple TLB Exception */ - cs->exception_index = 0x140; + cs->exception_index = SH4_EXCP_TLB_MULTIPLE; s->tea = addr; break; } @@ -828,33 +828,33 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size, switch (ret) { case MMU_ITLB_MISS: case MMU_DTLB_MISS_READ: - cs->exception_index = 0x040; + cs->exception_index = SH4_EXCP_TLB_MISS; break; case MMU_DTLB_MULTIPLE: case MMU_ITLB_MULTIPLE: - cs->exception_index = 0x140; + cs->exception_index = SH4_EXCP_TLB_MULTIPLE; break; case MMU_ITLB_VIOLATION: - cs->exception_index = 0x0a0; + cs->exception_index = SH4_EXCP_TLB_VIOLATION; break; case MMU_DTLB_MISS_WRITE: - cs->exception_index = 0x060; + cs->exception_index = SH4_EXCP_DTLB_MISS_WRITE; break; case MMU_DTLB_INITIAL_WRITE: - cs->exception_index = 0x080; + cs->exception_index = SH4_EXCP_INITIAL_PAGE_WRITE; break; case MMU_DTLB_VIOLATION_READ: - cs->exception_index = 0x0a0; + cs->exception_index = SH4_EXCP_TLB_VIOLATION; break; case MMU_DTLB_VIOLATION_WRITE: - cs->exception_index = 0x0c0; + cs->exception_index = SH4_EXCP_DTLB_VIOLATION_WRITE; break; case MMU_IADDR_ERROR: case MMU_DADDR_ERROR_READ: - cs->exception_index = 0x0e0; + cs->exception_index = SH4_EXCP_ADDR_ERROR; break; case MMU_DADDR_ERROR_WRITE: - cs->exception_index = 0x100; + cs->exception_index = SH4_EXCP_DATA_WRITE; break; default: cpu_abort(cs, "Unhandled MMU fault"); diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 777380f8e40..8beac9ca034 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -33,10 +33,10 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr, switch (access_type) { case MMU_INST_FETCH: case MMU_DATA_LOAD: - cs->exception_index = 0x0e0; + cs->exception_index = SH4_EXCP_ADDR_ERROR; break; case MMU_DATA_STORE: - cs->exception_index = 0x100; + cs->exception_index = SH4_EXCP_DATA_WRITE; break; default: g_assert_not_reached(); @@ -67,22 +67,22 @@ void raise_exception(CPUSH4State *env, int index, void helper_raise_illegal_instruction(CPUSH4State *env) { - raise_exception(env, 0x180, 0); + raise_exception(env, SH4_EXCP_ILLEGAL_INSTRUCTION, 0); } void helper_raise_slot_illegal_instruction(CPUSH4State *env) { - raise_exception(env, 0x1a0, 0); + raise_exception(env, SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION, 0); } void helper_raise_fpu_disable(CPUSH4State *env) { - raise_exception(env, 0x800, 0); + raise_exception(env, SH4_EXCP_FPU_DISABLE, 0); } void helper_raise_slot_fpu_disable(CPUSH4State *env) { - raise_exception(env, 0x820, 0); + raise_exception(env, SH4_EXCP_SLOT_FPU_DISABLE, 0); } void helper_sleep(CPUSH4State *env) @@ -97,7 +97,7 @@ void helper_sleep(CPUSH4State *env) void helper_trapa(CPUSH4State *env, uint32_t tra) { env->tra = tra << 2; - raise_exception(env, 0x160, 0); + raise_exception(env, SH4_EXCP_TRAPA, 0); } void helper_exclusive(CPUSH4State *env) @@ -255,7 +255,7 @@ static void update_fpscr(CPUSH4State *env, uintptr_t retaddr) cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT; enable = (env->fpscr & FPSCR_ENABLE_MASK) >> FPSCR_ENABLE_SHIFT; if (cause & enable) { - raise_exception(env, 0x120, retaddr); + raise_exception(env, SH4_EXCP_FPU, retaddr); } } } From patchwork Fri Oct 2 07:50:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=XZ1y4xlE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGfh66DFz1xxW for ; Sat, 03 Oct 2026 03:55:56 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChTq-0008V9-9h; Fri, 02 Oct 2026 13:55:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQD-00049R-R8 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:52 -0400 Received: from mail-dy1-x132c.google.com ([2607:f8b0:4864:20::132c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQA-0007O5-Mc for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:49 -0400 Received: by mail-dy1-x132c.google.com with SMTP id 5a478bee46e88-32efd24b2aeso427992eec.1 for ; Fri, 02 Oct 2026 10:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963505; x=1791568305; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=X726aYrpD9juLsEOlPI9NMDBbZTvlx2zMhvFSPMsy/w=; b=XZ1y4xlE4kyR5EcYbgz5XkvXt5TxzodGuC5shAu2wvmD1bANicJxXzlWitWHhAcY7z tPZTnAW9gny5QetzGJV1zMe1OTcXbkG1dGdJwhNAeKmcrTJzkdSrq4o6FRj0pyvW5zMh O0J3k9meHpM5MVa88mOqdHk+bXUTLspciU+te03Ty9PyEoMO418/lkCyQp4nYXAOm7Ev QTuT3KsCXYd+rOFDXPhaSuabgoKsJJiLhUrlPRQCc77CcwYf5bTDJ+D2RqLJtGLTQOmt XVoRbMrR6zNsh9u2WNITUzo9bBy26VbIr39xMvkcpc4wIUmVT6SIhbHUZmYXtIvqFQx1 Y7Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963505; x=1791568305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=X726aYrpD9juLsEOlPI9NMDBbZTvlx2zMhvFSPMsy/w=; b=T0n2xyLqckF4YykCSOiWOlvbGDHmzrZLplzzPZ3GqN2pBc3Z73L2dElcU8LnE6zxjE BexmZRh10T4eM5c1QIZB1V3j0xGpj7N/BqQvDQX1qZ81QpS1vb69jkUvnF5iZm/mDZRV Ve7UscrvWVJU2orJEIfOJeNwasOvwT6T1NiShE+8u6Xfn3vYjHkj3D9X0xlQ6LuOtdas KIzdNCAHbwchnsweNIXn1q3WQPykYlwZTSPP26fMe3pAe5nV/TX3IeOchIy1pYFn3onb cPaARfKfV3Lliq7NiyJU4tcYuN6EQX/6W457UHt5Evjmd0mKbELlOuwjKMj+q+lirPho ELLA== X-Forwarded-Encrypted: i=1; AKwUvBwHu0DaQ/OpILlXkhbFTPcN40nN2emaq0T+uEAD8fB88YE6U4zKGubcEa2Ts1YIR0mTFBw9xqkfXw==@nongnu.org X-Gm-Message-State: AFq9FYL/eGzC9sUR4Pg/2Wplr/QOh/Db0F7MbAMvRNX+TzJ2tSAwoVuy vsc1BAZzUO50wtYVQkOXgYc7CN0QLkXnVrN8zS05r8setZ7kosghCbWt X-Gm-Gg: AYBFou15zYrimdKYXqGdaM78Ym728uxNuv1ICE1gEPI/5x/ABGM6uc2b7x0Rv93dHRa xzNMHKQoJVXW3tjlnZBzX3JnC1SBB+PkZ0vRUtaGydmjGkyav2qsgozQLxqj7fhMHxFzT6LAENe Fq2Q9VmHuznSpve8GmTxyO3FJpAIpi51pgBzXZy3nRaeMdKT0hV+1UiAq8cBhYKYMLjVXjavp4k gqo2GNljLgUekEPCdr6knrbgd+kvDVmJQSzqbXxovI+E8hqY3IcIvwn5kGwYk+nKhBpsqqNzBGe sQPecNWttLki17kZTsN57d9No/Dzy3aqH0KyJIP+K89g2vwFjN5eCDCSl2V4zR5JqhK2VVQmOxX 2pDoRKk0h2+ERQKmqgw7t5o2wV5Y7rQ4c5C1P0zvUjh+U2yigYMkeUO0sgZ06nRzl9Ce1J3dhNQ MZvLrlKx3WaOkwzfbQOEVB+BzIhJjami37+kqJdzdAfyufP8zHJ6bdHa+u9uDBVIMbaARdyTzq6 ZrtM7dRN0aVE+3FvmWbM4ZeWC8EA9qe X-Received: by 2002:a05:7301:4b10:b0:34b:c18d:c294 with SMTP id 5a478bee46e88-35111487d92mr347738eec.24.1790963504764; Fri, 02 Oct 2026 10:51:44 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:44 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 07/27] target/hppa: remove helper_excp Date: Sat, 3 Oct 2026 01:50:15 +0800 Message-ID: <20261002175037.1747-8-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::132c; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x132c.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the common raise_excp helper for translated exceptions and route the remaining C callers through cpu_raise_excp(). Signed-off-by: Yonggang Luo --- target/hppa/helper.h | 2 -- target/hppa/op_helper.c | 10 +--------- target/hppa/sys_helper.c | 5 +++-- target/hppa/translate.c | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 8369855d78e..5ed39e01e31 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -1,5 +1,3 @@ -DEF_HELPER_2(excp, noreturn, env, int) - DEF_HELPER_FLAGS_3(stby_b, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(stby_b_parallel, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tl) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 76a8d8a0d34..9c560a56d34 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -30,14 +30,6 @@ #include "user/page-protection.h" #endif -G_NORETURN void HELPER(excp)(CPUHPPAState *env, int excp) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = excp; - cpu_loop_exit(cs); -} - G_NORETURN void hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra) { CPUState *cs = env_cpu(env); @@ -341,7 +333,7 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr, if (excp == EXCP_DTLB_MISS) { excp = EXCP_NA_DTLB_MISS; } - helper_excp(env, excp); + cpu_raise_excp(env_cpu(env), excp); } return (want & prot) != 0; #endif diff --git a/target/hppa/sys_helper.c b/target/hppa/sys_helper.c index 88109f0181a..1c10d3d85b3 100644 --- a/target/hppa/sys_helper.c +++ b/target/hppa/sys_helper.c @@ -21,6 +21,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/helper-proto.h" +#include "accel/tcg/cpu-loop.h" #include "qemu/timer.h" #include "system/runstate.h" #include "system/system.h" @@ -51,13 +52,13 @@ void HELPER(write_interval_timer)(CPUHPPAState *env, target_ulong val) void HELPER(halt)(CPUHPPAState *env) { qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); - helper_excp(env, EXCP_HLT); + cpu_raise_excp(env_cpu(env), EXCP_HLT); } void HELPER(reset)(CPUHPPAState *env) { qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - helper_excp(env, EXCP_HLT); + cpu_raise_excp(env_cpu(env), EXCP_HLT); } target_ulong HELPER(swap_system_mask)(CPUHPPAState *env, target_ulong nsm) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 41300c0dd73..35766e6ee06 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -726,7 +726,7 @@ static void install_link(DisasContext *ctx, unsigned link, bool with_sr0) static void gen_excp_1(int exception) { - gen_helper_excp(tcg_env, tcg_constant_i32(exception)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(exception)); } static void gen_excp(DisasContext *ctx, int exception) From patchwork Fri Oct 2 07:50:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=PLtqjOXT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGfZ2mSMz1xxW for ; Sat, 03 Oct 2026 03:55:50 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChTQ-000712-KL; Fri, 02 Oct 2026 13:55:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQL-0004E2-Pv for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:01 -0400 Received: from mail-dy2-x0e.google.com ([2607:f8b0:4864:36::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQI-0007Qq-Nr for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:51:57 -0400 Received: by mail-dy2-x0e.google.com with SMTP id 5a478bee46e88-3510b42f4e3so598602eec.2 for ; Fri, 02 Oct 2026 10:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963512; x=1791568312; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sB6wgEvVNcwq25z55JvixoNQOs+J2ayZm8e/ED1pw70=; b=PLtqjOXTaKhUn3LWIHAhZahRHKiSWiIMF0Ulhhzm4AojXkwZ1/0Io3B8/WKoxt7aZ7 vtrRYdDdXXIIhHEZ0UJ/iekRENKmhVN0LZtn/zWRLpP/N8stKfQUPY5SdDUyA9PdpHWH 8JsWh1zZ7CAcs770B9AjpUtesH4Oj2HwcBzMU+uBG5vsg7DqlV7LKjESSsq8Vard0gTX ZzTcerOLVS1S8Y0P+yYCSyTYg/2RcmILUq1iG1N4ueJovQgXkBGvGwZGey/QFi9QE+QR nL4SNgs1MVC3fD1oKWhdj50X+tSN5ECFhsrqoB8DmsI+7NCVvDFG4fZUtH5IvPSAlxC0 UifQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963512; x=1791568312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sB6wgEvVNcwq25z55JvixoNQOs+J2ayZm8e/ED1pw70=; b=JHHAsxmNpxCAcPfe8pWgQMJw8KFXH4NEV3FsLWB+UwSsm1+LcsEF9dVtnfV1NF7LEa +lAabYNs+aiRdDcOYUC0l+6zQvMX8f+an3PaC0oH2h1ALq2ql2ZC+3XeEagrrEwugBjg EgTxD/YdGhX7CoB5fFpnoGOgJPEcP4ST4fPlX0mYMaV8+S4VGXb/MTL+Yej0dWSrEe0B uOEheac9TQb2URhBxp0ZmFGYHnTG5Xda3e1Q9IQAMgXTmFOjDMNQ6h+F9sq91mvSaxkQ oRetAH4BmThwelhpIDltW37kflUoACpYaqB4M9iEcM0nkoWaAlrIDZJ/a+4C6vQFzDB6 OrLw== X-Forwarded-Encrypted: i=1; AKwUvBxqRRHpWok1kG2/6H7J0QTyQUuo4yva12u7B6Di/K2c1h9+Xny1Mzsbj5D53Bp2siIuSbNhsrhCwQ==@nongnu.org X-Gm-Message-State: AFuF++klL5v5MFMwqpnadKvMKW7/7EnnzoB0CcIKQx5myn/AoU+3uILj QMZ1zb1j5mr3CP5qUMakA+3koqDl2Sb2v5ajR+eKA1uDEGYkv5YewfDA X-Gm-Gg: AYBFou0eFuz75vLz7hD7HgU72rWt/C4Ossifv9zRynbVQFzOpr9KHkoFiXS1we7U0J/ Xs6B9lw3I678s7vQHxyL78rHNNmgki86G81KjYzyccu/B9Zx8hOv1ksJc7dK0lwWeQzA902dOHC FCSYdPWuBwzQSHkMeO6Hn6ud+A6cfDwWkUoB7hw5PucnRsVnMiz7fwCrfyUeXSFtQAdD5CK6Bgu KGdcUhH3WSV+1X6iDZL2WaUAxYKjKm92tyRxHgVudcxaBBEYmFdsB4g24xxBs93NBGTbSG3SEbf rY3j0Qs+L3maSntYZtcZjX/J1rrbrxeql2p6iTguJySwPkPpIL5FhclXekvBKufAamIuM201lca 4pQweFoKFyI5LIh2V//EGINSPcgMcl+LgEFASuav6JhNkOl2Kt5vrat+JNolu0MO1FppuX7eRva +xFH16O013ZAmFLGOGoRc0zaIxVOK6CpR8uQlGj7mZrGGp94+6c0dZeOp1zJ8aYqOdPCS3eX3ME kl6jnG2lLxAz/LCSiQF64S3jvXmhCF+ X-Received: by 2002:a05:7301:b0a:b0:344:1bd9:1f0d with SMTP id 5a478bee46e88-34f150d42e6mr3482254eec.21.1790963512373; Fri, 02 Oct 2026 10:51:52 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:51 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 08/27] target/hppa: remove hppa_dynamic_excp Date: Sat, 3 Oct 2026 01:50:16 +0800 Message-ID: <20261002175037.1747-9-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::e; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0e.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use cpu_raise_excp_restore() for FPU exceptions and remove the redundant HPPA wrapper. Signed-off-by: Yonggang Luo --- target/hppa/cpu.h | 1 - target/hppa/fpu_helper.c | 3 ++- target/hppa/op_helper.c | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index f453444d7f9..da3cc15fe9a 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -407,6 +407,5 @@ extern const MemoryRegionOps hppa_io_eir_ops; extern const VMStateDescription vmstate_hppa_cpu; void hppa_cpu_alarm_timer(void *); #endif -G_NORETURN void hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra); #endif /* HPPA_CPU_H */ diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c index cdbebcfeb3a..1115b90407d 100644 --- a/target/hppa/fpu_helper.c +++ b/target/hppa/fpu_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" +#include "accel/tcg/cpu-loop.h" #include "fpu/softfloat.h" void HELPER(loaded_fr0)(CPUHPPAState *env) @@ -131,7 +132,7 @@ static void update_fr0_op(CPUHPPAState *env, uintptr_t ra) env->fr[0] = (uint64_t)shadow << 32 | fr1; if (hard_exp & shadow) { - hppa_dynamic_excp(env, EXCP_ASSIST, ra); + cpu_raise_excp_restore(env_cpu(env), EXCP_ASSIST, ra); } } diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 9c560a56d34..c1728f1fb91 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -30,14 +30,6 @@ #include "user/page-protection.h" #endif -G_NORETURN void hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = excp; - cpu_loop_exit_restore(cs, ra); -} - static void atomic_store_mask32(CPUHPPAState *env, target_ulong addr, uint32_t val, uint32_t mask, uintptr_t ra) { From patchwork Fri Oct 2 07:50:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IBzgNP/n; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGds2wKgz1yFp for ; Sat, 03 Oct 2026 03:55:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChRQ-0005DU-J3; Fri, 02 Oct 2026 13:53:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQR-0004Hj-FC for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:04 -0400 Received: from mail-dl2-x0f.google.com ([2607:f8b0:4864:38::f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQP-0007TA-EV for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:02 -0400 Received: by mail-dl2-x0f.google.com with SMTP id a92af1059eb24-145ab8fd39cso7272747c88.2 for ; Fri, 02 Oct 2026 10:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963520; x=1791568320; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=y/3BzewNHHqU34EleAU1q6MHo4NgKn6+G6D1GFCx46I=; b=IBzgNP/n57TiHf1rc7QhfcafTlQlny5MRPMI61AiGOZr9YeOXDif9f65f19rZd6SNj i8zk3VsSg8TIRD6ATit3D715/OApLTl8g9uFUnOR4ZVsRxR0pmoX+pizi8MNHjz3FUl8 XPp2PQ9/k4i/xPFIzD/jGVMw4pJ/OyNWSBe++ucRW/KASv+FUOWDUL0qZ+mryfEcceqP C3S2xknrpmwlZ708JFltW2px7bMHFjYuQBfgH6ne07QBGpRnk+J3vwbj2qL+Cj5s8TVA pmuJ/5/sVNAWpNAvNVt1Tgma897or3AZnybPldQpruKGqiIYiaGBQDiwBMnoHW9jz5GG OydA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963520; x=1791568320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=y/3BzewNHHqU34EleAU1q6MHo4NgKn6+G6D1GFCx46I=; b=tK327+yFujGp5JrwHjh8gqj6wUPVtUHMpJfi9Y2P78FSR1dC8fENClPjIiPs2xnwmK qlOsBTzut3JjaPx82H1Y/hqxlx3Mu+RQ2QrhlcTy8Jtsc2gVlYIRbrz3I81MCtkWKM64 ILmdcjUVl+cRUS3ulzyrcwi3w2S4CYLTAV99h+Y17S5krxiQkjO4x57MgohpIy8yLdS5 LsqgUpbYkTIN56NDOVP51xq7bDraOreE0pBEYD5X1gU+U/vnrrkATz9uAfz0CAq/uu0z VA6dTvUYkNmfQ6ssaSgbtuQ+Ms8qNU5uAktlOB/7FOlcq9nfgY2u745INTu69Ti3O+wT sCWA== X-Forwarded-Encrypted: i=1; AKwUvByLy3nS6j+H5EBkcR4JzoJ+L8FFbbQ4GtcS1hxPLrjcTORducq7nqkkmmHxvmjKusnIAplCZocl/Q==@nongnu.org X-Gm-Message-State: AFuF++mbBZHZ6VrDidE3GuhXcjWeT177oof/7SHxIvQHN1/tqxTRlTyo q/75YtGCRrnIAk862p2itFpaFBtoXT80Vgkpc0Aq0QilZDuQTVNed2lJ X-Gm-Gg: AYBFou1/idSBbV9tH515xP1trmRqwXs8kWm9HabNmSr9WpbObeH5NUCqzbB8N0J8itk WNs9VbrXOZPBlscMkfQxosGu364mzeSy1Pbple1e8lKoM6uEwMCIQq0+rPK9fTqH3cn9AzgmE06 rEAtv8uD2kiyWxRb2Vql7lAU3OP5zhaV32qSexN1nq7NoL0b1mFKtQe8EPxLPdwYKCp6i3uw9s/ vqjegxiQE3cxk6tSm8cPDCoeUqzBPjri45voSOV+aULgj5fKKGZejiTijF0L/c+SvdjSHXYURex UZ6gpQnYzHjuhWOXOpmHlhNnlc3UlERzjqAuGt8vrBIIsUpJoGTZBzDLjJi8+wS/gcBd4Dg28sQ u7d0azdqb7KOfXiNWwzHnCQoGLOmbcGdB9yqed3Js0frJQL3IYbgikNrQrKToKvG+n767AU3Q0q rh2G4Dwvbc3mTdwa8oNIrWDV9tcJW4lyJwxCCUUosN+6/Jq2l19Fqeeu0bzruOaY4Ry02ftivIX TE9x+OEV/McLtTWci+VkIShSedgnbU= X-Received: by 2002:a05:7022:eb47:20b0:14d:baf5:c419 with SMTP id a92af1059eb24-14f58de5556mr3709348c88.6.1790963520018; Fri, 02 Oct 2026 10:52:00 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:59 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 09/27] target/rx: convert raises to raise_excp Date: Sat, 3 Oct 2026 01:50:17 +0800 Message-ID: <20261002175037.1747-10-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:38::f; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x0f.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, FREEMAIL_FROM=0.001, 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-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Translate privilege and illegal instructions through the shared exception helpers, and use them for BRK, INT, FPSW, and WAIT paths where applicable. Remove the redundant RX exception helpers. Signed-off-by: Yonggang Luo --- target/rx/helper.h | 4 ---- target/rx/op_helper.c | 39 ++------------------------------------- target/rx/translate.c | 9 ++++++--- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/target/rx/helper.h b/target/rx/helper.h index f3897ce7619..c6a85e968d9 100644 --- a/target/rx/helper.h +++ b/target/rx/helper.h @@ -1,8 +1,4 @@ -DEF_HELPER_1(raise_illegal_instruction, noreturn, env) -DEF_HELPER_1(raise_access_fault, noreturn, env) -DEF_HELPER_1(raise_privilege_violation, noreturn, env) DEF_HELPER_1(wait, noreturn, env) -DEF_HELPER_2(trap, noreturn, env, i32) DEF_HELPER_3(fadd, f32, env, f32, f32) DEF_HELPER_3(fsub, f32, env, f32, f32) DEF_HELPER_3(fmul, f32, env, f32, f32) diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c index d4e9ac2f192..ccd20c43a62 100644 --- a/target/rx/op_helper.c +++ b/target/rx/op_helper.c @@ -25,10 +25,6 @@ #include "fpu/softfloat.h" #include "tcg/debug-assert.h" -static inline G_NORETURN -void raise_exception(CPURXState *env, int index, - uintptr_t retaddr); - static void _set_psw(CPURXState *env, uint32_t psw, uint32_t rte) { uint32_t prev_u; @@ -115,7 +111,7 @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr) enable = FIELD_EX32(env->fpsw, FPSW, ENABLE); enable |= 1 << 5; /* CE always enabled */ if (cause & enable) { - raise_exception(env, RX_EXCP_ACCESS, retaddr); + cpu_raise_excp_restore(env_cpu(env), RX_EXCP_ACCESS, retaddr); } } } @@ -419,32 +415,6 @@ uint32_t helper_divu(CPURXState *env, uint32_t num, uint32_t den) return ret; } -/* exception */ -static inline G_NORETURN -void raise_exception(CPURXState *env, int index, - uintptr_t retaddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = index; - cpu_loop_exit_restore(cs, retaddr); -} - -G_NORETURN void helper_raise_privilege_violation(CPURXState *env) -{ - raise_exception(env, RX_EXCP_PRIVILEGE_VIOLATION, GETPC()); -} - -G_NORETURN void helper_raise_access_fault(CPURXState *env) -{ - raise_exception(env, RX_EXCP_ACCESS, GETPC()); -} - -G_NORETURN void helper_raise_illegal_instruction(CPURXState *env) -{ - raise_exception(env, RX_EXCP_ILLEGAL_INSTRUCTION, GETPC()); -} - G_NORETURN void helper_wait(CPURXState *env) { CPUState *cs = env_cpu(env); @@ -452,10 +422,5 @@ G_NORETURN void helper_wait(CPURXState *env) cs->halted = 1; env->in_sleep = 1; env->psw_i = 1; - raise_exception(env, EXCP_HLT, 0); -} - -G_NORETURN void helper_trap(CPURXState *env, uint32_t vec) -{ - raise_exception(env, RX_EXCP_TRAP_BASE + vec, 0); + cpu_raise_excp(env_cpu(env), EXCP_HLT); } diff --git a/target/rx/translate.c b/target/rx/translate.c index 1bacc7adf92..e6541ad0ab8 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -245,7 +245,8 @@ static int is_privileged(DisasContext *ctx, int is_exception) { if (FIELD_EX32(ctx->tb_flags, PSW, PM)) { if (is_exception) { - gen_helper_raise_privilege_violation(tcg_env); + gen_helper_raise_excp_restore( + tcg_env, tcg_constant_i32(RX_EXCP_PRIVILEGE_VIOLATION)); } return 0; } else { @@ -2173,7 +2174,8 @@ static bool trans_RTE(DisasContext *ctx, arg_RTE *a) static bool do_trap(DisasContext *ctx, uint8_t vec) { tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next); - gen_helper_trap(tcg_env, tcg_constant_i32(vec)); + gen_helper_raise_excp( + tcg_env, tcg_constant_i32(RX_EXCP_TRAP_BASE + vec)); ctx->base.is_jmp = DISAS_NORETURN; return true; } @@ -2227,7 +2229,8 @@ static void rx_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) ctx->pc = ctx->base.pc_next; insn = decode_load(ctx); if (!decode(ctx, insn)) { - gen_helper_raise_illegal_instruction(tcg_env); + gen_helper_raise_excp_restore( + tcg_env, tcg_constant_i32(RX_EXCP_ILLEGAL_INSTRUCTION)); } } From patchwork Fri Oct 2 07:50:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jjOkApyc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGjl4TqRz1xxW for ; Sat, 03 Oct 2026 03:58:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChUG-0000zu-Pb; Fri, 02 Oct 2026 13:56:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQZ-0004Q6-Ra for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:14 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQX-0007US-4P for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:11 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-344447f9c3dso4776854eec.0 for ; Fri, 02 Oct 2026 10:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963528; x=1791568328; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DnPGu3Cq8N2c5ApqFrNQY+BLbQI39d3Uoq0oUbreh6M=; b=jjOkApycNWb28C1gaxwSDGngiic/PmLmW6Nda/STH41NOcI2y7Lma/Y9MRHSHCBoFu KfYMf+kYvj7bFiHnoMac8R3yiGaivJTeiWYxWLju46ktWCWsMTF8Gi1Tjdoj3pMnmc5k qPxWn92RhRUKmON6yrNJi0L0BOpkjyWBB0MQVxJYOVt5WTtkXn9vj/txngMDo9GytkQu zIuD/z7WK3va5PO0zLZi+DBZT/E8F+cpujZxIgP24j0ou07c2KGVbXHchqGb03TfRJW3 xzbbGphrIIOIDgLYr/cE7kev+Ah+AWRZfk9na3K9nAjYVeiA41jBgUxY4lD3IA8gAlQD q3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963528; x=1791568328; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=DnPGu3Cq8N2c5ApqFrNQY+BLbQI39d3Uoq0oUbreh6M=; b=IcsSFje34YCMO2hH4n/ztoALn2AdXxPLdud4DKpic8DfxOZldMTtG50/jO6240SDGX X2y6sqUJqtgJxCRfk3WY1r9ib1VA4drlGZaDtqQQeKsEPrMrVnSJ2ap98RpiH0Wqhwvy 3e183MsubyxeafIZr/fJLi1luQ8T0dUojsvTPeTMuUMm8ErKWc2BZJd3tQQ+mNx6XYYc /BhHhIAO5bvidDqDTeRFZpGJGBLXuzqVwhthpORDSSTrVieU5lsH90mQkglh3+woIxzm 6tV9v2U/0lDKKZnrZyGmEkZvPxCTu1vlU2mL8MD608TsqylX8B5wbHcBsOQSmdfK6O1C Hs/A== X-Forwarded-Encrypted: i=1; AKwUvByFgtcsrImxS8ou1QXudLXSOl3MrkCjF4qrV+NL+GkNdqLQZZttiFwRM3znbyG2i6qBeQT02b+D6A==@nongnu.org X-Gm-Message-State: AFuF++ku6E6FYjgvMg6sQ3NWAFan7eaRWSs2adlJLBPB7yNEESvANiVS om9+cI6llIt56x+Bb89U+P5ZAyUuEAywRYRz0QYnZKYSCD0Dm2NR7Zjm X-Gm-Gg: AYBFou0P+2kI8glnP1ecaLW02RjXa4J8tE5n6O3pn/4Xp4g75GlwDhDSrtR5dU8tjn7 INi+z9HQmkUW1Hs5YqHtUFWOI+CU72o+MgkjIZHGfbXKAD/kA6j0d/BVQb33V44FoHXUc+IU54X k7+a+gCYHtW4FcuhlXYIIqUEYHZfZjincqswKMXNgj4HjgRCMzAh+44Bw0flB+4pCH14GX3AOXQ hvdcevvXKaTi6ycnHZzFZa79QZAo0zlWzhjM5sVZr7DzhsxeHGy4bpqt9+BEa+jrHSHsF0273bs w60iMBuiuPngOqTtSqSZMcnAx/hgA3H1vmvbyAxWcWCuyqjk6JhjPD0bJ/DcznBVod0UKr19+yM 7a9MsPgCmUhZ5sWjdUUkxj8U2197K+1P1i/N9vchnKoLkzyZU5iNSmsW3h/NBfuxcjMg27XooqC tG3Ch0uNFPEf33BJqh0z4+U3n20zyBLxIXgvgQOhkXAUmVoeUW/O7m7+v9GkCX0J5JLXHZ/XQn7 mmOkKD0zU7yglz/G6NjtMjolGvkJ4Q= X-Received: by 2002:a05:7301:4709:b0:34e:e7f4:cc78 with SMTP id 5a478bee46e88-34f14f18c23mr3650855eec.5.1790963527600; Fri, 02 Oct 2026 10:52:07 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:06 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 10/27] target/sh4: log all exception vector names Date: Sat, 3 Oct 2026 01:50:18 +0800 Message-ID: <20261002175037.1747-11-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add names for reset, manual reset, TLB multiple, and user break exceptions in the SH4 interrupt log. Signed-off-by: Yonggang Luo --- target/sh4/helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 0fbd613f333..68f495b5ede 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -97,12 +97,21 @@ void superh_cpu_do_interrupt(CPUState *cs) if (qemu_loglevel_mask(CPU_LOG_INT)) { const char *expname; switch (cs->exception_index) { + case SH4_EXCP_RESET: + expname = "reset"; + break; + case SH4_EXCP_MANUAL_RESET: + expname = "manual_reset"; + break; case SH4_EXCP_ADDR_ERROR: expname = "addr_error"; break; case SH4_EXCP_TLB_MISS: expname = "tlb_miss"; break; + case SH4_EXCP_TLB_MULTIPLE: + expname = "tlb_multiple"; + break; case SH4_EXCP_TLB_VIOLATION: expname = "tlb_violation"; break; @@ -136,6 +145,9 @@ void superh_cpu_do_interrupt(CPUState *cs) case SH4_EXCP_TRAPA: expname = "trapa"; break; + case SH4_EXCP_USER_BREAK: + expname = "user_break"; + break; default: expname = do_irq ? "interrupt" : "???"; break; From patchwork Fri Oct 2 07:50:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=W/cGtvfZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGjx2TpJz1xxW for ; Sat, 03 Oct 2026 03:58:45 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChVt-0002Dg-3x; Fri, 02 Oct 2026 13:57:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQx-0004iw-3h for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:38 -0400 Received: from mail-dl2-x1e.google.com ([2607:f8b0:4864:38::1e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQf-0007Vg-Mv for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:34 -0400 Received: by mail-dl2-x1e.google.com with SMTP id a92af1059eb24-144f47a9b57so7684047c88.2 for ; Fri, 02 Oct 2026 10:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963535; x=1791568335; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=J4ON10Qox2S9bqxuHcRxJiCXGipKK4DEZaxEJyKX9vM=; b=W/cGtvfZWo5XyIlQB+v6C6yg+JY6gTYXR8nFJm2y6JTQMkjl4j7gn46g2k9SI1Y8Su JA/c2HUErYizSjNeBP84IEJGA5w+SNp7vEOxIL6FiG0ggc+t/tkQ85UUS+6PuOHa89t6 AX+9IytSJgB+yRDxQDOLOyVKKzVSvAApfdQVx+pK3h2wq7USa9xnbMMho1HEGqpslzpM 0cuMP3mCcsyH9dXJu/jN9As7A00Nn8+EcL/dfJ1No9PBq1qxt7Boy22Xlj17nXI9J64y 7+QHOi3XjtyFmdqUVbXA7ilxkJsLgnmkgRFXXBQz0iFlIzpbsmumTdNuH5IeBHmGUszi 00ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963535; x=1791568335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=J4ON10Qox2S9bqxuHcRxJiCXGipKK4DEZaxEJyKX9vM=; b=XdY+XywfjgYJjw4CSknrGdhjDxSmyEHVMWdH7Vs6Z/Qzp/RQpm1lCly2SRZ/B+10DP U7PIzT5XQ8Et8m8n3mt38LOnWSbPESTWyKjlbX5scveZWWXNPDX0flunutjVZ/3Z+LJV zyU6nxcVKMYg2qGUWKA/gQJ9E+KzCKnw4aevX852Zx2isY/wGN9YMR7rqA5iGKmpDR9u NM06EKYvWUD5vYmTjo87+59sn1xR08nSQo6lToG7azWZg23rwHZIpBFSN3ien7sX56BW Fp7zWt8DVEY3NGAmM4UklAktfBmQlYcAY4/cxxmcTcVJnjiVm1PzTt1lEuiXN1hqS3uO LKVQ== X-Forwarded-Encrypted: i=1; AKwUvBwyXCcHqezT0gWWXkFgMAtXBGYeQpOUMcFcG2gBVwBmfQSf74y05PyCTgFRao7b4je7xvzH/fA18g==@nongnu.org X-Gm-Message-State: AFuF++lTZECp0UkXs0wcFUSn3hB7Ia59gPaiI2bxo8iUdp9Il4vdcaGb RVRQLbD39u20b0hqapgoeO8uRYwj+W7IqLAm3gqy0m0l4IEmQfXiBII1 X-Gm-Gg: AYBFou12ziZ547CSNRiE2IM5wXb+Pps3Pc/3qi8mfc4jGlt6WmSVpHq5sf5I34Hp+KU W4EzAIQgspukFI/5PXShpzsP4RD9aqCalqBXbQV9jbE+JrT9jiXVYkk8k/Ysi4uDIQdEj7lVpob 2FMP0JG47mmGKefqNQOxUYgj+I1SycPn37bowe2FnED0dAa2gO4IfkLsRO1/oS+q7QJCwgEnUv1 W/PIDVPK9ymCOH+gDfaO+Txiov33GDo8upheGx23mhyjjCnZIigj7BLG3zHLQK2KOLaOqjp9l5J N8CAUjSyX4BWOXb9riDpOXa0Sp0vsAWZDgmS6PduUUMl7r4ZDZXCVSKydtSQDEjHBE0yLhT2Gqa kt/xIaSI1lzyKr2nEi5bDFy+j42knKneQB5rMuk95VD0r2KOpYy/tPhnRbGcpaw0hIvNylh25of kxKPhLkmCGl/a4bgZd2pdKJovNm0OqyFHRl3vmBwS92ybPOSEKbts9ZbRJGbHhUO2eoyvifjwpY M4QoexrerkSN6pIYUXnBIvwTROYaXg= X-Received: by 2002:a05:693c:8087:b0:351:dbc:b663 with SMTP id 5a478bee46e88-3510dbcccfbmr1062876eec.31.1790963535278; Fri, 02 Oct 2026 10:52:15 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:14 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 11/27] target/sh4: convert raises to raise_excp Date: Sat, 3 Oct 2026 01:50:19 +0800 Message-ID: <20261002175037.1747-12-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:38::1e; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x1e.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Translate illegal and FPU-disable exceptions through raise_excp and route the remaining C exception paths through cpu_raise_excp helpers. Remove the redundant SH4 exception helpers. Signed-off-by: Yonggang Luo --- target/sh4/helper.h | 4 ---- target/sh4/op_helper.c | 36 +++--------------------------------- target/sh4/translate.c | 12 ++++++++---- 3 files changed, 11 insertions(+), 41 deletions(-) diff --git a/target/sh4/helper.h b/target/sh4/helper.h index 29011d3dbbb..593b20c0af2 100644 --- a/target/sh4/helper.h +++ b/target/sh4/helper.h @@ -1,8 +1,4 @@ DEF_HELPER_1(ldtlb, void, env) -DEF_HELPER_1(raise_illegal_instruction, noreturn, env) -DEF_HELPER_1(raise_slot_illegal_instruction, noreturn, env) -DEF_HELPER_1(raise_fpu_disable, noreturn, env) -DEF_HELPER_1(raise_slot_fpu_disable, noreturn, env) DEF_HELPER_1(sleep, noreturn, env) DEF_HELPER_2(trapa, noreturn, env, i32) DEF_HELPER_1(exclusive, noreturn, env) diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 8beac9ca034..f38d247c1a2 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -55,49 +55,19 @@ void helper_ldtlb(CPUSH4State *env) #endif } -static inline G_NORETURN -void raise_exception(CPUSH4State *env, int index, - uintptr_t retaddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = index; - cpu_loop_exit_restore(cs, retaddr); -} - -void helper_raise_illegal_instruction(CPUSH4State *env) -{ - raise_exception(env, SH4_EXCP_ILLEGAL_INSTRUCTION, 0); -} - -void helper_raise_slot_illegal_instruction(CPUSH4State *env) -{ - raise_exception(env, SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION, 0); -} - -void helper_raise_fpu_disable(CPUSH4State *env) -{ - raise_exception(env, SH4_EXCP_FPU_DISABLE, 0); -} - -void helper_raise_slot_fpu_disable(CPUSH4State *env) -{ - raise_exception(env, SH4_EXCP_SLOT_FPU_DISABLE, 0); -} - void helper_sleep(CPUSH4State *env) { CPUState *cs = env_cpu(env); cs->halted = 1; env->in_sleep = 1; - raise_exception(env, EXCP_HLT, 0); + cpu_raise_excp(cs, EXCP_HLT); } void helper_trapa(CPUSH4State *env, uint32_t tra) { env->tra = tra << 2; - raise_exception(env, SH4_EXCP_TRAPA, 0); + cpu_raise_excp(env_cpu(env), SH4_EXCP_TRAPA); } void helper_exclusive(CPUSH4State *env) @@ -255,7 +225,7 @@ static void update_fpscr(CPUSH4State *env, uintptr_t retaddr) cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT; enable = (env->fpscr & FPSCR_ENABLE_MASK) >> FPSCR_ENABLE_SHIFT; if (cause & enable) { - raise_exception(env, SH4_EXCP_FPU, retaddr); + cpu_raise_excp_restore(env_cpu(env), SH4_EXCP_FPU, retaddr); } } } diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 5729a757f19..590b62ba3c1 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -1756,10 +1756,13 @@ static void _decode_opc(DisasContext * ctx) if (ctx->envflags & TB_FLAG_DELAY_SLOT_MASK) { do_illegal_slot: gen_save_cpu_state(ctx, true); - gen_helper_raise_slot_illegal_instruction(tcg_env); + gen_helper_raise_excp(tcg_env, + tcg_constant_i32( + SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION)); } else { gen_save_cpu_state(ctx, true); - gen_helper_raise_illegal_instruction(tcg_env); + gen_helper_raise_excp(tcg_env, + tcg_constant_i32(SH4_EXCP_ILLEGAL_INSTRUCTION)); } ctx->base.is_jmp = DISAS_NORETURN; return; @@ -1767,9 +1770,10 @@ static void _decode_opc(DisasContext * ctx) do_fpu_disabled: gen_save_cpu_state(ctx, true); if (ctx->envflags & TB_FLAG_DELAY_SLOT_MASK) { - gen_helper_raise_slot_fpu_disable(tcg_env); + gen_helper_raise_excp(tcg_env, + tcg_constant_i32(SH4_EXCP_SLOT_FPU_DISABLE)); } else { - gen_helper_raise_fpu_disable(tcg_env); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(SH4_EXCP_FPU_DISABLE)); } ctx->base.is_jmp = DISAS_NORETURN; } From patchwork Fri Oct 2 07:50:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jA1NNC+d; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGfv3PPPz1xxW for ; Sat, 03 Oct 2026 03:56:07 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChU2-0000X3-VT; Fri, 02 Oct 2026 13:55:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChR2-0004nK-GX for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:43 -0400 Received: from mail-dy2-x0e.google.com ([2607:f8b0:4864:36::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQz-0007WN-AA for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:40 -0400 Received: by mail-dy2-x0e.google.com with SMTP id 5a478bee46e88-33e630052ebso8999798eec.0 for ; Fri, 02 Oct 2026 10:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963543; x=1791568343; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ChpBbIoUUB3K4Vnyut46y+psaR7c+v1x9LwLs1SfZyw=; b=jA1NNC+dctz3o1NBYUNNxYe21IuLDzwcZVBk67Hx1doVOc3pRytxKfeRJw8u5Ox/Rp +HElLCOy7yIyxqVLSS4TJgKd/oMvn4ly/P13vjvymZF7oykvFFpSYvKtwZQWXLWmvjYT +e1Wd02ZNieozXOVsoCXQmc8DacfWb0XY+LWAE+PZnHFXioSx45y09tFPodWV9JMRHEt yRBu4NOkzgJ40URld/mVKXu7fM9Mz0zkmtklzQ+L1PKUWN+EqsR1mTn2LJIhFt0F/tWr lJN43fwFOC9cTHlGbAW7xda112FRZU+XOJ8ELQJc8Vye/iV58VU+3m2dwy+7DaAbYhJu 2+JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963543; x=1791568343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ChpBbIoUUB3K4Vnyut46y+psaR7c+v1x9LwLs1SfZyw=; b=dLjViQdpa4sOYvPGJRZpJ2doWMoj6EtL3OYoZktF5OF9KPtg/SL7OdpmWzTVeiXxMo QLjiJpihV0CqP92Ec99iDsbsQFNTpbsFXjbXNDwz/CPkEUgZrHEmCoCLOhPkSjnrFxWk XBh5/vwyEhfU0aIcFAMyFlzraikwyG+QZtdaJ6Ya+VfayuctuxrhXm4fitoJfNLHkMXR DtoGFjJ5+ibJ6KpZKaUyXy4gr/FgLgHyUBNSdMksBtPhFGIycJ71i3BySGkj5y08EFTF +6HAx4gYHuNoawuUmhQrk06IDgFDIV668D7gO9cAhiND1iCvAaqS2xV/4LS1GK1mhAHW qHjg== X-Forwarded-Encrypted: i=1; AKwUvBzPvqqY1qT5UvalDhJgmQJH6IppKJG3fyjigUYwX/p+akUtwNsRxvTt/NaubWlOyIaYlCqjoYfsJw==@nongnu.org X-Gm-Message-State: AFq9FYLTkTMmckL1+WbIBQl1dRVAMMC+Dq68IlV0hNR7fae1tiF3/y4Z r/5KTl7ek3fEJ5qkwoGAe/Y9DQ08w2XLVQbkiDHTHcWTajLF4+fGJJNB X-Gm-Gg: AYBFou16diZMTar6sjXyE3D5bM6Ep0CZ0lzWDVsIzf5yAOzQ8p95UGn+0KF83XpPjh0 jeral6qC8gnWreK1eGoQGUpeFoMwNMlJ5PAbKu18TR+2g2gQv5x9yLKhPBeULWq1Fa1aIirRuA0 2SN7nT1qnmcpXkP4uHIglXp9Emq5mZJBpSLYzdD02gEx9Mw+KBQvSzxrvXgYZ6WvmXYSs60/XX+ PevZbdi1tdPVJl7pvvq9Gu40oL/RXgXj3HqvklIwjK/UPQLZA8WyKqCIzjjsCo+Ui5+85LaFZTm kgkfmYPo3CTkJf08EqoCNava985Dq4xHVl2Yh32fMTqkO+859UUZK3utDyICEzGNFuyPienfMHO S6u20xO9+HCRxUw0p3fwbx9x2NkmcSAKTrvHnl6THwUcz7gj88vhm2fV338CIA7R6UKHS+n3qOC SMNuFdTIpHjAKdv0MxUytaBPodmV6RoOVJX/isk7cRDSZfRb5G4Mw/DGJQJWfAzYNbJREEwJiHr fbDyCOQq2akg7RkVLqsWXUw8hts3RE= X-Received: by 2002:a05:7300:d40c:b0:334:7f2a:1188 with SMTP id 5a478bee46e88-34f1509e2a9mr3807155eec.14.1790963542651; Fri, 02 Oct 2026 10:52:22 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:22 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 12/27] target/s390x: convert exception to raise_excp Date: Sat, 3 Oct 2026 01:50:20 +0800 Message-ID: <20261002175037.1747-13-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::e; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0e.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Drop the redundant S390x exception helper and use the current cpu_raise_excp() API for SVC execution. Translate exceptions through the shared raise_excp helper. Signed-off-by: Yonggang Luo Reviewed-by: Ilya Leoshkevich --- target/s390x/helper.h | 1 - target/s390x/tcg/mem_helper.c | 2 +- target/s390x/tcg/misc_helper.c | 10 ---------- target/s390x/tcg/translate.c | 2 +- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 6a7426fdac7..ec27ef104f2 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -1,4 +1,3 @@ -DEF_HELPER_2(exception, noreturn, env, i32) DEF_HELPER_2(data_exception, noreturn, env, i32) DEF_HELPER_FLAGS_4(nc, TCG_CALL_NO_WG, i32, env, i32, i64, i64) DEF_HELPER_FLAGS_4(oc, TCG_CALL_NO_WG, i32, env, i32, i64, i64) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 414e6838c87..ca94960354a 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -2488,7 +2488,7 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr) } else if (opc == 0x0a) { env->int_svc_code = extract64(insn, 48, 8); env->int_svc_ilen = ilen; - helper_exception(env, EXCP_SVC); + cpu_raise_excp(env_cpu(env), EXCP_SVC); g_assert_not_reached(); } diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c index f1c8563af00..f5e31419268 100644 --- a/target/s390x/tcg/misc_helper.c +++ b/target/s390x/tcg/misc_helper.c @@ -56,16 +56,6 @@ #define HELPER_LOG(x...) #endif -/* Raise an exception statically from a TB. */ -void HELPER(exception)(CPUS390XState *env, uint32_t excp) -{ - CPUState *cs = env_cpu(env); - - HELPER_LOG("%s: exception %d\n", __func__, excp); - cs->exception_index = excp; - cpu_loop_exit(cs); -} - /* Store CPU Timer (also used for EXTRACT CPU TIME) */ uint64_t HELPER(stpt)(CPUS390XState *env) { diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 474d604ed17..d2bf1422b1f 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -400,7 +400,7 @@ static int get_mem_index(DisasContext *s) static void gen_exception(int excp) { - gen_helper_exception(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); } static void gen_program_exception(DisasContext *s, int code) From patchwork Fri Oct 2 07:50:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=RiRw696G; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGfc70Y9z1xxW for ; Sat, 03 Oct 2026 03:55:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChTZ-0007tM-75; Fri, 02 Oct 2026 13:55:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChQz-0004kZ-JJ for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:38 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQw-0007Wu-FJ for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:36 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34c4a0870d2so3021254eec.2 for ; Fri, 02 Oct 2026 10:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963550; x=1791568350; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0iShXIlUk1iYtKpGTlb7boAt3L1gqjusG6eXmIJcuWI=; b=RiRw696GjB+suufCoVti7ESMuewnZBicXAdofWOpxBVZVerqp+iTZHiMBAuglt+LnZ IsggYXJjnnZzwFsAXOmRej9uaJbIdePWJPjUoOeZ2jYw8JUufhzd3LjqNzbeez0GPgYy m3JDP0ru3ToJH7bifxnVIq01kD83ZP2FHX/AQ8Nw/dr5SuqUnhuVEHWDTNCZ2GWUWitR 4eIyD4GVcJt/vLMRkrkf+UsW6ij/I3/hG+AZldHe56JzTrKKI9ExgXfUGtJvBVK4C6hp 6Q5VftcAvJLrV3CkErAKMp3HyCED36L4JU8P8/kkh0TzrSowMYxVybsSO2onbRunZqAw h3yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963550; x=1791568350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0iShXIlUk1iYtKpGTlb7boAt3L1gqjusG6eXmIJcuWI=; b=a94G+LCCwlLBgXCFty2hnkB+jRoU2MdZTdKgoSX9kQ8TsfTZ1RAFAMJak7qQlOqZgA KUEu7DAm7ybJWJtoYhaOynb57Xa/Z010Ctkh8URP4rsnohjvJsthbMHcx18B4/CVdDr8 GPWlRDySLa53Lln5TQjeN60RWjbPQfrCNmlKfqK646cHrND69G7VdEn3gKcA2zzC7jb+ x8ZzlFUtCJQbXGsI/NCqPcLgWrkEE5EgfTedM/Sx9SPpj8xC6nFwSsK39pBBqFYWLCGJ pAsQvlPhQbxf3uqjAPuG3u7H/mUOA8CFsnRypyaNDqZGnBso/fbv8aEfOwvYjxMAi+dz gNFA== X-Forwarded-Encrypted: i=1; AKwUvBxnm8o1/kBz0PeWNMidC1X1IHp7zVGri2ZPun/n0H3F6lS1ksY1OSaHRr0LrpmbjBy9pb4GLmHyAQ==@nongnu.org X-Gm-Message-State: AFuF++keO42C1WfGeyoEXcnhsp+sKN/MC8yOKxP9GRUaCwzat+BJLQze Hprum1wzMVBTKXMlJUpqrKooDhDQdOyvSE7sdz0flrlLedDaFIf5Rbwn X-Gm-Gg: AYBFou0L3htOqjCQmJaMk3sT4Vb1t3Tq3EDrPPESXWK59/53enNKLeJTJlRPtuMht8U Khrry9axV2otxIYQYpiEeCGbvFYyso33dl0O5CvT7oEe6/d68WE8jN3fHKzxilleHJb5V5CDStI tP6rUYu99T86a8kauKDx8jkiNyQeI/k11Yn6K/5whEN8VmaMgT5NUZckdVEaSSuo7U+dDkcGSQR Cw0b+D8ZGGHzmHyowaeOtNe1PX+X25r+mfxD+EsfdX/vvDP5WQHBxXgTdYfdZFbQvDwCv6ld5JE BMv7vQYx2HFS/38HDjb8uUch5XRDxRgvAaJ+oWv17wN9UiXdWvaiQIo0hIYTQJ2yMByp+HRwSoW VT/jPgPqhuwy3IVJJuyT28MDhvrVRWrUuWPUIW+eTiWzMyyW+eF5VwX2ncMWG4QrflfonMvrvor 6gwiGUYXCrZeaMNRwiAtXK1bFWeHjm7NZyTDkwjU0jcLcOZKq8cOkHRp0g9aUPo5ZR2RH/Tf7vJ juZtMHV/2ODkIkSu9Nleg2z68FQUjk= X-Received: by 2002:a05:7301:348f:b0:34e:3ce1:39f8 with SMTP id 5a478bee46e88-34f150c7a93mr3568812eec.18.1790963550140; Fri, 02 Oct 2026 10:52:30 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:29 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 13/27] target/m68k: convert raises to raise_excp Date: Sat, 3 Oct 2026 01:50:21 +0800 Message-ID: <20261002175037.1747-14-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Translate pure exceptions through the shared raise_excp helper and use cpu_raise_excp() for no-restore C paths. Keep the format2 exception helper because it performs additional guest-state work. Signed-off-by: Yonggang Luo --- target/m68k/helper.c | 12 ++---------- target/m68k/helper.h | 1 - target/m68k/op_helper.c | 19 ------------------- target/m68k/translate.c | 2 +- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 5f91d206f59..22f6cde02d3 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -162,14 +162,6 @@ void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val) } } -static void raise_exception_ra(CPUM68KState *env, int tt, uintptr_t raddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = tt; - cpu_loop_exit_restore(cs, raddr); -} - void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val) { switch (reg) { @@ -291,7 +283,7 @@ void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val) } /* Invalid control registers will generate an exception. */ - raise_exception_ra(env, EXCP_ILLEGAL, 0); + cpu_raise_excp(env_cpu(env), EXCP_ILLEGAL); } uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) @@ -394,7 +386,7 @@ uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) } /* Invalid control registers will generate an exception. */ - raise_exception_ra(env, EXCP_ILLEGAL, 0); + cpu_raise_excp(env_cpu(env), EXCP_ILLEGAL); return 0; } diff --git a/target/m68k/helper.h b/target/m68k/helper.h index 0bda8f8152d..a6ca811ebe2 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -111,7 +111,6 @@ DEF_HELPER_3(set_mac_extu, void, env, i32, i32) DEF_HELPER_2(flush_flags, void, env, i32) DEF_HELPER_2(set_ccr, void, env, i32) DEF_HELPER_FLAGS_1(get_ccr, TCG_CALL_NO_WG_SE, i32, env) -DEF_HELPER_2(raise_exception, noreturn, env, i32) DEF_HELPER_FLAGS_3(bfffo_reg, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 38f7a689814..5f539f8fd75 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -539,25 +539,6 @@ bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request) #endif /* !CONFIG_USER_ONLY */ -G_NORETURN static void -raise_exception_ra(CPUM68KState *env, int tt, uintptr_t raddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = tt; - cpu_loop_exit_restore(cs, raddr); -} - -G_NORETURN static void raise_exception(CPUM68KState *env, int tt) -{ - raise_exception_ra(env, tt, 0); -} - -void HELPER(raise_exception)(CPUM68KState *env, uint32_t tt) -{ - raise_exception(env, tt); -} - G_NORETURN static void raise_exception_format2(CPUM68KState *env, int tt, int ilen, uintptr_t raddr) { diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 138c89d3e53..b5ce0ee6ccd 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -252,7 +252,7 @@ static void gen_jmp(DisasContext *s, TCGv dest) static void gen_raise_exception(int nr) { - gen_helper_raise_exception(tcg_env, tcg_constant_i32(nr)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(nr)); } static void gen_raise_exception_format2(DisasContext *s, int nr, From patchwork Fri Oct 2 07:50:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=VVW+CxTm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGpW0RGvz1xvt for ; Sat, 03 Oct 2026 04:02:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChUx-0001TA-FL; Fri, 02 Oct 2026 13:56:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRO-00057X-S4 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:03 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRB-0007Ye-Af for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:52:51 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34bcb929cceso2698404eec.0 for ; Fri, 02 Oct 2026 10:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963558; x=1791568358; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C60WimnL9SSW7LAxTDiiRt6rrJtccQkGf4ZasbM1n6Q=; b=VVW+CxTm2dW7C60OpiOuQElo9whgO3Jgp/bu2x6+mbTjUcFLU1tv2rqCdB1keoc6Cp IOte1oDRQZNXCr/UdW+fvP4/yXP0+cY31/AbV+5KSS46ZZz9jlpWB8vUI/UFoqP/sfLo Cm4REO9HgHsNFt1sPod7v3eok++Gt6kATnQ8BoTXLZAsoufIzEOyVsnZ3ed1RY8LZlAN AOcNFmIuFYeQ89WQGe80eUoHGWvYAsqx1HL0gh7mooVR6m52W8ghbMpad3Ww4o+28eDC np9si8MjkVDiTB4DYV9nYVJfO41LkyXU0bHI1RMhj3kCmCV0D+iCVWihrBuSK5XFlu6o HQhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963558; x=1791568358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=C60WimnL9SSW7LAxTDiiRt6rrJtccQkGf4ZasbM1n6Q=; b=SlihkHSEUcDaTGN18+/8H3h5qnGZGxVuXAru/N64pkjwSnFh04FDSd+dqShrD7uR3a KMT7dLOFcDoKFR8B02yKsPK3wuB6VUJyA0V+u0y/Ew4kPBEVic92GcIfc8V0MMGjCShv +w/ircdCQsh7wg6tT+nSd9jDXdG1zNfue/th5cdRlAI7G3RTpeWDW/AoPZTfRvDefiOz WxvT3lyaiXgofV5NaXn9GoFT9tGWcVdZ1CurcK2EnwhjI5BeF+3HV1S0uotMw52gwVXM pGdzLP6y/x/75gr2RakyPFykMK33FVvtJzrU747XyhZzW0xHfRvgQNFACBp40Z944630 Yg0g== X-Forwarded-Encrypted: i=1; AKwUvBxUDhp9qy2lc9mgjxVN0IJvcEtwNmiefpF3NAQL2TueI6msQafGQskHA60vkOdOq2RLyXPI05N04Q==@nongnu.org X-Gm-Message-State: AFq9FYIeyADlZO1KH7a5c9heAgseHNvG1OlWKkC+V9eK/HDazY/IkLB6 uBvWli6vbe/ro10xdEbRbwFnT/UaYCcWznyXXzW55p5nZExaDIgzayEF X-Gm-Gg: AYBFou2xTKf8goBXPhsw+E1zpqp91azYaO5/+uDDN1UkDIMfcr5L/NQ0ek6qHdAUFgW 6CC4jAqxmLXLmVCcOKzbbN1hFRukBUc0lEPa0St0nz5qwhF3LOUxPCsPC0m0Nc4GESetoOQjjmz WN4zP3nE+dCwlUsWYxqwjVZVL/r+eQ7atEu57Nwif3sSrRDQhL8rqSu8JyMa2JwdlFtHyNdaPKI Gvv00vk4pK5gcNQWMz4ILiqMKAQsCqYEagrRFOT1lg5srzIzy886kCCogj4yn9urtrXS1AZqVwQ XkF4YTpebjhIsib6WssGDHGbixQrFk3mXqfcfQCFLuhIdvBLM603gb01VIhKNVTFxJdaODgK123 UdwNJEX7/INiNHlgwRlMJwmPnZ7H2+cQ5ClbOFKb4037FraQ0rcDa7hBS7aO/isL5+To++CIaS9 YSK7EXl1G0W5iT+5UVFDwj8E69OvmKBb1zWHJFLZNNC6flyanobgPuVit+B7jQqb+7xuneZlJ45 PWm509cj7CIrDz6pIRjZjx1Aw6CuFc= X-Received: by 2002:a05:693c:4154:20b0:351:853:54a4 with SMTP id 5a478bee46e88-35108535aa9mr2020614eec.33.1790963557732; Fri, 02 Oct 2026 10:52:37 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:37 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 14/27] target/or1k: convert exception to raise_excp Date: Sat, 3 Oct 2026 01:50:22 +0800 Message-ID: <20261002175037.1747-15-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the shared raise_excp helper for translated exceptions. Use cpu_raise_excp_restore() for overflow helpers with GETPC() and cpu_raise_excp() for the zero-PC C wrapper. Signed-off-by: Yonggang Luo --- target/or1k/exception.c | 31 ------------------------------- target/or1k/exception.h | 7 ++++++- target/or1k/exception_helper.c | 13 +------------ target/or1k/helper.h | 1 - target/or1k/meson.build | 1 - target/or1k/translate.c | 2 +- 6 files changed, 8 insertions(+), 47 deletions(-) delete mode 100644 target/or1k/exception.c diff --git a/target/or1k/exception.c b/target/or1k/exception.c deleted file mode 100644 index 0479a069592..00000000000 --- a/target/or1k/exception.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * OpenRISC exception. - * - * Copyright (c) 2011-2012 Jia Liu - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "qemu/osdep.h" -#include "accel/tcg/cpu-loop.h" -#include "cpu.h" -#include "exception.h" - -G_NORETURN void raise_exception(OpenRISCCPU *cpu, uint32_t excp) -{ - CPUState *cs = CPU(cpu); - - cs->exception_index = excp; - cpu_loop_exit(cs); -} diff --git a/target/or1k/exception.h b/target/or1k/exception.h index f62fc314c1f..a206816d4d7 100644 --- a/target/or1k/exception.h +++ b/target/or1k/exception.h @@ -21,7 +21,12 @@ #define TARGET_OPENRISC_EXCEPTION_H #include "cpu.h" +#include "accel/tcg/cpu-loop.h" -G_NORETURN void raise_exception(OpenRISCCPU *cpu, uint32_t excp); +static inline G_NORETURN +void raise_exception(OpenRISCCPU *cpu, uint32_t excp) +{ + cpu_raise_excp(CPU(cpu), excp); +} #endif /* TARGET_OPENRISC_EXCEPTION_H */ diff --git a/target/or1k/exception_helper.c b/target/or1k/exception_helper.c index 3bd82b29719..113012439c8 100644 --- a/target/or1k/exception_helper.c +++ b/target/or1k/exception_helper.c @@ -21,22 +21,11 @@ #include "cpu.h" #include "accel/tcg/cpu-loop.h" #include "exec/helper-proto.h" -#include "exception.h" - -void HELPER(exception)(CPUOpenRISCState *env, uint32_t excp) -{ - OpenRISCCPU *cpu = env_archcpu(env); - - raise_exception(cpu, excp); -} static G_NORETURN void do_range(CPUOpenRISCState *env, uintptr_t pc) { - CPUState *cs = env_cpu(env); - - cs->exception_index = EXCP_RANGE; - cpu_loop_exit_restore(cs, pc); + cpu_raise_excp_restore(env_cpu(env), EXCP_RANGE, pc); } void HELPER(ove_cy)(CPUOpenRISCState *env) diff --git a/target/or1k/helper.h b/target/or1k/helper.h index e0a8d402271..d6e6bd4ffbc 100644 --- a/target/or1k/helper.h +++ b/target/or1k/helper.h @@ -18,7 +18,6 @@ */ /* exception */ -DEF_HELPER_FLAGS_2(exception, TCG_CALL_NO_WG, void, env, i32) DEF_HELPER_FLAGS_1(ove_cy, TCG_CALL_NO_WG, void, env) DEF_HELPER_FLAGS_1(ove_ov, TCG_CALL_NO_WG, void, env) DEF_HELPER_FLAGS_1(ove_cyov, TCG_CALL_NO_WG, void, env) diff --git a/target/or1k/meson.build b/target/or1k/meson.build index 7cea45287a2..dba5044b655 100644 --- a/target/or1k/meson.build +++ b/target/or1k/meson.build @@ -5,7 +5,6 @@ or1k_ss.add(gen) or1k_ss.add(files( 'cpu.c', 'disas.c', - 'exception.c', 'exception_helper.c', 'fpu_helper.c', 'interrupt_helper.c', diff --git a/target/or1k/translate.c b/target/or1k/translate.c index e00ef45b9b7..243a8eede23 100644 --- a/target/or1k/translate.c +++ b/target/or1k/translate.c @@ -140,7 +140,7 @@ void openrisc_translate_init(void) static void gen_exception(DisasContext *dc, unsigned int excp) { - gen_helper_exception(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); } static void gen_illegal_exception(DisasContext *dc) From patchwork Fri Oct 2 07:50:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s71HdQiZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGgl11xSz1xxW for ; Sat, 03 Oct 2026 03:56:51 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChU8-0000lW-HJ; Fri, 02 Oct 2026 13:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRQ-00059m-4k for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:04 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRJ-0007aK-8k for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:03 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34bcb929cceso2698474eec.0 for ; Fri, 02 Oct 2026 10:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963566; x=1791568366; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5o8QBC2V06VU8Hip/Yv/GKks4ZOHoJaCkD3lW4u1eNA=; b=s71HdQiZLZQDFJBMoFa+WMbIWFWjOIa8hU5J8J6oCEYDno44RzK+WdzdUAwWWtlUjp ogq0bp26C2vFAAcw8ykiq3CnGhQJdxOMVazqzGN+N1rZBmKbjp7jXJ5IcIzmAt+PXt/Q XXGkIHt3TQ0SJ+xzgsSy0DTG2lZhh+kZHRt68Yo5/DWnnbk1Y1H9rfplyirDq/UEWDrM aVcR/LGAEEh2TJMuLK9eME3JfGp99DAcM9MHFKXaswqdcElc8/a9MqUDCFY9ExocbbpV 1fHw5ybQaQcPzyjBCWEBwVABhR5IQkae98JqsGkR/0je6Ui8nY1XJ9VQhbespfWa6EvR njsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963566; x=1791568366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5o8QBC2V06VU8Hip/Yv/GKks4ZOHoJaCkD3lW4u1eNA=; b=SEaVJqrpXICd9U9Qg6Tkgd+B0azXx8UbHLOU0WDV+SUS6EzrKxpChpbi/eHhPme+3o LSr8a69AdWoj7CjAaTmYgzZE3FDn6mISDxcyKZKg+r7W6asXRC8Maub2b7w4fa12QRS5 uwWz8YOF8lWyMaameidcCeZwLRA6rstx0jTdY1ReU/RkVfVEBf47dhmybmApZvLJMKXc H9ZHxFVP1NFlrUpEUT+60xYosNH8KVSF9vUWcBdvz2ksYPqinfcGaD10TQ6hhXjNYNsK GOa+uoIdNoGC4v1XhXnKGvX5QWr1GkqUDVwH6WcXKvEbsdoNOnMu3E/ZswS5SI2q0muF UaUQ== X-Forwarded-Encrypted: i=1; AKwUvBzR6Yh3bubk+Y5AGIv90/VnYnabsTVU1jh/N5iys/pZpi5fhxj9qxNupD6WB0k5tkS6Zd6ODVgd0w==@nongnu.org X-Gm-Message-State: AFuF++lUOopUy7lngW08SQlvVSilvgrNOkfkCLZ7TeR9/YnrswwlGshX StRPhutpiDy1F7wKsD+lRF0w9/DjWD9mJcpPhuaet0NmehLoG3J3NtwB X-Gm-Gg: AYBFou2y35AApmgDLnO3o2V6kUm4+HmGIf8epSxF7Yzug4P4jwnMu5F9yVXgpqBS1hc qrJQuCfO29NNeW8PH6wZguE7ly8sFSHeiy7Z57MNtluwl8VFOop7PcS4FcxYQcZHJKXRvk6gkOq zLUVa+iDlqb2SX9eyqUqRaNCOKdKZ6mujUobqtqak4FdHwOEkIYZpYiQVq6EqDhB1NxprEdIZGp QeOf13HpruWcRLP23Q7Eypx91fHhMuGR1E+0dFhPRDIzNJP8epibRO4BfIz36vDKYXbRG19sy3n EMDXvNwzatqJU6HirhlVYmJ3cCIWlGR6ES1BJTwrQHEFrRLjuMDI/r+43zMRVZJRKqYwNbCGpnu DkFO4BOrsRA2gRvKzFnXS4cIyB7A/Rs6MjjSHuXeEHSEIGIGdFLYDrfAAL7HSqhMoBQe0xzFbHF Sr7VRF8OtMFU03bbAzHRV+pXoGLn2DqftUHoC/JyKG/QBbDOolVaAa2avhCttw+5e6dtyTtMP5e AqqerUytnfNMVDsxkehw+hgVq3i/Ic= X-Received: by 2002:a05:7301:dd97:b0:34b:d8dc:430f with SMTP id 5a478bee46e88-34f150ab82fmr3257575eec.7.1790963565409; Fri, 02 Oct 2026 10:52:45 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:44 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 15/27] target/microblaze: convert raise_exception to raise_excp Date: Sat, 3 Oct 2026 01:50:23 +0800 Message-ID: <20261002175037.1747-16-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the shared raise_excp helper for translated exceptions. Use cpu_raise_excp_restore() for GETPC() paths and preserve explicit cpu_loop_exit_restore() for MMU callbacks with possibly-zero retaddr. Signed-off-by: Yonggang Luo --- target/microblaze/helper.h | 2 -- target/microblaze/op_helper.c | 19 +++---------------- target/microblaze/translate.c | 2 +- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h index 1429c1727ef..ad9c22ed5b7 100644 --- a/target/microblaze/helper.h +++ b/target/microblaze/helper.h @@ -1,5 +1,3 @@ -DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) - DEF_HELPER_FLAGS_3(divs, TCG_CALL_NO_WG, i32, env, i32, i32) DEF_HELPER_FLAGS_3(divu, TCG_CALL_NO_WG, i32, env, i32, i32) diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index 3da0c68da39..9010c838d90 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -62,25 +62,14 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl) return 0xdead0000 | id; } -void helper_raise_exception(CPUMBState *env, uint32_t index) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = index; - cpu_loop_exit(cs); -} - /* Raises ESR_EC_DIVZERO if exceptions are enabled. */ static void raise_divzero(CPUMBState *env, uint32_t esr, uintptr_t unwind_pc) { env->msr |= MSR_DZ; if ((env->msr & MSR_EE) && env_archcpu(env)->cfg.div_zero_exception) { - CPUState *cs = env_cpu(env); - env->esr = esr; - cs->exception_index = EXCP_HW_EXCP; - cpu_loop_exit_restore(cs, unwind_pc); + cpu_raise_excp_restore(env_cpu(env), EXCP_HW_EXCP, unwind_pc); } } @@ -123,8 +112,7 @@ static void raise_fpu_exception(CPUMBState *env, uintptr_t ra) CPUState *cs = env_cpu(env); env->esr = ESR_EC_FPU; - cs->exception_index = EXCP_HW_EXCP; - cpu_loop_exit_restore(cs, ra); + cpu_raise_excp_restore(cs, EXCP_HW_EXCP, ra); } static void update_fpu_flags(CPUMBState *env, int flags, uintptr_t ra) @@ -390,8 +378,7 @@ void helper_stackprot(CPUMBState *env, uint32_t addr) env->ear = addr; env->esr = ESR_EC_STACKPROT; - cs->exception_index = EXCP_HW_EXCP; - cpu_loop_exit_restore(cs, GETPC()); + cpu_raise_excp_restore(cs, EXCP_HW_EXCP, GETPC()); } } diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 8b219afb5dd..9424208a04b 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -100,7 +100,7 @@ static void t_sync_flags(DisasContext *dc) static void gen_raise_exception(DisasContext *dc, uint32_t index) { - gen_helper_raise_exception(tcg_env, tcg_constant_i32(index)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(index)); dc->base.is_jmp = DISAS_NORETURN; } From patchwork Fri Oct 2 07:50:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pD0sds4V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGjg1G8kz1xxW for ; Sat, 03 Oct 2026 03:58:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChUs-0001QK-B5; Fri, 02 Oct 2026 13:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRS-0005KM-T2 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:07 -0400 Received: from mail-dy2-x0e.google.com ([2607:f8b0:4864:36::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRO-0007bG-KH for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:06 -0400 Received: by mail-dy2-x0e.google.com with SMTP id 5a478bee46e88-3510b42f4e3so599646eec.2 for ; Fri, 02 Oct 2026 10:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963573; x=1791568373; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WNFp+S7U4V1y7Qb+3VL79D1plTLvUAgf6A0U0toQ9Jw=; b=pD0sds4VCE7TUGVqmoTLIEwT8S1Jz/eoLrW2Q4Yiggs52BsXO1KvWMCbZ+X2zE7nHf 9HIh1eyPEyqJxUTFsyL5Wn7d0s1Ks1v9bVP7EyVB8JJlpoJcmaCfszsLHzJmKaLKoR/y JscGN3iJEwx7T/ON9f9ldPYJOdPGmhOsVF4nvj2+IxLZkERocP+uGKKJPd/QlhtmJ3dD 2uBN0ZrZduQYMTA0awWShrJi7OeG0OAm9XD6vpXnb5XANkA6AxA/ksqQviOHNt8R4Vri ACAUex+PzKUX1d8kHOM+6FjiPllEJFxs1puXozl3lderCw/7R7AXE1yf/fshvBvWYTn6 Avsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963573; x=1791568373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WNFp+S7U4V1y7Qb+3VL79D1plTLvUAgf6A0U0toQ9Jw=; b=HCqj//Z8mEV3I+1gMuEGK3i9bd2tibVvwFvf/TT/5Ae250FHvBjXNrT7KzaJe875qm p6t/Zdoj8tvX8iriB1AiSCWGDdQK7E7ohVXJ+lSGKl2KB7Ic8UI76H+WkT9p18XYO9nu X8FxRwBiUJLinBHuWkIF6T4nUhCoDb3w+gPY17j/kCIAQx0dKPWeM/+G+WZSZbuY2c1t r3UIa/LyLCDTMp9YiRqxjfND72CFMPD3Jy+clNayOiTBN0gs0OE33a7ooGKmQKgBwNR1 8lzIs3EsvAAbALAgK1QZm8/ZUYXFhUXLyBASh/JzbHXlNGQLrxAxrmlqWrlPmgRpoCWn zKCA== X-Forwarded-Encrypted: i=1; AKwUvBzpXbuWgHmwSi5MJJ6Uj2w9rXTEF+dyr5d1RdaeLK14DE7UqS2qBC+TuLSz6Ms3G56YOyclz1MznA==@nongnu.org X-Gm-Message-State: AFuF++kUFn/aoWcyE267ROGLgxYKaHXj3KK7heT87oWIwn6oNeSpav7a JXDuNomgi+7IaSOO8aDdZ74tGkyGVka6V/i4ffwzgW5GGQQkF2INCDUm X-Gm-Gg: AYBFou1L/oIK7oRWfATUDxbuL96brk+KcWVhbL+0COF7JxdkPQv+IoYxt6r953LPGa8 6oh8RgHUKTQ068hL2pouTEDV1hEHcJ6nPSw9fiPAwBAQ4aw46YnqAo6cenIAGM3YkarybwmAdqP F/vEBfmI4qIBeRrd/V1VYwaeS6ZyaMpHNxzfB7juhwTUC0Gyr9SGG1MW/VUSgUfZoQiBzXyUqCz NU+TSSyhkhZlZgPAxjWwuPR+7GaLswTmscvbQz40WHlSJ2yfYgafTopAAYQakczuE+JBtEPJQ6R /e5mZy+z3lYiWw+zzebrju+pa9Vu3ji7MYp9SiDk2JXdA59/TOAmCjMHSjHm19yN4D9BHao8ZzF DNBvbCen8mJoZQK7zeNNglSoqTAv9za3qZF9r0O8neuZr7KYDHNyd/BrqkBkokFtsjlaIvMdz9H gLc1Yrdhb53El90edI3QlIPXXJMndMonXGR855aWRqZvgJoJko//1s40UjW3bMix3cqK+7CuTjx Rw2UBFfmXeSkqf3Dw+IjEBHVC01OvO+n3VU8i9K5Q== X-Received: by 2002:a05:7300:e5c2:b0:341:3ca2:de2d with SMTP id 5a478bee46e88-34f15077edfmr3766742eec.6.1790963573128; Fri, 02 Oct 2026 10:52:53 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:52:52 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 16/27] target/sparc: convert raise_exception to raise_excp Date: Sat, 3 Oct 2026 01:50:24 +0800 Message-ID: <20261002175037.1747-17-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::e; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0e.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the shared raise_excp helper for translated exceptions and adapt SPARC C exits to cpu_raise_excp() or cpu_raise_excp_restore() according to the return-address contract. Keep cpu_raise_exception_ra(). Signed-off-by: Yonggang Luo --- target/sparc/helper.c | 21 +++------------------ target/sparc/helper.h | 2 -- target/sparc/translate.c | 6 +++--- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/target/sparc/helper.c b/target/sparc/helper.c index 8de261b0e30..dea908a8f7f 100644 --- a/target/sparc/helper.c +++ b/target/sparc/helper.c @@ -27,26 +27,12 @@ void cpu_raise_exception_ra(CPUSPARCState *env, int tt, uintptr_t ra) { - CPUState *cs = env_cpu(env); - - cs->exception_index = tt; - cpu_loop_exit_restore(cs, ra); -} - -void helper_raise_exception(CPUSPARCState *env, int tt) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = tt; - cpu_loop_exit(cs); + cpu_raise_excp_restore(env_cpu(env), tt, ra); } void helper_debug(CPUSPARCState *env) { - CPUState *cs = env_cpu(env); - - cs->exception_index = EXCP_DEBUG; - cpu_loop_exit(cs); + cpu_raise_excp(env_cpu(env), EXCP_DEBUG); } #ifdef TARGET_SPARC64 @@ -208,10 +194,9 @@ void helper_power_down(CPUSPARCState *env) CPUState *cs = env_cpu(env); cs->halted = 1; - cs->exception_index = EXCP_HLT; env->pc = env->npc; env->npc = env->pc + 4; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); } target_ulong helper_rdasr17(CPUSPARCState *env) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 3a7f7dc1296..9fc38f5706a 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -53,8 +53,6 @@ DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128) DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128) DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32) DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64) -DEF_HELPER_2(raise_exception, noreturn, env, int) - DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fsubd, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fmuld, TCG_CALL_NO_WG, f64, env, f64, f64) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 3156be6a94c..6dae5da7157 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1048,7 +1048,7 @@ static void gen_exception(DisasContext *dc, int which) { finishing_insn(dc); save_state(dc); - gen_helper_raise_exception(tcg_env, tcg_constant_i32(which)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(which)); dc->base.is_jmp = DISAS_NORETURN; } @@ -2811,7 +2811,7 @@ static bool do_tcc(DisasContext *dc, int cond, int cc, /* Trap always. */ if (cond == 8) { save_state(dc); - gen_helper_raise_exception(tcg_env, trap); + gen_helper_raise_excp(tcg_env, trap); dc->base.is_jmp = DISAS_NORETURN; return true; } @@ -5833,7 +5833,7 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) if (e->npc % 4 == 0) { tcg_gen_movi_tl(cpu_npc, e->npc); } - gen_helper_raise_exception(tcg_env, e->excp); + gen_helper_raise_excp(tcg_env, e->excp); e_next = e->next; g_free(e); From patchwork Fri Oct 2 07:50:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=WO1z/3b5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGkH3qyJz1xxW for ; Sat, 03 Oct 2026 03:59:03 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChVW-00020Q-TV; Fri, 02 Oct 2026 13:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRT-0005Kn-AK for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:07 -0400 Received: from mail-dy1-x132d.google.com ([2607:f8b0:4864:20::132d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRO-0007ck-MM for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:06 -0400 Received: by mail-dy1-x132d.google.com with SMTP id 5a478bee46e88-34ca2d54925so149911eec.0 for ; Fri, 02 Oct 2026 10:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963581; x=1791568381; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZNU4PHC3hnUAQwnMHFav3xH/N5F8DnZib4Be85nEsJE=; b=WO1z/3b58eD7oxWYuAGjtApyj0b8M4InXR4bYmTAWEJ/6KFHE5xEiWTbqryHP4zjcA N/rEapXak+ybaqfRg0/AAYRIQtqRBzZJQYSAO4hltjdI+6K4xbA4Chej5oUomhd0thEO 7fLjbCHUN5HQ8PcMu332SeLQhtuJy2J6CgX9ozyQ6h+saNhkTu0cZIp4W4za5Ms5j729 j0Kj6EvwYMmW6OYtdMPw5FB3WB78YYa6Vdawr4bYRhGVrqiwo+yery3+t8GVZRzE+lv8 8RJc1cUK+MOW4qidBxPX6JfanU0eJDR0uW7+hQRpYYerMYyrb4/b5Q1JkI8kW6g7vHa0 7FQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963581; x=1791568381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZNU4PHC3hnUAQwnMHFav3xH/N5F8DnZib4Be85nEsJE=; b=BHYlq1VocKeYiTJQArZgZZ1FICsiRYx7X41T44fwMrlMm+iKX1L1/AWXqzT9+osksz 5mZ751SpKJz+7PLR1BWsQCp6FlL8janR0iceP8ysT41MFlflXk31nHfxNrsE0A+oRBVr V8bSTRK2Dp1tJ76rm9RW5YPVUFOzwJ8rug+2MUxyyoBV5BOBBzSKsh7Qw0BY8TV+ZfFO 1xu5ZnMMqv8fPv+dok09NLy3A51/yzNSCVVxoTcYHNp07cp5Hd9MKn4iObGxRMVHbrS3 ksZojiloVV43RynED/JmT4ALRDazg9dtbuuax5ZVF6ZCd8us/7DkAgnZSBAPUDqGSBt5 KeSQ== X-Forwarded-Encrypted: i=1; AKwUvByeYcddNyoLBxjw9s6drFyiDjh80M37fJz44H6nYdmFA29takyKrmmc8+/7Y4pAGZeBRoYOz0btnA==@nongnu.org X-Gm-Message-State: AFuF++lRPfGmmL2DArL7fT/Ysbg2gA40K4JJS8sLalsdrQtNBb+DuJ2J zZHm7Gisipe08a6BMcArWVyPP2gHUVh/Fvz4wbbFStvC/TftjvsAw7cw X-Gm-Gg: AYBFou0j7aH1/jCBpUMU4jP/nY7OhjUg/JW/MVOcrD6nnPMwHgtvaIG4BhJ/WuowMzo KDIzoYheH4+DnGZnKLqH88PsQxmMLgMejodzFUZBN8wBIGVWqSH1WZv4+AtW58fZGGm9rri0Nr9 BLBcu5KXEM+CNQVTdMalAfEYy9DQ960B6tdLgIERJY8cJRtkEqkkGBgAasPCcuo6RLo+s6xd2Cq 3N9TXitQR6WcxeKeXIV0eBdQ5EYGqjOyLxzsw8Erx7l2ANadfL7df2HRhxGZJ20V8CNjPMvT5JM YlIqK9Mr4Vi5u5tsEJFnNokNAcn2S3Qjy9g6te2yAzp2y/OTZotHr5N+Us8VRIOzjvDy8WVoUss F/eFIk0lDrrS4q833WaJTHYeUQHjOa15gA63E9SYoT5gmnKygMo82z9iW4JCQ3rNbhn1cHFcneP aisocdUhlI63MU4BDfXO4XNd/1MeBJf1NLPImYPCvP3hmEotYsF/rNdcAZjGN2fRy1IAZoe++0W 3vRHCXMn2I6k1aTcTvN0DnjmFh+621gbrUg67YyzA== X-Received: by 2002:a05:693c:638f:10b0:34b:dde6:29c7 with SMTP id 5a478bee46e88-351114568a1mr356247eec.19.1790963580723; Fri, 02 Oct 2026 10:53:00 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:00 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 17/27] target/loongarch: convert raise_exception to raise_excp Date: Sat, 3 Oct 2026 01:50:25 +0800 Message-ID: <20261002175037.1747-18-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::132d; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x132d.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Inline do_raise_exception as it's used by other arch. Use the shared raise_excp_restore helper for translated exceptions and adapt the logging C exception path to cpu_raise_excp() or cpu_raise_excp_restore() according to the return-address contract. Signed-off-by: Yonggang Luo --- target/loongarch/internals.h | 12 +++++++++--- target/loongarch/tcg/helper.h | 2 -- target/loongarch/tcg/op_helper.c | 6 ------ target/loongarch/tcg/tcg_cpu.c | 10 ++++------ target/loongarch/tcg/translate.c | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index ff956823fd7..885d516fe52 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -19,9 +19,15 @@ void loongarch_translate_init(void); void loongarch_translate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, vaddr pc, void *host_pc); -void G_NORETURN do_raise_exception(CPULoongArchState *env, - uint32_t exception, - uintptr_t pc); +void G_NORETURN loongarch_do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc); +static inline void G_NORETURN do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc) +{ + loongarch_do_raise_exception(env, exception, pc); +} #ifdef CONFIG_TCG int ieee_ex_to_loongarch(int xcpt); diff --git a/target/loongarch/tcg/helper.h b/target/loongarch/tcg/helper.h index e76c73c7755..e3a7bc9e9da 100644 --- a/target/loongarch/tcg/helper.h +++ b/target/loongarch/tcg/helper.h @@ -3,8 +3,6 @@ * Copyright (c) 2021 Loongson Technology Corporation Limited */ -DEF_HELPER_2(raise_exception, noreturn, env, i32) - DEF_HELPER_FLAGS_3(asrtle_d, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(asrtgt_d, TCG_CALL_NO_WG, void, env, tl, tl) diff --git a/target/loongarch/tcg/op_helper.c b/target/loongarch/tcg/op_helper.c index f98fe4d4a16..109417b7503 100644 --- a/target/loongarch/tcg/op_helper.c +++ b/target/loongarch/tcg/op_helper.c @@ -16,12 +16,6 @@ #include /* for crc32 */ #include "cpu-csr.h" -/* Exceptions helpers */ -void helper_raise_exception(CPULoongArchState *env, uint32_t exception) -{ - do_raise_exception(env, exception, GETPC()); -} - /* loongarch assert op */ void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk) { diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c index 4b1d44a1644..0a1115721c0 100644 --- a/target/loongarch/tcg/tcg_cpu.c +++ b/target/loongarch/tcg/tcg_cpu.c @@ -59,9 +59,9 @@ static const char *loongarch_exception_name(int32_t exception) return "Unknown"; } -void G_NORETURN do_raise_exception(CPULoongArchState *env, - uint32_t exception, - uintptr_t pc) +void G_NORETURN loongarch_do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc) { CPUState *cs = env_cpu(env); @@ -69,9 +69,7 @@ void G_NORETURN do_raise_exception(CPULoongArchState *env, __func__, exception, loongarch_exception_name(exception)); - cs->exception_index = exception; - - cpu_loop_exit_restore(cs, pc); + cpu_raise_excp_restore(cs, exception, pc); } #ifndef CONFIG_USER_ONLY diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c index 124dce62695..b7e8ce8a653 100644 --- a/target/loongarch/tcg/translate.c +++ b/target/loongarch/tcg/translate.c @@ -95,7 +95,7 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); - gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp_restore(tcg_env, tcg_constant_i32(excp)); ctx->base.is_jmp = DISAS_NORETURN; } From patchwork Fri Oct 2 07:50:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=neTnudzV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGmW2x6Hz1xvt for ; Sat, 03 Oct 2026 04:00:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChYk-0006VG-8c; Fri, 02 Oct 2026 14:00:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRe-0005V4-J4 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:25 -0400 Received: from mail-dl2-x10.google.com ([2607:f8b0:4864:38::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRV-0007hm-Qq for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:15 -0400 Received: by mail-dl2-x10.google.com with SMTP id a92af1059eb24-142dd04f7f2so6295172c88.0 for ; Fri, 02 Oct 2026 10:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963588; x=1791568388; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=V/myMGrF9litc5fpiNrbS1vsILsiL7VfUUCto3gkYyo=; b=neTnudzVmbQFQW3bzJYFfmkqGjtv7C8qiWaLrshg4s2VcuyzWrBcZ+a6Q7NPIC2f2f fsg25+9t+IIltNnAAV9Ii7Mct9c6qA6crePjj4ijQZLuoUNPk53QHCXxNIbGmvLofOt1 tORKDoVNuxzLMgWIrUu2H3yVVR3nqIjm11GOWPdGeF+V0AJ42VNZ4t3UjN2kzOrWcSyo dYQWOFKhV7YKBhb8YlWHe0ET7mVO5YB334NIr0G/t8G9b/dr1rlqauflHchVHuAlvv17 X2LwvcvLn9fscYAg9o+ZrNKZM+9ALJI3VuPG+p3ZC98kzzpa/m4D7DaLmoBO7cjBfoZU IlBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963588; x=1791568388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=V/myMGrF9litc5fpiNrbS1vsILsiL7VfUUCto3gkYyo=; b=narmFJAAPrL8auLa9E53KhKBgLuBcm/AMPkzfyu1ZNI+Bn+p74k7ED/Zw8ivPXGGBS 1G1nM8k+9hm33XN2rC+vcBelWc+CTUHntQ6+iTrlZ5m0HXGsB7E1n6uYQAGPOduWXSMb w8RH6d6AvoUivUFSN8qdGT+xFmmkDqT7yXaQtNduRj3pf+ZfNn1H4lAMR9PGiZoGcBs2 DZNSUF1yUwqHkQHqAjcffhXoeUfY43OPmmz7i7cHGCKRDpG6ICN1HyTMtbL8OcAWbZRT sViPwJ2G5Ixl7VqCp7slO4px771cZRTwbcJmsRRrkTbt3Ug2sTAyjYVpEKVADhFf4cM9 WVyg== X-Forwarded-Encrypted: i=1; AKwUvBwiPAKGsm9YUS+sXuL1Cm0hDLE4uDDB7llhtc++JAEbje7tNKheSPxYD98My0fpYtmU0cXSeBIphQ==@nongnu.org X-Gm-Message-State: AFuF++kE9shXmPtq0LHwX5bGKU14OLPmzIe0tKwXz27Q+yjKvXmL5zDx S6MaGrrtMnGUtZYss8UoslxgogOp3WIuvu0qS3zUP8aNW/+CSAZ02pS+ X-Gm-Gg: AYBFou2ci45Dtql4xS7mVcdDm4qPeqmKTNlOm3rmo3TwpB8F+5zMz4Y4fsdFBLEQVFU MbYoL8Krsk+FUaA2MhnVEu2sTljA71HtcQTYy6rFUWMniHOLxppzskCyoTfxgu18JMJLBEb0yZk N1U3dRLg4ti3qPyPQ01Oc0wmcAzXbuS3zdJgNrZNqfzfmaDRinXNsqPpoJbqnmY49SklRobd4r8 xOmCGRxBih1fzfIpIizI3AviHR2iFiSwtg1eHi5XAV/hx36D/sdMCXPWgKCJPOD/gRB3WQ0c8Jx tQGCOO6ZtGiTeEau/xx9awaqh2wMVz4BjmbC4P3epZeqrTDjSiTpWg2/OcbxAwHYKmCd3UYRPo+ SFwbANCwKESCQcc58wP9KsThFNrUJ734je7ou2HJVzeLIsIYxLfb8iHFwxZ/aFlFL7etyxqbpai 3eVfceRKRn9MDPmFOj0JNRA9DkDNuRL07TXKsNmjFcJTVS7st/0+JQzq6mHLuUjeLkySozS0sJQ nBaHjp+M4emQtH8jVXAUjUh94HF9L4= X-Received: by 2002:a05:7022:1b11:b0:144:de98:eec3 with SMTP id a92af1059eb24-14f590cab13mr4538814c88.5.1790963588190; Fri, 02 Oct 2026 10:53:08 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:07 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 18/27] target/hexagon: reuse cpu_raise_excp_restore Date: Sat, 3 Oct 2026 01:50:26 +0800 Message-ID: <20261002175037.1747-19-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:38::10; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x10.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Inline do_raise_exception as it's used by other arch. Signed-off-by: Yonggang Luo --- target/hexagon/internal.h | 10 +++++++++- target/hexagon/op_helper.c | 5 ++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index 05d1129916e..981ff7c4607 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -36,11 +36,19 @@ extern const char * const hexagon_sregnames[]; extern const char * const hexagon_gregnames[]; #endif -void G_NORETURN do_raise_exception(CPUHexagonState *env, +void G_NORETURN hexagon_do_raise_exception(CPUHexagonState *env, uint32_t exception, uint32_t PC, uintptr_t retaddr); +static inline void G_NORETURN do_raise_exception(CPUHexagonState *env, + uint32_t exception, + uint32_t PC, + uintptr_t retaddr) +{ + hexagon_do_raise_exception(env, exception, PC, retaddr); +} + #define hexagon_cpu_mmu_enabled(env) ({ \ HexagonCPU *cpu = env_archcpu(env); \ cpu->globalregs ? \ diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 4f00ca773f3..1536e81d4b8 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -73,7 +73,7 @@ uint64_t HELPER(utimer)(void) /* Exceptions processing helpers */ G_NORETURN -void do_raise_exception(CPUHexagonState *env, uint32_t exception, +void hexagon_do_raise_exception(CPUHexagonState *env, uint32_t exception, uint32_t PC, uintptr_t retaddr) { CPUState *cs = env_cpu(env); @@ -82,8 +82,7 @@ void do_raise_exception(CPUHexagonState *env, uint32_t exception, ASSERT_DIRECT_TO_GUEST_UNSET(env, exception); env->gpr[HEX_REG_PC] = PC; - cs->exception_index = exception; - cpu_loop_exit_restore(cs, retaddr); + cpu_raise_excp_restore(cs, exception, retaddr); } G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env, From patchwork Fri Oct 2 07:50:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AKzboN9s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGjs4TN4z1yFp for ; Sat, 03 Oct 2026 03:58:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChWb-0002hf-Ry; Fri, 02 Oct 2026 13:58:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRg-0005Vs-NU for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:27 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRe-0007kU-9i for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:20 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34c4a0870d2so3021726eec.2 for ; Fri, 02 Oct 2026 10:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963596; x=1791568396; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oqWBynXG48ziNIxkSUIKa6qk7Q6YVsPFUYwmt+pO3lo=; b=AKzboN9sK8xAD4cqOy/bCmZdw5epqdQ9+dN47Sxkf+wllNolxRp1KpOn1X3xhQo48p Q+Eb+zS1ssg4vuyHs+7+ELJzicWaMg1p2JBKMn31xYyC1pmGpORN1I4E2eVFrvzrkfRW gVCgVMVHFnauLgBhqHw6c5mLkhbBy1W9cabfHyiX78Z+1+Vv1kNzwM0Vw02JnmEiDRPx TPa6XlOV+3Nt/Q1tVP6XLcdG538F1wsMnVzfCdLmHxEOGWBH26P2bSGs0GUBhngggxoE HnXn/Ol5WnnqMxW1qzXPZD6liViAcGNqklRmrb90cSf0kihuvMP8WgAstMqaGCzvDI24 PbJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963596; x=1791568396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oqWBynXG48ziNIxkSUIKa6qk7Q6YVsPFUYwmt+pO3lo=; b=KFBICtigN/GiQr4ylXEt1yIDwV+CLsHP9slgLCfo9YcZHo5FxcPwg2Mi9oiLOvnHo6 YV0kB0emf4jLdBzg5BtC0+VLZMYAAnIZ9gUpzR6Yf+R9OIg3SkLR234cmHkpbaDS/uDs 1AWWMv71gkQPCKtH7HfDQRRFpTcXGwK4SdAjWvp64x2rLg7koT2YZqAF3CwK/UsxjERU 7A2lIn8oy7vViMcjRJuPfQ4hGxba18ZoDzSwwoNnIb8x29/Rx1oH0N9jxm8YQ7iGBHVN M78lFOP5oSkLGkfGOKHDNd7ip514NfxzoGIHPqEKWUzldHDO9JY4LfompAx4BFf8MRA9 gVnw== X-Forwarded-Encrypted: i=1; AKwUvBwfRNkOC1hile/1z48fxyTI4j+7cTGToHJQpi9ouNr0dgBfXK5nw2z00y2tx2ROwGK1EYboYMANWg==@nongnu.org X-Gm-Message-State: AFq9FYJXNYFWO9a6xrimsDfWmMBPoUHB4ruhgYfrU85H0hLMVEpHdHSh 71kBZk3snRIkRi1BFzpm2+EJAVFGtRv+WifaTn7DZblOakZe8gWg8dws X-Gm-Gg: AYBFou1HnqpuVWnqBA8UrGuW4MAnqJYzZdjFkXx0WUNEYimLJ6n/DcgcZZjXM+ma4uF jZcIRotxkL6wljhb8HSVcQA6xrxmIEQJpQIFU6aqzAlKshRrcgB9THnThA2G8qmMeuG+c3M+P42 Mpcd0weCs6q0TYb/SBou9KnrGgeqaQa1Eia5m4gIq3+3Kv7impVrfgEfGqiMZMI1Ej/dBg+6F6t H2jt/WZHriMb7Kk6H/g77MSuC05nUxZo82xRuLQSVlaS0KKmGSDjS5DzsDg/UQ5rvzcsRRrWb+p PcCBWXuGi56+LntYxh+9RFp37rE0ofySmE0xmYvkVVy0+ZAF3Mra1mCfdTcp279zRZTg2TbuiDS Yqpti62QJosrEPVLGeHZqdVmF/gmc4rtYzsjEorL9jaPKcvZIcRxhgZ1u1S+do+6QzHGqisCAdp aW0++g4vp+85mbXUleRe4HTZncHTa4W/5OrYRIwTWQ15PH2hCX8rD4N+ok8GQ7ewc5AJhDMK6fy UEVwV2hbBu/QV8Xs9bxCUyc3whIbWk+1AlaMPzA5w== X-Received: by 2002:a05:7301:fd82:b0:350:1d30:6c0f with SMTP id 5a478bee46e88-3501d3072admr2819520eec.9.1790963595669; Fri, 02 Oct 2026 10:53:15 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:15 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 19/27] target/xtensa: reset yield state in the icount path Date: Sat, 3 Oct 2026 01:50:27 +0800 Message-ID: <20261002175037.1747-20-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Emit the yield_needed reset from gen_yield() before calling gen_helper_exception() for EXCP_YIELD. This keeps the state change at the Xtensa icount-yield call site instead of adding EXCP_YIELD-specific behavior to the generic exception helper. Signed-off-by: Yonggang Luo --- target/xtensa/cpu.h | 2 +- target/xtensa/exc_helper.c | 3 --- target/xtensa/translate.c | 8 +++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 49d6ad9083d..cab2df43709 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -541,7 +541,7 @@ struct CPUArchState { uint32_t ccount_base; #endif - int yield_needed; + int32_t yield_needed; unsigned static_vectors; /* Watchpoints for DBREAK registers */ diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 7cb67d179a8..793761a698f 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -40,9 +40,6 @@ void HELPER(exception)(CPUXtensaState *env, uint32_t excp) CPUState *cs = env_cpu(env); cs->exception_index = excp; - if (excp == EXCP_YIELD) { - env->yield_needed = 0; - } cpu_loop_exit(cs); } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 175fd4b5cfc..db48f0c562a 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -303,9 +303,11 @@ static void gen_left_shift_sar(DisasContext *dc, TCGv_i32 sa) dc->sar_m32_5bit = true; } -static void gen_exception(DisasContext *dc, int excp) +static void gen_yield(DisasContext *dc) { - gen_helper_exception(tcg_env, tcg_constant_i32(excp)); + tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, + offsetof(CPUXtensaState, yield_needed)); + gen_helper_exception(tcg_env, tcg_constant_i32(EXCP_YIELD)); } static void gen_exception_cause(DisasContext *dc, uint32_t cause) @@ -1167,7 +1169,7 @@ static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) but this is the first TranslateOps hook that allows exiting. */ if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT) && (dc->base.tb->flags & XTENSA_TBFLAG_YIELD)) { - gen_exception(dc, EXCP_YIELD); + gen_yield(dc); dc->base.pc_next = dc->pc + 1; dc->base.is_jmp = DISAS_NORETURN; return; From patchwork Fri Oct 2 07:50:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=tGAjrD1H; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGq43l2xz1xvt for ; Sat, 03 Oct 2026 04:03:12 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChWn-0003ZN-TU; Fri, 02 Oct 2026 13:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChRo-0005cP-SF for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:33 -0400 Received: from mail-dy1-x132f.google.com ([2607:f8b0:4864:20::132f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRl-0007lc-QA for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:28 -0400 Received: by mail-dy1-x132f.google.com with SMTP id 5a478bee46e88-32efd24b2aeso430300eec.1 for ; Fri, 02 Oct 2026 10:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963603; x=1791568403; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kqRcLzXufnn7eCg13Qui6eyAhOfVu52+aZltWVm5ghQ=; b=tGAjrD1H8YYbaVHq8pO31aWBtqiF/3gTm4JdgggeiiYIFRCibnT3+IGlfBpKeh1bws nsi1x6q98v4gCetx7D3bzFzJ1b6LaTnENHDbGcRe0AajXLe3tI1LnIQIRGWyimDdVi9d PIGp00Drn1aNHbU+ywnrP3D5mgwbLT0mK1041vThV6SKIjK8izquDfwGlgITvrK2zUyw IgOFhu8xhOe1GYKzKZ4wkv7sJ7v8HwMH+JXvNxrYvpINq47fcEIP6aryFTSNgAzbgzPC SWGDB2diSTvI8iljBZKlwYKsbSeyUZwdO7UkZ0Ea9gyeLZzRQrk4ci1/M5XwDJugmSJW IQrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963603; x=1791568403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kqRcLzXufnn7eCg13Qui6eyAhOfVu52+aZltWVm5ghQ=; b=iBf1S/ywEGRjp0Z7E0q4HyMhBnw4BUY+OKyTzSmsjQ5cfhR4lOxvT6cirmRS8MvxB8 i6zUvhEcXZyIvw6bfwznE9MlAgoVJxrO16TFpMVT98SpVK0Ckbca2v+G4e3jw/HjRpaO LDtt1QtsKGTjmbJOfr9cMzFpwW2M+44/FpKWeIeEg0FYLMg1RIQVjSXgWZ3LI+MzwQpv NgiURPpr0zbu5FgH0jbT+MYYMzusgXEiuNE8YUvOXWBSRbaT9yQ1/bX5vo0GJw3C1MKb yVco7Z6GCVCNyRYPkMiA6T9jKbH+52sF5eZ88EjANaXVedklmFYKpLMemK3VGIy7AweO IzNQ== X-Forwarded-Encrypted: i=1; AKwUvBwwV8/8ZDvYj09/MmFS+FhkrmmtOZ3Y95uH6gE/0guVpamUXiw9n0oU4NX44rdXuYng5TvYlbi1gQ==@nongnu.org X-Gm-Message-State: AFuF++nuSQNl+Yh0ut7mHUFwH7GYXMjZa4XSCwKAYmLLbEDiNLUxFChf Cv+Y4LxleEYjQObEvsWa5/owgx668s9It22gY+2xMRrz2GgcoOOUmY0a X-Gm-Gg: AYBFou39IzTfZ7hWNZ7a6t0NnZ/DwgV+i+uZUlZQ8ml2rY9TAFckTcL6AzIFIur8Qci rVed/2ot+WAATdjx6rHWgz221ZvTebC5zxr56KFx6Ge0D3aUEiIGC+HCGTbh/Ep5xPsnXjqPOhm +MCeMay+wRaCzoRMFPFaGSaw8ToXT3NK3IEXzhZz2wVEAS8FVvrYqMwCU7TdM4hfjHZLgfFvrkq h80yiJp4qho3eauhS6u7gbXfXAvY271u6brOSOdW1Tv2Ar/ZRulSMJxwrY4SqZOe1wRYRx/QUC2 /r6AwX6ilAkDE6Chib17VnFU7dw3vc2eNp5SJ3y8M7+upVcuZn16Vsm0InuItyEm9DLkRo/klXW ieoh9NzSEUb86TSU2WQP1JQ17Xb0p7iv09Xce99ej2xk2OPSyH60t4B4JCjZEaf6HPS1OAb/mTW NDUlwj45til7hQwzG58cA+Jlrzwjwq57AYUzE9InTx9ZyGxX1+Jmly3hJmgpM+OwY9yRAUyDkc5 GwCpFzdVHQF1mzAuuMVfSWBrFGnChs= X-Received: by 2002:a05:693c:41cb:20b0:34d:7ae5:8d78 with SMTP id 5a478bee46e88-351114dfb47mr356720eec.31.1790963603249; Fri, 02 Oct 2026 10:53:23 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:22 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 20/27] target/xtensa: convert exception to raise_excp Date: Sat, 3 Oct 2026 01:50:28 +0800 Message-ID: <20261002175037.1747-21-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::132f; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x132f.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Replace the forwarding wrapper with direct cpu_raise_excp() calls in Xtensa C helpers. Use gen_helper_raise_excp() for translated EXCP_YIELD, while preserving exception_cause helpers for architectural state updates. Signed-off-by: Yonggang Luo --- target/xtensa/exc_helper.c | 14 +++----------- target/xtensa/helper.h | 1 - target/xtensa/translate.c | 2 +- target/xtensa/win_helper.c | 13 +++++++------ 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 793761a698f..d49cc5558ad 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -35,14 +35,6 @@ #include "qemu/atomic.h" #include "qemu/plugin.h" -void HELPER(exception)(CPUXtensaState *env, uint32_t excp) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = excp; - cpu_loop_exit(cs); -} - void HELPER(exception_cause)(CPUXtensaState *env, uint32_t pc, uint32_t cause) { uint32_t vector; @@ -63,7 +55,7 @@ void HELPER(exception_cause)(CPUXtensaState *env, uint32_t pc, uint32_t cause) env->sregs[EXCCAUSE] = cause; env->sregs[PS] |= PS_EXCM; - HELPER(exception)(env, vector); + cpu_raise_excp(env_cpu(env), vector); } void HELPER(exception_cause_vaddr)(CPUXtensaState *env, @@ -90,7 +82,7 @@ void HELPER(debug_exception)(CPUXtensaState *env, uint32_t pc, uint32_t cause) env->sregs[EPS2 + level - 2] = env->sregs[PS]; env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) | PS_EXCM | (level << PS_INTLEVEL_SHIFT); - HELPER(exception)(env, EXC_DEBUG); + cpu_raise_excp(env_cpu(env), EXC_DEBUG); } #ifndef CONFIG_USER_ONLY @@ -113,7 +105,7 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, uint32_t intlevel) } cpu->halted = 1; - HELPER(exception)(env, EXCP_HLT); + cpu_raise_excp(env_cpu(env), EXCP_HLT); } void HELPER(check_interrupts)(CPUXtensaState *env) diff --git a/target/xtensa/helper.h b/target/xtensa/helper.h index ae938ceedb8..4640d0da59a 100644 --- a/target/xtensa/helper.h +++ b/target/xtensa/helper.h @@ -1,4 +1,3 @@ -DEF_HELPER_2(exception, noreturn, env, i32) DEF_HELPER_3(exception_cause, noreturn, env, i32, i32) DEF_HELPER_4(exception_cause_vaddr, noreturn, env, i32, i32, i32) DEF_HELPER_3(debug_exception, noreturn, env, i32, i32) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index db48f0c562a..05c73bef99d 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -307,7 +307,7 @@ static void gen_yield(DisasContext *dc) { tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, offsetof(CPUXtensaState, yield_needed)); - gen_helper_exception(tcg_env, tcg_constant_i32(EXCP_YIELD)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(EXCP_YIELD)); } static void gen_exception_cause(DisasContext *dc, uint32_t cause) diff --git a/target/xtensa/win_helper.c b/target/xtensa/win_helper.c index 4b25f8f4de7..b86a05d6203 100644 --- a/target/xtensa/win_helper.c +++ b/target/xtensa/win_helper.c @@ -27,6 +27,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" +#include "accel/tcg/cpu-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" @@ -125,13 +126,13 @@ void HELPER(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w) switch (ctz32(windowstart >> n)) { case 0: - HELPER(exception)(env, EXC_WINDOW_OVERFLOW4); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_OVERFLOW4); break; case 1: - HELPER(exception)(env, EXC_WINDOW_OVERFLOW8); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_OVERFLOW8); break; default: - HELPER(exception)(env, EXC_WINDOW_OVERFLOW12); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_OVERFLOW12); break; } } @@ -174,11 +175,11 @@ void HELPER(test_underflow_retw)(CPUXtensaState *env, uint32_t pc) env->sregs[EPC1] = env->pc = pc; if (n == 1) { - HELPER(exception)(env, EXC_WINDOW_UNDERFLOW4); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_UNDERFLOW4); } else if (n == 2) { - HELPER(exception)(env, EXC_WINDOW_UNDERFLOW8); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_UNDERFLOW8); } else if (n == 3) { - HELPER(exception)(env, EXC_WINDOW_UNDERFLOW12); + cpu_raise_excp(env_cpu(env), EXC_WINDOW_UNDERFLOW12); } } } From patchwork Fri Oct 2 07:50:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=DlkS/7Pt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGqm63tkz1xvt for ; Sat, 03 Oct 2026 04:03:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChYn-0006fQ-HA; Fri, 02 Oct 2026 14:00:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChS0-0005nO-BF for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:44 -0400 Received: from mail-dy1-x1331.google.com ([2607:f8b0:4864:20::1331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChRv-0007ml-6T for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:38 -0400 Received: by mail-dy1-x1331.google.com with SMTP id 5a478bee46e88-34bb8b31647so246237eec.0 for ; Fri, 02 Oct 2026 10:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963611; x=1791568411; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Xeh4/8nThzjkfpGh7OB2SbQr/xd31Pe82F8UwgQHt9w=; b=DlkS/7PtFwdnoEBQnWSAqD7jmQhM/9G1YfsC0nz0C4sgmLvYbSYMEi7s4p1xS1WgA6 M/VpqYgeNgY5IrgqQ7ROZQuZH4vsVDUHC7xbD1stql0VI6SaxQfGLEzWf/NhJ8A4wAvd rafB0mJan8ZIkQHTSinqTfWlUAl4JNL3J6v959fqCYzyJQHTmbz9EGiumgJMgtYme4Vo 93Gylzm8gOJ3o5vRAqohzv1FmWlo2YyY9hAdO5U+ZzY4mPzZT8+jnZTg3YoyudfK1r7a eb5oTX1IvUXV2HxmehPxEVSao1a/J4Cklqoc69mZqqGKiiPwpLv9j5ODr+EoKIm7/CVB JuhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963611; x=1791568411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Xeh4/8nThzjkfpGh7OB2SbQr/xd31Pe82F8UwgQHt9w=; b=HlKjlzab9sgFtP0b7KSQWQZzYmhrP359wQeItE6KA58mo1c4agyQzx/Nb05btfXnS6 U/ot4IXBBRHLhwEKzbbzK5exbLPqZnjqrZ5ISeTsWR/mvzkLr/ZGS9ykzCCkCkJKUKcs QUyHXlR6QzReq7RSy9GrrMxinnOEt08VB6vxz+vOF6dG+6i4rac7JoMxohSV8kZ/vT6N iRgMoFulOgOGBK2QaPr1l1hon+UYuK30Db9ku/qWuUQo76796GCe4+CG1ElOTNcrdg5+ oODOH3MPBfAchwhhXJ5XAtoPqKwi4ey8H1Fkx/ZvOP2IiVqLhteIYf++FgyS4OSVQ+3p v/5Q== X-Forwarded-Encrypted: i=1; AKwUvBw+iEQxL4j9kU6cD0RxiRsFAKP+g3QByCyEyAyIladFkT8Qh+LiYlj/E2nngQje4V2Qhtlmjebr6Q==@nongnu.org X-Gm-Message-State: AFuF++lDgAtMUDu1Mi6ydZv2tAFZaUgTQhUju9iPcKb032ETOnc4dySu ax4nI4GsJ6TQXNYGYSE0yOZNnNHCvR02+6Qgfmzamaqs2pxtGTEWBJAO X-Gm-Gg: AYBFou3YdYMCWWueIvspJ3tRC2kklrbL0pvdwsNRzDfmmAUZ/B44ApFH+Qag3ejUunY T2UIPfzcCTBbzojtWb39Z+/D7sWaj+Vu68U7xPsl53+cBG3cZAGp3bJaboQy7/N1X1eYI+aUGk9 ZqcXTatsZPOs5xX78j+yIZ4hf1HPn0Fwi3XW7qDsnI6ibLcFT6nvXVP2c+mGa0DJrWp+PjxYS25 uhUxUSCUi5qoJHroWwDfy077Ni3iKVRs41O/Gw1EtmOrLzFRF10Mf0+gl9aNP0+Cr9RJDk8244L s1iZo2gsDx4q8iXhsVOXZmHxVsF8Z1eMGv949b9uAd8sGmCg/JU6OSmOtIp0VYm7ZhC0T5Cw2El FVv/HzrMQLWMDLExooistR1Y6Ogzyz1LyNd7HrlFQf7328XiFH5ScGzbxINI0V7F+Djg1tfIOf3 0qIzCME7ZCJyg27d1wWNxpAqSA+rdXoih4p2ZkCnjiAnsuxgJ+7nIrepgbc+5QxE450auZqyXc7 dS+iQg6Wq7VwL+LuMr2qA6y0lAACaI= X-Received: by 2002:a05:7300:d519:b0:340:e422:fd40 with SMTP id 5a478bee46e88-3511141b58amr520456eec.16.1790963610844; Fri, 02 Oct 2026 10:53:30 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:30 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 21/27] target/avr: convert debug/break/sleep to raise_excp Date: Sat, 3 Oct 2026 01:50:29 +0800 Message-ID: <20261002175037.1747-22-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1331; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x1331.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the shared raise_excp helper for AVR debug, break, and sleep exceptions while preserving target-specific unsupported handling. Signed-off-by: Yonggang Luo --- target/avr/helper.c | 24 ------------------------ target/avr/helper.h | 3 --- target/avr/translate.c | 4 ++-- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/target/avr/helper.c b/target/avr/helper.c index f452c9d9040..ca58a0191fd 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -152,14 +152,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size, * helpers */ -void helper_sleep(CPUAVRState *env) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = EXCP_HLT; - cpu_loop_exit(cs); -} - void helper_unsupported(CPUAVRState *env) { CPUState *cs = env_cpu(env); @@ -176,22 +168,6 @@ void helper_unsupported(CPUAVRState *env) cpu_loop_exit(cs); } -void helper_debug(CPUAVRState *env) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = EXCP_DEBUG; - cpu_loop_exit(cs); -} - -void helper_break(CPUAVRState *env) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = EXCP_DEBUG; - cpu_loop_exit(cs); -} - void helper_wdr(CPUAVRState *env) { qemu_log_mask(LOG_UNIMP, "WDG reset (not implemented)\n"); diff --git a/target/avr/helper.h b/target/avr/helper.h index e8d13e925f4..09ce0624915 100644 --- a/target/avr/helper.h +++ b/target/avr/helper.h @@ -19,8 +19,5 @@ */ DEF_HELPER_1(wdr, void, env) -DEF_HELPER_1(debug, noreturn, env) -DEF_HELPER_1(break, noreturn, env) -DEF_HELPER_1(sleep, noreturn, env) DEF_HELPER_1(unsupported, noreturn, env) DEF_HELPER_3(fullwr, void, env, i32, i32) diff --git a/target/avr/translate.c b/target/avr/translate.c index 3c576060970..477610cd349 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -2554,7 +2554,7 @@ static bool trans_BREAK(DisasContext *ctx, arg_BREAK *a) #ifdef BREAKPOINT_ON_BREAK tcg_gen_movi_tl(cpu_pc, ctx->npc - 1); - gen_helper_debug(tcg_env); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(EXCP_DEBUG)); ctx->base.is_jmp = DISAS_EXIT; #else /* NOP */ @@ -2580,7 +2580,7 @@ static bool trans_NOP(DisasContext *ctx, arg_NOP *a) */ static bool trans_SLEEP(DisasContext *ctx, arg_SLEEP *a) { - gen_helper_sleep(tcg_env); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(EXCP_HLT)); ctx->base.is_jmp = DISAS_NORETURN; return true; } From patchwork Fri Oct 2 07:50:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=EQ8ebtFw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGmZ0z8mz1xvt for ; Sat, 03 Oct 2026 04:01:02 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChWw-0004VI-7n; Fri, 02 Oct 2026 13:58:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChS5-0005rX-49 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:45 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChS0-0007nf-3T for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:42 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34bcb929cceso2698964eec.0 for ; Fri, 02 Oct 2026 10:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963618; x=1791568418; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3djPD4lrHihRA2K/7/0xbymzaT+DB/5oE6KY6UCln9k=; b=EQ8ebtFwuJuYt4OZht3NJ7eNBlDcPW80r7tog4jrv10Z0N7efMsVtfbHQvaG7vpMWa mti59e5MsLmyuVY12cI2S9Vi1t9YG4kQ6dom7mOsfuDALjkwUkHtbp2hbg67HldZzX6/ 85taTbamY1TCqiWv1bz3vWNIbeiwdtnBwiq1Dh2EKr+21Gc0TY4cbaLANS0i8DIeGn3E ezUfe3veHAaVs5k3d9GH76GJ+ZV+U0LRTETaGnPoe+zEM9lXeckOg3kFqiFRhE3YKW8j dGi6mG0N6qoEKxFsOkYIfF5dCJviXBfofnfJVr5MWvvOdQfUCM6sAJZo7n+7kg5PnTTf uoiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963618; x=1791568418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3djPD4lrHihRA2K/7/0xbymzaT+DB/5oE6KY6UCln9k=; b=NT8rs5Ic+yyIKZ+RP10phBlBKWbxHPp68dTjzan6I1gFMaP8bb8yPoGoor/LrCW43S 4mw95dogYRAXoSHj1qHs8OCMFll+XzM9dpBct/rCs80xmCQwLW3PtTjXk9MDY9/I6C+g cW2cZF8KDQaUQiuleD3nFgINpZsCtpNsA/sGEAu6cEgCrmbzvbL6sM25wekD2b18tefl xjUE0ZUfgs1T5U9vIUaXsESaTDiIz9JAN9IrQs/rE2Qtdbv6GTmuA0gVkic1hPu3kxoe SkiKeWsMnmtKuT6MlfqEJUt2QJUyS82/hkZRu/ZjTpbfBmMsuWW2M7AeVEuJNTHGNFCQ HmBw== X-Forwarded-Encrypted: i=1; AKwUvBy8FoA+3qMvYxytf1EC2kACEbx0QcoPrbWUS06Tfz9gmiQ5pNsBrQ/hLXm53vWbZ4CPhbYwKKTo7Q==@nongnu.org X-Gm-Message-State: AFq9FYLdt2nVKF3Won/TsGp6G9slP5lA86pZPcZRj/epRQb1NqQSCML/ +TxO4M6ZzYBv3uKtPcGU+dp69+OA8c7S2QbWYgWuoHd+SxVqKzYd/Jr9 X-Gm-Gg: AYBFou3SM3TQcnvERj/VG8xIjuhzRHNPwORnScl/VyhsX1sm0Od7wqF9MVDVIMgHYTT FfgwAWLf0yqS+mQc+dzk9YywPpNCnrh3VDRZ+2OrNW460VZJevl/tbtHZVKqsvpr38Ju2eVCyUv J6PcFQMzZdyYoEEuoYPqp/vJRexiIvS8BRgvW6JcYgRzHN2KPXSt2eHNPBL3oufiUE58MgWAXqN JWJqfZB3MqZ2m17MaGocFJGCJ0bKMX+ZylqnCx1dGMZgD6xZHX8OpMLeBLIB6ojKLkNeAzyouYO q2qbfPil9dt4JtYIMW1cHglmULIcK3hbW3Ml8csh9znRbJvjdDWvzi5EBHyhHQo+eYfpX4ZnYHS P+Ke7W9rivBU+lAUlGZANieJN18MUwXhlWSTjSrRdi2itGypadJT0hBP2SXi3QGmIbyP8SA14TU Uj+SAaE78Nhi2KecciRc8HiVAYtdbvrjiuuY90mi14XU0leGLhck/PvhbMjyPDuO3dDVNFpPnl8 7qjKNQYXcwF7XQxM+0U4OmQEYnHEEc= X-Received: by 2002:a05:7300:c00e:10b0:34e:f85d:63fc with SMTP id 5a478bee46e88-34f219bf1e3mr4350001eec.39.1790963618351; Fri, 02 Oct 2026 10:53:38 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:37 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 22/27] target/arm: convert exception_internal to raise_excp Date: Sat, 3 Oct 2026 01:50:30 +0800 Message-ID: <20261002175037.1747-23-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the shared raise_excp helper for exception_internal and adapt zero-PC C exception exits to cpu_raise_excp(). Preserve ARM-specific exception helpers that carry additional state. Signed-off-by: Yonggang Luo --- target/arm/tcg/helper-defs.h | 1 - target/arm/tcg/m_helper.c | 3 ++- target/arm/tcg/op_helper.c | 33 ++++++--------------------------- target/arm/tcg/translate.c | 2 +- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/target/arm/tcg/helper-defs.h b/target/arm/tcg/helper-defs.h index 269ac515065..14ef3120373 100644 --- a/target/arm/tcg/helper-defs.h +++ b/target/arm/tcg/helper-defs.h @@ -45,7 +45,6 @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32) DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) -DEF_HELPER_2(exception_internal, noreturn, env, i32) DEF_HELPER_3(exception_with_syndrome, noreturn, env, i32, i32) DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32) DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 65dcf97adef..9c21df772ab 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -18,6 +18,7 @@ #include "exec/page-protection.h" #ifdef CONFIG_TCG #include "accel/tcg/cpu-ldst-common.h" +#include "accel/tcg/cpu-loop.h" #include "semihosting/common-semi.h" #endif #if !defined(CONFIG_USER_ONLY) @@ -575,7 +576,7 @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) */ env->regs[15] = dest & ~1; env->thumb = dest & 1; - HELPER(exception_internal)(env, EXCP_EXCEPTION_EXIT); + cpu_raise_excp(env_cpu(env), EXCP_EXCEPTION_EXIT); /* notreached */ } diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index af56eff9f18..522c309fa39 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -64,10 +64,9 @@ void raise_exception(CPUARMState *env, uint32_t excp, } assert(!excp_is_internal(excp)); - cs->exception_index = excp; env->exception.syndrome = syndrome; env->exception.target_el = target_el; - cpu_loop_exit(cs); + cpu_raise_excp(cs, excp); } void raise_exception_ra(CPUARMState *env, uint32_t excp, uint64_t syndrome, @@ -399,9 +398,8 @@ void HELPER(wfi)(CPUARMState *env, uint32_t insn_len) } qatomic_set(&env->halt_reason, HALT_WFI); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -462,9 +460,8 @@ void HELPER(wfit)(CPUARMState *env, uint32_t rd) timer_mod(cpu->wfxt_timer, nexttick); } qatomic_set(&env->halt_reason, HALT_WFI); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -631,9 +628,8 @@ void HELPER(wfe)(CPUARMState *env, uint32_t insn_len) } qatomic_set(&env->halt_reason, HALT_WFE); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -726,9 +722,8 @@ void HELPER(wfet)(CPUARMState *env, uint32_t rd) } qatomic_set(&env->halt_reason, HALT_WFE); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -740,23 +735,7 @@ void HELPER(yield)(CPUARMState *env) * that the guest is currently busy-looping. Yield control back to the * top level loop so that a more deserving VCPU has a chance to run. */ - cs->exception_index = EXCP_YIELD; - cpu_loop_exit(cs); -} - -/* Raise an internal-to-QEMU exception. This is limited to only - * those EXCP values which are special cases for QEMU to interrupt - * execution and not to be used for exceptions which are passed to - * the guest (those must all have syndrome information and thus should - * use exception_with_syndrome*). - */ -void HELPER(exception_internal)(CPUARMState *env, uint32_t excp) -{ - CPUState *cs = env_cpu(env); - - assert(excp_is_internal(excp)); - cs->exception_index = excp; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_YIELD); } /* Raise an exception with the specified syndrome register value */ diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 6983153ffc6..ad73813fe53 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -379,7 +379,7 @@ static void gen_rebuild_hflags(DisasContext *s, bool new_el) void gen_exception_internal(int excp) { assert(excp_is_internal(excp)); - gen_helper_exception_internal(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); } static void gen_singlestep_exception(DisasContext *s) From patchwork Fri Oct 2 07:50:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Y2APGmN3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGmh0YfJz1xvt for ; Sat, 03 Oct 2026 04:01:08 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChWs-0003v6-15; Fri, 02 Oct 2026 13:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChSB-00065D-UK for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:55 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChS8-0007p2-SQ for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:51 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-346c612c7a8so4171849eec.1 for ; Fri, 02 Oct 2026 10:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963627; x=1791568427; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XbMvtK8JbNTxbjYch33wuTiWl3YypTSLvZWi4QO5mug=; b=Y2APGmN3DrPB3p5oayi2l9aY+JQnBARSYveYhOrzdAuadHFNKeqiwzsXLz/SdqlMc5 67iLFYP1WSkk95PsRS6g9Wee3/uhCz+o7TUBEMeRH1MZWyQws4CYs+G3nz73rrLaJsYJ EU1o0gjZaxwC0+gsAXmj4vjMN8VZ+H7B9zZ8StGMkDSW06GIlJ7Nk0lQcjCmgVy+3Ogf VxX6D/G/KQl30VHSYm/0Y1gEyKZt/TIhCuP8Q+A99oaa+M2JBjmlLWRRxZKPOZj48gXW DEAEszKWdmmPRCqH0yH6Jmz8MzDlxmyVyu8DTMNPRW6X6mEVXAqZGmWLkf7pu7qWJJ+F RwBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963627; x=1791568427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XbMvtK8JbNTxbjYch33wuTiWl3YypTSLvZWi4QO5mug=; b=vw8QLbKc3tSlCCjNrexujqFZUJ1HRwoiHvC3EwXkvS0Pmsg1Ca3ULnVC+wgLzn9jwX 6eizB1J29FC4KNKKJ6jA3txA/ZN7XwzQT9Bzdac/s+mheqQALJnnQoyjdgqZhZNCKH2D gmXo4k0CKSMZmf1+YavdeVf35xkHcrEh2bQUKBO6c8/6JK9pRdEuZJJjSTgCcm2SHVFo YLUtH1y3w9OXQ6XMu+0Bc24x7zitID0+ifrPg9Ltuvg2B40zFvDTtcJwMi7T1AI49yps rI8z7hPZAktI8rt5Apk5y0wRIdnnmfAZguEQCTQq4PjEVShsrYBhvCuVIuw4fv0NHDOp fCiA== X-Forwarded-Encrypted: i=1; AKwUvBw2fgDLnCJtBh5jC3RKIXnvktzcuLrT2SJgmNtwRnD5jtcQ8e5GrO4/s9vwL4jPCOu24KTtf/sChg==@nongnu.org X-Gm-Message-State: AFq9FYIJjv9MdxCDKjcOjIVqxelQL5rqZFs68virsR9WzBliPmcqGF0A CnGIGUwBoepnMH7Eqyclq7NAWvKIy/81bfsrUZSFWEISTC9xrd0F5jDl X-Gm-Gg: AYBFou1xk0dZHeqvwzeaPWHlhlHdfaw/4Iypa26YNK9uI1aeUiluJOg4HLSMqIfpRwx r41QeOnl+e3jfbiGyLXZlBPrMQz1f6SGORiBgcvkisz1Su/1qXomtb28jzFupyrL0KPF2igWlui f0H1eHxyFpdWzYNnTZJ8KAKnwb9n4tL4Ju6WDvLMI6Nnef6jX9unEkxFKUNwN2iMwmV+6Lz7TeS /qXafo3R9WMa46ChImvYD0DdIYlIptEPJ3QsFWT7Ss4jNumvYUwIbyLguHNGOlunJ9jLdaL15iT eqGipyfp/WzS24zzahKiKbUshX/1uOaw/lnBBGYMFFFyGHUfPlJ7Lj7DQst0EI5MPNiPjroKQlz qDLMr7t4zvouscl10HYUyCUh9yN5KqR+EJk36RCc4JDXw7pmSWS9DCOLsdkBj+3drAMXSXfJI7b 4tMPcnK3CAnIKep6lnw+snZXBqEhkhV6VULJpOdnZifHNDxF0YeI+prougPXbFGfXZA62DA6hj9 bcNhvxjEGoq10UQQ++ZNpVVsaUi4v0= X-Received: by 2002:a05:7301:4b07:b0:34f:d831:7f71 with SMTP id 5a478bee46e88-34fd8318127mr3095952eec.23.1790963626419; Fri, 02 Oct 2026 10:53:46 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:45 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 23/27] target/riscv: use cpu_raise_excp_restore for exception exits Date: Sat, 3 Oct 2026 01:50:31 +0800 Message-ID: <20261002175037.1747-24-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Keep riscv_raise_exception() for PMU bookkeeping, but delegate exception handling to cpu_raise_excp_restore(). It restores guest state when pc is nonzero and falls back to a plain exception exit otherwise. Signed-off-by: Yonggang Luo --- target/riscv/tcg/op_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/riscv/tcg/op_helper.c b/target/riscv/tcg/op_helper.c index b67c7718db4..ca4efadec50 100644 --- a/target/riscv/tcg/op_helper.c +++ b/target/riscv/tcg/op_helper.c @@ -47,8 +47,7 @@ G_NORETURN void riscv_raise_exception(CPURISCVState *env, riscv_cpu_get_trap_name(exception, false), env->pc); - cs->exception_index = exception; - cpu_loop_exit_restore(cs, pc); + cpu_raise_excp_restore(cs, exception, pc); } void helper_raise_exception(CPURISCVState *env, uint32_t exception) From patchwork Fri Oct 2 07:50:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=b+8iTlAw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGpb54xcz1xvt for ; Sat, 03 Oct 2026 04:02:47 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChXW-0005kq-Vz; Fri, 02 Oct 2026 13:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChSI-0006Cx-JB for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:03 -0400 Received: from mail-dy2-x0f.google.com ([2607:f8b0:4864:36::f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChSF-0007qC-G0 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:53:58 -0400 Received: by mail-dy2-x0f.google.com with SMTP id 5a478bee46e88-34b1743e9c7so2342461eec.3 for ; Fri, 02 Oct 2026 10:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963634; x=1791568434; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=be9pR789RqOevAubKubuImhGiaujKFqfN5I1ORufONw=; b=b+8iTlAwP7weAATpLPOjkzTGqqkEGlIxc9bRbBZa/0x8WuTFOFPSHwhTpctVF1ZY9e yPoTpukEIV8Ktpnwr25+lN+SwjNhTRB+nl3bkrNC7vM9SwshKADY+l0sOrlo4Sq50upg GG+i5+ooqTXTP1m3v7T7+wTcLkXLJvDyeoNgGexBwWQMOwEX0fbt+XoLXzVjcMCbMnK3 kJXz7j62+dzUVob93wCBRyeUcrKoyZ/j2PbzLjTYEYkpy7XdQraTWbfTx3YmBUCINlqs RdAlRipVR8SPS+c9OWLou+PKQJsquBSDmZH+BkT0sXkc/eJXl8UCKb5J+18cyIim1K6C nTzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963634; x=1791568434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=be9pR789RqOevAubKubuImhGiaujKFqfN5I1ORufONw=; b=WCpNpuYwZDPsl9r1BgDJU+Na1kr8TTF7De0PAwYOyxtVjp2Gt7LdXjTz/glbcGCegJ c7ZH2d2Leb4MZGzeQYa6eS6DbG30LdFU3mL2iz+FRGzTtRAiuSGbJWHmrDE1njnleM/+ ijsAblIq/VZMioTqrWdOvITILiVfgNHwxcyuP6SKEQGqiogDh6rU6BFzO5HTZ6XiatvT pzy2dRuMFQXTz5bScWHXiIGREZalRUEwUQdXbcWM3aOqmWP5Dg1e1N1m3QvrL7Q91p+6 i16bdfxq9G9i9XyuLQ+U5SW9jVbl1sV9NkStFyepEXxpWFKshgcfLM9R2vdJ8K0uOP52 h3tg== X-Forwarded-Encrypted: i=1; AKwUvByxq+tg7uHDub4rn81yL6LDeUhubNG2q8B/xKfV9uNi/fglq78/slYdYfMMmagQTdJqbRWqs5obBA==@nongnu.org X-Gm-Message-State: AFq9FYICBZRPTSgR4TXKh4k7haTnu1p0KWbAbsXXc3ZXYJkHq1Qhi30u Lcs40ybvudQWzcWolK1jrld6o/UmUZ0KB/lM3lXvzvJIxIj+VrbTGQzj X-Gm-Gg: AYBFou3uNbRZDnYhqnnWJfMUXnWBXfn+Rx/epXCCiA04pDMgbinhZN12yHZPUi+p7NG KihDGtL5z7qKTXc6to8ft8DHiwsI44fulu9XlHsr0+22JJJosZ6wdO9gF8ZZ84rjaKOQv67sDdH nVSYHstE3vU17mMzZPUeX8Lf0vartyDDvShFu7L9DbGBT1yes48aE0Fe94ltLMZ3cOK+qIXA8aQ 3aJ84g6AoV/oLPJK5A+Aacllj3K9MMJ+yfTvtzaRk1K+eon345K9Er8tDJUsztXfdBsg62mHo7P efOQlC66eRRFIzTgDlOCQkeFd5kXQeDmv9kiNvxyzIfJO8k+twZJXCdaXNI2lu3T+YmrNHAkzss t+CBw5t/CdLyjeaR4DzYBE7YFIMwzHOK6f9MXTUxL1YMWRvh58ghrS0c7Tv8aeDGgWptYi+6YXt 9FPeOSn+AYxmX0ePnluf8x2VhM6RZGjt0OYAqUSxsa8zoVO6t1X5FDb9T8JiVCkzao/enSivXtZ UXTgnN+CgfqwBd6lWCVa6/OxFBVgrg= X-Received: by 2002:a05:7301:1526:b0:34e:f8bb:4e23 with SMTP id 5a478bee46e88-34f150b0142mr3668009eec.19.1790963634017; Fri, 02 Oct 2026 10:53:54 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:53:53 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 24/27] target/mips: call do_raise_exception directly Date: Sat, 3 Oct 2026 01:50:32 +0800 Message-ID: <20261002175037.1747-25-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::f; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0f.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use do_raise_exception() directly for reserved-instruction traps in the FPU helpers, passing GETPC() to restore guest state. Keep helper_wait() on the zero-PC path, where the guest PC was already updated. Signed-off-by: Yonggang Luo --- target/mips/tcg/exception.c | 7 +------ target/mips/tcg/fpu_helper.c | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c index 630b8b809fa..514880ccba8 100644 --- a/target/mips/tcg/exception.c +++ b/target/mips/tcg/exception.c @@ -60,11 +60,6 @@ void helper_raise_exception_debug(CPUMIPSState *env) do_raise_exception(env, EXCP_DEBUG, 0); } -static void raise_exception(CPUMIPSState *env, uint32_t exception) -{ - do_raise_exception(env, exception, 0); -} - void helper_wait(CPUMIPSState *env) { CPUState *cs = env_cpu(env); @@ -75,7 +70,7 @@ void helper_wait(CPUMIPSState *env) * Last instruction in the block, PC was updated before * - no need to recover PC and icount. */ - raise_exception(env, EXCP_HLT); + do_raise_exception(env, EXCP_HLT, 0); } void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) diff --git a/target/mips/tcg/fpu_helper.c b/target/mips/tcg/fpu_helper.c index 36af9808025..ce68cda1e43 100644 --- a/target/mips/tcg/fpu_helper.c +++ b/target/mips/tcg/fpu_helper.c @@ -61,7 +61,7 @@ target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg) if (env->CP0_Config5 & (1 << CP0C5_UFE)) { arg1 = (env->CP0_Config5 >> CP0C5_FRE) & 1; } else { - helper_raise_exception(env, EXCP_RI); + do_raise_exception(env, EXCP_RI, GETPC()); } } break; @@ -120,7 +120,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt) env->CP0_Config5 &= ~(1 << CP0C5_FRE); compute_hflags(env); } else { - helper_raise_exception(env, EXCP_RI); + do_raise_exception(env, EXCP_RI, GETPC()); } break; case 6: @@ -132,7 +132,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt) env->CP0_Config5 |= (1 << CP0C5_FRE); compute_hflags(env); } else { - helper_raise_exception(env, EXCP_RI); + do_raise_exception(env, EXCP_RI, GETPC()); } break; case 25: From patchwork Fri Oct 2 07:50:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=I+VUBRDx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGl34L52z1xxW for ; Sat, 03 Oct 2026 03:59:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChWw-0004VD-7b; Fri, 02 Oct 2026 13:58:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChSU-0006Lv-34 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:20 -0400 Received: from mail-dy2-x0d.google.com ([2607:f8b0:4864:36::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChSN-0007rO-74 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:07 -0400 Received: by mail-dy2-x0d.google.com with SMTP id 5a478bee46e88-34b6f8b8113so1815277eec.0 for ; Fri, 02 Oct 2026 10:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963642; x=1791568442; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EakiUp5Er8KTxWGtVN1gjNJevoTRcpm4tzLgGCRbVLs=; b=I+VUBRDxPJHu8iBsKoL8zmPPnKRLa2BReZp1pSdN0uz8bnwqG6CL+t82W2VnAxqUoM 83xseJ4uNLphCWaFBWo921VSp7bn/AMyQc9PwVcXJGohOIH2OMguhAjILEotAlRDXC3a FTTWq4bcAy5BO9DtXWigAQCSV45e2hE4JLZeTyiQZBi+pCThIzTIR6q4P+3xJVAeoYOJ 218T/cbQpeHl1uEFg+ITtaAoQ+aS6hOjNePfzLcEeZN9iAxf/p1bQDkqOkpWxqr3M7h5 JcMU/0PDupKhpBYfbwb1/DakcD2E4r3lI5GXpAero+PeZPtbDOVbPCQx+fQ2xkoXWLfJ 9ZQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963642; x=1791568442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EakiUp5Er8KTxWGtVN1gjNJevoTRcpm4tzLgGCRbVLs=; b=GzheAKgwI7paCnFBT3sEIIZfznXvqHYn6I1lVCWdYgjE8KsrGgTNpAljkJPdUhFI4/ zgw8JLsHEMt4pRHZ636fE5zxhpkRW4tsm8IA0RPXL5rDL5IzaveijB5CFCTbZRYpHGTz Ix+eNlkzsWEdpTWdyccxrjj2m29n1BhIAVUaFzKvq/D4i85xz3LUcUNIHQ990LrwqXek 8ZLtH66Ysv70AxBH/9CpHRXBg8FfdSoPQukoDlsz7LMfUnsA28DekuyzJIBMMOwuMOy8 Q+wMr6mMJhunxpht6JDjDQFmddpbP0iwctNyCTEk+szmHp77pj/OMgLGPhxxACgQQV1a BDBA== X-Forwarded-Encrypted: i=1; AKwUvBx9bZxfBpYsrp3ZT6CX1QHwtAS2V1qeiELbBpfBoZyJ84KeUwx2PZptH9hsqOYLNYwE28vrzwrZDw==@nongnu.org X-Gm-Message-State: AFq9FYIMo03ZRZ3w4PdZm1aNG+bD40G0XWJypFg4bjRrPjEpRP9I5FvL A+F7VJ9zFPXYO93Huyxm+sZEfCHcx/CstfehKKvoUXdHN61xQbw+gqEG X-Gm-Gg: AYBFou0kmbzhUUktfhgSbt5MVIbXl850lDrbBReXESbTToLpSPdLv6T9FLNIN9CxQjT zohiL5TYEjZAc3VfQXWZMMQ9qBcjJQD79An+DxwuUCbzzeRkBrICTRBsgtJWvHW8fveLMrXOuRm rooJHcxWRw+AZ67zzFSyMACwjiOmYbakD+qPRTIxUT4d/PPyItMqMUZu4mvfuIDWra4ZTHumRMA Gh8ld5L4JLLu8Nof8sKItmPonEkYEAzEbwqNx0TxSIeDcz3B3yv79Q2nPXcDtgxSeBXgObqeVpx 27lSDOsaviXTpOpuUT7f/fJt86uf5b7j6jiGuKnVZso7Y39tdk/CWFp+w1bHY2x0P39f3pCX71t BvNeB2KvhiAYP9l0l2Xoih1mNpT+0MqhC7Jv7fxZ7crWjzdiIrSF5wo/jYH18NYAL7q66Pud55H aUEwro+G1VfPfz/0cS7WY5bSd1+/SghRwIJryny2ksctIai3UxNpsTceKZJtiQJDMec5rNaorM9 a8BGyqEdNkpbG66rN2O390OJG+yEA8= X-Received: by 2002:a05:693c:65c5:b0:33c:43c:f3dd with SMTP id 5a478bee46e88-34f2196cd67mr3188654eec.11.1790963641539; Fri, 02 Oct 2026 10:54:01 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:54:00 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 25/27] target/mips: use shared TCG exception helpers Date: Sat, 3 Oct 2026 01:50:33 +0800 Message-ID: <20261002175037.1747-26-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::d; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0d.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Generate exceptions with gen_helper_raise_excp() and gen_helper_raise_excp_restore(), storing error_code in CPUMIPSState before raising. Route do_raise_exception_err() through cpu_raise_excp_restore() to preserve guest-state restoration. Signed-off-by: Yonggang Luo --- target/mips/cpu.h | 2 +- target/mips/helper.h | 4 ---- target/mips/tcg/exception.c | 20 +------------------- target/mips/tcg/translate.c | 9 ++++++--- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 32549791a18..b6bb9028ecf 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1141,7 +1141,7 @@ typedef struct CPUArchState { TCState tcs[MIPS_SHADOW_SET_MAX]; CPUMIPSFPUContext fpus[MIPS_FPU_MAX]; /* QEMU */ - int error_code; + int32_t error_code; #define EXCP_TLB_NOMATCH 0x1 #define EXCP_INST_NOTAVAIL 0x2 /* No valid instruction word for BadInstr */ uint32_t hflags; /* CPU State */ diff --git a/target/mips/helper.h b/target/mips/helper.h index 779b87101db..83a6dd0b3c4 100644 --- a/target/mips/helper.h +++ b/target/mips/helper.h @@ -1,7 +1,3 @@ -DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int) -DEF_HELPER_2(raise_exception, noreturn, env, i32) -DEF_HELPER_1(raise_exception_debug, noreturn, env) - #ifdef TARGET_MIPS64 DEF_HELPER_4(sdl, void, env, tl, tl, int) DEF_HELPER_4(sdr, void, env, tl, tl, int) diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c index 514880ccba8..20705192988 100644 --- a/target/mips/tcg/exception.c +++ b/target/mips/tcg/exception.c @@ -44,22 +44,6 @@ target_ulong exception_resume_pc(CPUMIPSState *env) return bad_pc; } -void helper_raise_exception_err(CPUMIPSState *env, uint32_t exception, - int error_code) -{ - do_raise_exception_err(env, exception, error_code, 0); -} - -void helper_raise_exception(CPUMIPSState *env, uint32_t exception) -{ - do_raise_exception(env, exception, GETPC()); -} - -void helper_raise_exception_debug(CPUMIPSState *env) -{ - do_raise_exception(env, EXCP_DEBUG, 0); -} - void helper_wait(CPUMIPSState *env) { CPUState *cs = env_cpu(env); @@ -140,8 +124,6 @@ void do_raise_exception_err(CPUMIPSState *env, uint32_t exception, qemu_log_mask(CPU_LOG_INT, "%s: %d (%s) %d\n", __func__, exception, mips_exception_name(exception), error_code); - cs->exception_index = exception; env->error_code = error_code; - - cpu_loop_exit_restore(cs, pc); + cpu_raise_excp_restore(cs, exception, pc); } diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 936f8c4eddc..81c4301f625 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -1316,14 +1316,17 @@ static inline void restore_cpu_state(CPUMIPSState *env, DisasContext *ctx) void generate_exception_err(DisasContext *ctx, int excp, int err) { save_cpu_state(ctx, 1); - gen_helper_raise_exception_err(tcg_env, tcg_constant_i32(excp), - tcg_constant_i32(err)); + tcg_gen_st_i32(tcg_constant_i32(err), tcg_env, + offsetof(CPUMIPSState, error_code)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); ctx->base.is_jmp = DISAS_NORETURN; } void generate_exception(DisasContext *ctx, int excp) { - gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp)); + tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, + offsetof(CPUMIPSState, error_code)); + gen_helper_raise_excp_restore(tcg_env, tcg_constant_i32(excp)); } void generate_exception_end(DisasContext *ctx, int excp) From patchwork Fri Oct 2 07:50:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=f7Wb45ar; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGtt0dxwz1xxW for ; Sat, 03 Oct 2026 04:06:30 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChcM-0000ik-Hn; Fri, 02 Oct 2026 14:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChSb-0006OF-N7 for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:30 -0400 Received: from mail-dy2-x0f.google.com ([2607:f8b0:4864:36::f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChSU-0007sD-Jq for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:13 -0400 Received: by mail-dy2-x0f.google.com with SMTP id 5a478bee46e88-340f56c44b0so3439942eec.1 for ; Fri, 02 Oct 2026 10:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963649; x=1791568449; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yKl9yArNq3w173PSahK6ICbfpEDWkJ6jn3RpCMJdn7U=; b=f7Wb45arpAD5m4bYFQjl3p90IWp83VfJi8BlSXC5fW14dBTsT6+uscBDddcBSIQPs5 +60zb0vv4fod/fPgObr5iVAJYRXA1h1ynimj35werdAKiAOImehutw7OwR/BUv8Z1rUG acvYddCwwcrVmrtyVtuAgIBbiY2JNBAStN1LlyW55vQVUAg9GvFNSbm0MDOaZNd0Z4Cv dmZWXfKBQcWwG+PE9ttFoxdjrnxrJogKJPI/qmk0hsukZhdNx4etQGEsQrirH7uOa6b0 PMsYHjUY67/3avD5Cv70b/oJDuo92hZodMtvpa8js23Y4ZEg1FELImN5XQ3SLQd6YBYa bYHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963649; x=1791568449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=yKl9yArNq3w173PSahK6ICbfpEDWkJ6jn3RpCMJdn7U=; b=FijbwR83aR30KyIvhHywUDK3lj4Hl7UrBqWvR/iEXvcuG/c43oqd/98kpnkbKKaChl //p7+RxkAufT9+EJMZxUKZPDXt2Cxp6Q7odAu1F8/kktFWxURjqfbCz4T8dqizmqbvDh 1BGsEO7R7+8OD1asNo6RZFjs5BznicUX1USogEMOXnzNfcdo/wuscxTScKvsowZ2FWL1 XgLZuqTrGBx4aocIqp/iktlo4v8GOYYc8MmSYuUTzM19stUhebM3sTXoFB874f12aa3u 3z8b9Ag9X64qooy4rtRWRxkX3JE8nSaoD81TkXDGbRPH/pMix4hd4ZMExkyEha0ZSjwb As8A== X-Forwarded-Encrypted: i=1; AKwUvBwfBAo4TvuZulkdSywE8PdD6DGXkGyJid9uaujhsXUcGBq6DF4WT8LEMM8OyttbeTU062fUsSdJAg==@nongnu.org X-Gm-Message-State: AFq9FYL2JVIqirUMBEXbQg9rVsoS6F9Y9NaYakjcKz7tyP614CZrV02d qgpC0oGYTp1l9c82JmIt8s3Un8De8CJ1Qrc5P4wPeloK7PgsY3r1xAN3 X-Gm-Gg: AYBFou2SYH6d5sVe4zeWC2MCoX9ZcbdY6067V7zVSuy0oeTk1BAAzI26bguPlDCQ2o2 f8RvEB58MASkC8LWbFuUUGU7fx1mLW2/GY824CyGDRmWOrVsgHPwscIZzAgHUjCabSPybmTX2ek SlNWYemyYXlPBi2vtM69VQhumW7Z0qo6URdLHSsZn805S1stCx56yMyAofBpaNjrejmGfucqVQR yf5nnzpnj1PyzQFvIGmLQbg2miS/3wnciJTZjglyrjcJG19iXOsJLWyzFFzCPSHSblHQ3Bcft+E y85vPUtuq8L9+NItbIbq7YTvNVAHhMWT93s+17EdXiN9aPKGcox0ijw3X0TYpXwiXbbEw8XqE6E bs1SgH5A1kRcorPf73E1s7Ulm2SuRwmm8k/oKviPwa781BJVjCdOTPhVpgPBlY+15pyuiAjQuHc IEKI9NQFBClxSA4kfWvr16XkDZ98ZfnvGTP2ApxK3r8QRbwh8M6Cr06/dKWYElTxFWo8+PPs/9a IM/OvNjNIgQ2u5N5N4ukJ4ftyhDjJ08 X-Received: by 2002:a05:7301:4547:b0:33b:e75b:cc42 with SMTP id 5a478bee46e88-34f150c2f6amr3129500eec.19.1790963649062; Fri, 02 Oct 2026 10:54:09 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:54:08 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 26/27] target/ppc: reuse the error-aware NIP exception path Date: Sat, 3 Oct 2026 01:50:34 +0800 Message-ID: <20261002175037.1747-27-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:36::f; envelope-from=luoyonggang@gmail.com; helo=mail-dy2-x0f.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, FREEMAIL_FROM=0.001, 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-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Route gen_exception_nip() through gen_exception_err_nip() with a zero error code, reusing its NIP update and exception-generation path. Signed-off-by: Yonggang Luo --- target/ppc/translate.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 467b8f3d4ec..f1a7039a325 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -330,12 +330,7 @@ static inline void gen_exception_err(DisasContext *ctx, uint32_t excp, static void gen_exception_nip(DisasContext *ctx, uint32_t excp, target_ulong nip) { - TCGv_i32 t0; - - gen_update_nip(ctx, nip); - t0 = tcg_constant_i32(excp); - gen_helper_raise_exception(tcg_env, t0); - ctx->base.is_jmp = DISAS_NORETURN; + gen_exception_err_nip(ctx, excp, 0, nip); } static inline void gen_exception(DisasContext *ctx, uint32_t excp) From patchwork Fri Oct 2 07:50:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 2315279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=HAG9RBX0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists1p.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxGrQ588cz1xvt for ; Sat, 03 Oct 2026 04:04:22 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChYn-0006fM-HA; Fri, 02 Oct 2026 14:00:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xChSf-0006Oy-Gi for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:32 -0400 Received: from mail-dl2-x2b.google.com ([2607:f8b0:4864:38::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChSc-0007t7-5V for qemu-ppc@nongnu.org; Fri, 02 Oct 2026 13:54:21 -0400 Received: by mail-dl2-x2b.google.com with SMTP id a92af1059eb24-1438cb9b3a3so6960308c88.2 for ; Fri, 02 Oct 2026 10:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963657; x=1791568457; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ppUhyKk2KJwdv1lKi3ysuIQtsrve0MU7LeCIa3mu2kU=; b=HAG9RBX08/NLbbDt0Y/xXuGpV0bpCZuVBRwzHhhEgmmmyYBT8RDMYHCuQ2efX8tCtC m01VoarBnfHWdWAhIobdnG/uh7hUAsDInSBh7IcztvT6HsXoQ+320vRV+vjRMORDEWZ4 dSxN53soOFb/0BeuFqB0rwoRd3erqwtGexD7cTHlnWPVUOZ6vB9OTnbfnYYYfcZPtaRA 4NNgx8zMK4KD5z6RYYvDe+pFbiBW1xEdh/95modsmCCDmZ5ywdnRCI0SU3H4he5Le4dq KzxkIDJBVbutyvuZubv8ccAzmGFd5/YtoB2zKvYnxVeq5t85wC70SzcCY28ryIEX5Vf7 Uh4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963657; x=1791568457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ppUhyKk2KJwdv1lKi3ysuIQtsrve0MU7LeCIa3mu2kU=; b=UhZ46gRXZkuSu4oTf6kG061GJl/htGX0yfXxh4aSlK3McRKIE1QyVJB6z/zUMRCltP ATCyDNgetLK1AgtRYEofObrWWBQhmPBpBcnm9w0HZo4lQDDKyW03EC+jDkeT+mLk34cE RY43mAEnYnVG45jmwhhIEEYXet2r2qdL5WulbdIrEfznFVUkOQj0t8bg4c4sJUAZ4+Ap sZ66+rtBZRwZSQl6zNGT2iyGNdAf4U3x94YaB83n28hy/2dJZNRE8YRAYN5HvRK1089A Jl4QZpQbsOliB+TOtUAO8wY6E8J5nKUCDf6nBWquc4MnLgbfn+nCCfWApZ6mdGVX9/T1 jeug== X-Forwarded-Encrypted: i=1; AKwUvBzioiFLwzD7nF1rHp13jP7H2JAH25ZeLKPdJwG16MJbIjrqF3SqPwSee/gPAAHXWBMht8LTQfdkjA==@nongnu.org X-Gm-Message-State: AFuF++nb6pRo2FM55tmXpMXS08aNMY54xJRGPA06FkjUS1aC4YOb1FFg UVV6dTN+0hjq0ZkIJ3VTBpLi1J1QzIslPlh1UV9ao70Yx4KbgTZCjuaa X-Gm-Gg: AYBFou1G/+G/v0b5ecTIAOgT0UPURKWejySk9ApkXH21QA9wEHLenAIngo5BUhFcWRC OCTHMe73fvRlHwfHHhftkzZCYy3lsMakxAVqgQ/jNKsX6DjR62ELbhmbdErCuqNTE1k7ENSgv/O il0o94fZRBtrvygP5ldWXXpzMHJeFI3QMXhHFuPqvx+y8XOEBm58X06TsF9LCnxXkwA6O6vKgdu eQw1ELZNe9ha2CZUGGLeIfIW9oUv99adsyvsaxEne9yBmNl4qY9HECFxsm68nD0gJjYsdHO9700 vCwm1rA7L/5mnPGcGEYXAAW6Lkc/qtIY3O3ZTDKs8c2keH1chTfnXdeRUT8pSlNxPL/XK9Q6C1Q uNCFko3hd4/nSkeH8fLLI+GEfwqgAln/w7jrWVqMsmIEwL3iIqthzKarIlQrG1vjU9nuGTu5Kb3 MNkT8ezElroYk+G2zcr0jEhmnZnniWs53BFpdkbB/Vnw0eTW+GcIE0qhfyDvtRGTCE4TPo50w6q HcbrMMNTbkVhmCMRT26koWer/6Z9oA= X-Received: by 2002:a05:7022:3b88:b0:144:ddf7:2570 with SMTP id a92af1059eb24-14f5cec202amr4422608c88.39.1790963656699; Fri, 02 Oct 2026 10:54:16 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:54:16 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 27/27] target/ppc: use shared helpers for translated exceptions Date: Sat, 3 Oct 2026 01:50:35 +0800 Message-ID: <20261002175037.1747-28-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:38::2b; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x2b.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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Store error_code before gen_helper_raise_excp() and define raise_exception_err_ra() inline in internal.h to preserve PPC error-code handling while using cpu_raise_excp_restore(). Remove the obsolete TCG exception helpers. Signed-off-by: Yonggang Luo --- target/ppc/cpu.h | 5 +---- target/ppc/helper.h | 2 -- target/ppc/internal.h | 9 +++++++++ target/ppc/misc_helper.c | 1 + target/ppc/tcg-excp_helper.c | 21 --------------------- target/ppc/timebase_helper.c | 1 + target/ppc/translate.c | 13 ++++++------- 7 files changed, 18 insertions(+), 34 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 3fb51bbeb82..f1b1cf94331 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1392,7 +1392,7 @@ struct CPUArchState { uint64_t insns_flags; uint64_t insns_flags2; - int error_code; + int32_t error_code; uint32_t pending_interrupts; #if !defined(CONFIG_USER_ONLY) uint64_t excp_stats[POWERPC_EXCP_NB]; @@ -2819,9 +2819,6 @@ void cpu_write_xer(CPUPPCState *env, target_ulong xer); */ #define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B)) -G_NORETURN void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, - uint32_t error_code, uintptr_t raddr); - /* PERFM EBB helper*/ #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) void raise_ebb_perfm_exception(CPUPPCState *env); diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 80d6616bab4..8a804d326ac 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -1,5 +1,3 @@ -DEF_HELPER_FLAGS_3(raise_exception_err, TCG_CALL_NO_WG, noreturn, env, i32, i32) -DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) DEF_HELPER_FLAGS_4(TW, TCG_CALL_NO_WG, void, env, tl, tl, i32) #if defined(TARGET_PPC64) DEF_HELPER_FLAGS_4(TD, TCG_CALL_NO_WG, void, env, tl, tl, i32) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index a20a0f9f7e0..66e017be74b 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -320,8 +320,17 @@ static inline int ger_pack_masks(int pmsk, int ymsk, int xmsk) #ifdef CONFIG_TCG #include "accel/tcg/tb-cpu-state.h" +#include "accel/tcg/cpu-loop.h" TCGTBCPUState ppc_get_tb_cpu_state(CPUState *cs); + +static inline G_NORETURN +void raise_exception_err_ra(CPUPPCState *env, uint32_t excp, + uint32_t err, uintptr_t ra) +{ + env->error_code = err; + cpu_raise_excp_restore(env_cpu(env), excp, ra); +} #endif #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 0e625cbb704..527af513f92 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" +#include "internal.h" #include "exec/cputlb.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" diff --git a/target/ppc/tcg-excp_helper.c b/target/ppc/tcg-excp_helper.c index 93aedb0c8e2..6289ca7dfd5 100644 --- a/target/ppc/tcg-excp_helper.c +++ b/target/ppc/tcg-excp_helper.c @@ -34,27 +34,6 @@ /*****************************************************************************/ /* Exceptions processing helpers */ -void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, - uint32_t error_code, uintptr_t raddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = exception; - env->error_code = error_code; - cpu_loop_exit_restore(cs, raddr); -} - -void helper_raise_exception_err(CPUPPCState *env, uint32_t exception, - uint32_t error_code) -{ - raise_exception_err_ra(env, exception, error_code, 0); -} - -void helper_raise_exception(CPUPPCState *env, uint32_t exception) -{ - raise_exception_err_ra(env, exception, 0, 0); -} - #ifndef CONFIG_USER_ONLY static G_NORETURN void raise_exception_err(CPUPPCState *env, uint32_t exception, diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 7209b418fb6..d0986ff261a 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" +#include "internal.h" #include "hw/ppc/ppc.h" #include "exec/helper-proto.h" #include "qemu/log.h" diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f1a7039a325..767b8ed7697 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -308,12 +308,10 @@ static inline void gen_update_nip(DisasContext *ctx, target_ulong nip) static void gen_exception_err_nip(DisasContext *ctx, uint32_t excp, uint32_t error, target_ulong nip) { - TCGv_i32 t0, t1; - gen_update_nip(ctx, nip); - t0 = tcg_constant_i32(excp); - t1 = tcg_constant_i32(error); - gen_helper_raise_exception_err(tcg_env, t0, t1); + tcg_gen_st_i32(tcg_constant_i32(error), tcg_env, + offsetof(CPUPPCState, error_code)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); ctx->base.is_jmp = DISAS_NORETURN; } @@ -372,8 +370,9 @@ static void gen_debug_exception(DisasContext *ctx, bool rfi_type) gen_load_spr(t0, SPR_BOOKE_DBSR); tcg_gen_ori_tl(t0, t0, dbsr); gen_store_spr(SPR_BOOKE_DBSR, t0); - gen_helper_raise_exception(tcg_env, - tcg_constant_i32(POWERPC_EXCP_DEBUG)); + tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, + offsetof(CPUPPCState, error_code)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(POWERPC_EXCP_DEBUG)); ctx->base.is_jmp = DISAS_NORETURN; } else { if (!rfi_type) { /* BookS does not single step rfi type instructions */