* [PATCH] KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests
@ 2026-10-16 8:15 Fuad Tabba
2026-10-16 10:10 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Fuad Tabba @ 2026-10-16 8:15 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton
Cc: Joey Gouly, Suzuki K Poulose, Zenghui Yu, Steffen Eiden,
Catalin Marinas, Will Deacon, Mark Rutland, Fuad Tabba, kvmarm,
linux-arm-kernel, linux-kernel
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@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)
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests
2026-10-16 8:15 [PATCH] KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests Fuad Tabba
@ 2026-10-16 10:10 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2026-10-16 10:10 UTC (permalink / raw)
To: Fuad Tabba
Cc: Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Steffen Eiden, Catalin Marinas, Will Deacon, Mark Rutland,
Fuad Tabba, kvmarm, linux-arm-kernel, linux-kernel
On Fri, 16 Oct 2026 09:15:58 +0100,
Fuad Tabba <fuad.tabba@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@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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-16 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 8:15 [PATCH] KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests Fuad Tabba
2026-10-16 10:10 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox