cpus: Prefer cached CpuClass over CPU_GET_CLASS() macro
cover cpus: Prefer cached CpuClass over CPU_GET_CLASS() macro
Use cached CPUState::cc to get CPUClass.
Main rationale is overall code style.
Philippe Mathieu-Daudé (11):
cpus: Cache CPUClass early in instance_init() handler
cpus: Prefer cached CpuClass over CPU_GET_CLASS() macro
accel: Prefer cached CpuClass over CPU_GET_CLASS() macro
user: Prefer cached CpuClass over CPU_GET_CLASS() macro
disas: Prefer cached CpuClass over CPU_GET_CLASS() macro
gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro hw/acpi: Prefer cached CpuClass over CPU_GET_CLASS() macro hw/core/generic-loader: Prefer cached CpuClass over CPU_GET_CLASS
macro
target/arm: Prefer cached CpuClass over CPU_GET_CLASS() macro target/microblaze: Prefer cached CpuClass over CPU_GET_CLASS() macro target/openrisc: Prefer cached CpuClass over CPU_GET_CLASS() macro
include/hw/core/cpu.h | 10 ++----- linux-user/alpha/target_proc.h | 2 +- accel/accel-target.c | 12 ++++---- accel/tcg/tcg-accel-ops.c | 3 +- accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 9 +++--- bsd-user/signal.c | 4 +-- cpu-common.c | 10 +++---- cpu-target.c | 9 ++---- disas/disas-common.c | 5 ++-- gdbstub/gdbstub.c | 26 ++++++---------- gdbstub/system.c | 7 ++--- gdbstub/user-target.c | 6 ++-- gdbstub/user.c | 7 ++--- hw/acpi/cpu.c | 4 +-- hw/acpi/cpu_hotplug.c | 3 +- hw/core/cpu-common.c | 16 +++++----- hw/core/cpu-system.c | 55 ++++++++++++---------------------- hw/core/generic-loader.c | 5 +--- linux-user/signal.c | 4 +-- target/arm/cpu.c | 3 +- target/arm/tcg/cpu-v7m.c | 3 +- target/microblaze/gdbstub.c | 3 +- target/openrisc/gdbstub.c | 3 +- 24 files changed, 76 insertions(+), 135 deletions(-)
Signature · 1 line
2.47.1
PATCH 1/11 cpus: Cache CPUClass early in instance_init() handler
Cache CPUClass as early as possible, when the instance is initialized.
--- cpu-target.c | 3 --- hw/core/cpu-common.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
cpu-target.c +0 -3
@@ -134,9 +134,6 @@ const VMStateDescription vmstate_cpu_common = {bool cpu_exec_realizefn (CPUState *cpu,Error **errp) { -/* cache the cpu class for the hotpath */ - cpu->cc =CPU_GET_CLASS (cpu); -if (!accel_cpu_common_realize (cpu, errp)) {return false; }
hw/core/cpu-common.c +3 -0
@@ -238,6 +238,9 @@ static void cpu_common_initfn(Object *obj) {CPUState *cpu =CPU (obj); +/* cache the cpu class for the hotpath */ + cpu->cc =CPU_GET_CLASS (cpu); +gdb_init_cpu (cpu); cpu->cpu_index =UNASSIGNED_CPU_INDEX ; cpu->cluster_index =UNASSIGNED_CLUSTER_INDEX ;
Signature · 1 line
2.47.1
Re: [PATCH 01/11] cpus: Cache CPUClass early in instance_init() handler
Quoted 8 lines · Philippe Mathieu-Daudé
Cache CPUClass as early as possible, when the instance is initialized.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- cpu-target.c | 3 --- hw/core/cpu-common.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
r~
Quoted 29 lines
cpu-target.c +0
-3@@ -134,9 +134,6 @@ const VMStateDescription vmstate_cpu_common = {bool cpu_exec_realizefn (CPUState *cpu,Error **errp) { -/* cache the cpu class for the hotpath */ - cpu->cc =CPU_GET_CLASS (cpu); -if (!accel_cpu_common_realize (cpu, errp)) {return false; }hw/core/cpu-common.c +3
-0@@ -238,6 +238,9 @@ static void cpu_common_initfn(Object *obj) {CPUState *cpu =CPU (obj); +/* cache the cpu class for the hotpath */ + cpu->cc =CPU_GET_CLASS (cpu); +gdb_init_cpu (cpu); cpu->cpu_index =UNASSIGNED_CPU_INDEX ; cpu->cluster_index =UNASSIGNED_CLUSTER_INDEX ;
PATCH 2/11 cpus: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- include/hw/core/cpu.h | 10 +++----- cpu-common.c | 10 ++++---- cpu-target.c | 6 ++--- hw/core/cpu-common.c | 13 ++++------ hw/core/cpu-system.c | 55 +++++++++++++++---------------------------- 5 files changed, 32 insertions(+), 62 deletions(-)
include/hw/core/cpu.h +3 -7
@@ -824,10 +824,8 @@ const char *parse_cpu_option(const char *cpu_option);*/ static inline bool cpu_has_work (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); - -g_assert (cc->has_work); -return cc->has_work (cpu); +g_assert (cpu->cc->has_work); +return cpu->cc->has_work (cpu); }/**
@@ -966,9 +964,7 @@ void cpu_interrupt(CPUState *cpu, int mask);*/ static inline void cpu_set_pc (CPUState *cpu,vaddr addr) { -CPUClass *cc =CPU_GET_CLASS (cpu); - - cc->set_pc (cpu, addr); + cpu->cc->set_pc (cpu, addr); }/**
cpu-common.c +4 -6
@@ -389,11 +389,10 @@ void process_queued_cpu_work(CPUState *cpu)int cpu_breakpoint_insert (CPUState *cpu,vaddr pc,int flags,CPUBreakpoint **breakpoint) { -CPUClass *cc =CPU_GET_CLASS (cpu);CPUBreakpoint *bp; -if (cc->gdb_adjust_breakpoint) { - pc = cc->gdb_adjust_breakpoint (cpu, pc); +if (cpu->cc->gdb_adjust_breakpoint) { + pc = cpu->cc->gdb_adjust_breakpoint (cpu, pc); } bp =g_malloc (sizeof (*bp));
@@ -419,11 +418,10 @@ int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,/* Remove a specific breakpoint. */ int cpu_breakpoint_remove (CPUState *cpu,vaddr pc,int flags) { -CPUClass *cc =CPU_GET_CLASS (cpu);CPUBreakpoint *bp; -if (cc->gdb_adjust_breakpoint) { - pc = cc->gdb_adjust_breakpoint (cpu, pc); +if (cpu->cc->gdb_adjust_breakpoint) { + pc = cpu->cc->gdb_adjust_breakpoint (cpu, pc); } QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
cpu-target.c +2 -4
@@ -159,10 +159,8 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp)void cpu_exec_unrealizefn (CPUState *cpu) {#ifndef CONFIG_USER_ONLY -CPUClass *cc =CPU_GET_CLASS (cpu); - -if (cc->sysemu_ops->legacy_vmsd !=NULL ) { -vmstate_unregister (NULL , cc->sysemu_ops->legacy_vmsd, cpu); +if (cpu->cc->sysemu_ops->legacy_vmsd !=NULL ) { +vmstate_unregister (NULL , cpu->cc->sysemu_ops->legacy_vmsd, cpu); }if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_unregister (NULL , &vmstate_cpu_common, cpu);
hw/core/cpu-common.c +4 -9
@@ -40,9 +40,7 @@ CPUState *cpu_by_arch_id(int64_t id)CPUState *cpu;CPU_FOREACH (cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); - -if (cc->get_arch_id (cpu) == id) { +if (cpu->cc->get_arch_id (cpu) == id) {return cpu; } }
@@ -101,11 +99,9 @@ static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg)void cpu_dump_state (CPUState *cpu,FILE *f,int flags) { -CPUClass *cc =CPU_GET_CLASS (cpu); - -if (cc->dump_state) { +if (cpu->cc->dump_state) {cpu_synchronize_state (cpu); - cc->dump_state (cpu, f, flags); + cpu->cc->dump_state (cpu, f, flags); } }
@@ -119,11 +115,10 @@ void cpu_reset(CPUState *cpu)static void cpu_common_reset_hold (Object *obj,ResetType type) {CPUState *cpu =CPU (obj); -CPUClass *cc =CPU_GET_CLASS (cpu);if (qemu_loglevel_mask (CPU_LOG_RESET )) {qemu_log ("CPU Reset (CPU %d)\n" , cpu->cpu_index); -log_cpu_state (cpu, cc->reset_dump_flags); +log_cpu_state (cpu, cpu->cc->reset_dump_flags); } cpu->interrupt_request =0 ;
hw/core/cpu-system.c +19 -36
117 lines not on this page · raw message
Signature · 1 line
2.47.1
Quoted 4 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/core/cpu.h | 10 +++----- cpu-common.c | 10 ++++---- cpu-target.c | 6 ++--- hw/core/cpu-common.c | 13 ++++------ hw/core/cpu-system.c | 55 +++++++++++++++---------------------------- 5 files changed, 32 insertions(+), 62 deletions(-)
r~
PATCH 3/11 accel: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- accel/accel-target.c | 12 +++++------- accel/tcg/tcg-accel-ops.c | 3 +-- accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 9 ++++----- 4 files changed, 11 insertions(+), 15 deletions(-)
accel/accel-target.c +5 -7
@@ -112,22 +112,20 @@ void accel_init_interfaces(AccelClass *ac)void accel_cpu_instance_init (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); - -if (cc->accel_cpu && cc->accel_cpu->cpu_instance_init) { - cc->accel_cpu->cpu_instance_init (cpu); +if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { + cpu->cc->accel_cpu->cpu_instance_init (cpu); } }bool accel_cpu_common_realize (CPUState *cpu,Error **errp) { -CPUClass *cc =CPU_GET_CLASS (cpu);AccelState *accel =current_accel ();AccelClass *acc =ACCEL_GET_CLASS (accel);/* target specific realization */ -if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize - && !cc->accel_cpu->cpu_target_realize (cpu, errp)) { +if (cpu->cc->accel_cpu + && cpu->cc->accel_cpu->cpu_target_realize + && !cpu->cc->accel_cpu->cpu_target_realize (cpu, errp)) {return false; }
accel/tcg/tcg-accel-ops.c +1 -2
@@ -120,10 +120,9 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype) [GDB_WATCHPOINT_ACCESS] = BP_GDB | BP_MEM_ACCESS, }; - CPUClass *cc =CPU_GET_CLASS (cpu);int cputype = xlat[gdbtype]; -if (cc->gdb_stop_before_watchpoint) { +if (cpu->cc->gdb_stop_before_watchpoint) { cputype |=BP_STOP_BEFORE_ACCESS ; }return cputype;
accel/tcg/translate-all.c +1 -1
@@ -622,7 +622,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)* to account for the re-execution of the branch. */ n =1 ; - cc =CPU_GET_CLASS (cpu); + 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++;
accel/tcg/watchpoint.c +4 -5
@@ -69,7 +69,6 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len)void cpu_check_watchpoint (CPUState *cpu,vaddr addr,vaddr len,MemTxAttrs attrs,int flags,uintptr_t ra) { -CPUClass *cc =CPU_GET_CLASS (cpu);CPUWatchpoint *wp;assert (tcg_enabled ());
@@ -85,9 +84,9 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,return ; } -if (cc->tcg_ops->adjust_watchpoint_address) { +if (cpu->cc->tcg_ops->adjust_watchpoint_address) {/* this is currently used only by ARM BE32 */ - addr = cc->tcg_ops->adjust_watchpoint_address (cpu, addr, len); + addr = cpu->cc->tcg_ops->adjust_watchpoint_address (cpu, addr, len); }assert ((flags & ~BP_MEM_ACCESS ) ==0 );
@@ -119,8 +118,8 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, wp->hitattrs = attrs;if (wp->flags &BP_CPU - && cc->tcg_ops->debug_check_watchpoint - && !cc->tcg_ops->debug_check_watchpoint (cpu, wp)) { + && cpu->cc->tcg_ops->debug_check_watchpoint + && !cpu->cc->tcg_ops->debug_check_watchpoint (cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT ;continue ; }
Signature · 1 line
2.47.1
Re: [PATCH 03/11] accel: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 11 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/accel-target.c | 12 +++++------- accel/tcg/tcg-accel-ops.c | 3 +-- accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 9 ++++----- 4 files changed, 11 insertions(+), 15 deletions(-)
r~
PATCH 4/11 user: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- linux-user/alpha/target_proc.h | 2 +- bsd-user/signal.c | 4 ++-- linux-user/signal.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
linux-user/alpha/target_proc.h +1 -1
@@ -15,7 +15,7 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)const char *p, *q;int t; - p =object_class_get_name (OBJECT_CLASS (CPU_GET_CLASS (env_cpu (cpu_env)))); + p =object_class_get_name (OBJECT_CLASS (env_cpu (cpu_env)->cc)); q =strchr (p,'-' ); t = q - p;assert (t <sizeof (model));
bsd-user/signal.c +2 -2
@@ -1021,7 +1021,7 @@ void process_pending_signals(CPUArchState *env)void cpu_loop_exit_sigsegv (CPUState *cpu,target_ulong addr,MMUAccessType access_type,bool maperr,uintptr_t ra) { -const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv (cpu, addr, access_type, maperr, ra);
@@ -1037,7 +1037,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,void cpu_loop_exit_sigbus (CPUState *cpu,target_ulong addr,MMUAccessType access_type,uintptr_t ra) { -const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus (cpu, addr, access_type, ra);
linux-user/signal.c +2 -2
@@ -743,7 +743,7 @@ void force_sigsegv(int oldsig)void cpu_loop_exit_sigsegv (CPUState *cpu,target_ulong addr,MMUAccessType access_type,bool maperr,uintptr_t ra) { -const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv (cpu, addr, access_type, maperr, ra);
@@ -759,7 +759,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,void cpu_loop_exit_sigbus (CPUState *cpu,target_ulong addr,MMUAccessType access_type,uintptr_t ra) { -const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus (cpu, addr, access_type, ra);
Signature · 1 line
2.47.1
Re: [PATCH 04/11] user: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 10 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- linux-user/alpha/target_proc.h | 2 +- bsd-user/signal.c | 4 ++-- linux-user/signal.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
r~
PATCH 5/11 disas: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- disas/disas-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
disas/disas-common.c +2 -3
@@ -67,9 +67,8 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) s->info.endian =BFD_ENDIAN_LITTLE ; } -CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->disas_set_info) { - cc->disas_set_info (cpu, &s->info); +if (cpu->cc->disas_set_info) { + cpu->cc->disas_set_info (cpu, &s->info); } }
Signature · 1 line
2.47.1
Re: [PATCH 05/11] disas: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 15 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- disas/disas-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)disas/disas-common.c +0
-0@@ -67,9 +67,8 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) s->info.endian =BFD_ENDIAN_LITTLE ;
disas/disas-common.c void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) · line 74
Quoted 10 lines
disas/disas-common.c +2
-3} -CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->disas_set_info) { - cc->disas_set_info (cpu, &s->info); +if (cpu->cc->disas_set_info) { + cpu->cc->disas_set_info (cpu, &s->info); } }
r~
PATCH 6/11 gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- gdbstub/gdbstub.c | 26 +++++++++----------------- gdbstub/system.c | 7 ++----- gdbstub/user-target.c | 6 ++---- gdbstub/user.c | 7 ++----- 4 files changed, 15 insertions(+), 31 deletions(-)
gdbstub/gdbstub.c +9 -17
@@ -354,7 +354,6 @@ static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) {CPUState *cpu =gdb_get_first_cpu_in_process (process); -CPUClass *cc =CPU_GET_CLASS (cpu);GDBRegisterState *r;size_t len;
@@ -377,11 +376,11 @@ static const char *get_feature_xml(const char *p, const char **newp,"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" "<target>")); -if (cc->gdb_arch_name) { +if (cpu->cc->gdb_arch_name) {g_ptr_array_add ( xml,g_markup_printf_escaped ("<architecture>%s</architecture>" , - cc->gdb_arch_name (cpu))); + cpu->cc->gdb_arch_name (cpu))); }for (guint i =0 ; i < cpu->gdb_regs->len; i++) { r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i);
@@ -520,11 +519,10 @@ GArray *gdb_get_register_list(CPUState *cpu)int gdb_read_register (CPUState *cpu,GByteArray *buf,int reg) { -CPUClass *cc =CPU_GET_CLASS (cpu);GDBRegisterState *r; -if (reg < cc->gdb_num_core_regs) { -return cc->gdb_read_register (cpu, buf, reg); +if (reg < cpu->cc->gdb_num_core_regs) { +return cpu->cc->gdb_read_register (cpu, buf, reg); }for (guint i =0 ; i < cpu->gdb_regs->len; i++) {
@@ -538,11 +536,10 @@ int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)static int gdb_write_register (CPUState *cpu,uint8_t *mem_buf,int reg) { -CPUClass *cc =CPU_GET_CLASS (cpu);GDBRegisterState *r; -if (reg < cc->gdb_num_core_regs) { -return cc->gdb_write_register (cpu, mem_buf, reg); +if (reg < cpu->cc->gdb_num_core_regs) { +return cpu->cc->gdb_write_register (cpu, mem_buf, reg); }for (guint i =0 ; i < cpu->gdb_regs->len; i++) {
@@ -570,7 +567,7 @@ static void gdb_register_feature(CPUState *cpu, int base_reg,void gdb_init_cpu (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); +CPUClass *cc = cpu->cc;const GDBFeature *feature; cpu->gdb_regs =g_array_new (false, false,sizeof (GDBRegisterState));
@@ -1646,11 +1643,8 @@ void gdb_extend_qsupported_features(char *qflags)static void handle_query_supported (GArray *params,void *user_ctx) { -CPUClass *cc; -g_string_printf (gdbserver_state.str_buf,"PacketSize=%x" ,MAX_PACKET_LENGTH ); - cc =CPU_GET_CLASS (first_cpu); -if (cc->gdb_core_xml_file) { +if (first_cpu->cc->gdb_core_xml_file) {g_string_append (gdbserver_state.str_buf,";qXfer:features:read+" ); }
@@ -1697,7 +1691,6 @@ static void handle_query_supported(GArray *params, void *user_ctx)static void handle_query_xfer_features (GArray *params,void *user_ctx) {GDBProcess *process; -CPUClass *cc;unsigned long len, total_len, addr;const char *xml;const char *p;
@@ -1708,8 +1701,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) } process =gdb_get_cpu_process (gdbserver_state.g_cpu); - cc =CPU_GET_CLASS (gdbserver_state.g_cpu); -if (!cc->gdb_core_xml_file) { +if (!gdbserver_state.g_cpu->cc->gdb_core_xml_file) {gdb_put_packet ("" );return ; }
gdbstub/system.c +2 -5
@@ -452,8 +452,6 @@ static int phy_memory_mode;int gdb_target_memory_rw_debug (CPUState *cpu,hwaddr addr,uint8_t *buf,int len,bool is_write) { -CPUClass *cc; -if (phy_memory_mode) {if (is_write) {cpu_physical_memory_write (addr, buf, len);
@@ -463,9 +461,8 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr,return 0 ; } - cc =CPU_GET_CLASS (cpu); -if (cc->memory_rw_debug) { -return cc->memory_rw_debug (cpu, addr, buf, len, is_write); +if (cpu->cc->memory_rw_debug) { +return cpu->cc->memory_rw_debug (cpu, addr, buf, len, is_write); }return cpu_memory_rw_debug (cpu, addr, buf, len, is_write);
gdbstub/user-target.c +2 -4
@@ -233,10 +233,8 @@ void gdb_handle_query_offsets(GArray *params, void *user_ctx)static inline int target_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,bool is_write) { -CPUClass *cc; - cc =CPU_GET_CLASS (cpu); -if (cc->memory_rw_debug) { -return cc->memory_rw_debug (cpu, addr, buf, len, is_write); +if (cpu->cc->memory_rw_debug) { +return cpu->cc->memory_rw_debug (cpu, addr, buf, len, is_write); }return cpu_memory_rw_debug (cpu, addr, buf, len, is_write); }
gdbstub/user.c +2 -5
@@ -665,11 +665,8 @@ int gdb_continue_partial(char *newstates)int gdb_target_memory_rw_debug (CPUState *cpu,hwaddr addr,uint8_t *buf,int len,bool is_write) { -CPUClass *cc; - - cc =CPU_GET_CLASS (cpu); -if (cc->memory_rw_debug) { -return cc->memory_rw_debug (cpu, addr, buf, len, is_write); +if (cpu->cc->memory_rw_debug) { +return cpu->cc->memory_rw_debug (cpu, addr, buf, len, is_write); }return cpu_memory_rw_debug (cpu, addr, buf, len, is_write); }
Signature · 1 line
2.47.1
Re: [PATCH 06/11] gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 5 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 06/11] gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- gdbstub/gdbstub.c | 26 +++++++++----------------- gdbstub/system.c | 7 ++----- gdbstub/user-target.c | 6 ++---- gdbstub/user.c | 7 ++----- 4 files changed, 15 insertions(+), 31 deletions(-)
r~
PATCH 7/11 hw/acpi: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- hw/acpi/cpu.c | 4 ++-- hw/acpi/cpu_hotplug.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
hw/acpi/cpu.c +2 -2
@@ -235,8 +235,8 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,static AcpiCpuStatus *get_cpu_status (CPUHotplugState *cpu_st,DeviceState *dev) { -CPUClass *k =CPU_GET_CLASS (dev); -uint64_t cpu_arch_id = k->get_arch_id (CPU (dev)); +CPUState *cpu =CPU (dev); +uint64_t cpu_arch_id = cpu->cc->get_arch_id (cpu);int i;for (i =0 ; i < cpu_st->dev_count; i++) {
hw/acpi/cpu_hotplug.c +1 -2
@@ -62,10 +62,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {static void acpi_set_cpu_present_bit (AcpiCpuHotplug *g,CPUState *cpu,bool *swtchd_to_modern) { -CPUClass *k =CPU_GET_CLASS (cpu);int64_t cpu_id; - cpu_id = k->get_arch_id (cpu); + cpu_id = cpu->cc->get_arch_id (cpu);if ((cpu_id /8 ) >=ACPI_GPE_PROC_LEN ) {object_property_set_bool (g->device,"cpu-hotplug-legacy" , false, &error_abort);
Signature · 1 line
2.47.1
Re: [PATCH 07/11] hw/acpi: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 9 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/acpi/cpu.c | 4 ++-- hw/acpi/cpu_hotplug.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
r~
Quoted 32 lines
hw/acpi/cpu.c +2
-2@@ -235,8 +235,8 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,static AcpiCpuStatus *get_cpu_status (CPUHotplugState *cpu_st,DeviceState *dev) { -CPUClass *k =CPU_GET_CLASS (dev); -uint64_t cpu_arch_id = k->get_arch_id (CPU (dev)); +CPUState *cpu =CPU (dev); +uint64_t cpu_arch_id = cpu->cc->get_arch_id (cpu);int i;for (i =0 ; i < cpu_st->dev_count; i++) {hw/acpi/cpu_hotplug.c +1
-2@@ -62,10 +62,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {static void acpi_set_cpu_present_bit (AcpiCpuHotplug *g,CPUState *cpu,bool *swtchd_to_modern) { -CPUClass *k =CPU_GET_CLASS (cpu);int64_t cpu_id; - cpu_id = k->get_arch_id (cpu); + cpu_id = cpu->cc->get_arch_id (cpu);if ((cpu_id /8 ) >=ACPI_GPE_PROC_LEN ) {object_property_set_bool (g->device,"cpu-hotplug-legacy" , false, &error_abort);
PATCH 8/11 hw/core/generic-loader: Prefer cached CpuClass over CPU_GET_CLASS macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- hw/core/generic-loader.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/core/generic-loader.c +1 -4
@@ -48,11 +48,8 @@ static void generic_loader_reset(void *opaque)GenericLoaderState *s =GENERIC_LOADER (opaque);if (s->set_pc) { -CPUClass *cc =CPU_GET_CLASS (s->cpu);cpu_reset (s->cpu); -if (cc) { - cc->set_pc (s->cpu, s->addr); - } + s->cpu->cc->set_pc (s->cpu, s->addr); }if (s->data_len) {
Signature · 1 line
2.47.1
Re: [PATCH 08/11] hw/core/generic-loader: Prefer cached CpuClass over CPU_GET_CLASS macro
Quoted 14 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/generic-loader.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/core/generic-loader.c +0
-0
hw/core/generic-loader.c static void generic_loader_reset(void *opaque) · line 52
Quoted 9 lines
hw/core/generic-loader.c +1
-4@@ -48,11 +48,8 @@ static void generic_loader_reset(void *opaque)GenericLoaderState *s =GENERIC_LOADER (opaque);if (s->set_pc) { -CPUClass *cc =CPU_GET_CLASS (s->cpu);cpu_reset (s->cpu); -if (cc) { - cc->set_pc (s->cpu, s->addr); - } + s->cpu->cc->set_pc (s->cpu, s->addr);
I guess we can directly use:
cpu_set_pc(s->cpu, s->addr);
Quoted 3 lines
hw/core/generic-loader.c +0
-0}if (s->data_len) {
PATCH 9/11 target/arm: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- target/arm/cpu.c | 3 +-- target/arm/tcg/cpu-v7m.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
target/arm/cpu.c +1 -2
@@ -846,7 +846,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,static bool arm_cpu_exec_interrupt (CPUState *cs,int interrupt_request) { -CPUClass *cc =CPU_GET_CLASS (cs);CPUARMState *env =cpu_env (cs);uint32_t cur_el =arm_current_el (env);bool secure =arm_is_secure (env);
@@ -946,7 +945,7 @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) found: cs->exception_index = excp_idx; env->exception.target_el = target_el; - cc->tcg_ops->do_interrupt (cs); + cs->cc->tcg_ops->do_interrupt (cs);return true; }
target/arm/tcg/cpu-v7m.c +1 -2
@@ -19,7 +19,6 @@static bool arm_v7m_cpu_exec_interrupt (CPUState *cs,int interrupt_request) { -CPUClass *cc =CPU_GET_CLASS (cs);ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;bool ret = false;
@@ -35,7 +34,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)if (interrupt_request &CPU_INTERRUPT_HARD && (armv7m_nvic_can_take_pending_exception (env->nvic))) { cs->exception_index =EXCP_IRQ ; - cc->tcg_ops->do_interrupt (cs); + cs->cc->tcg_ops->do_interrupt (cs); ret = true; }return ret;
Signature · 1 line
2.47.1
Re: [PATCH 09/11] target/arm: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 5 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
PATCH 10/11 target/microblaze: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- target/microblaze/gdbstub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/microblaze/gdbstub.c +1 -2
@@ -110,11 +110,10 @@ int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n)int mb_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) { -CPUClass *cc =CPU_GET_CLASS (cs);CPUMBState *env =cpu_env (cs);uint32_t tmp; -if (n > cc->gdb_num_core_regs) { +if (n > cs->cc->gdb_num_core_regs) {return 0 ; }
Signature · 1 line
2.47.1
Re: [PATCH 10/11] target/microblaze: Prefer cached CpuClass over CPU_GET_CLASS() macro
Quoted 15 lines · Philippe Mathieu-Daudé
CpuState caches its CPUClass since commit
6fbdff87062("cpu: cache CPUClass in CPUState for hot code paths"), use it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/microblaze/gdbstub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/microblaze/gdbstub.c +0
-0@@ -110,11 +110,10 @@ int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n)
target/microblaze/gdbstub.c int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n) · line 118
Quoted 10 lines
target/microblaze/gdbstub.c +1
-2int mb_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) { -CPUClass *cc =CPU_GET_CLASS (cs);CPUMBState *env =cpu_env (cs);uint32_t tmp; -if (n > cc->gdb_num_core_regs) { +if (n > cs->cc->gdb_num_core_regs) {return 0 ; }
Apparently gdb_write_register() deals with that, so we can remove.
PATCH 11/11 target/openrisc: Prefer cached CpuClass over CPU_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéCpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it.
--- target/openrisc/gdbstub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/openrisc/gdbstub.c +1 -2
@@ -47,11 +47,10 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)int openrisc_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) { -CPUClass *cc =CPU_GET_CLASS (cs);CPUOpenRISCState *env =cpu_env (cs);uint32_t tmp; -if (n > cc->gdb_num_core_regs) { +if (n > cs->cc->gdb_num_core_regs) {return 0 ; }
Signature · 1 line
2.47.1