cpu: move adjust_watchpoint_address to tcg_ops

commit 40612000599e ("arm: Correctly handle watchpoints for BE32 CPUs")

introduced this ARM-specific, TCG-specific hack to adjust the address,
before checking it with cpu_check_watchpoint.

Make adjust_watchpoint_address optional and move it to tcg_ops.

Backports 9ea9087bb4a86893e4ac6ff643837937dc9e5849
This commit is contained in:
Claudio Fontana 2021-03-04 17:24:30 -05:00 committed by Lioncash
parent ddfed5f3a6
commit 7b0c98c236
4 changed files with 7 additions and 5 deletions

View file

@ -869,7 +869,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
return; return;
} }
addr = cc->adjust_watchpoint_address(cpu, addr, len); addr = cc->tcg_ops.adjust_watchpoint_address(cpu, addr, len);
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
if (watchpoint_address_matches(wp, addr, len) if (watchpoint_address_matches(wp, addr, len)
&& (wp->flags & flags)) { && (wp->flags & flags)) {

View file

@ -135,6 +135,10 @@ typedef struct TcgCpuOperations {
void (*do_unaligned_access)(CPUState *cpu, vaddr addr, void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
MMUAccessType access_type, MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr); int mmu_idx, uintptr_t retaddr);
/**
* @adjust_watchpoint_address: hack for cpu_check_watchpoint used by ARM
*/
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
} TcgCpuOperations; } TcgCpuOperations;
@ -208,8 +212,6 @@ typedef struct CPUClass {
const struct VMStateDescription *vmsd; const struct VMStateDescription *vmsd;
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
/* Keep non-pointer data at the end to minimize holes. */ /* Keep non-pointer data at the end to minimize holes. */
TcgCpuOperations tcg_ops; TcgCpuOperations tcg_ops;
bool tcg_initialized; bool tcg_initialized;

View file

@ -295,10 +295,10 @@ static void cpu_class_init(struct uc_struct *uc, ObjectClass *klass, void *data)
k->get_memory_mapping = cpu_common_get_memory_mapping; k->get_memory_mapping = cpu_common_get_memory_mapping;
k->tcg_ops.debug_excp_handler = cpu_common_noop; k->tcg_ops.debug_excp_handler = cpu_common_noop;
k->debug_check_watchpoint = cpu_common_debug_check_watchpoint; k->debug_check_watchpoint = cpu_common_debug_check_watchpoint;
k->tcg_ops.adjust_watchpoint_address = cpu_adjust_watchpoint_address;
k->tcg_ops.cpu_exec_enter = cpu_common_noop; k->tcg_ops.cpu_exec_enter = cpu_common_noop;
k->tcg_ops.cpu_exec_exit = cpu_common_noop; k->tcg_ops.cpu_exec_exit = cpu_common_noop;
k->tcg_ops.cpu_exec_interrupt = cpu_common_exec_interrupt; k->tcg_ops.cpu_exec_interrupt = cpu_common_exec_interrupt;
k->adjust_watchpoint_address = cpu_adjust_watchpoint_address;
dc->realize = cpu_common_realizefn; dc->realize = cpu_common_realizefn;
/* /*
* Reason: CPUs still need special care by board code: wiring up * Reason: CPUs still need special care by board code: wiring up

View file

@ -2116,7 +2116,7 @@ static void arm_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
cc->tcg_ops.do_transaction_failed = arm_cpu_do_transaction_failed; cc->tcg_ops.do_transaction_failed = arm_cpu_do_transaction_failed;
cc->tcg_ops.do_unaligned_access = arm_cpu_do_unaligned_access; cc->tcg_ops.do_unaligned_access = arm_cpu_do_unaligned_access;
cc->adjust_watchpoint_address = arm_adjust_watchpoint_address; cc->tcg_ops.adjust_watchpoint_address = arm_adjust_watchpoint_address;
cc->tcg_ops.do_interrupt = arm_cpu_do_interrupt; cc->tcg_ops.do_interrupt = arm_cpu_do_interrupt;
#endif #endif
#endif /* CONFIG_TCG */ #endif /* CONFIG_TCG */