[PATCH] KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests

Marc Zyngier maz at kernel.org
Fri Oct 16 03:10:28 PDT 2026


On Fri, 16 Oct 2026 09:15:58 +0100,
Fuad Tabba <fuad.tabba at linux.dev> wrote:
> 
> KVM sets HCR_EL2.BSU to Inner Shareable for guests, so that a guest's
> barriers cover the TLB and I-cache invalidations that HCR_EL2.FB
> broadcasts. However, since HCR_BSU_IS became an alias of the generated
> HCR_EL2_BSU_IS, it is the unshifted field value 0b01, which sets bit
> 0 (VM, already set) and leaves BSU at 0b00. A guest's DSB NSH is then
> not required to wait for a broadcast TLBI to complete on other CPUs.
> 
> Build the field with SYS_FIELD_PREP_ENUM().
> 
> Fixes: d0f39259eff4 ("arm64: sysreg: Add layout for HCR_EL2")
> Signed-off-by: Fuad Tabba <fuad.tabba at linux.dev>
> ---
> Found while testing Marc's HCR cleanup [1]. Its patch 1 carries this
> line over as HCR_EL2_BSU_IS, so on top of this fix that hunk would
> keep SYS_FIELD_PREP_ENUM() instead. I can also rebase this on top of
> the series if that's easier.
> 
> [1] https://lore.kernel.org/r/20261015173605.1072963-1-maz@kernel.org
> 
>  arch/arm64/include/asm/kvm_arm.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
> index 4bfbd827c5aa7..b3e9dd302730e 100644
> --- a/arch/arm64/include/asm/kvm_arm.h
> +++ b/arch/arm64/include/asm/kvm_arm.h
> @@ -98,7 +98,7 @@
>   * TID1:	Trap REVIDR_EL1, AIDR_EL1, and SMIDR_EL1
>   */
>  #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
> -			 HCR_BSU_IS | HCR_FB | HCR_TACR | \
> +			 SYS_FIELD_PREP_ENUM(HCR_EL2, BSU, IS) | HCR_EL2_FB | HCR_EL2_TACR | \
>  			 HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
>  			 HCR_FMO | HCR_IMO | HCR_PTW | HCR_TID3 | HCR_TID1)
>  #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK)

Huh. That's a bad one. I've added a Cc: stable to that, and queued it
as a prefix of the cleanup series.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list