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 52023C7EE23 for ; Fri, 24 Feb 2023 18:37:35 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6iF5FTBEJSSmrUJI2HOuto+/FsKs8AwmNKjbp3mDgSg=; b=Nvxeb6/8P99yAD NoauR0mcUmQ0AUY+ldjeZdd4JAjd0fPxwGSYT27eGa8AIcJHMpLc5uYWDnWtol1AVnuBFVyZZSdA6 zGzEFiyHdKN+Jc1BDvcXJCDCGAnnQutbjCx9j99YpzKktuMrfwGGJMaUQTDfleu3NDMYr/XTisPxs 1QRPTk1rq41Ldjy51b/m+a2IUCghYeApbesVZxVjnwqzZoluAMdIqRRGpNQ5sdU24RN1bgtCj8xXQ iAd++9Zsp6dFtEPmHFHir5L7jqHiVU0yGDyIsVScsLhgCE5YD4zJJRok5s+VmXo4GEowOUBdNifMq eSka9s/QWJ7NdSogmy3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVcvv-003WyT-Iw; Fri, 24 Feb 2023 18:36:39 +0000 Received: from out-57.mta0.migadu.com ([2001:41d0:1004:224b::39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVcvr-003WxD-U2 for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 18:36:37 +0000 Date: Fri, 24 Feb 2023 18:36:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1677263789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EsjdFfT3WIVIStv91sTwvYp/k4Cco0RtXYYhSN2jo8g=; b=OQv9SozBYfKxZ3lBlV2ee1KmUxzSknEZIE2JhrQjifKoWxxwquNBjWnXTxJtlmefYB3+he RUNcPDcB2+Ab+gvJ1/ndkGOkzeLOsb1CJ9Rem36WmvkmHG9THs0mJBHE31yom14gnwelWe glH1eicPUplYZos4CXWI9k1YYdEcSAM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Joey Gouly Cc: Marc Zyngier , 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 Message-ID: References: <20230209175820.1939006-1-maz@kernel.org> <20230209175820.1939006-9-maz@kernel.org> <20230224173915.GA17407@e124191.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230224173915.GA17407@e124191.cambridge.arm.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_103636_154331_B0B1649F X-CRM114-Status: GOOD ( 15.62 ) 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 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. > 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 [*]. 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/ -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel