[PATCH 3/4] softmmu: fix for "after access" watchpoints

Pavel Dovgalyuk posted 4 patches 4 years, 3 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>
There is a newer version of this series
[PATCH 3/4] softmmu: fix for "after access" watchpoints
Posted by Pavel Dovgalyuk 4 years, 3 months ago
Watchpoints that should fire after the memory access
break an execution of the current block, try to
translate current instruction into the separate block,
which then causes debug interrupt.
But cpu_interrupt can't be called in such block when
icount is enabled, because interrupts muse be allowed
explicitly.
This patch sets CF_LAST_IO flag for retranslated block,
allowing interrupt request for the last instruction.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
---
 softmmu/physmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 94eda44459..482d80708f 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -946,7 +946,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
                 cpu_loop_exit(cpu);
             } else {
                 /* Force execution of one insn next time.  */
-                cpu->cflags_next_tb = 1 | curr_cflags(cpu);
+                cpu->cflags_next_tb = 1 | CF_LAST_IO | curr_cflags(cpu);
                 mmap_unlock();
                 cpu_loop_exit_noexc(cpu);
             }


Re: [PATCH 3/4] softmmu: fix for "after access" watchpoints
Posted by Richard Henderson 4 years, 3 months ago
On 10/28/21 4:48 AM, Pavel Dovgalyuk wrote:
> Watchpoints that should fire after the memory access
> break an execution of the current block, try to
> translate current instruction into the separate block,
> which then causes debug interrupt.
> But cpu_interrupt can't be called in such block when
> icount is enabled, because interrupts muse be allowed
> explicitly.
> This patch sets CF_LAST_IO flag for retranslated block,
> allowing interrupt request for the last instruction.
> 
> Signed-off-by: Pavel Dovgalyuk<Pavel.Dovgalyuk@ispras.ru>
> ---
>   softmmu/physmem.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Indeed, the other such assignment, about 30 lines up, already does this.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~