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 638E9C678D5 for ; Wed, 8 Mar 2023 07:54:51 +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=ACPAKlI2VAMlLmsIZ8xiShe1SBWYCr+0kCZBB+MmMWs=; b=NFKLolglFOsKoG 1sZNbXxLy7GKKPbD74a8m0B6771vqYixRvzy35hK3GAiqNpQKwQhXHWLzxcNRrUJ1yKjDG7o2R+S/ h5s2jBXa2bWayKFq3lonq25GeeBH7y44NxS8tKCzsJ1MJYCSFjIdid+pM0k+dOjWt//EV8hRIU6Y8 R++sryvJis2ss6LvwH2JNxk9gsFZNganS5gU8mn4RSBIf2/VI7E+R37uUa9Wc+0Lna6skYXQaKxhM 5jlabQhsriV3R90CONXC/Xq6uHe1wmHDOSvoJPiLw+3XmlmC5F84gWyExNPrTp0gf15Sryd7pcbt1 jssyaQ43JjGGgOax/MwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZocZ-003ra3-4R; Wed, 08 Mar 2023 07:53:59 +0000 Received: from out-39.mta0.migadu.com ([91.218.175.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZocU-003rYV-Qc for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2023 07:53:57 +0000 Date: Wed, 8 Mar 2023 07:53:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1678262030; 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=fnGvIajA/bpm/TJMpImEUXN1dg0/39rmZkvKiAUZXNI=; b=XdNkyFqc4HLgPEK+wIQY/dcFiKFsRgHBqET/fpTOwKEyaoLDUjs2G1YOtFw0lfRSUJ9auw TEb4jJ0lKeEkvl2b0UhUVXVYX+ClM2E4ldo5RVIGJrZIeYKKBrexUHqa1vLgqi8lPpoxPY bbnPNEy4ebofORIBfZZfTim4xn///Tg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Zenghui Yu , Ricardo Koller , Simon Veith , dwmw2@infradead.org Subject: Re: [PATCH 08/16] KVM: arm64: timers: Allow userspace to set the counter offsets Message-ID: References: <20230216142123.2638675-1-maz@kernel.org> <20230216142123.2638675-9-maz@kernel.org> <86k00gy4so.wl-maz@kernel.org> <86bkllyku2.wl-maz@kernel.org> <867cw8xmq2.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_235355_051847_087B7AC6 X-CRM114-Status: GOOD ( 37.12 ) 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 Wed, Mar 08, 2023 at 07:46:00AM +0000, Oliver Upton wrote: > Hey Marc, > > On Thu, Feb 23, 2023 at 06:25:57PM +0000, Marc Zyngier wrote: > > [...] > > > > Do we need to bend over backwards for a theoretical use case with > > > the new UAPI? If anyone depends on the existing behavior then they can > > > continue to use the old UAPI to partially migrate the guest counters. > > > > I don't buy the old/new thing. My take is that these things should be > > cumulative if there isn't a hard reason to break the existing API. > > Unsurprisingly, I may have been a bit confusing in my replies to you. > > I have zero interest in breaking the existing API. Any suggestion of > 'changing the rules' was more along the lines of providing an alternate > scheme for the counters and letting the quirks of the old interface > continue. > > > > My previous suggestion of tying the physical and virtual counters > > > together at VM creation would definitely break such a use case, though, > > > so we'd be at the point of requiring explicit opt-in from userspace. > > > > I'm trying to find a middle ground, so bear with me. Here's the > > situation as I see it: > > > > (1) a VM that is migrating today can only set the virtual offset and > > doesn't affect the physical counter. This behaviour must be > > preserved in we cannot prove that nobody relies on it. > > > > (2) setting the physical offset could be done by two means: > > > > (a) writing the counter register (like we do for CNTVCT) > > (b) providing an offset via a side channel > > > > I think (1) must stay forever, just like we still support the old > > GICv2 implicit initialisation. > > No argument here. Unless userspace pokes some new bit of UAPI, the old > behavior of CNTVCT must live on. > > > (2a) is also desirable as it requires no extra work on the VMM side. > > Just restore the damn thing, and nothing changes (we're finally able > > to migrate the physical timer). (2b) really is icing on the cake. > > > > The question is whether we can come up with an API offering (2b) that > > still allows (1) and (2a). I'd be happy with a new API that, when > > used, resets both offsets to the same value, matching your pretty > > picture. But the dual offsetting still has to exist internally. > > > > When it comes to NV, it uses either the physical offset that has been > > provided by writing CNTPCT, or the one that has been written via the > > new API. Under the hood, this is the same piece of data, of course. > > > > The only meaningful difference with my initial proposal is that there > > is no new virtual offset API. It is either register writes that obey > > the same rules as before, or a single offset setting. > > I certainly agree that (2a) is highly desirable to get existing VMMs to > 'do the right thing' for free. Playing devil's advocate, would this not > also break the tracing example you've given of correlating timestamps > between the host and guest? I wouldn't expect a userspace + VM tracing > contraption to live migrate but restoring from a snapshot seems > plausible. The problem I'm alluding to here is that the VMM will save/restore the physical counter value and cause KVM to offset the physical counter. Live migration is a pretty obvious example, but resuming from a snapshot after resetting a system be similarly affected. > Regardless, I like the general direction you've proposed. IIUC, you'll > want to go ahead with ignoring writes to CNT{P,V}CT if the offset was > written by userspace, right? > > -- > Thanks, > Oliver > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel