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 46488CAC582 for ; Tue, 9 Sep 2025 17:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=9hIFvQS1Pf1bZOui06T8uhRKNHB+fE/Pl3qzulDRCIA=; b=UeaKMJ2i6Xe9UK2RQYOBSqTDgZ GTtrJDLRDMKvz2ipgnLHU7LmjFPe5yft6qSkJPD58gFMEVb+xf+MFj5UszKBmhqsxt/TqlHEvXOOX YiRepFEjj8zA5FWFfGi7BRrqLEORlRb9B4lefSGP9t4O99g/ToYUxMEeuI7SZ3rT7r7+2dGxcx2RN gwOryrofPzqzIRMkn3ldX1dNxWGgnvBND1+cD5oUjHwXMRNvA0HcKKg+wAFGKimG6hOjyrDjJkiAS U0yFa0BZqopxczcwXO4l/dpjIZPZFc55vGaDe4yCdeScHoyShqcoxs/6r3DM47qqo8aD4ekkJVPlH j58w2TnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uw26I-000000094On-01Z7; Tue, 09 Sep 2025 17:25:50 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uw0hf-00000008Lms-3kQ2 for linux-arm-kernel@lists.infradead.org; Tue, 09 Sep 2025 15:56:20 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 57225442EA; Tue, 9 Sep 2025 15:56:19 +0000 (UTC) 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250909_085619_976159_CA7F14A0 X-CRM114-Status: GOOD ( 26.96 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.