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 BF33F33F6; Tue, 30 Sep 2025 07:48:11 +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=1759218491; cv=none; b=cH/oUSLsl/UPohoo5wGkOWUK9bUmLtB45T5OHchx8VoYAZ9cLcm+IueWfuNY0/e1qEaj7iI8BUv/zrkQWc1G+zZFLWFB0vx0Mp1ITBKwVBGjnCyCkayyOQ/Fak5VsDojApc6YWl2m9fnKVONT31y3by3fYeJ6eG3vOvvx24z6yw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759218491; c=relaxed/simple; bh=4T+XQXD3LHjmczUTO39ClqL11skFL4B6shLS9cZAwxg=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=PoVilRfzzpXn57QZmnnjH1N9gqnXVHxZK6U8VF9y+fo7jRFLV1HyYuw47u5Sa8LT4ICvvnlJGpRXiFtXtY/78tmIpwNPswgH+TqD+nuUUlA7ZN6+NyeO/SUyyEFAh5P6eX+PrHOe/IZR9nFpYGOd3EMuf2tW6XFJQYRMl4Ynmcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VEb6B3/V; 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="VEb6B3/V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F20C4CEF0; Tue, 30 Sep 2025 07:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759218491; bh=4T+XQXD3LHjmczUTO39ClqL11skFL4B6shLS9cZAwxg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VEb6B3/VJCPnNK82slvGZUWFmpJmpyI1qBH3M/UFtekDuEB5dYj3Bh2HmPpUDQWG2 FUuOEQuna1z47W2eRq9cT8S7UgGr6SRNHaDXYLg/DKpH2UH2mcZFO7Jx5Z6zoTOx4B YvGLdTnc2DzGGnI9FVZwFYJ/2I4PcIZCiW1KgRyDSb7yRYQsC/qOAcOQo5hgIY0PfE +9uc9WIHYYprNuQIprPEv1V5Dj3FEN2xoBH93sWfRRIeVQ/ot9a0PUDW+cBSsizW/5 3G67FiEx+g9yi2ZPclLFzE7Obfo/dgzm/iFUCduaIr8jI6HAukBoGnqxx3B/i3w84g hJeL8R5oNmVbw== 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 1v3V5l-0000000ASwF-0Ixc; Tue, 30 Sep 2025 07:48:09 +0000 Date: Tue, 30 Sep 2025 08:48:08 +0100 Message-ID: <86y0pwz8hz.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Joey Gouly , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH 05/13] KVM: arm64: Add timer UAPI workaround to sysreg infrastructure In-Reply-To: References: <20250929160458.3351788-1-maz@kernel.org> <20250929160458.3351788-6-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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@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=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.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, 30 Sep 2025 01:41:01 +0100, Oliver Upton wrote: > > On Mon, Sep 29, 2025 at 05:04:49PM +0100, Marc Zyngier wrote: > > Amongst the numerous bugs that plague the KVM/arm64 UAPI, one of > > the most annoying thing is that the userspace view of the virtual > > timer has its CVAL and CNT encodings swapped. > > > > In order to reduce the amount of code that has to know about this, > > start by adding handling for this bug in the sys_reg code. > > > > Nothing is making use of it yet, as the code responsible for userspace > > interaction is catching the accesses early. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kvm/sys_regs.c | 33 ++++++++++++++++++++++++++++++--- > > arch/arm64/kvm/sys_regs.h | 6 ++++++ > > 2 files changed, 36 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index 9f2f4e0b042e8..8e6f50f54b4bf 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -5231,15 +5231,28 @@ static int demux_c15_set(struct kvm_vcpu *vcpu, u64 id, void __user *uaddr) > > } > > } > > > > +static u64 kvm_one_reg_to_id(const struct kvm_one_reg *reg) > > +{ > > + switch(reg->id) { > > + case KVM_REG_ARM_TIMER_CVAL: > > + return TO_ARM64_SYS_REG(CNTV_CVAL_EL0); > > + case KVM_REG_ARM_TIMER_CNT: > > + return TO_ARM64_SYS_REG(CNTVCT_EL0); > > + default: > > + return reg->id; > > + } > > +} > > + > > Seems like a good spot to name n' blame the commit that introduced this > bug as a comment. Sure. That'd be 39735a3a39043 ("ARM/KVM: save and restore generic timer registers"), but that's also the first time save/restore was implemented at all, and there wasn't a sane version before that. Thanks, M. -- Without deviation from the norm, progress is not possible.