Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mostafa Saleh" <smostafa@google.com>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v2 2/3] KVM: arm64: Fix timer offsets for non-protected VMs
Date: Sat, 08 Aug 2026 09:09:48 +0000	[thread overview]
Message-ID: <20260808090949.4C6441F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260808085824.732659-3-smostafa@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing Context Synchronization Event (`isb()`) after writing to control-plane system register `cnthctl_el2`.
--

--- Patch [2]: [PATCH v2 2/3] KVM: arm64: Fix timer offsets for non-protected VMs ---
commit 0ed46cb1bdd2dc0d545a0cd2b0b6f500a46a254f
Author: Mostafa Saleh <smostafa@google.com>

KVM: arm64: Fix timer offsets for non-protected VMs

This commit fixes an issue where timer offsets for non-protected guests
were not correctly applied in pKVM. It corrects the protected VM check
in __timer_enable_traps() and initializes the previously null timer offsets.

> diff --git a/arch/arm64/kvm/hyp/nvhe/timer-sr.c b/arch/arm64/kvm/hyp/nvhe/timer-sr.c
> index ff176f4ce7deb..51b4f5010b660 100644
> --- a/arch/arm64/kvm/hyp/nvhe/timer-sr.c
> +++ b/arch/arm64/kvm/hyp/nvhe/timer-sr.c
> @@ -45,11 +45,11 @@ void __timer_enable_traps(struct kvm_vcpu *vcpu)
[ ... ]
>  	clr = CNTHCTL_EL1PCEN;
> -	if (is_protected_kvm_enabled() ||
> -	    !kern_hyp_va(vcpu->kvm)->arch.timer_data.poffset)
> +	if (vcpu_is_protected(vcpu) ||
> +	    !timer_get_offset(vcpu_ptimer(vcpu)))
>  		set |= CNTHCTL_EL1PCTEN;
>  	else
>  		clr |= CNTHCTL_EL1PCTEN;

[Severity: High]
This is a pre-existing issue, but do __timer_enable_traps() and
__timer_disable_traps() in arch/arm64/kvm/hyp/nvhe/timer-sr.c need an
explicit isb() after writing to cnthctl_el2?

Looking at the end of __timer_enable_traps(), it updates cnthctl_el2 and
returns:

arch/arm64/kvm/hyp/nvhe/timer-sr.c:__timer_enable_traps() {
    ...
    sysreg_clear_set(cnthctl_el2, clr, set);
}

The same pattern exists in __timer_disable_traps().

Because sysreg_clear_set() does not embed a Context Synchronization Event,
the CPU executes the subsequent RET instruction (and any caller instructions
before an eventual isb() or ERET) against an architecturally undefined
pipeline state.

Could this missing immediate context synchronization event after a
control-plane system register write lead to unexpected traps or memory
safety violations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260808085824.732659-1-smostafa@google.com?part=2

  reply	other threads:[~2026-08-08  9:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08  8:58 [PATCH v2 0/3] KVM: arm64: Fixes for timers and pKVM Mostafa Saleh
2026-08-08  8:58 ` [PATCH v2 1/3] KVM: arm64: Make timer_get_offset() work in all contexts Mostafa Saleh
2026-08-08  8:58 ` [PATCH v2 2/3] KVM: arm64: Fix timer offsets for non-protected VMs Mostafa Saleh
2026-08-08  9:09   ` sashiko-bot [this message]
2026-08-08  8:58 ` [PATCH v2 3/3] KVM: arm64: Fix hvhe and broken CNTVOFF_EL2 Mostafa Saleh
2026-08-08 14:31   ` Mostafa Saleh
2026-08-08 18:44 ` [PATCH v2 0/3] KVM: arm64: Fixes for timers and pKVM Oliver Upton
2026-08-11 12:17   ` Mostafa Saleh
2026-08-11 13:18     ` Marc Zyngier
2026-08-11 17:21       ` Mostafa Saleh
2026-08-11 18:44         ` Mostafa Saleh

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=20260808090949.4C6441F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=smostafa@google.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