From patchwork Tue Sep 1 09:52:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 2295768 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=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=IoKRzIWQ; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=SlnsbRZ4; 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 4hZ1Ss0tYLz1xwg for ; Tue, 01 Sep 2026 19:55:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1LCs-0004CZ-BA; Tue, 01 Sep 2026 05:55:06 -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 1x1LCr-0004AG-1d for qemu-ppc@nongnu.org; Tue, 01 Sep 2026 05:55:05 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1LCo-0007n6-M8 for qemu-ppc@nongnu.org; Tue, 01 Sep 2026 05:55:04 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68179Ce92061528 for ; Tue, 1 Sep 2026 09:55:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= bCUerKU8i6MSUxweaHPVhCPYkRB41oDv8MTEbo0FvN0=; b=IoKRzIWQlzAYLFvF J5k8+NZLGaeFP+PvCKldGjLZs+UZbpBLIIPdEHIggM1MpZusn/7EMzT0ZyIXkqu3 JZ219cgqEOECdPxTrAqwb21LH9A7JpuS2jvfSB3E4f9HoFP3yQeHawcDCS0Ejr3L eDWAdmkWaKhMduscoisTkZgloGIgJNOXW2C1EYpDk4v6LF61N5Inpz0UuqazLn0Z x55Gf7XWs+lLK6VVKsZu5zpujXj9DyVEdnsADFy0Qs3CDL+rpWrZGjngqU9C8+Bi OVBL1IuXWF28zUqmcw2ygPjzLablMaoO7LSz0mbfNpqh9jeQrRTTwU9r8ff48KVt yh+Tyg== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gdqbh1e39-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Sep 2026 09:55:01 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-92e5fc4c7e9so81765785a.3 for ; Tue, 01 Sep 2026 02:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788256501; x=1788861301; 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=bCUerKU8i6MSUxweaHPVhCPYkRB41oDv8MTEbo0FvN0=; b=SlnsbRZ4oLaCb+tWRJZPZVR2Fr+wEFE9HcrsehhKnpOL2imgL9B1Cgs3EMWzH1SzWl uSNZrsA4UUAjeFi9yoQ6z+9kBD8CYBeWL0tNrPDH/CdkdizWfx8fqkFSGr7PXEXiGAeR WMkKQB5BRqJIqB1iavDG2TmNrxgPwWMvs7b47uDrjwF92A3INribzMpiY5GFvcdpdY+w zLLeeyQ9E1S2Cf3dh8B3pv4bWVN9pXAAKy8UIxG35e/oqUhdxQyPj2mzRDigFehO3M+O KEvRS0RwGMl2bbdbBOSnCfVuzHY3N6fxVszGmQ0Zo7nAADSGLVoMrHyqKK/ytcWzS73o R9dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788256501; x=1788861301; 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=bCUerKU8i6MSUxweaHPVhCPYkRB41oDv8MTEbo0FvN0=; b=oD4Q5ZN0FGUucGXoYPHI3xouZARNX75UEB/7e8YExjUKn+K48kQhCbLtGqQ6BQqI3b ekieiib2d99c/LuW5CUc0kY+WGWgmLMJwYEV1u2JsrKZolSU62CMUO7xdF9UVnEMXoG9 6Gz7m4+zSzwIDBYLUc/iExgTkSySJR7awS8zXEddVj9R3Ju8iokM3GPWkcmG4opuPVDz 0djQxW3HwMP67vaXLXeiJh1F4yp1hXRwqozLputLnqKKFPPlQ/NFFRDBfLVoSXQ5O2Xt zvJy/J/39PIotU6hwECZmQkZJf/tnNdSq/Kb1hRTQlIwScsZkl82A2hK+kKVL9yKpbXF h/sQ== X-Forwarded-Encrypted: i=1; AHgh+Rpggm7jfvJqXMXYAoPlRxFY7j5YPRxO85eIY0w/+ms2MYDOIZzHICqJuTGvZGHKX6/TeAdBXdufPw==@nongnu.org X-Gm-Message-State: AFuF++mF0Gl8JjMkr+bZ30+JFxjf6unMx+yE7uE+/dijBtdgAWO6l3e0 06cbJzi6j7sfOSiC6q3CTgTnDeUwNQfdL4W4Of0OIVLVyL5zg18Lv/TuR/Exzq3SE2bM2N7kTmW lrjOWEI9VQnDpGVDBap5IyXPapMLsmsJjYWSbgzhaFFEGy3nEqLhW9Us= X-Gm-Gg: AR+sD13vwjtrHQIRwffBpblaOmIm2oGsqNQFDQk3rjYDsDPN7NAsi+u6aFhPqeRyuBz SSWEeNtmKKUWNj1TAatv+FxF9yzmkHwr5XJkcTuI8EQ6Ao5q6M5J5/4A1VMeat246E8/59UofJe 6k34oVmegwI9CWsKkcd6IIM+9z7ppRJEPlAGFV5GwDVEtWiyejYnVsYevUKpWlfVhkCaR3UW/D1 P07Xn/DTnx7czCICyprQhjBsGBqIFiqRtSQdmd4pKQGAfO+G3iz9zcof9vnaaU6LZ1DJuo1cz6Y mKEVWihx5tgTR57ADxgEh21p3lFajj8/5ABTcrNV+q9N6Rx+HioMtYgKshPco96bG6/leJlt68W NBxqxAB13c7+lcPu5pWQv4TeEATZwwhGK8CTsTt22 X-Received: by 2002:a05:620a:2812:b0:937:7e90:ecc with SMTP id af79cd13be357-939138ae5c0mr3843637485a.25.1788256500617; Tue, 01 Sep 2026 02:55:00 -0700 (PDT) X-Received: by 2002:a05:620a:2812:b0:937:7e90:ecc with SMTP id af79cd13be357-939138ae5c0mr3843630085a.25.1788256499754; Tue, 01 Sep 2026 02:54:59 -0700 (PDT) Received: from localhost.localdomain (pmd666.hd.free.fr. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48442d37ce3sm3754006f8f.8.2026.09.01.02.54.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 01 Sep 2026 02:54:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Zhao Liu , Peter Maydell , Richard Henderson , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Brian Cain , Pierrick Bouvier , Helge Deller , Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Laurent Vivier , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Chinmay Rath , Nicholas Piggin , Glenn Miles , Harsh Prateek Bora , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Yoshinori Sato , Cornelia Huck , Eric Farman , Matthew Rosato , Ilya Leoshkevich , David Hildenbrand , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 20/21] cpus: Constify @cpu in SysemuCPUOps::has_work() handler Date: Tue, 1 Sep 2026 11:52:26 +0200 Message-ID: <20260901095229.72018-21-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901095229.72018-1-philmd@oss.qualcomm.com> References: <20260901095229.72018-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTAxMDA4NyBTYWx0ZWRfXzWn88dsG/AVe 6WuzFG67N5+3Rrzt+DjDQ2BgIp30eTrIWYst0PgqhKtE80R08+wKNn2JMa53wJBjnU1Y1sNSLaS fM+Irnisb2Mv6z0JddA9aeT0OMpjRq4= X-Authority-Analysis: v=2.4 cv=R9wz39RX c=1 sm=1 tr=0 ts=6a96a0f5 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=4s3hRJSeHn4rkQlkrse1kQ==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=cM1bI5kxBi4gRGPUlTgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: 5X5mlsnAN-KuV9iqefi0qA5mRFuDpNWD X-Proofpoint-ORIG-GUID: 5X5mlsnAN-KuV9iqefi0qA5mRFuDpNWD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTAxMDA4NyBTYWx0ZWRfXx07X1PDwUP6X hy4oN4Kl/J4isAw6Vf7DY73H3KODoUUWeQqS6ynrgOTt+kQcZYP1PT5fgeSozH+EfHL12Dna939 DYgEJ4GHjknkBXnsqD5fN4i4Wlhl33yJqPwLjgUy4QDUFbXlMYpG3U638eaIc8hK3wIyZUI7LyZ kloWcXplkJv3LRCwU2D8DBfAw6BzcMJhTpf1jHswNbk7BmGXiWTM7VDij2qOAS5pajnGq7cE5oe D/cZxpcLDCuybT4fBc4khFDZxaaks1X5U9NQ0Z5AHrVF+vN9WTu5szAOpK+BKL64pzsTVyDm/6g vAH7kCcIabJZa8rkvnyAkCGtGSkkHaVc9eDAjcnIaortEN15YsjjTJG+p5On0mCz4AjmeEI5ECI lCJMg0Y7NZoj1Cts9lIc6iW1/fQWsxNmhP3Ilnwp3JtbCt1U/o2sFb6tSEq/KDtbTCoW18Y182H 8PIDvWJbEkFWkEV/M5g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-01_02,2026-08-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 clxscore=1015 phishscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609010087 Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 All functions called by target has_work() handler take a const @cpu argument. We can now fulfill the comment added in commit c2804566f6 ("target/arm: do not clear halting reason in has_work helper"), qualifying the handler const to denote its idempotency. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/core/sysemu-cpu-ops.h | 4 ++-- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 4 ++-- target/avr/cpu.c | 3 ++- target/hexagon/cpu.c | 4 ++-- target/hppa/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 4 ++-- target/or1k/cpu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/riscv/cpu.c | 5 ++--- target/rx/cpu.c | 2 +- target/s390x/cpu-system.c | 4 ++-- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 4 ++-- 20 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h index 9a45596169a..095bdcd997a 100644 --- a/include/hw/core/sysemu-cpu-ops.h +++ b/include/hw/core/sysemu-cpu-ops.h @@ -19,10 +19,10 @@ typedef struct SysemuCPUOps { /** * @has_work: Callback for checking if there is work to do. * - * This function should be idempotent (i.e. not change state) as + * This function is idempotent (i.e. not change state) as * it will likely be queried multiple times before a CPU resumes. */ - bool (*has_work)(CPUState *cpu); /* MANDATORY NON-NULL */ + bool (*has_work)(const CPUState *cpu); /* MANDATORY NON-NULL */ /** * @get_memory_mapping: Callback for obtaining the memory mappings. */ diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 7d1d036e1d3..21d4f8ac23b 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -77,7 +77,7 @@ static void alpha_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool alpha_cpu_has_work(CPUState *cs) +static bool alpha_cpu_has_work(const CPUState *cs) { /* Here we are checking to see if the CPU should wake up from HALT. We will have gotten into this state only for WTINT from PALmode. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 9761bb173c1..ba66359d410 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -141,9 +141,9 @@ int arm_cpu_mmu_index(CPUState *cs, bool ifetch) * CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here * unconditionally. */ -static bool arm_cpu_has_work(CPUState *cs) +static bool arm_cpu_has_work(const CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); + const ARMCPU *cpu = ARM_CPU(cs); /* * Only another PSCI call can wake the CPU up in which case the diff --git a/target/avr/cpu.c b/target/avr/cpu.c index a01e6fa4751..a96bef46ff1 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -23,6 +23,7 @@ #include "qemu/qemu-print.h" #include "exec/translation-block.h" #include "system/address-spaces.h" +#include "hw/core/cpu.h" #include "cpu.h" #include "disas/dis-asm.h" #include "tcg/debug-assert.h" @@ -43,7 +44,7 @@ static vaddr avr_cpu_get_pc(CPUState *cs) return cpu->env.pc_w * 2; } -static bool avr_cpu_has_work(CPUState *cs) +static bool avr_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET) && cpu_interrupts_enabled(cpu_env(cs)); diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 4cc6bd67c28..868aef0cde4 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -364,9 +364,9 @@ bool hexagon_thread_is_enabled(const CPUHexagonState *env) return E_bit; } -static bool hexagon_cpu_has_work(CPUState *cs) +static bool hexagon_cpu_has_work(const CPUState *cs) { - CPUHexagonState *env = cpu_env(cs); + const CPUHexagonState *env = cpu_env(cs); return hexagon_thread_is_enabled(env) && (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_SWI diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 7b1309a7c38..dbf58466c24 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -134,7 +134,7 @@ static void hppa_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool hppa_cpu_has_work(CPUState *cs) +static bool hppa_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1fc02cf94e6..0606ac16664 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -10638,7 +10638,7 @@ int x86_cpu_pending_interrupt(const CPUState *cs, int interrupt_request) return 0; } -static bool x86_cpu_has_work(CPUState *cs) +static bool x86_cpu_has_work(const CPUState *cs) { return x86_cpu_pending_interrupt(cs, cs->interrupt_request) != 0; } diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 3b3cbde882f..3fc208e44f8 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -110,7 +110,7 @@ bool cpu_loongarch_hw_interrupts_pending(const CPULoongArchState *env) #endif #ifndef CONFIG_USER_ONLY -static bool loongarch_cpu_has_work(CPUState *cs) +static bool loongarch_cpu_has_work(const CPUState *cs) { bool has_work = false; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 523694d8fbf..da3681fab1f 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -76,7 +76,7 @@ static void m68k_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool m68k_cpu_has_work(CPUState *cs) +static bool m68k_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD); } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 6013a8def8e..d1d2f0ec7e3 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -127,7 +127,7 @@ static void mb_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool mb_cpu_has_work(CPUState *cs) +static bool mb_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } diff --git a/target/mips/cpu.c b/target/mips/cpu.c index c069aa1c0b7..0f39f8fe0a5 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -134,9 +134,9 @@ static vaddr mips_cpu_get_pc(CPUState *cs) } #if !defined(CONFIG_USER_ONLY) -static bool mips_cpu_has_work(CPUState *cs) +static bool mips_cpu_has_work(const CPUState *cs) { - CPUMIPSState *env = cpu_env(cs); + const CPUMIPSState *env = cpu_env(cs); bool has_work = false; /* diff --git a/target/or1k/cpu.c b/target/or1k/cpu.c index 42d9351b6d7..10b13ae69cd 100644 --- a/target/or1k/cpu.c +++ b/target/or1k/cpu.c @@ -76,7 +76,7 @@ static void openrisc_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool openrisc_cpu_has_work(CPUState *cs) +static bool openrisc_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER); } diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index ef59c56f416..c72a7168a23 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7222,7 +7222,7 @@ static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch) #endif /* CONFIG_TCG */ #ifndef CONFIG_USER_ONLY -static bool ppc_cpu_has_work(CPUState *cs) +static bool ppc_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD); } diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6004da4ac33..5c16c52e010 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -953,10 +953,9 @@ int riscv_cpu_vsirq_pending(const CPURISCVState *env) (irqs | irqs_f_vs), env->hviprio); } -static bool riscv_cpu_has_work(CPUState *cs) +static bool riscv_cpu_has_work(const CPUState *cs) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + const CPURISCVState *env = cpu_env(cs); /* * Definition of the WFI instruction requires it to ignore the privilege * mode and delegation registers, but respect individual enables diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 69946928995..dfa09a85bce 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -73,7 +73,7 @@ static void rx_restore_state_to_opc(CPUState *cs, cpu->env.pc = data[0]; } -static bool rx_cpu_has_work(CPUState *cs) +static bool rx_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR); } diff --git a/target/s390x/cpu-system.c b/target/s390x/cpu-system.c index 84faceb3338..3a0ff46e144 100644 --- a/target/s390x/cpu-system.c +++ b/target/s390x/cpu-system.c @@ -39,9 +39,9 @@ #include "system/tcg.h" #include "hw/core/sysemu-cpu-ops.h" -static bool s390_cpu_has_work(CPUState *cs) +static bool s390_cpu_has_work(const CPUState *cs) { - S390CPU *cpu = S390_CPU(cs); + const S390CPU *cpu = S390_CPU(cs); /* STOPPED cpus can never wake up */ if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD && diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 55c73a1da35..b0ed356d0f7 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -107,7 +107,7 @@ static bool superh_io_recompile_replay_branch(CPUState *cs, return false; } -static bool superh_cpu_has_work(CPUState *cs) +static bool superh_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD); } diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 2baa5036871..8dd9b0d5ee3 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -783,7 +783,7 @@ static void sparc_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool sparc_cpu_has_work(CPUState *cs) +static bool sparc_cpu_has_work(const CPUState *cs) { return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD) && cpu_interrupts_enabled(cpu_env(cs)); diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 82b56c3cd56..357f3737053 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -111,7 +111,7 @@ static void tricore_cpu_reset_hold(Object *obj, ResetType type) cpu_state_reset(cpu_env(cs)); } -static bool tricore_cpu_has_work(CPUState *cs) +static bool tricore_cpu_has_work(const CPUState *cs) { /* Interrupts are not implemented */ return true; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 99c8bd4b5fb..1b299568776 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -140,9 +140,9 @@ static void xtensa_restore_state_to_opc(CPUState *cs, } #ifndef CONFIG_USER_ONLY -static bool xtensa_cpu_has_work(CPUState *cs) +static bool xtensa_cpu_has_work(const CPUState *cs) { - CPUXtensaState *env = cpu_env(cs); + const CPUXtensaState *env = cpu_env(cs); return !env->runstall && env->pending_irq_level; } From patchwork Tue Sep 1 09:52:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 2295773 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=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KKLY84XW; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=Tu6V/TQa; 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 4hZ1Tp6R24z1xwg for ; Tue, 01 Sep 2026 19:56:30 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1LD6-0004Ti-GO; Tue, 01 Sep 2026 05:55:20 -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 1x1LD2-0004Mr-0Z for qemu-ppc@nongnu.org; Tue, 01 Sep 2026 05:55:17 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1LCx-00080S-DZ for qemu-ppc@nongnu.org; Tue, 01 Sep 2026 05:55:15 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68179PlG2321959 for ; Tue, 1 Sep 2026 09:55:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= MTwxkxS/Zd7vHUks2tQPGnCsvxECdtOVgx/W1zGj3M0=; b=KKLY84XWz6E7NiN5 shSzybLuGq/TjJf3+hEnL86UvyXqQr5Y88A3HXtX5vCILENTSznXJ4T9T+zoFLy4 eAC0bfw8ZW6hKGWOcdFT0Zeq3MBoPwNv6Afkdwkf0QsTlquOJz3+gRoiLSFYGeFm oZieBMOArHzILrqV2+yZw52VXqf1S+yUbGLRzZKXfUKFISq5RWn6jKhqK7Tu4H3C Lu1kIHFjZmr6Mh3livHZ2VbqakZCesH0u/gdlZxZpyBHdrny73E4yiSiVIl/jQKK usrNVhyMiXfUzwjF90uvIkhvDG0Ld0qdrBjhnLw8dVuenrXH8rR1B67KwG8Qpzux jEoPwA== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gdfchbark-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Sep 2026 09:55:10 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-9390ca1a9abso116220185a.2 for ; Tue, 01 Sep 2026 02:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788256510; x=1788861310; 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=MTwxkxS/Zd7vHUks2tQPGnCsvxECdtOVgx/W1zGj3M0=; b=Tu6V/TQaA0iKV74nPMTPjbs77BAmXfqGCVdGZcOFzbm8JdSiq+ibrnXvB4stleEhE7 jqQhuX96Wvfcqb3arH2VXLS3TMuLBtsYYU4dcTbDZcrX8ptwa4ppI3A5LPJqhgm+yJBX xkSJKNUH0sifVxsXGN+HSmVSGmxgOQAbLIip8RPr4TVzV14d7lJOjFoWbjXXmwTjdhHO o+bgHFALf8zXmbsjbAl3FJHb6HaBX1Yg/g6kX0+xmdXa3jLRcJsMC1j3KRn+oeeSGs/V aNu2URyn+z3cDzuU+q0K5i0vxLllpk/sNq5cSlAvi/l7WeLJ6DqwEjGiYTIKzPgvjxE7 Jnfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788256510; x=1788861310; 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=MTwxkxS/Zd7vHUks2tQPGnCsvxECdtOVgx/W1zGj3M0=; b=RjoIcEtp0A/dNWFZg14jUYp9tlzxxAlykwBN/zIFQiwu4GsPUYsC41gsJJtGxAh7Pm sLsrhpHWMmxAXvia6UpzZxyT775p/3O2zOCFH1ukeTH69dCCiPHZB1GjN+GJyf+i3Si1 z2ENkzwA/DP3F+VtwV1D+K4ftr9SBNWkzSP+2cAbUJ5sIdYjt65jZwHOUz37cufG048d CqHmtRfjBonjidhm/byMkHEx06ME9c64f+hTPCBeKQjC8H5KxMIDZ3mefhAUDGWKLH6y oDVJfkH+2+vu9bw0FCN8yDuWxWYhrV3Gz7OkxtCzjUvvTZZ4VMaJxMmxQlWVwuxAAZwO tjOA== X-Forwarded-Encrypted: i=1; AHgh+Rr04KcTJiLq+r3sRRysysw6lrGBF0y3lOY62NXdmgyekNXsBkOoozeINMU7h1LhGZ/syE5DRXwctA==@nongnu.org X-Gm-Message-State: AFuF++lqYurRJcZYhoXE70f2bMi24qumwzLPyen7XD/sr6PG70kdLnr9 hws4eDKXc5nR2uJ7LBDLbqC/yOgQ8mEOqkCVUuXGHALkF0fFHGvZUFrZb2ebXgymxlnAQnIxAP2 qGa/2JeieW4O4FBrwXWWqJfVJYnW3v4gcxHVYmbh1X6IIQRpQHJG7lZk= X-Gm-Gg: AR+sD129+Db3wNMgMAjz67kpA+aBBi9MRqZbqcezo0XF9Cze3u6GaBTJc+E/kTTiqpe +V942J6smTDBjhSyf2VriNBEkv/486YY52BnBBYs2nBDSsqe6EpZHVSc4OR+5oHWKd5rUWY20iv Y4Qes8udjjDBYRRS8zea4Q/3ulHCKF1l+SX0TJ57dNXZm35YNedsVckOR/gfeLPnN35kKBl1m3D Hp1WQmfeLUHdvCf2lKcJOZoaa3LZKGvaXsu4Cobyq2qGn0+Hd03VD4ZZ4bKvmw5qCScASxEDFH/ qK03uzpQx1qhB55Kzu4mvA4TefgLi8cNUi93tGKrbe06VyFmxBS76kSN1R6ZjnUYjY0jZJny7Wg U2DGtUyY+ag4M+zyt3DjmElkErmWu9jvOLD1JwnPd X-Received: by 2002:a05:620a:4802:b0:92e:dddc:6588 with SMTP id af79cd13be357-939139b2552mr3551143685a.42.1788256509385; Tue, 01 Sep 2026 02:55:09 -0700 (PDT) X-Received: by 2002:a05:620a:4802:b0:92e:dddc:6588 with SMTP id af79cd13be357-939139b2552mr3551135985a.42.1788256508386; Tue, 01 Sep 2026 02:55:08 -0700 (PDT) Received: from localhost.localdomain (pmd666.hd.free.fr. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cdce1e1ebsm56962825e9.14.2026.09.01.02.55.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 01 Sep 2026 02:55:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Zhao Liu , Peter Maydell , Richard Henderson , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Brian Cain , Pierrick Bouvier , Helge Deller , Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Laurent Vivier , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Chinmay Rath , Nicholas Piggin , Glenn Miles , Harsh Prateek Bora , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Yoshinori Sato , Ilya Leoshkevich , David Hildenbrand , Cornelia Huck , Eric Farman , Matthew Rosato , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 21/21] accel/tcg: Constify @cpu in cpu_mmu_index() and TCGCPUOps handlers Date: Tue, 1 Sep 2026 11:52:27 +0200 Message-ID: <20260901095229.72018-22-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901095229.72018-1-philmd@oss.qualcomm.com> References: <20260901095229.72018-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Cc7xfYzRyLMEgc2hT5ezXGOtEROSRoCn X-Authority-Analysis: v=2.4 cv=G9Ms1dk5 c=1 sm=1 tr=0 ts=6a96a0fe cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=4s3hRJSeHn4rkQlkrse1kQ==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=g_x95mRnQQNavG41apYA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-GUID: Cc7xfYzRyLMEgc2hT5ezXGOtEROSRoCn X-Proofpoint-Spam-Info: AW1haW4tMjYwOTAxMDA4NyBTYWx0ZWRfX79lb9jiEHHDr tUQYXlBif00NVLbY0aoRWy4KVFH67C/Zr29selaiNjdM8rcG9DIgyVjEhbSvPiTFT++6oXO7iOQ yNHordfsWgEdcjmjxJMw6xfUUhBlF/Y= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTAxMDA4NyBTYWx0ZWRfX0x39SGJOVqtl FsnPDZnUSgEPGprINcjtNBpxHqlpVM/nqFlGHBRM4IWZkXKWh+qrHPH4wMk7fSe754NlhOdyAkQ mrKmb90bm8XnF4r9w8/rXMdxRKADz9LYRdnSxCqOQmNIPpC0yuq1q0IjvF0Q7zrcNfrr2bNcJiu XqZSW92FxWgSQaCOtUhFw7PWQppcCZ9KzdB1peLkT0fvNn4+gRrt1VFm8jvg5a/b6VdxfeXtyN+ KIPTJY22JSqWqfXKzS126dyM1fLmM34O9WsaAiXajj97xsq1Vk7dgBsSsNwi0/y9AkO3+hhMt47 ofcJLW+3GsoGFb2KOlBJH0gg6XuCd9k1u1B+Zdw5ABBSZ/Yv+RDsfyge8lOlTZJ1KrgK5e8VKWt vU7+mY1WpYIY2Z3f+egVinYNtEFJwiK75V6e4EwdzccLgQL6kWL8m+BUKNvZzn7XRiK/1YoyMKD k3aBqqHUpDixJrjMw+g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-01_02,2026-08-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609010087 Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 All functions called by cpu_mmu_index() take a const @cpu argument. Propagate the constness to the caller (CPU state should not mutate when resolving the MMU index of the current translation regime). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau --- include/accel/tcg/cpu-mmu-index.h | 2 +- include/accel/tcg/cpu-ops.h | 2 +- target/alpha/cpu.h | 2 +- target/arm/internals.h | 4 ++-- target/i386/tcg/tcg-cpu.h | 2 +- target/ppc/cpu.h | 2 +- target/s390x/cpu.h | 2 +- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/hexagon/cpu.c | 6 +++--- target/hppa/cpu.c | 4 ++-- target/i386/tcg/tcg-cpu.c | 6 +++--- target/loongarch/tcg/tcg_cpu.c | 4 ++-- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 6 +++--- target/mips/cpu.c | 2 +- target/or1k/cpu.c | 4 ++-- target/ppc/cpu_init.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 4 ++-- target/sparc/cpu.c | 4 ++-- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 26 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/accel/tcg/cpu-mmu-index.h b/include/accel/tcg/cpu-mmu-index.h index e0fb6ef91c8..01152075372 100644 --- a/include/accel/tcg/cpu-mmu-index.h +++ b/include/accel/tcg/cpu-mmu-index.h @@ -30,7 +30,7 @@ * Return the core mmu index for the current translation regime. * This function is used by generic TCG code paths. */ -static inline int cpu_mmu_index(CPUState *cs, bool ifetch) +static inline int cpu_mmu_index(const CPUState *cs, bool ifetch) { #ifdef COMPILING_PER_TARGET # ifdef CONFIG_USER_ONLY diff --git a/include/accel/tcg/cpu-ops.h b/include/accel/tcg/cpu-ops.h index a88cc4dc572..69d7ec29115 100644 --- a/include/accel/tcg/cpu-ops.h +++ b/include/accel/tcg/cpu-ops.h @@ -102,7 +102,7 @@ struct TCGCPUOps { void (*debug_excp_handler)(CPUState *cpu); /** @mmu_index: Callback for choosing softmmu mmu index */ - int (*mmu_index)(CPUState *cpu, bool ifetch); + int (*mmu_index)(const CPUState *cpu, bool ifetch); #ifdef CONFIG_USER_ONLY /** diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 378bd96d941..1c9f9fce20b 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -383,7 +383,7 @@ enum { #define TB_FLAG_UNALIGN (1u << 1) -static inline int alpha_env_mmu_index(CPUAlphaState *env) +static inline int alpha_env_mmu_index(const CPUAlphaState *env) { int ret = env->flags & ENV_FLAG_PS_USER ? MMU_USER_IDX : MMU_KERNEL_IDX; if (env->flags & ENV_FLAG_PAL_MODE) { diff --git a/target/arm/internals.h b/target/arm/internals.h index f1a80c890ee..d582cefcfa4 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -55,7 +55,7 @@ static inline MemOp mo_endian(const CPUARMState *env) return EX_TBFLAG_ANY(env->hflags, BE_DATA) ? MO_BE : MO_LE; } -static inline int arm_env_mmu_index(CPUARMState *env) +static inline int arm_env_mmu_index(const CPUARMState *env) { return EX_TBFLAG_ANY(env->hflags, MMUIDX); } @@ -431,7 +431,7 @@ void arm_restore_state_to_opc(CPUState *cs, #ifdef CONFIG_TCG TCGTBCPUState arm_get_tb_cpu_state(CPUState *cs); void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); -int arm_cpu_mmu_index(CPUState *cs, bool ifetch); +int arm_cpu_mmu_index(const CPUState *cs, bool ifetch); #endif /* CONFIG_TCG */ typedef enum ARMFPRounding { diff --git a/target/i386/tcg/tcg-cpu.h b/target/i386/tcg/tcg-cpu.h index 85bcd61678f..1127861e337 100644 --- a/target/i386/tcg/tcg-cpu.h +++ b/target/i386/tcg/tcg-cpu.h @@ -82,6 +82,6 @@ extern const TCGCPUOps x86_tcg_ops; bool tcg_cpu_realizefn(CPUState *cs, Error **errp); -int x86_mmu_index_pl(CPUX86State *env, unsigned pl); +int x86_mmu_index_pl(const CPUX86State *env, unsigned pl); #endif /* TCG_CPU_H */ diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 3fb51bbeb82..56264752c1b 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1736,7 +1736,7 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val); /* MMU modes definitions */ #define MMU_USER_IDX 0 -static inline int ppc_env_mmu_index(CPUPPCState *env, bool ifetch) +static inline int ppc_env_mmu_index(const CPUPPCState *env, bool ifetch) { #ifdef CONFIG_USER_ONLY return MMU_USER_IDX; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 998bbb0d7ff..cd5f9256b24 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -373,7 +373,7 @@ QEMU_BUILD_BUG_ON(FLAG_MASK_DAT != PSW_MASK_DAT >> FLAG_MASK_PSW_SHIFT); #define MMU_HOME_IDX 2 #define MMU_REAL_IDX 3 -static inline int s390x_env_mmu_index(CPUS390XState *env, bool ifetch) +static inline int s390x_env_mmu_index(const CPUS390XState *env, bool ifetch) { #ifdef CONFIG_USER_ONLY return MMU_USER_IDX; diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 21d4f8ac23b..3bf88702dc1 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -93,7 +93,7 @@ static bool alpha_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int alpha_cpu_mmu_index(CPUState *cs, bool ifetch) +static int alpha_cpu_mmu_index(const CPUState *cs, bool ifetch) { return alpha_env_mmu_index(cpu_env(cs)); } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ba66359d410..63ef00735ca 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -126,7 +126,7 @@ void arm_restore_state_to_opc(CPUState *cs, } } -int arm_cpu_mmu_index(CPUState *cs, bool ifetch) +int arm_cpu_mmu_index(const CPUState *cs, bool ifetch) { return arm_env_mmu_index(cpu_env(cs)); } diff --git a/target/avr/cpu.c b/target/avr/cpu.c index a96bef46ff1..24a5a9debc9 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -50,7 +50,7 @@ static bool avr_cpu_has_work(const CPUState *cs) && cpu_interrupts_enabled(cpu_env(cs)); } -static int avr_cpu_mmu_index(CPUState *cs, bool ifetch) +static int avr_cpu_mmu_index(const CPUState *cs, bool ifetch) { return ifetch ? MMU_CODE_IDX : MMU_DATA_IDX; } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 868aef0cde4..2bc58fc6305 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -482,11 +482,11 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp) mcc->parent_realize(dev, errp); } -static int hexagon_cpu_mmu_index(CPUState *cs, bool ifetch) +static int hexagon_cpu_mmu_index(const CPUState *cs, bool ifetch) { #ifndef CONFIG_USER_ONLY - CPUHexagonState *env = cpu_env(cs); - HexagonCPU *cpu = HEXAGON_CPU(cs); + const CPUHexagonState *env = cpu_env(cs); + const HexagonCPU *cpu = HEXAGON_CPU(cs); int cpu_mode; BQL_LOCK_GUARD(); diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index dbf58466c24..ec351302406 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -140,9 +140,9 @@ static bool hppa_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int hppa_cpu_mmu_index(CPUState *cs, bool ifetch) +static int hppa_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUHPPAState *env = cpu_env(cs); + const CPUHPPAState *env = cpu_env(cs); if (env->psw & (ifetch ? PSW_C : PSW_D)) { return PRIV_P_TO_MMU_IDX(env->iaoq_f & 3, env->psw & PSW_P); diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index e4fc212aca5..da1498ee45d 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -114,7 +114,7 @@ static void x86_restore_state_to_opc(CPUState *cs, } } -int x86_mmu_index_pl(CPUX86State *env, unsigned pl) +int x86_mmu_index_pl(const CPUX86State *env, unsigned pl) { int mmu_index_32 = (env->hflags & HF_CS64_MASK) ? 0 : 1; int mmu_index_base = @@ -125,9 +125,9 @@ int x86_mmu_index_pl(CPUX86State *env, unsigned pl) return mmu_index_base + mmu_index_32; } -static int x86_cpu_mmu_index(CPUState *cs, bool ifetch) +static int x86_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUX86State *env = cpu_env(cs); + const CPUX86State *env = cpu_env(cs); return x86_mmu_index_pl(env, env->hflags & HF_CPL_MASK); } diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c index 7ea2a1eb933..a26233d5eed 100644 --- a/target/loongarch/tcg/tcg_cpu.c +++ b/target/loongarch/tcg/tcg_cpu.c @@ -301,9 +301,9 @@ static void loongarch_restore_state_to_opc(CPUState *cs, set_pc(cpu_env(cs), data[0]); } -static int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch) +static int loongarch_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPULoongArchState *env = cpu_env(cs); + const CPULoongArchState *env = cpu_env(cs); CPUSysState *sys = env_sys(env); if (FIELD_EX64(sys->CSR_CRMD, CSR_CRMD, PG)) { diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index da3681fab1f..f1fd2e6f14d 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -82,7 +82,7 @@ static bool m68k_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int m68k_cpu_mmu_index(CPUState *cs, bool ifetch) +static int m68k_cpu_mmu_index(const CPUState *cs, bool ifetch) { return cpu_env(cs)->sr & SR_S ? MMU_KERNEL_IDX : MMU_USER_IDX; } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index d1d2f0ec7e3..524175d2236 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -133,10 +133,10 @@ static bool mb_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int mb_cpu_mmu_index(CPUState *cs, bool ifetch) +static int mb_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUMBState *env = cpu_env(cs); - MicroBlazeCPU *cpu = env_archcpu(env); + const CPUMBState *env = cpu_env(cs); + const MicroBlazeCPU *cpu = env_archcpu(env); /* Are we in nommu mode?. */ if (!(env->msr & MSR_VM) || !cpu->cfg.use_mmu) { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 0f39f8fe0a5..a428176d9e8 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -671,7 +671,7 @@ static const Property mips_cpu_properties[] = { #ifdef CONFIG_TCG #include "accel/tcg/cpu-ops.h" -static int mips_cpu_mmu_index(CPUState *cs, bool ifunc) +static int mips_cpu_mmu_index(const CPUState *cs, bool ifunc) { return mips_env_mmu_index(cpu_env(cs)); } diff --git a/target/or1k/cpu.c b/target/or1k/cpu.c index 10b13ae69cd..c9ab5c0f1c1 100644 --- a/target/or1k/cpu.c +++ b/target/or1k/cpu.c @@ -82,9 +82,9 @@ static bool openrisc_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int openrisc_cpu_mmu_index(CPUState *cs, bool ifetch) +static int openrisc_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUOpenRISCState *env = cpu_env(cs); + const CPUOpenRISCState *env = cpu_env(cs); if (env->sr & (ifetch ? SR_IME : SR_DME)) { /* The mmu is enabled; test supervisor state. */ diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index c72a7168a23..a33a074b796 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7215,7 +7215,7 @@ static void ppc_restore_state_to_opc(CPUState *cs, cpu->env.nip = data[0]; } -static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch) +static int ppc_cpu_mmu_index(const CPUState *cs, bool ifetch) { return ppc_env_mmu_index(cpu_env(cs), ifetch); } diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index cd303660f1f..a0210ca50e3 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -95,7 +95,7 @@ static const char *cpu_priv_ver_to_str(int priv_ver) return priv_spec_str; } -static int riscv_cpu_mmu_index(CPUState *cs, bool ifetch) +static int riscv_cpu_mmu_index(const CPUState *cs, bool ifetch) { return riscv_env_mmu_index(cpu_env(cs), ifetch); } diff --git a/target/rx/cpu.c b/target/rx/cpu.c index dfa09a85bce..c5dfba8976a 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -78,7 +78,7 @@ static bool rx_cpu_has_work(const CPUState *cs) return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR); } -static int rx_cpu_mmu_index(CPUState *cs, bool ifunc) +static int rx_cpu_mmu_index(const CPUState *cs, bool ifunc) { return 0; } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index c34f4b23472..a043f1e7920 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -311,7 +311,7 @@ static const Property s390x_cpu_properties[] = { #include "accel/tcg/cpu-ops.h" #include "tcg/tcg_s390x.h" -static int s390x_cpu_mmu_index(CPUState *cs, bool ifetch) +static int s390x_cpu_mmu_index(const CPUState *cs, bool ifetch) { return s390x_env_mmu_index(cpu_env(cs), ifetch); } diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index b0ed356d0f7..f8b33844d2a 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -113,9 +113,9 @@ static bool superh_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int sh4_cpu_mmu_index(CPUState *cs, bool ifetch) +static int sh4_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUSH4State *env = cpu_env(cs); + const CPUSH4State *env = cpu_env(cs); /* * The instruction in a RTE delay slot is fetched in privileged mode, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 8dd9b0d5ee3..f1ae16c91e9 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -790,9 +790,9 @@ static bool sparc_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch) +static int sparc_cpu_mmu_index(const CPUState *cs, bool ifetch) { - CPUSPARCState *env = cpu_env(cs); + const CPUSPARCState *env = cpu_env(cs); #ifndef TARGET_SPARC64 if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */ diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 357f3737053..09d4270df60 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -117,7 +117,7 @@ static bool tricore_cpu_has_work(const CPUState *cs) return true; } -static int tricore_cpu_mmu_index(CPUState *cs, bool ifetch) +static int tricore_cpu_mmu_index(const CPUState *cs, bool ifetch) { return 0; } diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 1b299568776..8cf973632e7 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -148,7 +148,7 @@ static bool xtensa_cpu_has_work(const CPUState *cs) } #endif /* !CONFIG_USER_ONLY */ -static int xtensa_cpu_mmu_index(CPUState *cs, bool ifetch) +static int xtensa_cpu_mmu_index(const CPUState *cs, bool ifetch) { return xtensa_get_cring(cpu_env(cs)); }