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 1E7A7AD58 for ; Fri, 24 Feb 2023 19:03:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BECAEC433EF; Fri, 24 Feb 2023 19:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677265403; bh=gCXvVswG+5BJ4eLw8cXXd2lIKc6j1StQlEVV4zpsmGY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bteC247cuY8lqVHIP5fSW8WbA80ZJaeeA0QA2eU9K5g7K0UGRNPpDn+xnVoGV6GJa ERbEYw/u4vNPBQmhE39jH7ueEuWpRRpev1dV4dbjpl6rB+9z1LlPX6bPaOcT0v/OU/ 6fZ+Ddop7SjirvXVRd/fpkt2Gg3Mnr3za2u1G79Xd7MAcxocwgdDTOR0tnKV3/LQlJ 0bnazS3Hx6QMeIvXPuZq+cktOM4xr99F9YWhwbgjI9X+Dz9+GQ0fuPqX5JlQsmU7c8 4B1pJPQ19oRaX1ei938Qiz4o5nwBwnKFSwSC0mCH4t2hiz7ktHjc3Z5gXiWmI+s0CM XqH21f28/LMTQ== 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 1pVdLl-00Czbp-BB; Fri, 24 Feb 2023 19:03:21 +0000 Date: Fri, 24 Feb 2023 19:03:21 +0000 Message-ID: <86v8jqx4w6.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Joey Gouly , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexandru Elisei , Andre Przywara , Catalin Marinas , Christoffer Dall , Ganapatrao Kulkarni , Russell King , James Morse , Suzuki K Poulose , Zenghui Yu , nd@arm.com Subject: Re: [PATCH 08/18] KVM: arm64: nv: Handle HCR_EL2.NV system register traps In-Reply-To: References: <20230209175820.1939006-1-maz@kernel.org> <20230209175820.1939006-9-maz@kernel.org> <20230224173915.GA17407@e124191.cambridge.arm.com> 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/28.2 (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, joey.gouly@arm.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com, andre.przywara@arm.com, catalin.marinas@arm.com, christoffer.dall@arm.com, gankulkarni@os.amperecomputing.com, rmk+kernel@armlinux.org.uk, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, nd@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, 24 Feb 2023 18:36:23 +0000, Oliver Upton wrote: > > Hi Joey, > > On Fri, Feb 24, 2023 at 05:39:15PM +0000, Joey Gouly wrote: > > I'm having an issue with this commit where a VCPU is getting a CNTVOFF_EL2 set > > to 0, so it sees the same time as the host system, and the other VCPU has the > > correct offset. > > Yikes! > > > The flow of execution looks like this: > > KVM_CREATE_VCPU 0 (VMM) -> > > kvm_timer_vcpu_init -> > > update_vtimer_cntvoff (VCPU0.CNTVOFF_EL2=kvm_phys_timer_read) > > KVM_ARM_VCPU_INIT (VMM) -> > > kvm_arch_vcpu_ioctl_vcpu_init -> > > kvm_vcpu_set_target -> > > kvm_reset_vcpu -> > > kvm_reset_sys_regs (VCPU0.CNTVOFF_EL2=0) > > > > KVM_CREATE_VCPU 1 (VMM) -> > > kvm_timer_vcpu_init -> > > update_vtimer_cntvoff (VCPU0.CNTVOFF_EL2=VCPU1.CNTVOFF_EL2=kvm_phys_timer_read) > > KVM_ARM_VCPU_INIT (VMM) -> > > kvm_arch_vcpu_ioctl_vcpu_init -> > > kvm_vcpu_set_target -> > > kvm_reset_vcpu -> > > kvm_reset_sys_regs (VCPU1.CNTVOFF_EL2=0) > > > > At this point VCPU0 has CNTVOFF_EL2 == kvm_phys_timer_read, and VCPU1 > > has CNTVOFF_EL2 == 0. > > > > The VCPUs having different CNTVOFF_EL2 valuess is just a symptom of the fact that > > CNTVOFF_EL2 is now reset in kvm_reset_sys_regs. > > Right, and the fundamental problem at hand is that we used CNTVOFF_EL2 > to stash the _host's_ offset even though we are trying to change the > meaning of it to be part of the virtual EL2's context. What is driving me nuts is that I have never managed to reproduce the problem so far. I guess I have too much crap in my tree to spot it... > > > The following patch gets it booting again, but I'm sure it's not the right fix. > > I'd rather we just break the host away from using the shadow reg > altogether and separately track the host offset. As it so happens Marc > has a patch that does exactly that [*]. Yup, might as well fix that *and* kill the lock inversion issue in one go... > Marc, do you want to resend that patch in isolation addressing the > feedback and link to this bug report? > > [*] https://lore.kernel.org/kvmarm/20230216142123.2638675-6-maz@kernel.org/ Joey, could you please give that patch a go, just to be on the safe side? Thanks, M. -- Without deviation from the norm, progress is not possible. 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 E2E3FC7EE23 for ; Fri, 24 Feb 2023 19:04:23 +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=xGwiTcrvlz2h103hvl1aRMqXJmuS2tGWE5dLsHbLdOM=; b=Zd41/efQSms5mb s843S3yqZbVnwcDb1OPJSM4c6Z71R4WBBzCs4sYcf5mgUAFBWie8MmwprrcDynGRO1IdMqup5xkyM 0eUtQzYDXDFUfdELxpzBoannsnBTzLuvVK834WLQiaSu/MtRS5g2cU9RE9okUcMTQDYsK+jSxNE6X JxDKg7YXQoYMwPuu+j6bZfYmjAwwlBzojp/rENoaynC7gGWHTti+dEubsbzjofK3u69qhX4B7LgMD Esdx98UjW1oPbghkgC+DwekEH7ki10cq7hOGX/0khKwRTe+sa2Mugo/nXDQE2XlwIxkQHdnLdDc3N MQGbnPxwsVHNs8qUUigA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVdLs-003aqe-Gm; Fri, 24 Feb 2023 19:03:28 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVdLo-003apK-Vc for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 19:03:26 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 5738F618DF; Fri, 24 Feb 2023 19:03:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BECAEC433EF; Fri, 24 Feb 2023 19:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677265403; bh=gCXvVswG+5BJ4eLw8cXXd2lIKc6j1StQlEVV4zpsmGY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bteC247cuY8lqVHIP5fSW8WbA80ZJaeeA0QA2eU9K5g7K0UGRNPpDn+xnVoGV6GJa ERbEYw/u4vNPBQmhE39jH7ueEuWpRRpev1dV4dbjpl6rB+9z1LlPX6bPaOcT0v/OU/ 6fZ+Ddop7SjirvXVRd/fpkt2Gg3Mnr3za2u1G79Xd7MAcxocwgdDTOR0tnKV3/LQlJ 0bnazS3Hx6QMeIvXPuZq+cktOM4xr99F9YWhwbgjI9X+Dz9+GQ0fuPqX5JlQsmU7c8 4B1pJPQ19oRaX1ei938Qiz4o5nwBwnKFSwSC0mCH4t2hiz7ktHjc3Z5gXiWmI+s0CM XqH21f28/LMTQ== 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 1pVdLl-00Czbp-BB; Fri, 24 Feb 2023 19:03:21 +0000 Date: Fri, 24 Feb 2023 19:03:21 +0000 Message-ID: <86v8jqx4w6.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Joey Gouly , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexandru Elisei , Andre Przywara , Catalin Marinas , Christoffer Dall , Ganapatrao Kulkarni , Russell King , James Morse , Suzuki K Poulose , Zenghui Yu , nd@arm.com Subject: Re: [PATCH 08/18] KVM: arm64: nv: Handle HCR_EL2.NV system register traps In-Reply-To: References: <20230209175820.1939006-1-maz@kernel.org> <20230209175820.1939006-9-maz@kernel.org> <20230224173915.GA17407@e124191.cambridge.arm.com> 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/28.2 (aarch64-unknown-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: oliver.upton@linux.dev, joey.gouly@arm.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com, andre.przywara@arm.com, catalin.marinas@arm.com, christoffer.dall@arm.com, gankulkarni@os.amperecomputing.com, rmk+kernel@armlinux.org.uk, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, nd@arm.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-20230224_110325_110829_7235C295 X-CRM114-Status: GOOD ( 30.87 ) 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 Fri, 24 Feb 2023 18:36:23 +0000, Oliver Upton wrote: > > Hi Joey, > > On Fri, Feb 24, 2023 at 05:39:15PM +0000, Joey Gouly wrote: > > I'm having an issue with this commit where a VCPU is getting a CNTVOFF_EL2 set > > to 0, so it sees the same time as the host system, and the other VCPU has the > > correct offset. > > Yikes! > > > The flow of execution looks like this: > > KVM_CREATE_VCPU 0 (VMM) -> > > kvm_timer_vcpu_init -> > > update_vtimer_cntvoff (VCPU0.CNTVOFF_EL2=kvm_phys_timer_read) > > KVM_ARM_VCPU_INIT (VMM) -> > > kvm_arch_vcpu_ioctl_vcpu_init -> > > kvm_vcpu_set_target -> > > kvm_reset_vcpu -> > > kvm_reset_sys_regs (VCPU0.CNTVOFF_EL2=0) > > > > KVM_CREATE_VCPU 1 (VMM) -> > > kvm_timer_vcpu_init -> > > update_vtimer_cntvoff (VCPU0.CNTVOFF_EL2=VCPU1.CNTVOFF_EL2=kvm_phys_timer_read) > > KVM_ARM_VCPU_INIT (VMM) -> > > kvm_arch_vcpu_ioctl_vcpu_init -> > > kvm_vcpu_set_target -> > > kvm_reset_vcpu -> > > kvm_reset_sys_regs (VCPU1.CNTVOFF_EL2=0) > > > > At this point VCPU0 has CNTVOFF_EL2 == kvm_phys_timer_read, and VCPU1 > > has CNTVOFF_EL2 == 0. > > > > The VCPUs having different CNTVOFF_EL2 valuess is just a symptom of the fact that > > CNTVOFF_EL2 is now reset in kvm_reset_sys_regs. > > Right, and the fundamental problem at hand is that we used CNTVOFF_EL2 > to stash the _host's_ offset even though we are trying to change the > meaning of it to be part of the virtual EL2's context. What is driving me nuts is that I have never managed to reproduce the problem so far. I guess I have too much crap in my tree to spot it... > > > The following patch gets it booting again, but I'm sure it's not the right fix. > > I'd rather we just break the host away from using the shadow reg > altogether and separately track the host offset. As it so happens Marc > has a patch that does exactly that [*]. Yup, might as well fix that *and* kill the lock inversion issue in one go... > Marc, do you want to resend that patch in isolation addressing the > feedback and link to this bug report? > > [*] https://lore.kernel.org/kvmarm/20230216142123.2638675-6-maz@kernel.org/ Joey, could you please give that patch a go, just to be on the safe side? 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