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 AEE7C747F; Tue, 9 Sep 2025 15:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757433379; cv=none; b=s5CYMUY5H2amyT2TquCNj1FQm0ew5nRox4RmRA1T6hBn2o7PEdP/5rTTpB3R3szSp/dCDI17kiSK/XSuyyRCpF/yZyxtQnDl/s0Ff2LsnZtOP9MvOz/WUzFctPlTQAqG3s0wJaXK+p/qo8iqif4h5A4JBer2W8e60cyOo+SThbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757433379; c=relaxed/simple; bh=RtUitodWOkKeQEEaclflXS12jq+q0qRZEHBeguTytIc=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=pIEfdrsETGhHsehp8+HzIjuy+MpeEDrxqSTla2iFc6SgKo2gd9PbGRwwNGAnXMLHD/tnKo90Txg1+4Pk24BKI0O1Gbjmk3KXAoANsS0mny0jxzlftwgxyQB249XMezuDiXSFaLN6zqITouIilAjZBfQByyQnXjB+Bh3FQxkd7Tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X8mexh43; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X8mexh43" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BECBC4CEF4; Tue, 9 Sep 2025 15:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757433379; bh=RtUitodWOkKeQEEaclflXS12jq+q0qRZEHBeguTytIc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=X8mexh43sOY/SEveLtu9JYR24EqArE2lyojo7jK49c2ClNxxjSMm2pQQ7EV3ADYTB JhxSONgh4k/2k3o5UV/SzG1EebwiW6VK4ro6+AooG/1BpT7PD1W2ZY4rht9bbbhgAB vkYp8Rqz6H8Sboxip4bhijsZCdG9t8wBPL8GIJ36WIzdEBVjDmQIb2/t0+JNJ1r9cw t8X3rDnmLW79xEwWkcQ2XsZ/cICUpn3DtGVLxnQ7Tw2cl5AXVbdLDjFc6M7qtufEYL sF9zrY36pYK5fFqoZ6aPKR+y0e1j8xKuhJ+BtRfo+glELJfoTjooEIvtUkYY65NMCN /kOgBZIVWcjAQ== 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.98.2) (envelope-from ) id 1uw0hc-00000004kKc-37ay; Tue, 09 Sep 2025 15:56:16 +0000 Date: Tue, 09 Sep 2025 16:56:16 +0100 Message-ID: <86frcvd3hb.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Mostafa Saleh , linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, robin.murphy@arm.com, jean-philippe@linaro.org, qperret@google.com, tabba@google.com, jgg@ziepe.ca, mark.rutland@arm.com, praan@google.com Subject: Re: [PATCH v4 03/28] KVM: arm64: pkvm: Add pkvm_time_get() In-Reply-To: References: <20250819215156.2494305-1-smostafa@google.com> <20250819215156.2494305-4-smostafa@google.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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: will@kernel.org, smostafa@google.com, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, robin.murphy@arm.com, jean-philippe@linaro.org, qperret@google.com, tabba@google.com, jgg@ziepe.ca, mark.rutland@arm.com, praan@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 09 Sep 2025 15:16:26 +0100, Will Deacon wrote: >=20 > On Tue, Aug 19, 2025 at 09:51:31PM +0000, Mostafa Saleh wrote: > > Add a function to return time in us. > >=20 > > This can be used from IOMMU drivers while waiting for conditions as > > for SMMUv3 TLB invalidation waiting for sync. > >=20 > > Signed-off-by: Mostafa Saleh > > Signed-off-by: Jean-Philippe Brucker > > --- > > arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 2 ++ > > arch/arm64/kvm/hyp/nvhe/setup.c | 4 ++++ > > arch/arm64/kvm/hyp/nvhe/timer-sr.c | 33 ++++++++++++++++++++++++++ > > 3 files changed, 39 insertions(+) [...] > > +#define SEC_TO_US 1000000 > > + > > +int pkvm_timer_init(void) > > +{ > > + timer_freq =3D read_sysreg(cntfrq_el0); > > + /* > > + * TODO: The highest privileged level is supposed to initialize this > > + * register. But on some systems (which?), this information is only > > + * contained in the device-tree, so we'll need to find it out some ot= her > > + * way. > > + */ > > + if (!timer_freq || timer_freq < SEC_TO_US) > > + return -ENODEV; > > + return 0; > > +} >=20 > Right, I think the frequency should be provided by the host once the arch > timer driver has probed successfully. Relying on CNTFRQ isn't viable imo. We can always patch the value in, =C3=A0 la kimage_voffset. But it really begs the question: who is their right mind doesn't set CNTFRQ_EL0 to something sensible? Why should we care about supporting such contraption? I'd be happy to simply disable KVM when CNTFRQ_EL0 is misprogrammed, or that the device tree provides a clock frequency. Because there is no good way to support a guest in that case. M. --=20 Without deviation from the norm, progress is not possible.