KVM: PPC: Inform userspace about singlestep support
Subsystems (3)
cover KVM: PPC: Inform userspace about singlestep support
I am looking for a way to inform userspace about the lack of an implementation in KVM HV for single stepping of instructions (KVM_GUESTDGB_SINGLESTEP bit from SET_GUEST_DEBUG ioctl).
This will be used by QEMU to decide whether to attempt a call to the set_guest_debug ioctl (for BookE, KVM PR) or fallback to a QEMU only implementation (for KVM HV).
QEMU thread:
http://patchwork.ozlabs.org/cover/1049811/
My current proposal is to introduce a ppc-specific capability for this. However I'm not sure if this would be better as a cap common for all architectures or even if it should report on all of the possible set_guest_debug flags to cover for the future.
Please comment. Thanks.
Fabiano Rosas (1):
KVM: PPC: Report single stepping capability
arch/powerpc/kvm/powerpc.c | 5 +++++ include/uapi/linux/kvm.h | 1 + 2 files changed, 6 insertions(+)
--
2.20.1
RFC PATCH 1/1 KVM: PPC: Report single stepping capability
When calling the KVM_SET_GUEST_DEBUG ioctl, userspace might request the next instruction to be single stepped via the KVM_GUESTDBG_SINGLESTEP control bit of the kvm_guest_debug structure.
We currently don't have support for guest single stepping implemented in Book3S HV.
This patch adds the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability in order to inform userspace about the state of single stepping support.
--- arch/powerpc/kvm/powerpc.c | 5 +++++ include/uapi/linux/kvm.h | 1 + 2 files changed, 6 insertions(+)
arch/powerpc/kvm/powerpc.c +5 -0
@@ -538,6 +538,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_IMMEDIATE_EXIT : r =1 ;break ; +case KVM_CAP_PPC_GUEST_DEBUG_SSTEP : +#ifdef CONFIG_BOOKE + r =1 ; +break ; +#endif case KVM_CAP_PPC_PAIRED_SINGLES :case KVM_CAP_PPC_OSI :case KVM_CAP_PPC_GET_PVINFO :
include/uapi/linux/kvm.h +1 -0
@@ -988,6 +988,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_ARM_VM_IPA_SIZE 165#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166#define KVM_CAP_HYPERV_CPUID 167 +#define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 168#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
2.20.1
Re: [RFC PATCH 1/1] KVM: PPC: Report single stepping capability
Quoted 21 lines · Fabiano Rosas
When calling the
KVM_SET_GUEST_DEBUGioctl, userspace might request the next instruction to be single stepped via theKVM_GUESTDBG_SINGLESTEPcontrol bit of thekvm_guest_debugstructure.We currently don't have support for guest single stepping implemented in Book3S HV.
This patch adds the
KVM_CAP_PPC_GUEST_DEBUG_SSTEPcapability in order to inform userspace about the state of single stepping support.Signed-off-by Fabiano Rosas <[email protected]>--- arch/powerpc/kvm/powerpc.c | 5 +++++ include/uapi/linux/kvm.h | 1 + 2 files changed, 6 insertions(+)arch/powerpc/kvm/powerpc.c +0
-0
arch/powerpc/kvm/powerpc.c int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · line 542
Quoted 5 lines
arch/powerpc/kvm/powerpc.c +2
-0@@ -538,6 +538,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_IMMEDIATE_EXIT : r =1 ;break ; +case KVM_CAP_PPC_GUEST_DEBUG_SSTEP : +#ifdef CONFIG_BOOKE
In the cover letter (which is not really required for a single patch) you say the capability will be present for BookE and PR KVM (which Book3s) but here it is BookE only, is that intentional?
Also, you need to update Documentation/virtual/kvm/api.txt for the new capability. After reading which I started wondering could not we just use existing KVM_CAP_GUEST_DEBUG_HW_BPS?
Quoted 19 lines
arch/powerpc/kvm/powerpc.c +3
-0+ r =1 ; +break ; +#endif case KVM_CAP_PPC_PAIRED_SINGLES :case KVM_CAP_PPC_OSI :case KVM_CAP_PPC_GET_PVINFO :include/uapi/linux/kvm.h +1
-0@@ -988,6 +988,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_ARM_VM_IPA_SIZE 165#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166#define KVM_CAP_HYPERV_CPUID 167 +#define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 168#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
Alexey
Re: [RFC PATCH 1/1] KVM: PPC: Report single stepping capability
Quoted 3 lines · Alexey Kardashevskiy
In the cover letter (which is not really required for a single patch) you say the capability will be present for BookE and PR KVM (which Book3s) but here it is BookE only, is that intentional?
A few lines below (falling through) we have:
/* We support this only for PR */
r = !hv_enabled;Quoted 3 lines
Also, you need to update
Documentation/virtual/kvm/api.txtfor the new capability. After reading which I started wondering could not we just use existingKVM_CAP_GUEST_DEBUG_HW_BPS?
We _could_, but I think that would conflate two different concepts. Single stepping does not necessarily makes use of hardware breakpoints (e.g. Trace Interrupt on Book3s PR).
I also think we should use KVM_CAP_GUEST_DEBUG_HW_BPS in the future to let QEMU know about: i) the lack of hardware breakpoints in Book3s and ii) BookE's hardware breakpoints (Instruction Address Compare) that are currently not being reported via HW_BPS.
Re: [RFC PATCH 1/1] KVM: PPC: Report single stepping capability
In reply to Fabiano RosasQuoted 7 lines · Fabiano Rosas
When calling the
KVM_SET_GUEST_DEBUGioctl, userspace might request the next instruction to be single stepped via theKVM_GUESTDBG_SINGLESTEPcontrol bit of thekvm_guest_debugstructure.We currently don't have support for guest single stepping implemented in Book3S HV.
Quoted 8 lines
This patch adds the
KVM_CAP_PPC_GUEST_DEBUG_SSTEPcapability in order to inform userspace about the state of single stepping support.Signed-off-by Fabiano Rosas <[email protected]>--- arch/powerpc/kvm/powerpc.c | 5 +++++ include/uapi/linux/kvm.h | 1 + 2 files changed, 6 insertions(+)
I assume since this is [RFC] that you're not expecting it to go upstream as-is. If it were to go upstream it would need to include an update to Documentation/virtual/kvm/api.txt.
Paul.