From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbdKMJcc (ORCPT ); Mon, 13 Nov 2017 04:32:32 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44276 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbdKMJcb (ORCPT ); Mon, 13 Nov 2017 04:32:31 -0500 Subject: Re: [PATCH v2 1/3] kvm: arm debug: introduce helper for single-step To: =?UTF-8?Q?Alex_Benn=c3=a9e?= , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: Russell King , Catalin Marinas , Will Deacon , open list References: <20171109170021.2984-1-alex.bennee@linaro.org> <20171109170021.2984-2-alex.bennee@linaro.org> From: Julien Thierry Message-ID: <883136c1-1a22-6b19-e019-cd666ed53444@arm.com> Date: Mon, 13 Nov 2017 09:32:27 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171109170021.2984-2-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/17 17:00, Alex Bennée wrote: > After emulating instructions we may want return to user-space to > handle a single-step. If single-step is enabled the helper set the run > structure for return and returns true. > > Signed-off-by: Alex Bennée With the fixup: Reviewed-by: Julien Thierry > > --- > v2 > - kvm_arm_maybe_return_debug -> kvm_arm_handle_step_debug > - return bool, true if return to userspace is required > --- > arch/arm/include/asm/kvm_host.h | 2 ++ > arch/arm64/include/asm/kvm_host.h | 1 + > arch/arm64/kvm/debug.c | 22 ++++++++++++++++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index 4a879f6ff13b..a2e881d6108e 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -285,6 +285,8 @@ static inline void kvm_arm_init_debug(void) {} > static inline void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) {} > static inline void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) {} > static inline void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) {} > +static inline bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, > + struct kvm_run *run) {} > > int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu, > struct kvm_device_attr *attr); > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index e923b58606e2..bbfd6a2adb2b 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -369,6 +369,7 @@ void kvm_arm_init_debug(void); > void kvm_arm_setup_debug(struct kvm_vcpu *vcpu); > void kvm_arm_clear_debug(struct kvm_vcpu *vcpu); > void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu); > +bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, struct kvm_run *run); > int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu, > struct kvm_device_attr *attr); > int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu, > diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c > index dbadfaf850a7..95afd22a4634 100644 > --- a/arch/arm64/kvm/debug.c > +++ b/arch/arm64/kvm/debug.c > @@ -221,3 +221,25 @@ void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) > } > } > } > + > + > +/* > + * When KVM has successfully emulated the instruction we might want to > + * return to user space with a KVM_EXIT_DEBUG. We can only do this > + * once the emulation is complete though so for userspace emulations > + * we have to wait until we have re-entered KVM before calling this > + * helper. > + * > + * Return true (and set exit_reason) to return to userspace or false > + * if no further action required. > + */ > + > +bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, struct kvm_run *run) > +{ > + if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { > + run->exit_reason = KVM_EXIT_DEBUG; > + run->debug.arch.hsr = ESR_ELx_EC_SOFTSTP_LOW << ESR_ELx_EC_SHIFT; > + return true; > + } > + return false; > +} > -- Julien Thierry