From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BB9CC433EF for ; Wed, 8 Jun 2022 16:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RqI+Y3QWYIGQJwDskUjXEGCwiC1VOPPyHNQsI1898n8=; b=kq6PecR5+0ay8w ZCrhUJCywMnrxHtQGCyYwbnZk/v9EX7QoxWhmrOV90cHFCxIAvhSWz/R8Xim8VkpmibOrzwUoNRLA s70qSn/lvQkVrgdAMcoHh8UGnfKms0QnfDroPO17xGLRWmjMzGDaJuzdJG0KpgPx5EyHlMh4EiB93 FJruh7bo0yDmst7k0NA3sdXdb8RxQ+U5Md3Bd4EDq1t4FskElcXTwcUEVaxIkZUvgdjUeDjCTcoqo KsnAMuWgDAl0qi4L85wyKTYV9rIVfEJIZjCX3CR3iKFL9rxwPWt+FEAOnVnyr0duBd35BZ4J3+3n1 +G4XKSZo9E7fKqutXMQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyy7n-00EByt-7q; Wed, 08 Jun 2022 16:01:39 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyy7j-00EByJ-AN for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 16:01:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A04B5B8287F; Wed, 8 Jun 2022 16:01:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45F22C34116; Wed, 8 Jun 2022 16:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654704092; bh=ImV1qtmSlQSEWCbDAMmIBcY4fkJG7qnGOynjwaFo1GM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EyU2mZRxvm8doByGzp2z1CIA4zm3K7h1+om9FglRi/wdbVxCrcH3lwfTeGncm7NNR JqYxdOqaLOlliZXoCIfYzS3MbKk11XeLYnsTkwStmKfbYdFn2HC5RQe0YEwQK0PV1P gzmvqJQmtJ3+NHtXmU977kHN1OyhGmKNAqUXEiGQw29ZCVjOOzT7pOCpkSG8yTLv0q B4y//jz9aAOsEfCZogoXn0k8eCWsiwubzMNkIZ+75DoPwDfQtahKWJjgUeGudnm+o9 KiubcdkoYhZqGtCyzZT8ZM/jksOAIKzAfjpZ9rDfOB2b250BwlTz+leDLI+rALj1kG 2FZM/SPdLpHVA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyy7d-00GelU-PE; Wed, 08 Jun 2022 17:01:29 +0100 Date: Wed, 08 Jun 2022 17:01:29 +0100 Message-ID: <87ilpb4012.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Oliver Upton , Will Deacon , Quentin Perret , Mark Brown , kernel-team@android.com Subject: Re: [PATCH 09/18] KVM: arm64: Move vcpu debug/SPE/TRBE flags to the input flag set In-Reply-To: References: <20220528113829.1043361-1-maz@kernel.org> <20220528113829.1043361-10-maz@kernel.org> 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/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oupton@google.com, will@kernel.org, qperret@google.com, broonie@kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_090135_703765_773514CD X-CRM114-Status: GOOD ( 36.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 08 Jun 2022 16:16:16 +0100, Fuad Tabba wrote: > > Hi Marc, > > On Sat, May 28, 2022 at 12:38 PM Marc Zyngier wrote: > > > > The three debug flags (which deal with the debug registers, SPE and > > TRBE) all are input flags to the hypervisor code. > > > > Move them into the input set and convert them to the new accessors. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_host.h | 9 ++++++--- > > arch/arm64/kvm/debug.c | 22 +++++++++++----------- > > arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 6 +++--- > > arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 4 ++-- > > arch/arm64/kvm/hyp/nvhe/debug-sr.c | 8 ++++---- > > arch/arm64/kvm/sys_regs.c | 8 ++++---- > > 6 files changed, 30 insertions(+), 27 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index 078567f5709c..a426cd3aaa74 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -500,6 +500,12 @@ struct kvm_vcpu_arch { > > #define EXCEPT_AA64_EL2_IRQ __vcpu_except_flags(5) > > #define EXCEPT_AA64_EL2_FIQ __vcpu_except_flags(6) > > #define EXCEPT_AA64_EL2_SERR __vcpu_except_flags(7) > > +/* Guest debug is live */ > > +#define DEBUG_DIRTY __vcpu_single_flag(iflags, BIT(4)) > > +/* Save SPE context if active */ > > +#define DEBUG_STATE_SAVE_SPE __vcpu_single_flag(iflags, BIT(5)) > > +/* Save TRBE context if active */ > > +#define DEBUG_STATE_SAVE_TRBE __vcpu_single_flag(iflags, BIT(6)) > > > > /* Pointer to the vcpu's SVE FFR for sve_{save,load}_state() */ > > #define vcpu_sve_pffr(vcpu) (kern_hyp_va((vcpu)->arch.sve_state) + \ > > @@ -522,10 +528,7 @@ struct kvm_vcpu_arch { > > }) > > > > /* vcpu_arch flags field values: */ > > -#define KVM_ARM64_DEBUG_DIRTY (1 << 0) > > #define KVM_ARM64_HOST_SVE_ENABLED (1 << 4) /* SVE enabled for EL0 */ > > -#define KVM_ARM64_DEBUG_STATE_SAVE_SPE (1 << 12) /* Save SPE context if active */ > > -#define KVM_ARM64_DEBUG_STATE_SAVE_TRBE (1 << 13) /* Save TRBE context if active */ > > #define KVM_ARM64_ON_UNSUPPORTED_CPU (1 << 15) /* Physical CPU not in supported_cpus */ > > #define KVM_ARM64_HOST_SME_ENABLED (1 << 16) /* SME enabled for EL0 */ > > #define KVM_ARM64_WFIT (1 << 17) /* WFIT instruction trapped */ > > diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c > > index 4fd5c216c4bb..c5c4c1837bf3 100644 > > --- a/arch/arm64/kvm/debug.c > > +++ b/arch/arm64/kvm/debug.c > > @@ -104,11 +104,11 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu) > > * Trap debug register access when one of the following is true: > > * - Userspace is using the hardware to debug the guest > > * (KVM_GUESTDBG_USE_HW is set). > > - * - The guest is not using debug (KVM_ARM64_DEBUG_DIRTY is clear). > > + * - The guest is not using debug (DEBUG_DIRTY clear). > > * - The guest has enabled the OS Lock (debug exceptions are blocked). > > */ > > if ((vcpu->guest_debug & KVM_GUESTDBG_USE_HW) || > > - !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY) || > > + !vcpu_get_flag(vcpu, DEBUG_DIRTY) || > > kvm_vcpu_os_lock_enabled(vcpu)) > > vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; > > > > @@ -147,8 +147,8 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) > > * debug related registers. > > * > > * Additionally, KVM only traps guest accesses to the debug registers if > > - * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY > > - * flag on vcpu->arch.flags). Since the guest must not interfere > > + * the guest is not actively using them (see the DEBUG_DIRTY > > + * flag on vcpu->arch.iflags). Since the guest must not interfere > > * with the hardware state when debugging the guest, we must ensure that > > * trapping is enabled whenever we are debugging the guest using the > > * debug registers. > > @@ -205,7 +205,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) > > * > > * We simply switch the debug_ptr to point to our new > > * external_debug_state which has been populated by the > > - * debug ioctl. The existing KVM_ARM64_DEBUG_DIRTY > > + * debug ioctl. The existing KVM_ARM64_IFLAG_DEBUG_DIRTY > > This should be DEBUG_DIRTY. Ah, nice catch. That's a left-over from a previous implementation that didn't have the notion of flag-set built-in. There is also another one of these in kvm_host.h, which I will fix as well. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel