Skip to contentSkip to conversation

KVM: arm64: Don't use FIELD_PREP() in initialisers

PATCH Applied Marc Zyngier 2 participants 2 messages Nov 25, 2025

Subsystems (3)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: Don't use FIELD_PREP() in initialisers

Nathan reports that compiling with CONFIG_PTDUMP_STAGE2_DEBUGFS results in a compilation failure, with the compiler moaning about "braced-group within expression allowed only inside a function"...

Replace FIELD_PREP() with its shifting primitive, which does the trick here.

Fixes 81e9fe5c6f25d ("KVM: arm64: Teach ptdump about FEAT_XNX permissions")
---
 arch/arm64/kvm/ptdump.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kvm/ptdump.c +4 -4
index bd722383d0e3f..6cbe018fd6fda 100644
@@ -46,22 +46,22 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = {
 	},
 	{
 		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
-		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b00),
+		.val	= 0b00UL << __bf_shf(KVM_PTE_LEAF_ATTR_HI_S2_XN),
 		.set	= "px ux ",
 	},
 	{
 		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
-		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b01),
+		.val	= 0b01UL << __bf_shf(KVM_PTE_LEAF_ATTR_HI_S2_XN),
 		.set	= "PXNux ",
 	},
 	{
 		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
-		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b10),
+		.val	= 0b10UL << __bf_shf(KVM_PTE_LEAF_ATTR_HI_S2_XN),
 		.set	= "PXNUXN",
 	},
 	{
 		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
-		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b11),
+		.val	= 0b11UL << __bf_shf(KVM_PTE_LEAF_ATTR_HI_S2_XN),
 		.set	= "px UXN",
 	},
 	{
Signature · 1 line
2.47.3
maintainer Applied
#1 lore raw
Quoted 8 lines · Marc Zyngier

Nathan reports that compiling with CONFIG_PTDUMP_STAGE2_DEBUGFS results in a compilation failure, with the compiler moaning about "braced-group within expression allowed only inside a function"...

Replace FIELD_PREP() with its shifting primitive, which does the trick here.

[...]

Applied to next, thanks!

[1/1] KVM: arm64: Don't use FIELD_PREP() in initialisers

      https://git.kernel.org/kvmarm/kvmarm/c/5742f3650013

--
Best,
Oliver