From: Fabiano Rosas <farosas@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: david@gibson.dropbear.id.au
Subject: [Qemu-devel] [RFC PATCH 0/1] single step for KVM HV
Date: Mon, 19 Nov 2018 19:37:38 -0200 [thread overview]
Message-ID: <20181119213739.773-1-farosas@linux.ibm.com> (raw)
Single stepping via GDB/gdbstub is currently not working with KVM
HV. When asking for a single step (stepi), KVM simply ignores the
request and execution continues.
This has the direct effect of breaking GDB's 'step', 'stepi', 'next',
'nexti' commands. The 'continue' command is also affected since
continuing right after a breakpoint requires that GDB first perform a
single step so that the breakpoint can be re-inserted before
continuing - in this case the breakpoint is not re-inserted and it
won't hit again.
The issue here is that single stepping in POWER makes use of an
interrupt (Trace Interrupt [1]) that does not reach the hypervisor, so
while the single step would happen if properly triggered, it would not
cause an exit to KVM so there would be no way of handing control back
to GDB. Aside from that, the guest kernel is not prepared to deal with
such an interrupt in kernel mode (when not using KGDB, or some other
debugging facility) and it causes an Oops.
This series implements a "software single step" approach that makes
use of: i) the Trace Interrupt to perform the step inside the guest
and ii) a breakpoint at the Trace Interrupt handler address to cause a
vm exit (Emulation Assist) so that we can return control to QEMU.
With (i), we basically get the single step for free, without having to
discover what are the possible targets of instructions that divert
execution.
With (ii), we hide the single step from the guest and keep all of the
step logic in QEMU.
This was so far tested with single and multiple vcpus and with GDB
scheduler locking on and off [2].
I have not fully explored yet the potential issues when using
debuggers simultaneously inside and outside the guest, however I was
able to single step the ptrace code while single stepping a userspace
program inside the guest with GDB.
I'm looking for feedback on the general approach before I develop this
further.
1- PowerISA Section 6.5.15 - Trace Interrupt
2- https://sourceware.org/gdb/onlinedocs/gdb/All_002dStop-Mode.html
Fabiano Rosas (1):
target/ppc: support single stepping with KVM HV
accel/kvm/kvm-all.c | 10 +++++++
exec.c | 1 +
include/sysemu/kvm.h | 4 +++
target/arm/kvm.c | 4 +++
target/i386/kvm.c | 4 +++
target/ppc/kvm.c | 65 +++++++++++++++++++++++++++++++++++++++++++-
target/s390x/kvm.c | 4 +++
7 files changed, 91 insertions(+), 1 deletion(-)
--
2.17.1
next reply other threads:[~2018-11-19 21:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 21:37 Fabiano Rosas [this message]
2018-11-19 21:37 ` [Qemu-devel] [RFC PATCH 1/1] target/ppc: support single stepping with KVM HV Fabiano Rosas
2018-11-20 12:40 ` Philippe Mathieu-Daudé
2018-11-20 14:08 ` Philippe Mathieu-Daudé
2019-01-16 4:55 ` Alexey Kardashevskiy
2019-01-16 11:07 ` Fabiano Rosas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181119213739.773-1-farosas@linux.ibm.com \
--to=farosas@linux.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).