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 72EE4CD37B0 for ; Mon, 18 Sep 2023 11:30:00 +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=zORSgN93b3irOnYXCJO2cFYHNA8Ss8EhAtCC0aGXnMs=; b=uxuCWP/Eanv0rh 01XEfdRdaeaezinZiR+tQu5oLAg3JLMW4CFifUccFCd8C+UznOsIdIbhSOYemlct8e49Iidl8W41M raLP1UbTZSpIyJFLjwKJZQn1DYhqyNwSyVgqO6l6/JwrZk+8Rc64WUkZbxaRTMifE/S8xGsePSPH6 FwF1GjMXd23D2yHmWP09qPHEtHeJYqdFYvcsPglS63FLBVYQtUWT4HzP9VHJZQrwGTLV+sq9bFj1D lx3zkxxjLZhyyPmsdW8PC9tJzM+LWzkfmHsO70q3ykF+K9y49UmLVSzflUMBQU029Eo1Z6Aj5B5uP ibXg+ROm6ULkI5WwtHIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiCRZ-00FKMw-2M; Mon, 18 Sep 2023 11:29:33 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qiCRX-00FKMX-0v for linux-arm-kernel@lists.infradead.org; Mon, 18 Sep 2023 11:29:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 960D360EA8; Mon, 18 Sep 2023 11:29:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0682EC433C8; Mon, 18 Sep 2023 11:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695036570; bh=Tbr+toJ7rxfRlTgt5CS9qWcSUDf7oL+wndOlXs4306I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=E4uohRupViqvyoCsYMQFNJIMv9Peywk1vugrjqhC0UBj+TQ4x3ZA7fTIX+aG2QYf8 9b1WaQ5qPULnay5na3KSMoK1h/5Tefr2fYn4HOTYpVQThnG6dCJFR6AbLdxwNVldkO zzSwbNJDCuxB5Z3ZbTs5vx5Cy8AN7ilxGuIZ8AKbnwbFP6IhM2RoAFHYKsdqt3kv6D xaLDKkYPMEpAJBh2AGq1IqHWKQAoRs9jHPFcwY0LUilU1kkYy5Rh48GjgmTWrMHQgF ZwnAzTaJQPUsPwDv3E4Fv6tPvoFGr3R1SHu7WvgP799Q/eW07GD7G3CDliltLOcCbX tRU8yiHuCNNpg== 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 1qiCRT-00DwSv-J2; Mon, 18 Sep 2023 12:29:27 +0100 Date: Mon, 18 Sep 2023 12:29:26 +0100 Message-ID: <8634zben3d.wl-maz@kernel.org> From: Marc Zyngier To: Ganapatrao Kulkarni Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Christoffer.Dall@arm.com, eauger@redhat.com, miguel.luis@oracle.com, darren@os.amperecomputing.com, scott@os.amperecomputing.com Subject: Re: [PATCH v2 2/2] KVM: arm64: timers: Save restore CVAL of a ptimer across guest entry and exits In-Reply-To: References: <20230904114218.590304-1-gankulkarni@os.amperecomputing.com> <20230904114218.590304-3-gankulkarni@os.amperecomputing.com> <86bkeadzf0.wl-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/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: gankulkarni@os.amperecomputing.com, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Christoffer.Dall@arm.com, eauger@redhat.com, miguel.luis@oracle.com, darren@os.amperecomputing.com, scott@os.amperecomputing.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-20230918_042931_412450_E8114A64 X-CRM114-Status: GOOD ( 21.99 ) 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, 15 Sep 2023 10:57:46 +0100, Ganapatrao Kulkarni wrote: > > This patch did not work. > After adding changes as in below diff, it is started working. Thanks for looking into this. > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c > b/arch/arm64/kvm/hyp/vhe/switch.c > index b0b07658f77d..91d2cfb03e26 100644 > --- a/arch/arm64/kvm/hyp/vhe/switch.c > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > @@ -117,7 +117,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu) > val = __vcpu_sys_reg(vcpu, CNTHP_CVAL_EL2); > > if (map.direct_ptimer) { > - write_sysreg_s(val, SYS_CNTP_CVAL_EL0); > + write_sysreg_el0(val, SYS_CNTP_CVAL); Duh, of course. Silly me. > isb(); > } > } > @@ -161,8 +161,6 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu) > > ___deactivate_traps(vcpu); > > - write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2); > - > if (has_cntpoff()) { > struct timer_map map; > u64 val, offset; > @@ -173,7 +171,7 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu) > * We're exiting the guest. Save the latest CVAL value > * to memory and apply the offset now that TGE is set. > */ > - val = read_sysreg_s(SYS_CNTP_CVAL_EL0); > + val = read_sysreg_el0(SYS_CNTP_CVAL); > if (map.direct_ptimer == vcpu_ptimer(vcpu)) > __vcpu_sys_reg(vcpu, CNTP_CVAL_EL0) = val; > if (map.direct_ptimer == vcpu_hptimer(vcpu)) > @@ -182,12 +180,13 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu) > offset = read_sysreg_s(SYS_CNTPOFF_EL2); > > if (map.direct_ptimer && offset) { > - offset = read_sysreg_s(SYS_CNTPOFF_EL2); > - write_sysreg_s(val + offset, SYS_CNTP_CVAL_EL0); > + write_sysreg_el0(val + offset, SYS_CNTP_CVAL); > isb(); > } > } > > + write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2); Why moving the HCR_EL2 update? I don't grok what it changes. Or is it that you end-up with spurious interrupts because your GIC is slow to retire interrupts that are transiently pending? 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