Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Colton Lewis" <coltonlewis@google.com>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH 6.6 v3 3/6] arm64: Fix early handling of FEAT_E2H0 not being implemented
Date: Thu, 09 Jul 2026 22:46:17 +0000	[thread overview]
Message-ID: <20260709224617.761791F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709223604.12934-4-coltonlewis@google.com>

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

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but writes to control-plane system registers (such as `SYS_SCTLR_EL12`, `sctlr_el1`, `cnthctl_el2`, `cntvoff_el2`, `SYS_HCRX_EL2`, and fine-grained trap registers like `SYS_HDFGRTR_EL2`) are not immediately followed by an `isb()` instruction. This violates architectural context synchronization rules which mandate that every control-plane sysreg write must be followed by an `isb()` as the very next instruction.
--

--- Patch [3]: [PATCH 6.6 v3 3/6] arm64: Fix early handling of FEAT_E2H0 not being implemented ---
commit 7771c286d908263811f7e18fed1ebdcc2d0d16e0
Author: Marc Zyngier <maz@kernel.org>

arm64: Fix early handling of FEAT_E2H0 not being implemented

This commit fixes a bug where the check for ID_AA64MMFR4_EL1.E2H0
was incorrect and happened too late in the initialization sequence.
It updates the check and publishes the HCR_EL2.E2H bit earlier to
ensure hVHE mode boots successfully as a nested guest.

Link: https://lore.kernel.org/r/20240321115414.3169115-1-maz@kernel.org

> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index e32c8dd0b17a7..e0e710b36da37 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
[ ... ]
> @@ -588,22 +603,10 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
>  
>  	mov_q	x1, INIT_SCTLR_EL1_MMU_OFF
>  
> -	/*
> -	 * Compliant CPUs advertise their VHE-onlyness with
> -	 * ID_AA64MMFR4_EL1.E2H0 < 0. HCR_EL2.E2H can be
> -	 * RES1 in that case.
> -	 *
> -	 * Fruity CPUs seem to have HCR_EL2.E2H set to RES1, but
> -	 * don't advertise it (they predate this relaxation).
> -	 */
> -	mrs_s	x0, SYS_ID_AA64MMFR4_EL1
> -	ubfx	x0, x0, #ID_AA64MMFR4_EL1_E2H0_SHIFT, #ID_AA64MMFR4_EL1_E2H0_WIDTH
> -	tbnz	x0, #(ID_AA64MMFR4_EL1_E2H0_SHIFT + ID_AA64MMFR4_EL1_E2H0_WIDTH - 1), 1f
> -
>  	mrs	x0, hcr_el2
>  	and	x0, x0, #HCR_E2H
>  	cbz	x0, 2f
> -1:
> +
>  	/* Set a sane SCTLR_EL1, the VHE way */
>  	pre_disable_mmu_workaround
>  	msr_s	SYS_SCTLR_EL12, x1

[Severity: High]
This isn't a bug introduced by this patch, but do the writes to control-plane
system registers here and in nearby setup functions need to be immediately
followed by an isb() instruction?

Looking at init_el2() in arch/arm64/kernel/head.S, the write to
SYS_SCTLR_EL12 is immediately followed by a mov instruction instead of
an isb():

        msr_s   SYS_SCTLR_EL12, x1
        mov     x2, #BOOT_CPU_FLAG_E2H

Operating with a stale pipeline configuration after control-plane sysreg writes
can cause unexpected CPU traps, undefined behavior, or boot failures.

The same pattern appears in init_el2() where sctlr_el1 is written:

2:
        pre_disable_mmu_workaround
        msr     sctlr_el1, x1
        mov     x2, xzr

This also seems to occur in arch/arm64/include/asm/el2_setup.h:

- __init_el2_timers() writes cnthctl_el2 and cntvoff_el2 without an
  intervening isb().
- __init_el2_hcrx() writes to SYS_HCRX_EL2.
- __init_el2_fgt() writes to fine-grained trap registers like
  SYS_HDFGRTR_EL2.

Could these missing synchronization barriers cause boot failures on
microarchitectures that require strict enforcement?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709223604.12934-1-coltonlewis@google.com?part=3

  reply	other threads:[~2026-07-09 22:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 22:35 [PATCH 6.6 v3 0/6] arm64: KVM: Backport VHE-only boot fixes Colton Lewis
2026-07-09 22:35 ` [PATCH 6.6 v3 1/6] arm64: sysreg: Add layout for ID_AA64MMFR4_EL1 Colton Lewis
2026-07-09 22:35 ` [PATCH 6.6 v3 2/6] arm64: Treat HCR_EL2.E2H as RES1 when ID_AA64MMFR4_EL1.E2H0 is negative Colton Lewis
2026-07-09 22:45   ` sashiko-bot
2026-07-09 22:36 ` [PATCH 6.6 v3 3/6] arm64: Fix early handling of FEAT_E2H0 not being implemented Colton Lewis
2026-07-09 22:46   ` sashiko-bot [this message]
2026-07-09 22:36 ` [PATCH 6.6 v3 4/6] KVM: arm64: Initialize HCR_EL2.E2H early Colton Lewis
2026-07-09 22:46   ` sashiko-bot
2026-07-09 22:36 ` [PATCH 6.6 v3 5/6] KVM: arm64: Initialize SCTLR_EL1 in __kvm_hyp_init_cpu() Colton Lewis
2026-07-09 22:36 ` [PATCH 6.6 v3 6/6] arm64: Revamp HCR_EL2.E2H RES1 detection Colton Lewis
2026-07-10 21:03 ` [PATCH 6.6 v3 0/6] arm64: KVM: Backport VHE-only boot fixes Sasha Levin
2026-07-13 22:07   ` Colton Lewis

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=20260709224617.761791F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=coltonlewis@google.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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