ANDROID: arm64: Disallow use of backported SYS_FIELD_*() access macros

These are dangerous because they assume mask macros are pre-shifted,
GENMASK style. Most of the masks in this kernel tree are not shifted.
Avoid accidental buggy backports in future by turning the SYS_FIELD
accessors into BUILD_BUG().

Signed-off-by: Keir Fraser <keirf@google.com>
Bug: 233588291
Fixes: 1bf4f91abe ("UPSTREAM: arm64/sysreg: Introduce helpers for access to sysreg fields")
Change-Id: I647a66d59279e69c916f66b42705fc20cd256fa8
This commit is contained in:
Keir Fraser
2023-01-16 17:03:33 +00:00
parent d87c96fad7
commit d41b9e441e

View File

@@ -1430,14 +1430,20 @@
par; \
})
/*
* Disallow any use of the following backported SYS_FIELD macros. They rely on
* use of pre-shifted masked (for example, as generated by GENMASK). Most of
* the masks defined in this tree are not shifted, making these macros subtly
* dangerous!
*/
#define SYS_FIELD_GET(reg, field, val) \
FIELD_GET(reg##_##field##_MASK, val)
BUILD_BUG()
#define SYS_FIELD_PREP(reg, field, val) \
FIELD_PREP(reg##_##field##_MASK, val)
BUILD_BUG()
#define SYS_FIELD_PREP_ENUM(reg, field, val) \
FIELD_PREP(reg##_##field##_MASK, reg##_##field##_##val)
BUILD_BUG()
#endif