tcg patch queue
This is v4 of my notdirty + rom patch set with two suggested name changes (qemu_build_not_reached, TLB_DISCARD_WRITE) from David and Alex.
r~
The following changes since commit 240ab11fb72049d6373cbbec8d788f8e411a00bc:
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190924' into staging (2019-09-24 15:36:31 +0100)
are available in the Git repository at:
https://github.com/rth7680/qemu.git tags/pull-tcg-20190925
for you to fetch changes up to ae57db63acf5a0399232f852acc5c1d83ef63400:
cputlb: Pass retaddr to tb_check_watchpoint (2019-09-25 10:56:28 -0700)
----------------------------------------------------------------
Fixes for TLB_BSWAP
Coversion of NOTDIRTY and ROM handling to cputlb
Followup cleanups to cputlb
----------------------------------------------------------------
Richard Henderson (16):
exec: Use TARGET_PAGE_BITS_MIN for TLB flags
cputlb: Disable __always_inline__ without optimization qemu/compiler.h: Add qemu_build_not_reached
cputlb: Use qemu_build_not_reached in load/store_helpers
cputlb: Split out load/store_memop
cputlb: Introduce TLB_BSWAP
exec: Adjust notdirty tracing
cputlb: Move ROM handling from I/O path to TLB path
cputlb: Move NOTDIRTY handling from I/O path to TLB path
cputlb: Partially inline memory_region_section_get_iotlb
cputlb: Merge and move memory_notdirty_write_{prepare,complete}
cputlb: Handle TLB_NOTDIRTY in probe_access
cputlb: Remove cpu->mem_io_vaddr
cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access
cputlb: Pass retaddr to tb_invalidate_phys_page_fast
cputlb: Pass retaddr to tb_check_watchpoint
accel/tcg/translate-all.h | 8 +- include/exec/cpu-all.h | 23 ++- include/exec/cpu-common.h | 3 - include/exec/exec-all.h | 6 +- include/exec/memory-internal.h | 65 -------- include/hw/core/cpu.h | 2 - include/qemu/compiler.h | 26 +++ accel/tcg/cputlb.c | 348 +++++++++++++++++++++++++---------------- accel/tcg/translate-all.c | 51 +++--- exec.c | 158 +------------------ hw/core/cpu.c | 1 - memory.c | 20 --- trace-events | 4 +- 13 files changed, 288 insertions(+), 427 deletions(-)
[PULL 02/16] cputlb: Disable __always_inline__ without optimization
This forced inlining can result in missing symbols, which makes a debugging build harder to follow.
--- include/qemu/compiler.h | 11 +++++++++++ accel/tcg/cputlb.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-)
include/qemu/compiler.h +11 -0
@@ -170,6 +170,17 @@# define QEMU_NONSTRING #endif +/* +* Forced inlining may be desired to encourage constant propagation +* of function parameters. However, it can also make debugging harder, +* so disable it for a non-optimizing build. +*/ +#if defined(__OPTIMIZE__) +#define QEMU_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define QEMU_ALWAYS_INLINE +#endif +/* Implement C11 _Generic via GCC builtins. Example: * * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)
accel/tcg/cputlb.c +2 -2
@@ -1281,7 +1281,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,typedef uint64_t FullLoadHelper (CPUArchState *env,target_ulong addr,TCGMemOpIdx oi,uintptr_t retaddr); -static inline uint64_t __attribute__((always_inline)) +static inline uint64_t QEMU_ALWAYS_INLINEload_helper (CPUArchState *env,target_ulong addr,TCGMemOpIdx oi,uintptr_t retaddr,MemOp op,bool code_read,FullLoadHelper *full_load)
@@ -1530,7 +1530,7 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,* Store Helpers */ -static inline void __attribute__((always_inline)) +static inline void QEMU_ALWAYS_INLINEstore_helper (CPUArchState *env,target_ulong addr,uint64_t val,TCGMemOpIdx oi,uintptr_t retaddr,MemOp op) {
Signature · 1 line
2.17.1
[PULL 03/16] qemu/compiler.h: Add qemu_build_not_reached
In reply to Richard HendersonUse this as a compile-time assert that a particular code path is not reachable.
--- include/qemu/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/qemu/compiler.h +15 -0
@@ -221,4 +221,19 @@#define QEMU_GENERIC9 (x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, __VA_ARGS__))#define QEMU_GENERIC10 (x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x, __VA_ARGS__)) +/** +* qemu_build_not_reached() +* +* The compiler, during optimization, is expected to prove that a call +* to this function cannot be reached and remove it. If the compiler +* supports QEMU_ERROR, this will be reported at compile time; otherwise +* this will be reported at link time due to the missing symbol. +*/ +#ifdef __OPTIMIZE__ +extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") +qemu_build_not_reached (void); +#else +#define qemu_build_not_reached () g_assert_not_reached() +#endif +#endif /* COMPILER_H */
Signature · 1 line
2.17.1
[PULL 05/16] cputlb: Split out load/store_memop
In reply to Richard HendersonWe will shortly be using these more than once.
--- accel/tcg/cputlb.c | 107 +++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 52 deletions(-)
accel/tcg/cputlb.c +55 -52
@@ -1281,6 +1281,29 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,typedef uint64_t FullLoadHelper (CPUArchState *env,target_ulong addr,TCGMemOpIdx oi,uintptr_t retaddr); +static inline uint64_t QEMU_ALWAYS_INLINE +load_memop (const void *haddr,MemOp op) +{ +switch (op) { +case MO_UB : +return ldub_p (haddr); +case MO_BEUW : +return lduw_be_p (haddr); +case MO_LEUW : +return lduw_le_p (haddr); +case MO_BEUL : +return (uint32_t )ldl_be_p (haddr); +case MO_LEUL : +return (uint32_t )ldl_le_p (haddr); +case MO_BEQ : +return ldq_be_p (haddr); +case MO_LEQ : +return ldq_le_p (haddr); +default : +qemu_build_not_reached (); + } +} + static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read,
@@ -1373,33 +1396,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, do_aligned_access: haddr = (void *)((uintptr_t )addr + entry->addend); -switch (op) { -case MO_UB : - res =ldub_p (haddr); -break ; -case MO_BEUW : - res =lduw_be_p (haddr); -break ; -case MO_LEUW : - res =lduw_le_p (haddr); -break ; -case MO_BEUL : - res = (uint32_t )ldl_be_p (haddr); -break ; -case MO_LEUL : - res = (uint32_t )ldl_le_p (haddr); -break ; -case MO_BEQ : - res =ldq_be_p (haddr); -break ; -case MO_LEQ : - res =ldq_le_p (haddr); -break ; -default : -qemu_build_not_reached (); - } - -return res; +return load_memop (haddr, op); }/*
@@ -1530,6 +1527,36 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,* Store Helpers */ +static inline void QEMU_ALWAYS_INLINE +store_memop (void *haddr,uint64_t val,MemOp op) +{ +switch (op) { +case MO_UB : +stb_p (haddr, val); +break ; +case MO_BEUW : +stw_be_p (haddr, val); +break ; +case MO_LEUW : +stw_le_p (haddr, val); +break ; +case MO_BEUL : +stl_be_p (haddr, val); +break ; +case MO_LEUL : +stl_le_p (haddr, val); +break ; +case MO_BEQ : +stq_be_p (haddr, val); +break ; +case MO_LEQ : +stq_le_p (haddr, val); +break ; +default : +qemu_build_not_reached (); + } +} + static inline void QEMU_ALWAYS_INLINEstore_helper (CPUArchState *env,target_ulong addr,uint64_t val,TCGMemOpIdx oi,uintptr_t retaddr,MemOp op)
@@ -1657,31 +1684,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, do_aligned_access: haddr = (void *)((uintptr_t )addr + entry->addend); -switch (op) { -case MO_UB : -stb_p (haddr, val); -break ; -case MO_BEUW : -stw_be_p (haddr, val); -break ; -case MO_LEUW : -stw_le_p (haddr, val); -break ; -case MO_BEUL : -stl_be_p (haddr, val); -break ; -case MO_LEUL : -stl_le_p (haddr, val); -break ; -case MO_BEQ : -stq_be_p (haddr, val); -break ; -case MO_LEQ : -stq_le_p (haddr, val); -break ; -default : -qemu_build_not_reached (); - } +store_memop (haddr, val, op); } void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val,
Signature · 1 line
2.17.1
[PULL 01/16] exec: Use TARGET_PAGE_BITS_MIN for TLB flags
In reply to Richard HendersonThese bits do not need to vary with the actual page size used by the guest.
--- include/exec/cpu-all.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
include/exec/cpu-all.h +10 -6
@@ -317,20 +317,24 @@ CPUArchState *cpu_copy(CPUArchState *env);#if !defined(CONFIG_USER_ONLY ) -/* Flags stored in the low bits of the TLB virtual address. These are -* defined so that fast path ram access is all zeros. +/* +* Flags stored in the low bits of the TLB virtual address. +* These are defined so that fast path ram access is all zeros. * The flags all must be between TARGET_PAGE_BITS and * maximum address alignment bit. +* +* Use TARGET_PAGE_BITS_MIN so that these bits are constant +* when TARGET_PAGE_BITS_VARY is in effect. */ /* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS - 1)) +#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1))/* Set if TLB entry references a clean RAM page. The iotlb entry will contain the page physical address. */ -#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) +#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2))/* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) +#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3))/* Set if TLB entry contains a watchpoint. */ -#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS - 4)) +#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4))/* Use this mask to check interception with an alignment mask * in a TCG backend.
Signature · 1 line
2.17.1
[PULL 07/16] exec: Adjust notdirty tracing
In reply to Richard HendersonThe memory_region_tb_read tracepoint is unreachable, since notdirty is supposed to apply only to writes. The memory_region_tb_write tracepoint is mis-named, because notdirty is not only used for TB invalidation. It is also used for e.g. VGA RAM updates and migration.
Replace memory_region_tb_write with memory_notdirty_write_access, and place it in memory_notdirty_write_prepare where it can catch all of the instances. Add memory_notdirty_set_dirty to log when we no longer intercept writes to a page.
--- exec.c | 3 +++ memory.c | 4 ---- trace-events | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-)
exec.c +3 -0
@@ -2755,6 +2755,8 @@ void memory_notdirty_write_prepare(NotDirtyInfo *ndi, ndi->size = size; ndi->pages =NULL ; +trace_memory_notdirty_write_access (mem_vaddr, ram_addr, size); +assert (tcg_enabled ());if (!cpu_physical_memory_get_dirty_flag (ram_addr,DIRTY_MEMORY_CODE )) { ndi->pages =page_collection_lock (ram_addr, ram_addr + size);
@@ -2779,6 +2781,7 @@ void memory_notdirty_write_complete(NotDirtyInfo *ndi)/* we remove the notdirty callback only if the code has been flushed */ if (!cpu_physical_memory_is_clean (ndi->ram_addr)) { +trace_memory_notdirty_set_dirty (ndi->mem_vaddr);tlb_set_dirty (ndi->cpu, ndi->mem_vaddr); } }
memory.c +0 -4
@@ -438,7 +438,6 @@ static MemTxResult memory_region_read_accessor(MemoryRegion *mr,/* Accesses to code which has previously been translated into a TB show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ -trace_memory_region_tb_read (get_cpu_index (), addr, tmp, size); }else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_read (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -465,7 +464,6 @@ static MemTxResult memory_region_read_with_attrs_accessor(MemoryRegion *mr,/* Accesses to code which has previously been translated into a TB show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ -trace_memory_region_tb_read (get_cpu_index (), addr, tmp, size); }else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_read (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -490,7 +488,6 @@ static MemTxResult memory_region_write_accessor(MemoryRegion *mr,/* Accesses to code which has previously been translated into a TB show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ -trace_memory_region_tb_write (get_cpu_index (), addr, tmp, size); }else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_write (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -515,7 +512,6 @@ static MemTxResult memory_region_write_with_attrs_accessor(MemoryRegion *mr,/* Accesses to code which has previously been translated into a TB show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ -trace_memory_region_tb_write (get_cpu_index (), addr, tmp, size); }else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_write (get_cpu_index (), mr, abs_addr, tmp, size);
trace-events +2 -2
@@ -52,14 +52,14 @@ dma_map_wait(void *dbs) "dbs=%p" find_ram_offset(uint64_t size, uint64_t offset) "size: 0x%" PRIx64 " @ 0x%" PRIx64 find_ram_offset_loop(uint64_t size, uint64_t candidate, uint64_t offset, uint64_t next, uint64_t mingap) "trying size: 0x%" PRIx64 " @ 0x%" PRIx64 ", offset: 0x%" PRIx64" next: 0x%" PRIx64 " mingap: 0x%" PRIx64 ram_block_discard_range(const char *rbname, void *hva, size_t length, bool need_madvise, bool need_fallocate, int ret) "%s@%p + 0x%zx: madvise: %d fallocate: %d ret: %d" +memory_notdirty_write_access(uint64_t vaddr, uint64_t ram_addr, unsigned size) "0x%" PRIx64 " ram_addr 0x%" PRIx64 " size %u" +memory_notdirty_set_dirty(uint64_t vaddr) "0x%" PRIx64 # memory.c memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_subpage_read(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64" size %u" -memory_region_tb_read(int cpu_index, uint64_t addr, uint64_t value, unsigned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" -memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u" flatview_new(void *view, void *root) "%p (root %p)"
Signature · 1 line
2.17.1
[PULL 04/16] cputlb: Use qemu_build_not_reached in load/store_helpers
In reply to Richard HendersonIncrease the current runtime assert to a compile-time assert.
--- accel/tcg/cputlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
accel/tcg/cputlb.c +2 -3
@@ -1396,7 +1396,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, res =ldq_le_p (haddr);break ;default : -g_assert_not_reached (); +qemu_build_not_reached (); }return res;
@@ -1680,8 +1680,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val,stq_le_p (haddr, val);break ;default : -g_assert_not_reached (); -break ; +qemu_build_not_reached (); } }
Signature · 1 line
2.17.1
[PULL 08/16] cputlb: Move ROM handling from I/O path to TLB path
In reply to Richard HendersonIt does not require going through the whole I/O path in order to discard a write.
--- include/exec/cpu-all.h | 5 ++++- include/exec/cpu-common.h | 1 - accel/tcg/cputlb.c | 36 ++++++++++++++++++++-------------- exec.c | 41 +-------------------------------------- 4 files changed, 26 insertions(+), 57 deletions(-)
include/exec/cpu-all.h +4 -1
@@ -337,12 +337,15 @@ CPUArchState *cpu_copy(CPUArchState *env);#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4))/* Set if TLB entry requires byte swap. */ #define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5)) +/* Set if TLB entry writes ignored. */ +#define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 6))/* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSWAP) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ + | TLB_WATCHPOINT | TLB_BSWAP | TLB_DISCARD_WRITE)/** * tlb_hit_page: return true if page aligned @addr is a hit against the
include/exec/cpu-common.h +0 -1
@@ -100,7 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void);void cpu_flush_icache_range (hwaddr start,hwaddr len); -extern struct MemoryRegion io_mem_rom;extern struct MemoryRegion io_mem_notdirty;typedef int (RAMBlockIterFunc )(RAMBlock *rb,void *opaque);
accel/tcg/cputlb.c +21 -15
@@ -577,7 +577,8 @@ static void tlb_reset_dirty_range_locked(CPUTLBEntry *tlb_entry, {uintptr_t addr = tlb_entry->addr_write; -if ((addr & (TLB_INVALID_MASK |TLB_MMIO |TLB_NOTDIRTY )) ==0 ) { +if ((addr & (TLB_INVALID_MASK |TLB_MMIO | +TLB_DISCARD_WRITE |TLB_NOTDIRTY )) ==0 ) { addr &=TARGET_PAGE_MASK ; addr += tlb_entry->addend;if ((addr - start) < length) {
@@ -745,7 +746,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, address |=TLB_MMIO ; addend =0 ; }else { -/* TLB_MMIO for rom/romd handled below */ addend = (uintptr_t )memory_region_get_ram_ptr (section->mr) + xlat; }
@@ -822,16 +822,17 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, tn.addr_write =-1 ;if (prot &PAGE_WRITE ) { -if ((memory_region_is_ram (section->mr) && section->readonly) - ||memory_region_is_romd (section->mr)) { -/* Write access calls the I/O callback. */ - tn.addr_write = address |TLB_MMIO ; - }else if (memory_region_is_ram (section->mr) - &&cpu_physical_memory_is_clean ( -memory_region_get_ram_addr (section->mr) + xlat)) { - tn.addr_write = address |TLB_NOTDIRTY ; - }else { - tn.addr_write = address; + tn.addr_write = address; +if (memory_region_is_romd (section->mr)) { +/* Use the MMIO path so that the device can switch states. */ + tn.addr_write |=TLB_MMIO ; + }else if (memory_region_is_ram (section->mr)) { +if (section->readonly) { + tn.addr_write |=TLB_DISCARD_WRITE ; + }else if (cpu_physical_memory_is_clean ( +memory_region_get_ram_addr (section->mr) + xlat)) { + tn.addr_write |=TLB_NOTDIRTY ; + } }if (prot &PAGE_WRITE_INV ) { tn.addr_write |=TLB_INVALID_MASK ;
@@ -904,7 +905,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, mr = section->mr; mr_offset = (iotlbentry->addr &TARGET_PAGE_MASK ) + addr; cpu->mem_io_pc = retaddr; -if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu->can_do_io) { +if (mr != &io_mem_notdirty && !cpu->can_do_io) {cpu_io_recompile (cpu, retaddr); }
@@ -945,7 +946,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, section =iotlb_to_section (cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr &TARGET_PAGE_MASK ) + addr; -if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu->can_do_io) { +if (mr != &io_mem_notdirty && !cpu->can_do_io) {cpu_io_recompile (cpu, retaddr); } cpu->mem_io_vaddr = addr;
@@ -1125,7 +1126,7 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, }/* Reject I/O access, or other required slow-path. */ -if (tlb_addr & (TLB_NOTDIRTY |TLB_MMIO |TLB_BSWAP )) { +if (tlb_addr & (TLB_NOTDIRTY |TLB_MMIO |TLB_BSWAP |TLB_DISCARD_WRITE )) {return NULL ; }
@@ -1617,6 +1618,11 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val,return ; } +/* Ignore writes to ROM. */ +if (unlikely (tlb_addr &TLB_DISCARD_WRITE )) { +return ; + } + haddr = (void *)((uintptr_t )addr + entry->addend);/*
exec.c +1 -40
77 lines not on this page · raw message
Signature · 1 line
2.17.1
[PULL 06/16] cputlb: Introduce TLB_BSWAP
In reply to Richard HendersonHandle bswap on ram directly in load/store_helper. This fixes a bug with the previous implementation in that one cannot use the I/O path for RAM.
--- include/exec/cpu-all.h | 4 ++- accel/tcg/cputlb.c | 72 +++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 30 deletions(-)
include/exec/cpu-all.h +3 -1
@@ -335,12 +335,14 @@ CPUArchState *cpu_copy(CPUArchState *env);#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3))/* Set if TLB entry contains a watchpoint. */ #define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) +/* Set if TLB entry requires byte swap. */ +#define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5))/* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSWAP)/** * tlb_hit_page: return true if page aligned @addr is a hit against the
accel/tcg/cputlb.c +43 -29
138 lines not on this page · raw message
Signature · 1 line
2.17.1
[PULL 11/16] cputlb: Merge and move memory_notdirty_write_{prepare, complete}
In reply to Richard HendersonSince 9458a9a1df1a, all readers of the dirty bitmaps wait for the rcu lock, which means that they wait until the end of any executing TranslationBlock.
As a consequence, there is no need for the actual access to happen in between the _prepare and _complete. Therefore, we can improve things by merging the two functions into notdirty_write and dropping the NotDirtyInfo structure.
In addition, the only users of notdirty_write are in cputlb.c, so move the merged function there. Pass in the CPUIOTLBEntry from which the ram_addr_t may be computed.
--- include/exec/memory-internal.h | 65 ----------------------------- accel/tcg/cputlb.c | 76 +++++++++++++++++++--------------- exec.c | 44 -------------------- 3 files changed, 42 insertions(+), 143 deletions(-)
include/exec/memory-internal.h +0 -65
@@ -49,70 +49,5 @@ void address_space_dispatch_free(AddressSpaceDispatch *d);void mtree_print_dispatch (struct AddressSpaceDispatch *d,MemoryRegion *root); - -struct page_collection ; - -/* Opaque struct for passing info from memory_notdirty_write_prepare() -* to memory_notdirty_write_complete(). Callers should treat all fields -* as private, with the exception of @active. -* -* @active is a field which is not touched by either the prepare or -* complete functions, but which the caller can use if it wishes to -* track whether it has called prepare for this struct and so needs -* to later call the complete function. -*/ -typedef struct { -CPUState *cpu; -struct page_collection *pages; -ram_addr_t ram_addr; -vaddr mem_vaddr; -unsigned size; -bool active; -}NotDirtyInfo ; - -/** -* memory_notdirty_write_prepare: call before writing to non-dirty memory -* @ndi: pointer to opaque NotDirtyInfo struct -* @cpu: CPU doing the write -* @mem_vaddr: virtual address of write -* @ram_addr: the ram address of the write -* @size: size of write in bytes -* -* Any code which writes to the host memory corresponding to -* guest RAM which has been marked as NOTDIRTY must wrap those -* writes in calls to memory_notdirty_write_prepare() and -* memory_notdirty_write_complete(): -* -* NotDirtyInfo ndi; -* memory_notdirty_write_prepare(&ndi, ....); -* ... perform write here ... -* memory_notdirty_write_complete(&ndi); -* -* These calls will ensure that we flush any TCG translated code for -* the memory being written, update the dirty bits and (if possible) -* remove the slowpath callback for writing to the memory. -* -* This must only be called if we are using TCG; it will assert otherwise. -* -* We may take locks in the prepare call, so callers must ensure that -* they don't exit (via longjump or otherwise) without calling complete. -* -* This call must only be made inside an RCU critical section. -* (Note that while we're executing a TCG TB we're always in an -* RCU critical section, which is likely to be the case for callers -* of these functions.) -*/ -void memory_notdirty_write_prepare (NotDirtyInfo *ndi, -CPUState *cpu, -vaddr mem_vaddr, -ram_addr_t ram_addr, -unsigned size); -/** -* memory_notdirty_write_complete: finish write to non-dirty memory -* @ndi: pointer to the opaque NotDirtyInfo struct which was initialized -* by memory_not_dirty_write_prepare(). -*/ -void memory_notdirty_write_complete (NotDirtyInfo *ndi); -#endif #endif
accel/tcg/cputlb.c +42 -34
123 lines not on this page · raw message
exec.c +0 -44
50 lines not on this page · raw message
Signature · 1 line
2.17.1
[PULL 10/16] cputlb: Partially inline memory_region_section_get_iotlb
In reply to Richard HendersonThere is only one caller, tlb_set_page_with_attrs. We cannot inline the entire function because the AddressSpaceDispatch structure is private to exec.c, and cannot easily be moved to include/exec/memory-internal.h.
Compute is_ram and is_romd once within tlb_set_page_with_attrs. Fold the number of tests against these predicates. Compute cpu_physical_memory_is_clean outside of the tlb lock region.
--- include/exec/exec-all.h | 6 +--- accel/tcg/cputlb.c | 68 ++++++++++++++++++++++++++--------------- exec.c | 22 ++----------- 3 files changed, 47 insertions(+), 49 deletions(-)
include/exec/exec-all.h +1 -5
@@ -509,11 +509,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, hwaddr *xlat, hwaddr *plen, MemTxAttrs attrs, int *prot);hwaddr memory_region_section_get_iotlb (CPUState *cpu, -MemoryRegionSection *section, -target_ulong vaddr, -hwaddr paddr,hwaddr xlat, -int prot, -target_ulong *address); +MemoryRegionSection *section);#endif /* vl.c */
accel/tcg/cputlb.c +43 -25
107 lines not on this page · raw message
exec.c +3 -19
@@ -1459,26 +1459,10 @@ bool cpu_physical_memory_snapshot_get_dirty(DirtyBitmapSnapshot *snap,/* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb (CPUState *cpu, -MemoryRegionSection *section, -target_ulong vaddr, -hwaddr paddr,hwaddr xlat, -int prot, -target_ulong *address) +MemoryRegionSection *section) { -hwaddr iotlb; - -if (memory_region_is_ram (section->mr)) { -/* Normal RAM. */ - iotlb =memory_region_get_ram_addr (section->mr) + xlat; - }else { -AddressSpaceDispatch *d; - - d =flatview_to_dispatch (section->fv); - iotlb = section - d->map.sections; - iotlb += xlat; - } - -return iotlb; +AddressSpaceDispatch *d =flatview_to_dispatch (section->fv); +return section - d->map.sections; }#endif /* defined(CONFIG_USER_ONLY) */
Signature · 1 line
2.17.1
[PULL 09/16] cputlb: Move NOTDIRTY handling from I/O path to TLB path
In reply to Richard HendersonPages that we want to track for NOTDIRTY are RAM. We do not really need to go through the I/O path to handle them.
--- include/exec/cpu-common.h | 2 -- accel/tcg/cputlb.c | 26 +++++++++++++++++--- exec.c | 50 --------------------------------------- memory.c | 16 ------------- 4 files changed, 23 insertions(+), 71 deletions(-)
include/exec/cpu-common.h +0 -2
@@ -100,8 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void);void cpu_flush_icache_range (hwaddr start,hwaddr len); -extern struct MemoryRegion io_mem_notdirty; -typedef int (RAMBlockIterFunc )(RAMBlock *rb,void *opaque);int qemu_ram_foreach_block (RAMBlockIterFunc func,void *opaque);
accel/tcg/cputlb.c +23 -3
@@ -905,7 +905,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, mr = section->mr; mr_offset = (iotlbentry->addr &TARGET_PAGE_MASK ) + addr; cpu->mem_io_pc = retaddr; -if (mr != &io_mem_notdirty && !cpu->can_do_io) { +if (!cpu->can_do_io) {cpu_io_recompile (cpu, retaddr); }
@@ -946,7 +946,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, section =iotlb_to_section (cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr &TARGET_PAGE_MASK ) + addr; -if (mr != &io_mem_notdirty && !cpu->can_do_io) { +if (!cpu->can_do_io) {cpu_io_recompile (cpu, retaddr); } cpu->mem_io_vaddr = addr;
@@ -1612,7 +1612,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, need_swap = size >1 && (tlb_addr &TLB_BSWAP );/* Handle I/O access. */ -if (likely (tlb_addr & (TLB_MMIO |TLB_NOTDIRTY ))) { +if (tlb_addr &TLB_MMIO ) {io_writex (env, iotlbentry, mmu_idx, val, addr, retaddr, op ^ (need_swap *MO_BSWAP ));return ;
@@ -1625,6 +1625,26 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, haddr = (void *)((uintptr_t )addr + entry->addend); +/* Handle clean RAM pages. */ +if (tlb_addr &TLB_NOTDIRTY ) { +NotDirtyInfo ndi; + +/* We require mem_io_pc in tb_invalidate_phys_page_range. */ +env_cpu (env)->mem_io_pc = retaddr; + +memory_notdirty_write_prepare (&ndi,env_cpu (env), addr, + addr + iotlbentry->addr, size); + +if (unlikely (need_swap)) { +store_memop (haddr, val, op ^MO_BSWAP ); + }else { +store_memop (haddr, val, op); + } + +memory_notdirty_write_complete (&ndi); +return ; + } +/* * Keep these two store_memop separate to ensure that the compiler * is able to fold the entire function to a single instruction.
exec.c +0 -50
86 lines not on this page · raw message
memory.c +0 -16
@@ -434,10 +434,6 @@ static MemTxResult memory_region_read_accessor(MemoryRegion *mr, tmp = mr->ops->read (mr->opaque, addr, size);if (mr->subpage) {trace_memory_region_subpage_read (get_cpu_index (), mr, addr, tmp, size); - }else if (mr == &io_mem_notdirty) { -/* Accesses to code which has previously been translated into a TB show -* up in the MMIO path, as accesses to the io_mem_notdirty -* MemoryRegion. */ }else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_read (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -460,10 +456,6 @@ static MemTxResult memory_region_read_with_attrs_accessor(MemoryRegion *mr, r = mr->ops->read_with_attrs (mr->opaque, addr, &tmp, size, attrs);if (mr->subpage) {trace_memory_region_subpage_read (get_cpu_index (), mr, addr, tmp, size); - }else if (mr == &io_mem_notdirty) { -/* Accesses to code which has previously been translated into a TB show -* up in the MMIO path, as accesses to the io_mem_notdirty -* MemoryRegion. */ }else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_read (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -484,10 +476,6 @@ static MemTxResult memory_region_write_accessor(MemoryRegion *mr,if (mr->subpage) {trace_memory_region_subpage_write (get_cpu_index (), mr, addr, tmp, size); - }else if (mr == &io_mem_notdirty) { -/* Accesses to code which has previously been translated into a TB show -* up in the MMIO path, as accesses to the io_mem_notdirty -* MemoryRegion. */ }else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_write (get_cpu_index (), mr, abs_addr, tmp, size);
@@ -508,10 +496,6 @@ static MemTxResult memory_region_write_with_attrs_accessor(MemoryRegion *mr,if (mr->subpage) {trace_memory_region_subpage_write (get_cpu_index (), mr, addr, tmp, size); - }else if (mr == &io_mem_notdirty) { -/* Accesses to code which has previously been translated into a TB show -* up in the MMIO path, as accesses to the io_mem_notdirty -* MemoryRegion. */ }else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED ) {hwaddr abs_addr =memory_region_to_absolute_addr (mr, addr);trace_memory_region_ops_write (get_cpu_index (), mr, abs_addr, tmp, size);
Signature · 1 line
2.17.1
[PULL 13/16] cputlb: Remove cpu->mem_io_vaddr
In reply to Richard HendersonWith the merge of notdirty handling into store_helper, the last user of cpu->mem_io_vaddr was removed.
--- include/hw/core/cpu.h | 2 -- accel/tcg/cputlb.c | 2 -- hw/core/cpu.c | 1 - 3 files changed, 5 deletions(-)
include/hw/core/cpu.h +0 -2
@@ -338,7 +338,6 @@ struct qemu_work_item;* @next_cpu: Next CPU sharing TB cache. * @opaque: User data. * @mem_io_pc: Host Program Counter at which the memory was accessed. -* @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. * @work_mutex: Lock to prevent multiple access to queued_work_*. * @queued_work_first: First asynchronous work pending.
@@ -413,7 +412,6 @@ struct CPUState {* we store some rarely used information in the CPU context. */ uintptr_t mem_io_pc; -vaddr mem_io_vaddr;/* * This is only needed for the legacy cpu_unassigned_access() hook; * when all targets using it have been converted to use
accel/tcg/cputlb.c +0 -2
@@ -928,7 +928,6 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,cpu_io_recompile (cpu, retaddr); } - cpu->mem_io_vaddr = addr; cpu->mem_io_access_type = access_type;if (mr->global_locking && !qemu_mutex_iothread_locked ()) {
@@ -968,7 +967,6 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,if (!cpu->can_do_io) {cpu_io_recompile (cpu, retaddr); } - cpu->mem_io_vaddr = addr; cpu->mem_io_pc = retaddr;if (mr->global_locking && !qemu_mutex_iothread_locked ()) {
hw/core/cpu.c +0 -1
@@ -261,7 +261,6 @@ static void cpu_common_reset(CPUState *cpu) cpu->interrupt_request =0 ; cpu->halted =0 ; cpu->mem_io_pc =0 ; - cpu->mem_io_vaddr =0 ; cpu->icount_extra =0 ;atomic_set (&cpu->icount_decr_ptr->u32,0 ); cpu->can_do_io =1 ;
Signature · 1 line
2.17.1
[PULL 12/16] cputlb: Handle TLB_NOTDIRTY in probe_access
In reply to Richard HendersonWe can use notdirty_write for the write and return a valid host pointer for this case.
--- accel/tcg/cputlb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
accel/tcg/cputlb.c +17 -9
@@ -1168,16 +1168,24 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size,return NULL ; } -/* Handle watchpoints. */ -if (tlb_addr &TLB_WATCHPOINT ) { -cpu_check_watchpoint (env_cpu (env), addr, size, -env_tlb (env)->d[mmu_idx].iotlb[index].attrs, - wp_access, retaddr); - } +if (unlikely (tlb_addr &TLB_FLAGS_MASK )) { +CPUIOTLBEntry *iotlbentry = &env_tlb (env)->d[mmu_idx].iotlb[index]; -/* Reject I/O access, or other required slow-path. */ -if (tlb_addr & (TLB_NOTDIRTY |TLB_MMIO |TLB_BSWAP |TLB_DISCARD_WRITE )) { -return NULL ; +/* Reject I/O access, or other required slow-path. */ +if (tlb_addr & (TLB_MMIO |TLB_BSWAP |TLB_DISCARD_WRITE )) { +return NULL ; + } + +/* Handle watchpoints. */ +if (tlb_addr &TLB_WATCHPOINT ) { +cpu_check_watchpoint (env_cpu (env), addr, size, + iotlbentry->attrs, wp_access, retaddr); + } + +/* Handle clean RAM pages. */ +if (tlb_addr &TLB_NOTDIRTY ) { +notdirty_write (env_cpu (env), addr, size, iotlbentry, retaddr); + } }return (void *)((uintptr_t )addr + entry->addend);
Signature · 1 line
2.17.1
[PULL 14/16] cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access
In reply to Richard HendersonAll callers pass false to this argument. Remove it and pass the constant on to tb_invalidate_phys_page_range__locked.
--- accel/tcg/translate-all.h | 3 +-- accel/tcg/translate-all.c | 6 ++---- exec.c | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-)
accel/tcg/translate-all.h +1 -2
@@ -28,8 +28,7 @@ struct page_collection *page_collection_lock(tb_page_addr_t start,void page_collection_unlock (struct page_collection *set);void tb_invalidate_phys_page_fast (struct page_collection *pages,tb_page_addr_t start,int len); -void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access); +void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end);void tb_check_watchpoint (CPUState *cpu);#ifdef CONFIG_USER_ONLY
accel/tcg/translate-all.c +2 -4
@@ -1983,8 +1983,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,* * Called with mmap_lock held for user-mode emulation */ -void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access) +void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end) {struct page_collection *pages;PageDesc *p;
@@ -1996,8 +1995,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,return ; } pages =page_collection_lock (start, end); -tb_invalidate_phys_page_range__locked (pages, p, start, end, - is_cpu_write_access); +tb_invalidate_phys_page_range__locked (pages, p, start, end,0 );page_collection_unlock (pages); }
exec.c +2 -2
@@ -1012,7 +1012,7 @@ const char *parse_cpu_option(const char *cpu_option)void tb_invalidate_phys_addr (target_ulong addr) {mmap_lock (); -tb_invalidate_phys_page_range (addr, addr +1 ,0 ); +tb_invalidate_phys_page_range (addr, addr +1 );mmap_unlock (); }
@@ -1039,7 +1039,7 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)return ; } ram_addr =memory_region_get_ram_addr (mr) + addr; -tb_invalidate_phys_page_range (ram_addr, ram_addr +1 ,0 ); +tb_invalidate_phys_page_range (ram_addr, ram_addr +1 );rcu_read_unlock (); }
Signature · 1 line
2.17.1
[PULL 15/16] cputlb: Pass retaddr to tb_invalidate_phys_page_fast
In reply to Richard HendersonRather than rely on cpu->mem_io_pc, pass retaddr down directly.
Within tb_invalidate_phys_page_range__locked, the is_cpu_write_access parameter is non-zero exactly when retaddr would be non-zero, so that is a simple replacement.
Recognize that current_tb_not_found is true only when mem_io_pc (and now retaddr) are also non-zero, so remove a redundant test.
--- accel/tcg/translate-all.h | 3 ++- accel/tcg/cputlb.c | 6 +----- accel/tcg/translate-all.c | 39 +++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 26 deletions(-)
accel/tcg/translate-all.h +2 -1
@@ -27,7 +27,8 @@ struct page_collection *page_collection_lock(tb_page_addr_t start, tb_page_addr_t end);void page_collection_unlock (struct page_collection *set);void tb_invalidate_phys_page_fast (struct page_collection *pages, -tb_page_addr_t start,int len); +tb_page_addr_t start,int len, +uintptr_t retaddr);void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end);void tb_check_watchpoint (CPUState *cpu);
accel/tcg/cputlb.c +1 -5
@@ -1094,11 +1094,7 @@ static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,if (!cpu_physical_memory_get_dirty_flag (ram_addr,DIRTY_MEMORY_CODE )) {struct page_collection *pages =page_collection_lock (ram_addr, ram_addr + size); - -/* We require mem_io_pc in tb_invalidate_phys_page_range. */ - cpu->mem_io_pc = retaddr; - -tb_invalidate_phys_page_fast (pages, ram_addr, size); +tb_invalidate_phys_page_fast (pages, ram_addr, size, retaddr);page_collection_unlock (pages); }
accel/tcg/translate-all.c +19 -20
@@ -1889,7 +1889,7 @@ static void tb_invalidate_phys_page_range__locked(struct page_collection *pages, PageDesc *p, tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access) + uintptr_t retaddr) { TranslationBlock *tb;tb_page_addr_t tb_start, tb_end;
@@ -1897,9 +1897,9 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,#ifdef TARGET_HAS_PRECISE_SMC CPUState *cpu = current_cpu;CPUArchState *env =NULL ; -int current_tb_not_found = is_cpu_write_access; +bool current_tb_not_found = retaddr !=0 ; +bool current_tb_modified = false;TranslationBlock *current_tb =NULL ; -int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ;uint32_t current_flags =0 ;
@@ -1931,24 +1931,21 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,if (!(tb_end <= start || tb_start >= end)) {#ifdef TARGET_HAS_PRECISE_SMC if (current_tb_not_found) { - current_tb_not_found =0 ; - current_tb =NULL ; -if (cpu->mem_io_pc) { -/* now we have a real cpu fault */ - current_tb =tcg_tb_lookup (cpu->mem_io_pc); - } + current_tb_not_found = false; +/* now we have a real cpu fault */ + current_tb =tcg_tb_lookup (retaddr); }if (current_tb == tb && (tb_cflags (current_tb) &CF_COUNT_MASK ) !=1 ) { -/* If we are modifying the current TB, we must stop -its execution. We could be more precise by checking -that the modification is after the current PC, but it -would require a specialized function to partially -restore the CPU state */ - - current_tb_modified =1 ; -cpu_restore_state_from_tb (cpu, current_tb, - cpu->mem_io_pc, true); +/* +* If we are modifying the current TB, we must stop +* its execution. We could be more precise by checking +* that the modification is after the current PC, but it +* would require a specialized function to partially +* restore the CPU state. +*/ + current_tb_modified = true; +cpu_restore_state_from_tb (cpu, current_tb, retaddr, true);cpu_get_tb_cpu_state (env, ¤t_pc, ¤t_cs_base, ¤t_flags); }
@@ -2042,7 +2039,8 @@ void tb_invalidate_phys_range(target_ulong start, target_ulong end)* Call with all @pages in the range [@start, @start + len[ locked. */ void tb_invalidate_phys_page_fast (struct page_collection *pages, -tb_page_addr_t start,int len) +tb_page_addr_t start,int len, +uintptr_t retaddr) {PageDesc *p;
@@ -2069,7 +2067,8 @@ void tb_invalidate_phys_page_fast(struct page_collection *pages, } }else { do_invalidate: -tb_invalidate_phys_page_range__locked (pages, p, start, start + len,1 ); +tb_invalidate_phys_page_range__locked (pages, p, start, start + len, + retaddr); } }#else
Signature · 1 line
2.17.1
[PULL 16/16] cputlb: Pass retaddr to tb_check_watchpoint
In reply to Richard HendersonFixes the previous TLB_WATCHPOINT patches because we are currently failing to set cpu->mem_io_pc with the call to cpu_check_watchpoint. Pass down the retaddr directly because it's readily available.
--- accel/tcg/translate-all.h | 2 +- accel/tcg/translate-all.c | 6 +++--- exec.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
accel/tcg/translate-all.h +1 -1
@@ -30,7 +30,7 @@ void tb_invalidate_phys_page_fast(struct page_collection *pages, tb_page_addr_t start, int len, uintptr_t retaddr);void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end); -void tb_check_watchpoint (CPUState *cpu); +void tb_check_watchpoint (CPUState *cpu,uintptr_t retaddr);#ifdef CONFIG_USER_ONLY int page_unprotect (target_ulong address,uintptr_t pc);
accel/tcg/translate-all.c +3 -3
@@ -2142,16 +2142,16 @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc)#endif /* user-mode: call with mmap_lock held */ -void tb_check_watchpoint (CPUState *cpu) +void tb_check_watchpoint (CPUState *cpu,uintptr_t retaddr) {TranslationBlock *tb;assert_memory_lock (); - tb =tcg_tb_lookup (cpu->mem_io_pc); + tb =tcg_tb_lookup (retaddr);if (tb) {/* We can use retranslation to find the PC. */ -cpu_restore_state_from_tb (cpu, tb, cpu->mem_io_pc, true); +cpu_restore_state_from_tb (cpu, tb, retaddr, true);tb_phys_invalidate (tb,-1 ); }else {/* The exception probably happened in a helper. The CPU state should
exec.c +1 -1
@@ -2758,7 +2758,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, cpu->watchpoint_hit = wp;mmap_lock (); -tb_check_watchpoint (cpu); +tb_check_watchpoint (cpu, ra);if (wp->flags &BP_STOP_BEFORE_ACCESS ) { cpu->exception_index =EXCP_DEBUG ;mmap_unlock ();
Signature · 1 line
2.17.1
Peter Maydell
AppliedQuoted 16 lines · Richard Henderson
This is v4 of my notdirty + rom patch set with two suggested name changes (
qemu_build_not_reached,TLB_DISCARD_WRITE) from David and Alex.r~
The following changes since commit
240ab11fb72049d6373cbbec8d788f8e411a00bc:Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190924' into staging (2019-09-24 15:36:31 +0100)
are available in the Git repository at:
https://github.com/rth7680/qemu.git tags/pull-tcg-20190925
Quoted 9 lines
for you to fetch changes up to
ae57db63acf5a0399232f852acc5c1d83ef63400:cputlb: Pass retaddr to
tb_check_watchpoint(2019-09-25 10:56:28 -0700)----------------------------------------------------------------
Fixes forTLB_BSWAP
Coversion of NOTDIRTY and ROM handling to cputlb
Followup cleanups to cputlb
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.
-- PMM