From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Exposing host debug capabilities to userspace Date: Tue, 25 Nov 2014 17:21:53 +0100 Message-ID: <5474ACA1.20908@redhat.com> References: <87mw7l3j7x.fsf@linaro.org> <87egssn91o.fsf@zen.linaro.local.i-did-not-set--mail-host-address--so-tickle-me> <87d28cn84s.fsf@linaro.org> <87a93gn1go.fsf@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvmarm@lists.cs.columbia.edu, KVM devel mailing list To: =?UTF-8?B?QWxleCBCZW5uw6ll?= , Will Deacon , Marc Zyngier , Christoffer Dall , Peter Maydell , Alexander Graf Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751045AbaKYQWL (ORCPT ); Tue, 25 Nov 2014 11:22:11 -0500 In-Reply-To: <87a93gn1go.fsf@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: On 24/11/2014 14:59, Alex Benn=C3=A9e wrote: > Alexander Graf pointed out that KVM_CHECK_EXTENSION can return any > positive number for success. How about using: >=20 > max_hw_bps =3D kvm_check_extension(kvm_state, KVM_CAP_GUEST_DEBUG_HW_= BPS); > max_hw_wps =3D kvm_check_extension(kvm_state, KVM_CAP_GUEST_DEBUG_HW_= WPS); >=20 > Seems pretty sane, doesn't change the semantics of an API and is > architecture agnostic if others need the number? Yes, this was going to be my suggestion as well. Just I would use a bitmask in case some register can act as both breakpoint and watchpoint= =2E On x86, each of the four bp/wp registers (each register can act as both= ) can be used for either guest or gdbstub debugging. If the KVM_GUESTDBG_USE_HW_BP feature is enabled, the guest is entered with "made up" debug register contents, that we pass via KVM_SET_GUEST_DEBUG's struct kvm_guest_debug_arch. Otherwise, the gues= t is entered with real debug register contents passed via KVM_SET_DEBUGREGS. Reads/writes of the debug registers trap to KVM (which helps the guest see the expected values of the debug registers i= n the former case). There is no KVM_GET_GUEST_DEBUG because the corresponding info is passed via struct kvm_debug_exit_arch. If gdbstub hardware breakpoints are enabled, all hardware breakpoints exit to userspace. QEMU then decides whether the breakpoint came from guest debugging (and then injects an exception), or from gdbstub debugging (and then suspends execution). Same for software breakpoints= =2E If the total request is >4 hardware breakpoints, someone will have to lose and some gdbstub breakpoints will be missed. Paolo