accel/tcg: Stubs cleanups
cover accel/tcg: Stubs cleanups
- Remove unused stubs,
- Guard with tcg_enabled() and remove more,
- Reduce tlb_set_dirty() scope?
Philippe Mathieu-Daudé (4):
accel/tcg: Remove tlb_set_dirty() stub
accel/tcg: Remove unused tcg_flush_jmp_cache() stub accel/tcg: Guard tb_flush() with tcg_enabled() and remove the stub accel/tcg: Keep tlb_set_dirty() internal
include/exec/exec-all.h | 1 - accel/stubs/tcg-stub.c | 12 ------------ accel/tcg/cputlb.c | 2 +- cpu.c | 15 +++++++++------ gdbstub/softmmu.c | 5 ++++- hw/ppc/spapr_hcall.c | 2 +- 6 files changed, 15 insertions(+), 22 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/4 accel/tcg: Remove tlb_set_dirty() stub
Since commit 34d49937e4 ("accel/tcg: Handle atomic accesses to notdirty memory correctly") there is only a single call to tlb_set_dirty(), within accel/tcg/cputlb.c itself where the function is defined.
--- accel/stubs/tcg-stub.c | 4 ---- 1 file changed, 4 deletions(-)
accel/stubs/tcg-stub.c +0 -4
@@ -18,10 +18,6 @@ void tb_flush(CPUState *cpu) { } -void tlb_set_dirty (CPUState *cpu,vaddr vaddr) -{ -} -void tcg_flush_jmp_cache (CPUState *cpu) { }
Signature · 1 line
2.41.0
Re: [PATCH 1/4] accel/tcg: Remove tlb_set_dirty() stub
Quoted 6 lines · Philippe Mathieu-Daudé
Since commit
34d49937e4("accel/tcg: Handle atomic accesses to notdirty memory correctly") there is only a single call totlb_set_dirty(), withinaccel/tcg/cputlb.citself where the function is defined.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 19 lines
--- accel/stubs/tcg-stub.c | 4 ---- 1 file changed, 4 deletions(-)accel/stubs/tcg-stub.c +0
-4@@ -18,10 +18,6 @@ void tb_flush(CPUState *cpu) { } -void tlb_set_dirty (CPUState *cpu,vaddr vaddr) -{ -} -void tcg_flush_jmp_cache (CPUState *cpu) { }
PATCH 2/4 accel/tcg: Remove unused tcg_flush_jmp_cache() stub
In reply to Philippe Mathieu-DaudéSince commit ba7d3d1858 ("cpu_common_reset: wrap TCG specific code in tcg_enabled()") we protect the single call to tcg_flush_jmp_cache() with a check on tcg_enabled(). The stub isn't needed anymore.
--- accel/stubs/tcg-stub.c | 4 ---- 1 file changed, 4 deletions(-)
accel/stubs/tcg-stub.c +0 -4
@@ -18,10 +18,6 @@ void tb_flush(CPUState *cpu) { } -void tcg_flush_jmp_cache (CPUState *cpu) -{ -} -int probe_access_flags (CPUArchState *env,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool nonfault,void **phost,uintptr_t retaddr)
Signature · 1 line
2.41.0
Re: [PATCH 2/4] accel/tcg: Remove unused tcg_flush_jmp_cache() stub
Quoted 6 lines · Philippe Mathieu-Daudé
Since commit
ba7d3d1858("cpu_common_reset: wrap TCG specific code intcg_enabled()") we protect the single call totcg_flush_jmp_cache()with a check ontcg_enabled(). The stub isn't needed anymore.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Commit log might need rephrase as I see multiple instance of call,
with one without check for tcg_enabled() in plugin_cpu_update__async but seems to be building only with tcg enabled so no build breaks.
Thanks
Harsh
Quoted 19 lines
--- accel/stubs/tcg-stub.c | 4 ---- 1 file changed, 4 deletions(-)accel/stubs/tcg-stub.c +0
-4@@ -18,10 +18,6 @@ void tb_flush(CPUState *cpu) { } -void tcg_flush_jmp_cache (CPUState *cpu) -{ -} -int probe_access_flags (CPUArchState *env,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool nonfault,void **phost,uintptr_t retaddr)
Re: [PATCH 2/4] accel/tcg: Remove unused tcg_flush_jmp_cache() stub
Quoted 8 lines · Harsh Prateek Bora
Quoted 5 lines · Philippe Mathieu-Daudé
Since commit
ba7d3d1858("cpu_common_reset: wrap TCG specific code intcg_enabled()") we protect the single call totcg_flush_jmp_cache()with a check ontcg_enabled(). The stub isn't needed anymore.
Quoted 4 lines
Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Commit log might need rephrase as I see multiple instance of call,
with one without check fortcg_enabled()inplugin_cpu_update__asyncbut seems to be building only with tcg enabled so no build breaks.
TCG Plugins are restricted to TCG, so we don't need to guard there :) I'll update the description mentioning it.
Thanks for your review!
Quoted 20 lines
Thanks
HarshQuoted 18 lines
---
accel/stubs/tcg-stub.c| 4 ----1 file changed, 4 deletions(-)accel/stubs/tcg-stub.c +0
-4@@ -18,10 +18,6 @@ void tb_flush(CPUState *cpu) { } -void tcg_flush_jmp_cache (CPUState *cpu) -{ -} - int probe_access_flags(CPUArchState *env, vaddr addr, int size, MMUAccessType access_type, int mmu_idx, bool nonfault, void **phost, uintptr_t retaddr)
RFC PATCH 3/4 accel/tcg: Guard tb_flush() with tcg_enabled() and remove the stub
In reply to Philippe Mathieu-DaudéThe check on tcg_enabled() make it clearer we want this call under TCG.
--- accel/stubs/tcg-stub.c | 4 ---- cpu.c | 15 +++++++++------ gdbstub/softmmu.c | 5 ++++- hw/ppc/spapr_hcall.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-)
accel/stubs/tcg-stub.c +0 -4
@@ -14,10 +14,6 @@#include "exec/tb-flush.h" #include "exec/exec-all.h" -void tb_flush (CPUState *cpu) -{ -} -int probe_access_flags (CPUArchState *env,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool nonfault,void **phost,uintptr_t retaddr)
cpu.c +9 -6
@@ -57,12 +57,15 @@ static int cpu_common_post_load(void *opaque, int version_id) cpu->interrupt_request &= ~0x01 ;tlb_flush (cpu); -/* loadvm has just updated the content of RAM, bypassing the -* usual mechanisms that ensure we flush TBs for writes to -* memory we've translated code from. So we must flush all TBs, -* which will now be stale. -*/ -tb_flush (cpu); +if (tcg_enabled ()) { +/* +* loadvm has just updated the content of RAM, bypassing the +* usual mechanisms that ensure we flush TBs for writes to +* memory we've translated code from. So we must flush all TBs, +* which will now be stale. +*/ +tb_flush (cpu); + }return 0 ; }
gdbstub/softmmu.c +4 -1
@@ -21,6 +21,7 @@#include "sysemu/cpus.h" #include "sysemu/runstate.h" #include "sysemu/replay.h" +#include "sysemu/tcg.h" #include "hw/core/cpu.h" #include "hw/cpu/cluster.h" #include "hw/boards.h"
@@ -170,7 +171,9 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) }else {trace_gdbstub_hit_break (); } -tb_flush (cpu); +if (tcg_enabled ()) { +tb_flush (cpu); + } ret =GDB_SIGNAL_TRAP ;break ;case RUN_STATE_PAUSED :
hw/ppc/spapr_hcall.c +1 -1
@@ -296,7 +296,7 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprMachineState *spapr,if (flags & (H_ICACHE_SYNCHRONIZE |H_ICACHE_INVALIDATE )) {if (kvm_enabled ()) {kvmppc_icbi_range (cpu, pdst, len); - }else { + }else if (tcg_enabled ()) {tb_flush (CPU (cpu)); } }
Signature · 1 line
2.41.0
Re: [RFC PATCH 3/4] accel/tcg: Guard tb_flush() with tcg_enabled() and remove the stub
Quoted 3 lines · Philippe Mathieu-Daudé
The check on
tcg_enabled()make it clearer we want this call under TCG.
tb_flush already has a check for tcg_enabled() in its definition. Do we really need to check for same before calling it?
Thanks
Harsh
Quoted 85 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/stubs/tcg-stub.c | 4 ---- cpu.c | 15 +++++++++------ gdbstub/softmmu.c | 5 ++++- hw/ppc/spapr_hcall.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-)accel/stubs/tcg-stub.c +0
-4@@ -14,10 +14,6 @@#include "exec/tb-flush.h" #include "exec/exec-all.h" -void tb_flush (CPUState *cpu) -{ -} -int probe_access_flags (CPUArchState *env,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool nonfault,void **phost,uintptr_t retaddr)cpu.c +9
-6@@ -57,12 +57,15 @@ static int cpu_common_post_load(void *opaque, int version_id) cpu->interrupt_request &= ~0x01 ;tlb_flush (cpu); -/* loadvm has just updated the content of RAM, bypassing the -* usual mechanisms that ensure we flush TBs for writes to -* memory we've translated code from. So we must flush all TBs, -* which will now be stale. -*/ -tb_flush (cpu); +if (tcg_enabled ()) { +/* +* loadvm has just updated the content of RAM, bypassing the +* usual mechanisms that ensure we flush TBs for writes to +* memory we've translated code from. So we must flush all TBs, +* which will now be stale. +*/ +tb_flush (cpu); + }return 0 ; }gdbstub/softmmu.c +4
-1@@ -21,6 +21,7 @@#include "sysemu/cpus.h" #include "sysemu/runstate.h" #include "sysemu/replay.h" +#include "sysemu/tcg.h" #include "hw/core/cpu.h" #include "hw/cpu/cluster.h" #include "hw/boards.h" @@ -170,7 +171,9 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) }else {trace_gdbstub_hit_break (); } -tb_flush (cpu); +if (tcg_enabled ()) { +tb_flush (cpu); + } ret =GDB_SIGNAL_TRAP ;break ;case RUN_STATE_PAUSED :hw/ppc/spapr_hcall.c +1
-1@@ -296,7 +296,7 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprMachineState *spapr,if (flags & (H_ICACHE_SYNCHRONIZE |H_ICACHE_INVALIDATE )) {if (kvm_enabled ()) {kvmppc_icbi_range (cpu, pdst, len); - }else { + }else if (tcg_enabled ()) {tb_flush (CPU (cpu)); } }
Re: [RFC PATCH 3/4] accel/tcg: Guard tb_flush() with tcg_enabled() and remove the stub
Quoted 9 lines · Harsh Prateek Bora
Quoted 3 lines · Philippe Mathieu-Daudé
The check on
tcg_enabled()make it clearer we want this call under TCG.
tb_flushalready has a check fortcg_enabled()in its definition. Do we really need to check for same before calling it?
Good point, I didn't notice. I'll replace the call in tb_flush() by an assertion.
Quoted 11 lines
Thanks
HarshQuoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/stubs/tcg-stub.c| 4 ----
cpu.c | 15 +++++++++------
gdbstub/softmmu.c | 5 ++++-
hw/ppc/spapr_hcall.c | 2 +-4 files changed, 14 insertions(+), 12 deletions(-)
Re: [RFC PATCH 3/4] accel/tcg: Guard tb_flush() with tcg_enabled() and remove the stub
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Harsh Prateek Bora
Quoted 3 lines · Philippe Mathieu-Daudé
The check on
tcg_enabled()make it clearer we want this call under TCG.
Quoted 5 lines
Quoted 2 lines
tb_flushalready has a check fortcg_enabled()in its definition. Do we really need to check for same before calling it?Good point, I didn't notice. I'll replace the call in
tb_flush()by an assertion.
I guess you meant asserting in else case of the check inside ?
We may want to have the check internally only than having every caller to do that.
Quoted 14 lines
Quoted 12 lines
Thanks
HarshQuoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/stubs/tcg-stub.c| 4 ----
cpu.c | 15 +++++++++------
gdbstub/softmmu.c | 5 ++++-
hw/ppc/spapr_hcall.c | 2 +-4 files changed, 14 insertions(+), 12 deletions(-)
RFC PATCH 4/4 accel/tcg: Keep tlb_set_dirty() internal
In reply to Philippe Mathieu-DaudéSince commit 34d49937e4 ("accel/tcg: Handle atomic accesses to notdirty memory correctly") tlb_set_dirty() is only used (once) in the very same file it is defined... Make it static.
--- include/exec/exec-all.h | 1 - accel/tcg/cputlb.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
include/exec/exec-all.h +0 -1
@@ -695,7 +695,6 @@ static inline void mmap_unlock(void) {}#define WITH_MMAP_LOCK_GUARD ()void tlb_reset_dirty (CPUState *cpu,ram_addr_t start1,ram_addr_t length); -void tlb_set_dirty (CPUState *cpu,vaddr addr);MemoryRegionSection * address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
accel/tcg/cputlb.c +1 -1
@@ -1062,7 +1062,7 @@ static inline void tlb_set_dirty1_locked(CPUTLBEntry *tlb_entry,/* update the TLB corresponding to virtual page vaddr so that it is no longer dirty */ -void tlb_set_dirty (CPUState *cpu,vaddr addr) +static void tlb_set_dirty (CPUState *cpu,vaddr addr) {CPUArchState *env = cpu->env_ptr;int mmu_idx;
Signature · 1 line
2.41.0
Re: [RFC PATCH 4/4] accel/tcg: Keep tlb_set_dirty() internal
Quoted 5 lines · Philippe Mathieu-Daudé
Since commit
34d49937e4("accel/tcg: Handle atomic accesses to notdirty memory correctly")tlb_set_dirty()is only used (once) in the very same file it is defined... Make it static.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 30 lines
--- include/exec/exec-all.h | 1 - accel/tcg/cputlb.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)include/exec/exec-all.h +0
-1@@ -695,7 +695,6 @@ static inline void mmap_unlock(void) {}#define WITH_MMAP_LOCK_GUARD ()void tlb_reset_dirty (CPUState *cpu,ram_addr_t start1,ram_addr_t length); -void tlb_set_dirty (CPUState *cpu,vaddr addr);MemoryRegionSection * address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,accel/tcg/cputlb.c +1
-1@@ -1062,7 +1062,7 @@ static inline void tlb_set_dirty1_locked(CPUTLBEntry *tlb_entry,/* update the TLB corresponding to virtual page vaddr so that it is no longer dirty */ -void tlb_set_dirty (CPUState *cpu,vaddr addr) +static void tlb_set_dirty (CPUState *cpu,vaddr addr) {CPUArchState *env = cpu->env_ptr;int mmu_idx;