From: Oliver Upton <oliver.upton@linux.dev>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH 05/13] KVM: arm64: Add timer UAPI workaround to sysreg infrastructure
Date: Mon, 29 Sep 2025 17:41:01 -0700 [thread overview]
Message-ID: <aNsnHUTaHgrql07j@linux.dev> (raw)
In-Reply-To: <20250929160458.3351788-6-maz@kernel.org>
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 <maz@kernel.org>
> ---
> 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.
Thanks,
Oliver
next prev parent reply other threads:[~2025-09-30 0:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 16:04 [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI Marc Zyngier
2025-09-29 16:04 ` [PATCH 01/13] KVM: arm64: Hide CNTHV_*_EL2 from userspace for nVHE guests Marc Zyngier
2025-09-30 0:35 ` Oliver Upton
2025-09-30 7:44 ` Marc Zyngier
2025-09-29 16:04 ` [PATCH 02/13] KVM: arm64: Introduce timer_context_to_vcpu() helper Marc Zyngier
2025-09-29 16:04 ` [PATCH 03/13] KVM: arm64: Replace timer context vcpu pointer with timer_id Marc Zyngier
2025-09-30 10:13 ` Joey Gouly
2025-09-29 16:04 ` [PATCH 04/13] KVM: arm64: Make timer_set_offset() generally accessible Marc Zyngier
2025-09-29 16:04 ` [PATCH 05/13] KVM: arm64: Add timer UAPI workaround to sysreg infrastructure Marc Zyngier
2025-09-30 0:41 ` Oliver Upton [this message]
2025-09-30 7:48 ` Marc Zyngier
2025-09-29 16:04 ` [PATCH 06/13] KVM: arm64: Move CNT*_CTL_EL0 userspace accessors to generic infrastructure Marc Zyngier
2025-09-29 16:04 ` [PATCH 07/13] KVM: arm64: Move CNT*_CVAL_EL0 " Marc Zyngier
2025-09-29 16:04 ` [PATCH 08/13] KVM: arm64: Move CNT*CT_EL0 " Marc Zyngier
2025-09-30 10:45 ` Joey Gouly
2025-09-30 12:05 ` Marc Zyngier
2025-09-30 12:41 ` Joey Gouly
2025-09-29 16:04 ` [PATCH 09/13] KVM: arm64: Fix WFxT handling of nested virt Marc Zyngier
2025-09-29 16:04 ` [PATCH 10/13] KVM: arm64: Kill leftovers of ad-hoc timer userspace access Marc Zyngier
2025-09-29 16:04 ` [PATCH 11/13] KVM: arm64: selftests: Make dependencies on VHE-specific registers explicit Marc Zyngier
2025-09-29 16:04 ` [PATCH 12/13] KVM: arm64: selftests: Add an E2H=0-specific configuration to get_reg_list Marc Zyngier
2025-09-29 16:04 ` [PATCH 13/13] KVM: arm64: selftest: Fix misleading comment about virtual timer encoding Marc Zyngier
2025-10-13 16:55 ` [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aNsnHUTaHgrql07j@linux.dev \
--to=oliver.upton@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).