From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Subject: [PULL 01/32] cpu: Constify CPUState::cc (cached CPUClass pointer)
Date: Mon, 6 Jul 2026 15:44:56 +0200 [thread overview]
Message-ID: <20260706134527.84808-2-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20260706134527.84808-1-philmd@oss.qualcomm.com>
Various CPUState can share the same CPUClass parent,
and must not update its fields. Protect the CPUClass
by marking the CPUState pointer const.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Message-ID: <20260705215729.62196-2-philmd@oss.qualcomm.com>
---
include/hw/core/cpu.h | 2 +-
accel/tcg/cpu-exec.c | 2 +-
accel/tcg/translate-all.c | 3 +--
gdbstub/gdbstub.c | 2 +-
4 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 59d601465b4..60a23d6f38b 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -480,7 +480,7 @@ struct CPUState {
/*< private >*/
DeviceState parent_obj;
/* cache to avoid expensive CPU_GET_CLASS */
- CPUClass *cc;
+ const CPUClass *cc;
/*< public >*/
int nr_threads;
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 9c754b03656..d7f91dce9db 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -460,7 +460,7 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
* counter hit zero); we must restore the guest PC to the address
* of the start of the TB.
*/
- CPUClass *cc = cpu->cc;
+ const CPUClass *cc = cpu->cc;
const TCGCPUOps *tcg_ops = cc->tcg_ops;
if (tcg_ops->synchronize_from_tb) {
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 3f1a3a28438..328d96aba30 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -575,7 +575,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr)
void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
{
TranslationBlock *tb;
- CPUClass *cc;
+ const CPUClass *cc = cpu->cc;
uint32_t n;
tb = tcg_tb_lookup(retaddr);
@@ -591,7 +591,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
* to account for the re-execution of the branch.
*/
n = 1;
- cc = cpu->cc;
if (cc->tcg_ops->io_recompile_replay_branch &&
cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) {
cpu->neg.icount_decr.u16.low++;
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index c3c944e965b..26366acb674 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -578,7 +578,7 @@ static void gdb_register_feature(CPUState *cpu, int base_reg,
static const char *gdb_get_core_xml_file(CPUState *cpu)
{
- CPUClass *cc = cpu->cc;
+ const CPUClass *cc = cpu->cc;
/*
* The CPU class can provide the XML filename via a method,
--
2.53.0
next prev parent reply other threads:[~2026-07-06 13:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 13:44 [PULL 00/32] Accelerator patches for 2026-07-06 Philippe Mathieu-Daudé
2026-07-06 13:44 ` Philippe Mathieu-Daudé [this message]
2026-07-06 13:44 ` [PULL 02/32] target/i386: Remove duplicate tlb_flush() call in cpu_post_load() Philippe Mathieu-Daudé
2026-07-06 13:44 ` [PULL 03/32] accel/tcg: Restrict tlb_protect/unprotect_code() to TCG Philippe Mathieu-Daudé
2026-07-06 13:44 ` [PULL 04/32] accel/hvf: Remove left-over comment Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 05/32] accel/mshv: Replace @dirty field by generic CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 06/32] accel/mshv: Fix pointer to proc feature bitfield Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 07/32] gdbstub: Add trace event for STEP packet handler Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 08/32] gdbstub: Only return E22 when reverse GDB is not supported Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 09/32] accel/whpx: Implement missing AccelClass::gdbstub_supported_sstep_flags Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 10/32] accel/kvm: Always define AccelOpsClass::supports_guest_debug Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 11/32] accel/kvm: Simplify kvm_init() w.r.t. TARGET_KVM_HAVE_GUEST_DEBUG Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 12/32] accel/kvm: Hold have_guest_debug in KVMState Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 13/32] gdbstub: Reduce gdb_supports_guest_debug() scope Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 14/32] gdbstub: Move supported_sstep_flags in AccelGdbConfig structure Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 15/32] accel: Have each implementation return their AccelGdbConfig Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 16/32] gdbstub: Make default replay_mode value explicit in stubs Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 17/32] accel: Hold @can_reverse information in AccelGdbConfig Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 18/32] accel: Remove AccelOpsClass::supports_guest_debug Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 19/32] cpu: Move cpu_breakpoint_test out of line Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 20/32] cpu: Move BREAKPOINT definitions to 'exec/breakpoint.h' Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 21/32] accel: Remove unnecessary 'inline' qualifier in remove_all_breakpoints Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 22/32] gdbstub/user: Directly call gdb_breakpoint_remove_all() in user mode Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 23/32] gdbstub: Reduce @type variable scope Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 24/32] gdbstub: Introduce GdbBreakpointType enumerator Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 25/32] accel: Use GdbBreakpointType enum Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 26/32] target/arm: Inline check_watchpoints() in arm_debug_check_watchpoint() Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 27/32] target/ppc: Ensure TCG is used in ppc_update_daw() Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 28/32] accel/tcg: Improve docstrings around TCGCPUOps::*watchpoint* handlers Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 29/32] cpu: Better name cpu_single_step() trace event Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 30/32] cpu: Introduce cpu_single_stepping() helper Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 31/32] cpu: Rename CPUState @singlestep_enabled -> @singlestep_flags Philippe Mathieu-Daudé
2026-07-06 13:45 ` [PULL 32/32] cpu: Only check SSTEP_ENABLE flag in cpu_single_stepping() Philippe Mathieu-Daudé
2026-07-07 5:04 ` [PULL 00/32] Accelerator patches for 2026-07-06 Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706134527.84808-2-philmd@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.