All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL for-5.1 0/3] tcg patch queue
@ 2020-07-17 18:16 Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 1/3] tcg: Save/restore vecop_list around minmax fallback Richard Henderson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Richard Henderson @ 2020-07-17 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

The following changes since commit 95d1fbabae0cd44156ac4b96d512d143ca7dfd5e:

  Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200716-pull-request' into staging (2020-07-16 18:50:51 +0100)

are available in the Git repository at:

  https://github.com/rth7680/qemu.git tags/pull-tcg-20200717

for you to fetch changes up to ba3c35d9c4026361fd380b269dc6def9510b7166:

  tcg/cpu-exec: precise single-stepping after an interrupt (2020-07-17 11:09:34 -0700)

----------------------------------------------------------------
Fix vector min/max fallback expansion
Fix singlestep from exception and interrupt

----------------------------------------------------------------
Luc Michel (1):
      tcg/cpu-exec: precise single-stepping after an exception

Richard Henderson (2):
      tcg: Save/restore vecop_list around minmax fallback
      tcg/cpu-exec: precise single-stepping after an interrupt

 accel/tcg/cpu-exec.c | 19 ++++++++++++++++++-
 tcg/tcg-op-vec.c     |  2 ++
 2 files changed, 20 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PULL for-5.1 1/3] tcg: Save/restore vecop_list around minmax fallback
  2020-07-17 18:16 [PULL for-5.1 0/3] tcg patch queue Richard Henderson
@ 2020-07-17 18:16 ` Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 2/3] tcg/cpu-exec: precise single-stepping after an exception Richard Henderson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-07-17 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

Forgetting this asserts when tcg_gen_cmp_vec is called from
within tcg_gen_cmpsel_vec.

Fixes: 72b4c792c7a
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg-op-vec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
index f784517d84..ed6fb55fe1 100644
--- a/tcg/tcg-op-vec.c
+++ b/tcg/tcg-op-vec.c
@@ -657,7 +657,9 @@ static void do_minmax(unsigned vece, TCGv_vec r, TCGv_vec a,
                       TCGv_vec b, TCGOpcode opc, TCGCond cond)
 {
     if (!do_op3(vece, r, a, b, opc)) {
+        const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
         tcg_gen_cmpsel_vec(cond, vece, r, a, b, a, b);
+        tcg_swap_vecop_list(hold_list);
     }
 }
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL for-5.1 2/3] tcg/cpu-exec: precise single-stepping after an exception
  2020-07-17 18:16 [PULL for-5.1 0/3] tcg patch queue Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 1/3] tcg: Save/restore vecop_list around minmax fallback Richard Henderson
@ 2020-07-17 18:16 ` Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt Richard Henderson
  2020-07-19 18:23 ` [PULL for-5.1 0/3] tcg patch queue Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-07-17 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Luc Michel

From: Luc Michel <luc.michel@greensocs.com>

When single-stepping with a debugger attached to QEMU, and when an
exception is raised, the debugger misses the first instruction after the
exception:

$ qemu-system-aarch64 -M virt -display none -cpu cortex-a53 -s -S

$ aarch64-linux-gnu-gdb
GNU gdb (GDB) 9.2
[...]
(gdb) tar rem :1234
Remote debugging using :1234
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x0000000000000000 in ?? ()
(gdb) # writing nop insns to 0x200 and 0x204
(gdb) set *0x200 = 0xd503201f
(gdb) set *0x204 = 0xd503201f
(gdb) # 0x0 address contains 0 which is an invalid opcode.
(gdb) # The CPU should raise an exception and jump to 0x200
(gdb) si
0x0000000000000204 in ?? ()

With this commit, the same run steps correctly on the first instruction
of the exception vector:

(gdb) si
0x0000000000000200 in ?? ()

Buglink: https://bugs.launchpad.net/qemu/+bug/757702
Signed-off-by: Luc Michel <luc.michel@greensocs.com>
Message-Id: <20200716193947.3058389-1-luc.michel@greensocs.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/cpu-exec.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index d95c4848a4..6a3d3a3cfc 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -504,6 +504,17 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
             cc->do_interrupt(cpu);
             qemu_mutex_unlock_iothread();
             cpu->exception_index = -1;
+
+            if (unlikely(cpu->singlestep_enabled)) {
+                /*
+                 * After processing the exception, ensure an EXCP_DEBUG is
+                 * raised when single-stepping so that GDB doesn't miss the
+                 * next instruction.
+                 */
+                *ret = EXCP_DEBUG;
+                cpu_handle_debug_exception(cpu);
+                return true;
+            }
         } else if (!replay_has_interrupt()) {
             /* give a chance to iothread in replay mode */
             *ret = EXCP_INTERRUPT;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt
  2020-07-17 18:16 [PULL for-5.1 0/3] tcg patch queue Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 1/3] tcg: Save/restore vecop_list around minmax fallback Richard Henderson
  2020-07-17 18:16 ` [PULL for-5.1 2/3] tcg/cpu-exec: precise single-stepping after an exception Richard Henderson
@ 2020-07-17 18:16 ` Richard Henderson
  2020-07-29  5:31   ` Pavel Dovgalyuk
  2020-07-19 18:23 ` [PULL for-5.1 0/3] tcg patch queue Peter Maydell
  3 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2020-07-17 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Luc Michel

When single-stepping with a debugger attached to QEMU, and when an
interrupt is raised, the debugger misses the first instruction after
the interrupt.

Tested-by: Luc Michel <luc.michel@greensocs.com>
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Buglink: https://bugs.launchpad.net/qemu/+bug/757702
Message-Id: <20200717163029.2737546-1-richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/cpu-exec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 6a3d3a3cfc..66d38f9d85 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -588,7 +588,13 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
         else {
             if (cc->cpu_exec_interrupt(cpu, interrupt_request)) {
                 replay_interrupt();
-                cpu->exception_index = -1;
+                /*
+                 * After processing the interrupt, ensure an EXCP_DEBUG is
+                 * raised when single-stepping so that GDB doesn't miss the
+                 * next instruction.
+                 */
+                cpu->exception_index =
+                    (cpu->singlestep_enabled ? EXCP_DEBUG : -1);
                 *last_tb = NULL;
             }
             /* The target hook may have updated the 'cpu->interrupt_request';
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PULL for-5.1 0/3] tcg patch queue
  2020-07-17 18:16 [PULL for-5.1 0/3] tcg patch queue Richard Henderson
                   ` (2 preceding siblings ...)
  2020-07-17 18:16 ` [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt Richard Henderson
@ 2020-07-19 18:23 ` Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2020-07-19 18:23 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Developers

On Fri, 17 Jul 2020 at 19:16, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> The following changes since commit 95d1fbabae0cd44156ac4b96d512d143ca7dfd5e:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200716-pull-request' into staging (2020-07-16 18:50:51 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/rth7680/qemu.git tags/pull-tcg-20200717
>
> for you to fetch changes up to ba3c35d9c4026361fd380b269dc6def9510b7166:
>
>   tcg/cpu-exec: precise single-stepping after an interrupt (2020-07-17 11:09:34 -0700)
>
> ----------------------------------------------------------------
> Fix vector min/max fallback expansion
> Fix singlestep from exception and interrupt

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt
  2020-07-17 18:16 ` [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt Richard Henderson
@ 2020-07-29  5:31   ` Pavel Dovgalyuk
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Dovgalyuk @ 2020-07-29  5:31 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: peter.maydell, Luc Michel

On 17.07.2020 21:16, Richard Henderson wrote:
> When single-stepping with a debugger attached to QEMU, and when an
> interrupt is raised, the debugger misses the first instruction after
> the interrupt.
> 
> Tested-by: Luc Michel <luc.michel@greensocs.com>
> Reviewed-by: Luc Michel <luc.michel@greensocs.com>
> Buglink: https://bugs.launchpad.net/qemu/+bug/757702
> Message-Id: <20200717163029.2737546-1-richard.henderson@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   accel/tcg/cpu-exec.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 6a3d3a3cfc..66d38f9d85 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -588,7 +588,13 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>           else {
>               if (cc->cpu_exec_interrupt(cpu, interrupt_request)) {
>                   replay_interrupt();
> -                cpu->exception_index = -1;
> +                /*
> +                 * After processing the interrupt, ensure an EXCP_DEBUG is
> +                 * raised when single-stepping so that GDB doesn't miss the
> +                 * next instruction.
> +                 */
> +                cpu->exception_index =
> +                    (cpu->singlestep_enabled ? EXCP_DEBUG : -1);
>                   *last_tb = NULL;

I just rebased my reverse debugging patches and noticed that this breaks 
the debugging in record/replay icount mode for i386.
At some points "si" in remote gdb does nothing.

This happens because of CPU_INTERRUPT_POLL. These are not real 
interrupts and converted into HW interrupt_request flags later.

Therefore we shouldn't stop when there is CPU_INTERRUPT_POLL request.

>               }
>               /* The target hook may have updated the 'cpu->interrupt_request';
> 


Pavel Dovgalyuk


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-29  5:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 18:16 [PULL for-5.1 0/3] tcg patch queue Richard Henderson
2020-07-17 18:16 ` [PULL for-5.1 1/3] tcg: Save/restore vecop_list around minmax fallback Richard Henderson
2020-07-17 18:16 ` [PULL for-5.1 2/3] tcg/cpu-exec: precise single-stepping after an exception Richard Henderson
2020-07-17 18:16 ` [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt Richard Henderson
2020-07-29  5:31   ` Pavel Dovgalyuk
2020-07-19 18:23 ` [PULL for-5.1 0/3] tcg patch queue Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.