Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6107954rdb; Mon, 18 Sep 2023 04:41:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxNJZWQRM4X20/2lmunhlyyH3G2rC6gxrYoK97rQUvtJPWIRynPS/B9+gdsRHp1TJh7Ast X-Received: by 2002:a05:6a21:7889:b0:140:730b:4b3f with SMTP id bf9-20020a056a21788900b00140730b4b3fmr9613679pzc.1.1695037315145; Mon, 18 Sep 2023 04:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695037315; cv=none; d=google.com; s=arc-20160816; b=xfzH5TmS/6rT8m5H12mLj87soIWX1HQft++8Z6chY7tuMrMsEu5iQzUVAgWe4g03pw g+eI/bXcFe8zsqkcK6S6NvGa0xcZNhJA8j1DxJCVBhkLjJHzxQ9OC6ABRWV/zXa8ebkY nyNojbE8HjNsNXRNSq0PIsQpFYzv/U1BzSpocXBCTnsreqE1TQeuA7MnZFnuxXVtmVhR 6YIivX8eguvprA1u8y4zAKODQJoGXJZPj2lgxpccKEfvhpAFHe9XcZaujkjOK0EPIFNo M2lfQG1zCikjtel1YcNga4Sev1Qn2Tzv4pDCOTBhkbkaFGwwqt1DDiYwjlFyH9l73mVQ avCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=iq/klBh7Km3V8dJojz33t/bmzqsq70Kc/jzcjC789f8=; fh=k+eCuzdb3Me1VAxvC46zvg304hJsaqqFuxNtfV4vfuE=; b=LXwTmSF93+lwtFsR+fx+MbwpNFUDi+bqx1aQiySSNVR+rSv9dOlQR147PVthmBQNFa TPPdbmXFJeJJDv3HLfReSw7XAPFbCbTmRZGnW2chM+f+5dDdZjEJ9qD0mfWqOCMaYG35 3UuIuaQgQlblo+lC+/vwkTq0Z6yZzHRxivsaUbPUFBhQHaX+QZlQrqmSWv0HTKAF3O9I YlYoajbpbOk7lDXifQS1DBzoaymUpuu+ZZRhx1qgC/RJQNh4Siqbx3O895q/RkGrcs4I xm3JvdU08HWU6/lrW8rKgE+9wEDR/golfTqzvxvlOoVYEKTcKelWFMmtCVfDOi8Ggjt1 PI1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E4uohRup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k3-20020a6568c3000000b00565f294417bsi7921806pgt.426.2023.09.18.04.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:41:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E4uohRup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7D56780758F9; Mon, 18 Sep 2023 04:32:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241632AbjIRLcS (ORCPT + 99 others); Mon, 18 Sep 2023 07:32:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241716AbjIRLbu (ORCPT ); Mon, 18 Sep 2023 07:31:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81506119 for ; Mon, 18 Sep 2023 04:29:30 -0700 (PDT) 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") Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 04:32:44 -0700 (PDT) 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.