All of lore.kernel.org
 help / color / mirror / Atom feed
* KVM: Book3S PR: unbreaking software breakpoints
@ 2019-05-11 14:08 Mark Cave-Ayland
  2019-05-13  6:01 ` Alexey Kardashevskiy
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Mark Cave-Ayland @ 2019-05-11 14:08 UTC (permalink / raw)
  To: kvm-ppc

Hi all,

Whilst trying to investigate some issues with MacOS under KVM PR I noticed that when
setting software breakpoints the KVM VCPU would stop as requested, but QEMU's gdbstub
would hang indefinitely.

I eventually traced it down to this code in QEMU's target/ppc/kvm.c:


static int kvm_handle_debug(PowerPCCPU *cpu, struct kvm_run *run)
{
    CPUState *cs = CPU(cpu);
    CPUPPCState *env = &cpu->env;
    struct kvm_debug_exit_arch *arch_info = &run->debug.arch;

    if (cs->singlestep_enabled) {
        return kvm_handle_singlestep();
    }

    if (arch_info->status) {
        return kvm_handle_hw_breakpoint(cs, arch_info);
    }

    if (kvm_find_sw_breakpoint(cs, arch_info->address)) {
        return kvm_handle_sw_breakpoint();
    }


The problem here is that with Book3S PR on my Mac hardware, run->debug.arch.status !0 which causes QEMU to think that this is a hardware breakpoint and so the software
breakpoint doesn't get handled correctly.

For comparison both booke.c and e500_emulate.c set debug.arch.status = 0 for software
breakpoints, whereas both book3s_hv.c and book3s_pr.c do not. Given that emulate.c
contains shared code for handling software breakpoints, would the following simple
patch suffice?


diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 9f5b8c01c4e1..e77becaad5dd 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -282,6 +282,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct
kvm_vcpu *vcpu)
                 */
                if (inst = KVMPPC_INST_SW_BREAKPOINT) {
                        run->exit_reason = KVM_EXIT_DEBUG;
+                       run->debug.arch.status = 0;
                        run->debug.arch.address = kvmppc_get_pc(vcpu);
                        emulated = EMULATE_EXIT_USER;
                        advance = 0;


ATB,

Mark.

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

end of thread, other threads:[~2019-05-13 19:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-11 14:08 KVM: Book3S PR: unbreaking software breakpoints Mark Cave-Ayland
2019-05-13  6:01 ` Alexey Kardashevskiy
2019-05-13  6:51 ` Mark Cave-Ayland
2019-05-13 18:14 ` Fabiano Rosas
2019-05-13 18:22 ` Fabiano Rosas
2019-05-13 19:15 ` Mark Cave-Ayland
2019-05-13 19:57 ` Mark Cave-Ayland

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.