[PATCH v3 0/3] Add gdbstub support to HVF

francesco.cagnin@gmail.com posted 3 patches 1 year, 3 months ago
There is a newer version of this series
accel/hvf/hvf-accel-ops.c | 123 ++++++++
accel/hvf/hvf-all.c       |  24 ++
cpu.c                     |   3 +
include/sysemu/hvf.h      |  29 ++
include/sysemu/hvf_int.h  |   1 +
target/arm/hvf/hvf.c      | 635 +++++++++++++++++++++++++++++++++++++-
target/arm/hyp_gdbstub.c  | 242 +++++++++++++++
target/arm/internals.h    |  50 +++
target/arm/kvm64.c        | 276 -----------------
target/arm/meson.build    |   3 +-
10 files changed, 1107 insertions(+), 279 deletions(-)
create mode 100644 target/arm/hyp_gdbstub.c
[PATCH v3 0/3] Add gdbstub support to HVF
Posted by francesco.cagnin@gmail.com 1 year, 3 months ago
From: Francesco Cagnin <fcagnin@quarkslab.com>

This patch series aims to add gdbstub support to HVF (the 'QEMU
accelerator on macOS that employs Hypervisor.framework') on Apple
Silicon hosts.

The proposed implementation, structured like the KVM counterpart,
handles single-stepping, software breakpoints, hardware breakpoints and
hardware watchpoints.

The patch has been most recently tested working on macOS Ventura 13.1
hosts and Linux kernel 5.19 guests with the test script
'tests/guest-debug/test-gdbstub.py' (slightly updated to make it work
with Linux kernels compiled on macOS).

v3:
* Keep separate views of DBG*_EL1 registers while guest debugging is
  enabled  
  NOTE: Should be implemented as Peter and Alex suggested, and works as
  intended in my (limited) tests. Any other register to handle beside
  DBG*_EL1?
* Handle singlestepping over instructions triggering a VM exit
  NOTE: I'm not aware of unwanted side effects, please double-check the
  fix is adequate.
* Merge patches 2 and 3 from previous patch series

v2:
* Move debug helpers to 'target/arm/hyp_gdbstub.c'
* Add support for SSTEP_NOIRQ and multi-core (thanks Mads Ynddal)
* Move calls to 'hv_vcpu_set_trap_debug_exceptions()' to
  'hvf_arch_update_guest_debug()'
* Use 'arm_num_brps()' and 'arm_num_wrps()' to compute the number of
  breakpoints and watchpoints available (thanks Peter Maydell)

Francesco Cagnin (3):
  arm: move KVM breakpoints helpers
  hvf: implement guest debugging on Apple Silicon hosts
  hvf: handle singlestepping over instructions which trigger a VM exit

 accel/hvf/hvf-accel-ops.c | 123 ++++++++
 accel/hvf/hvf-all.c       |  24 ++
 cpu.c                     |   3 +
 include/sysemu/hvf.h      |  29 ++
 include/sysemu/hvf_int.h  |   1 +
 target/arm/hvf/hvf.c      | 635 +++++++++++++++++++++++++++++++++++++-
 target/arm/hyp_gdbstub.c  | 242 +++++++++++++++
 target/arm/internals.h    |  50 +++
 target/arm/kvm64.c        | 276 -----------------
 target/arm/meson.build    |   3 +-
 10 files changed, 1107 insertions(+), 279 deletions(-)
 create mode 100644 target/arm/hyp_gdbstub.c

-- 
2.39.0
Re: [PATCH v3 0/3] Add gdbstub support to HVF
Posted by Philippe Mathieu-Daudé 1 year, 2 months ago
Hi Francesco,

On 14/1/23 17:12, francesco.cagnin@gmail.com wrote:
> From: Francesco Cagnin <fcagnin@quarkslab.com>
> 
> This patch series aims to add gdbstub support to HVF (the 'QEMU
> accelerator on macOS that employs Hypervisor.framework') on Apple
> Silicon hosts.

> The patch has been most recently tested working on macOS Ventura 13.1
> hosts and Linux kernel 5.19 guests with the test script
> 'tests/guest-debug/test-gdbstub.py' (slightly updated to make it work
> with Linux kernels compiled on macOS).

Could you share the test-gdbstub.py changes?

Thanks,

Phil.
Re: [PATCH v3 0/3] Add gdbstub support to HVF
Posted by Francesco Cagnin 1 year, 2 months ago
Hi Phil,

> Could you share the test-gdbstub.py changes?

I've just opened an issue on Gitlab:
https://gitlab.com/qemu-project/qemu/-/issues/1489

Thanks,
Francesco