Skip to content

Commit 53eaeb7

Browse files
Marc Zyngieroupton
authored andcommitted
arm64: Add macro to compose a sysreg field value
A common idiom is to compose a tupple (reg, field, val) into a symbol matching an autogenerated definition. Add a help performing the concatenation and replace it when open-coded implementations exist. Suggested-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 6613476 commit 53eaeb7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/arm64/include/asm/sysreg.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,14 +1181,17 @@
11811181
par; \
11821182
})
11831183

1184+
#define SYS_FIELD_VALUE(reg, field, val) reg##_##field##_##val
1185+
11841186
#define SYS_FIELD_GET(reg, field, val) \
11851187
FIELD_GET(reg##_##field##_MASK, val)
11861188

11871189
#define SYS_FIELD_PREP(reg, field, val) \
11881190
FIELD_PREP(reg##_##field##_MASK, val)
11891191

11901192
#define SYS_FIELD_PREP_ENUM(reg, field, val) \
1191-
FIELD_PREP(reg##_##field##_MASK, reg##_##field##_##val)
1193+
FIELD_PREP(reg##_##field##_MASK, \
1194+
SYS_FIELD_VALUE(reg, field, val))
11921195

11931196
#endif
11941197

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,8 @@ static u64 read_sanitised_id_aa64pfr0_el1(struct kvm_vcpu *vcpu,
16851685
u64 __f_val = FIELD_GET(reg##_##field##_MASK, val); \
16861686
(val) &= ~reg##_##field##_MASK; \
16871687
(val) |= FIELD_PREP(reg##_##field##_MASK, \
1688-
min(__f_val, (u64)reg##_##field##_##limit)); \
1688+
min(__f_val, \
1689+
(u64)SYS_FIELD_VALUE(reg, field, limit))); \
16891690
(val); \
16901691
})
16911692

0 commit comments

Comments
 (0)