From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C1E4433BB for ; Sat, 9 Nov 2024 11:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731152828; cv=none; b=og9rOVXmCcXQ7g7Bi42qKy3ONrDkkE4Wvje5UtOs0MU7G/OeSx7CGeG9FTzOTpfm5ydkJduGcXRHTwuZDgm0z58HP1nbkezlC74FN/Ks43rU3MtVTVLc6cvZM+c2w3c0HZw+JufqxwI/FpEYhKuSbK8hB8mSc9SCaqT3j4tqef4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731152828; c=relaxed/simple; bh=mWpL6bTacBg5qEwCm7HNC2ORnav7P1sXXoUaF9ur11g=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=gUZ0GTvLiiIHQyuYAcW9z9VwMDRTTENAnzdayS06fiY8oNNO+cDC8zk4qUDVgoKVg/SCB+JOj2Dy3UB6ULtqtYHjUkWD1DdyMp67YP7fQpYJBt6/O1iPcxVAo/+cjRySqcwgA8fPQcsqVBjQpWteY0RBv/xMB5JAd9BgbIKhWIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QHwrjnq3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QHwrjnq3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5FD0C4CECE; Sat, 9 Nov 2024 11:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731152827; bh=mWpL6bTacBg5qEwCm7HNC2ORnav7P1sXXoUaF9ur11g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QHwrjnq3g0B1rq5gIqSEHUHz+j19JKdkgV0RcdvWLTAt954PbvU1dUjG1c8WVdQ9U pOsEubRnlEf6IAoxEM3X1mzdybr/othQ1bmpe/0OeFxM92RdPokcbj715PoPMoc6mY VHh268xMpN3n6ykyFG4w47X2KLcgJ4zqqDTBoPAjlbFlBroHCEBragQsGcHXpKgnyM JTvwhbiOmCJvrQsFmBlb47sGRkF3kkgf4L1p0My0o3eqHHa4sN4BYxhtr/lte6Qdo2 BpkVeGijBnDOX3BZOLxoMOwGj5ivFV72zLF0Y9a9hKoM0cEsU+1E5ofUv6EBPZYY4/ yjw4n+x0LZQ6w== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t9jvl-00BPOI-NU; Sat, 09 Nov 2024 11:47:05 +0000 Date: Sat, 09 Nov 2024 11:47:04 +0000 Message-ID: <8634k01vev.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, Joey Gouly , Suzuki K Poulose , Zenghui Yu , Mingwei Zhang , Colton Lewis , Alexandru Elisei Subject: Re: [PATCH 06/15] KVM: arm64: Advance debug_owner state machine for sysreg traps In-Reply-To: <20241108222418.1677420-7-oliver.upton@linux.dev> References: <20241108222418.1677420-1-oliver.upton@linux.dev> <20241108222418.1677420-7-oliver.upton@linux.dev> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, mizhang@google.com, coltonlewis@google.com, alexandru.elisei@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 08 Nov 2024 22:24:10 +0000, Oliver Upton wrote: > > Preserve lazy restore of the breakpoint/watchpoint registers by updating > the debug owner after the first trap, assuming the host isn't using > them. > > Signed-off-by: Oliver Upton > --- > arch/arm64/include/asm/kvm_host.h | 1 + > arch/arm64/kvm/debug.c | 9 +++++++++ > arch/arm64/kvm/sys_regs.c | 2 ++ > 3 files changed, 12 insertions(+) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index f954b082dc4f..d76e4e44b65b 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1352,6 +1352,7 @@ 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); > void kvm_vcpu_load_debug(struct kvm_vcpu *vcpu); > +void kvm_handle_debug_access(struct kvm_vcpu *vcpu); > > #define kvm_vcpu_os_lock_enabled(vcpu) \ > (!!(__vcpu_sys_reg(vcpu, OSLSR_EL1) & OSLSR_EL1_OSLK)) > diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c > index e2798a4eec47..c2bf1b296b14 100644 > --- a/arch/arm64/kvm/debug.c > +++ b/arch/arm64/kvm/debug.c > @@ -336,3 +336,12 @@ void kvm_vcpu_load_debug(struct kvm_vcpu *vcpu) > vcpu->arch.debug_owner = VCPU_DEBUG_FREE; > } > } > + > +void kvm_handle_debug_access(struct kvm_vcpu *vcpu) > +{ > + if (kvm_host_owns_debug_regs(vcpu)) > + return; > + > + WARN_ON_ONCE(vcpu->arch.debug_owner == VCPU_DEBUG_GUEST_OWNED); > + vcpu->arch.debug_owner = VCPU_DEBUG_GUEST_OWNED; > +} I think it would make more sense to merge this patch with the previous one, so that we get a better idea of the ownership flow before getting in the meat of the debug surgery. Another thing is that kvm_handle_debug_access() is very generic and doesn't quite says what this does. How about something such as kvm_debug_set_guest_ownership(), or any variation on the same theme? Thanks, M. -- Without deviation from the norm, progress is not possible.