arm64: Automatic system register definition generation
v6 cover arm64: Automatic system register definition generation
The arm64 kernel requires some metadata for each system register it may need to access. Currently we have:
* A SYS_<regname> definition which sorresponds to a sys_reg() macro. This is used both to look up a sysreg by encoding (e.g. in KVM), and also to generate code to access a sysreg where the assembler is unaware of the specific sysreg encoding.
Where assemblers support the S3_<op1>_C<crn>_C<crm>_<op2> syntax for system registers, we could use this rather than manually assembling the instructions. However, we don't have consistent definitions for these and we currently still need to handle toolchains that lack this feature.
* A set of <regname>_<fieldname>_SHIFT and <regname>_<fieldname>_MASK definitions, which can be used to extract fields from the register, or to construct a register from a set of fields.
These do not follow the convention used by <linux/bitfield.h>, and the masks are not shifted into place, preventing their use in FIELD_PREP() and FIELD_GET(). We require the SHIFT definitions for inline assembly (and WIDTH definitions would be helpful for UBFX/SBFX), so we cannot only define a shifted MASK. Defining a SHIFT, WIDTH, shifted MASK and unshifted MASK is tedious and error-prone and life is much easier when they can be relied up to exist when writing code.
* A set of <regname>_<fieldname>_<valname> definitions for each enumerated value a field may hold. These are used when identifying the presence of features.
Atop of this, other code has to build up metadata at runtime (e.g. the sets of RES0/RES1 bits in a register). This patch series introduces a script which describes registers and the fields within them in a format that is easy to cross reference with the architecture reference manual and uses them to generate the constants we use in a standard format:
| #define REG_ID_AA64ISAR0_EL1 S3_0_C0_C6_0 | #define SYS_ID_AA64ISAR0_EL1 sys_reg(3, 0, 0, 6, 0) | #define SYS_ID_AA64ISAR0_EL1_Op0 3 | #define SYS_ID_AA64ISAR0_EL1_Op1 0 | #define SYS_ID_AA64ISAR0_EL1_CRn 0 | #define SYS_ID_AA64ISAR0_EL1_CRm 6 | #define SYS_ID_AA64ISAR0_EL1_Op2 0
| #define ID_AA64ISAR0_EL1_RNDR GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_MASK GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_SHIFT 60 | #define ID_AA64ISAR0_EL1_RNDR_WIDTH 4 | #define ID_AA64ISAR0_EL1_RNDR_NI UL(0b0000) | #define ID_AA64ISAR0_EL1_RNDR_IMP UL(0b0001)
This should be particularly useful for the ID registers where we will be able to specify just the register and field for more of the bitfield information, simplifying ARM64_FTR_BITS() and providing helpers for use in struct arm64_cpu_capabilities or for hwcaps.
For registers which have shared definitions (eg, registers that have versions with identical layouts at multiple ELs) we support defining a shared layout for those registers which is then referenced from the per register definition.
At the moment this is only intended to express metadata from the architecture, and does not handle policy imposed by the kernel, such as values exposed to userspace or VMs. In future this could be extended to express such information. This could also be extended to cover more information such as the FTR_SIGNED/FTR_UNSIGNED distinction. There is also currently no support for registers which change layout at runtime, for example based on virtualisation settings - these could be manually handled for the time being, or the script extended.
Rather than attempting to convert every register at once the current series converts a few sample registers to provide some concrete examples but allow for easier updating during review of the file format and the script. Handling a register at a time should also make review less taxing so it seems like a sensible approach in general.
The generation script was originally written by Mark Rutland and subsequently improved and integrated into the kernel build by me.
v6:
- Don't generate intermediate defines for individual RES0/1 bitfields, just emit GENMASK()s directly into the overall RES0/1 defines for the register.
v5:
- Introduce and use SYS_FIELD_PREP() and SYS_FIELD_PREP_ENUM().
- Use helper macros for SCTLR_ELx.TCF as well as TCF0.
- Rename sysreg-gen.h to sysreg-defs.h.
- Use UL rather than ULL.
- Implement a SharedLayout statement, currently as a noop.
- Fix checks to ensure regexps only match in the correct block in the script.
- Minor stylistic tweaks.
v4:
- Rebase onto v5.18-rc3.
v3:
- Rebase onto v5.18-rc1.
v2:
- Fix issue with building bounds.s in an O= build by renaming the generated header.
Mark Brown (11):
arm64/sysreg: Introduce helpers for access to sysreg fields arm64/mte: Make TCF0 naming and field values more standard arm64/mte: Make TCF field values and naming more standard arm64/sysreg: Rename SCTLR_EL1_NTWE/TWI to SCTLR_EL1_nTWE/TWI arm64/sysreg: Define bits for previously RES1 fields in SCTLR_EL1
arm64: Update name of ID_AA64ISAR0_EL1_ATOMIC to reflect ARM arm64/sysreg: Standardise ID_AA64ISAR0_EL1 macro names arm64/sysreg: Enable automatic generation of system register
definitions
arm64/sysreg: Generate definitions for ID_AA64ISAR0_EL1 arm64/sysreg: Generate definitions for TTBRn_EL1 arm64/sysreg: Generate definitions for SCTLR_EL1
Mark Rutland (1):
arm64: Add sysreg header generation scripting
arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/archrandom.h | 2 +- arch/arm64/include/asm/sysreg.h | 117 +++----- arch/arm64/kernel/cpufeature.c | 70 ++--- arch/arm64/kernel/mte.c | 15 +- .../arm64/kvm/hyp/include/nvhe/fixed_config.h | 28 +- arch/arm64/mm/fault.c | 3 +- arch/arm64/tools/Makefile | 8 +- arch/arm64/tools/gen-sysreg.awk | 261 ++++++++++++++++++ arch/arm64/tools/sysreg | 200 ++++++++++++++ 10 files changed, 570 insertions(+), 135 deletions(-) create mode 100755 arch/arm64/tools/gen-sysreg.awk create mode 100644 arch/arm64/tools/sysreg
base-commit: b2d229d4ddb17db541098b83524d901257e93845
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 1/12 arm64/sysreg: Introduce helpers for access to sysreg fields
The macros we define for the bitfields within sysregs have very regular names, especially once we switch to automatic generation of those macros. Take advantage of this to define wrappers around FIELD_PREP() allowing us to simplify setting values in fields either numerically
SYS_FIELD_PREP(SCTLR_EL1, TCF0, 0x0)
or using the values of enumerations within the fields
SYS_FIELD_PREP_ENUM(SCTLR_EL1, TCF0, ASYMM)
--- arch/arm64/include/asm/sysreg.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/include/asm/sysreg.h +6 -0
@@ -1345,4 +1345,10 @@#endif +#define SYS_FIELD_PREP (reg, field, val) \ + FIELD_PREP(reg##_##field##_MASK, val) + +#define SYS_FIELD_PREP_ENUM (reg, field, val) \ + FIELD_PREP(reg##_##field##_MASK, reg##_##field##_##val) +#endif /* __ASM_SYSREG_H */
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 2/12 arm64/mte: Make TCF0 naming and field values more standard
In reply to Mark BrownIn preparation for automatic generation of SCTLR_EL1 register definitions make the macros used to define SCTLR_EL1.TCF0 and the enumeration values it has more standard so they can be used with FIELD_PREP() via the newly defined SYS_FIELD_PREP_ helpers.
Since the field also exists in SCTLR_EL2 with the same values also rename the macros to SCTLR_ELx rather than SCTLR_EL1.
There should be no functional change as a result of this patch.
--- arch/arm64/include/asm/sysreg.h | 8 ++++---- arch/arm64/kernel/mte.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
arch/arm64/include/asm/sysreg.h +4 -4
@@ -678,10 +678,10 @@#define SCTLR_EL1_ATA0 (BIT(42))#define SCTLR_EL1_TCF0_SHIFT 38 -#define SCTLR_EL1_TCF0_NONE (UL(0x0) << SCTLR_EL1_TCF0_SHIFT) -#define SCTLR_EL1_TCF0_SYNC (UL(0x1) << SCTLR_EL1_TCF0_SHIFT) -#define SCTLR_EL1_TCF0_ASYNC (UL(0x2) << SCTLR_EL1_TCF0_SHIFT) -#define SCTLR_EL1_TCF0_ASYMM (UL(0x3) << SCTLR_EL1_TCF0_SHIFT) +#define SCTLR_EL1_TCF0_NONE (UL(0x0)) +#define SCTLR_EL1_TCF0_SYNC (UL(0x1)) +#define SCTLR_EL1_TCF0_ASYNC (UL(0x2)) +#define SCTLR_EL1_TCF0_ASYMM (UL(0x3))#define SCTLR_EL1_TCF0_MASK (UL(0x3) << SCTLR_EL1_TCF0_SHIFT)#define SCTLR_EL1_BT1 (BIT(36))
arch/arm64/kernel/mte.c +3 -3
@@ -216,11 +216,11 @@ static void mte_update_sctlr_user(struct task_struct *task)* default order. */ if (resolved_mte_tcf &MTE_CTRL_TCF_ASYMM ) - sctlr |=SCTLR_EL1_TCF0_ASYMM ; + sctlr |=SYS_FIELD_PREP_ENUM (SCTLR_EL1 ,TCF0 ,ASYMM );else if (resolved_mte_tcf &MTE_CTRL_TCF_ASYNC ) - sctlr |=SCTLR_EL1_TCF0_ASYNC ; + sctlr |=SYS_FIELD_PREP_ENUM (SCTLR_EL1 ,TCF0 ,ASYNC );else if (resolved_mte_tcf &MTE_CTRL_TCF_SYNC ) - sctlr |=SCTLR_EL1_TCF0_SYNC ; + sctlr |=SYS_FIELD_PREP_ENUM (SCTLR_EL1 ,TCF0 ,SYNC ); task->thread.sctlr_user = sctlr; }
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 3/12 arm64/mte: Make TCF field values and naming more standard
In reply to Mark BrownIn preparation for automatic generation of the defines for system registers make the values used for the enumeration in SCTLR_ELx.TCF suitable for use with the newly defined SYS_FIELD_PREP_ENUM helper, removing the shift from the define and using the helper to generate it on use instead. Since we only ever interact with this field in EL1 and in preparation for generation of the defines also rename from SCTLR_ELx to SCTLR_EL1. SCTLR_EL2 is not quite the same as SCTLR_EL1 so the conversion does not share the field definitions.
There should be no functional change from this patch.
--- arch/arm64/include/asm/sysreg.h | 14 +++++++------- arch/arm64/kernel/mte.c | 9 +++++---- arch/arm64/mm/fault.c | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-)
arch/arm64/include/asm/sysreg.h +7 -7
@@ -631,13 +631,6 @@#define SCTLR_ELx_DSSBS (BIT(44))#define SCTLR_ELx_ATA (BIT(43)) -#define SCTLR_ELx_TCF_SHIFT 40 -#define SCTLR_ELx_TCF_NONE (UL(0x0) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_SYNC (UL(0x1) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_ASYNC (UL(0x2) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_ASYMM (UL(0x3) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_MASK (UL(0x3) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_ENIA_SHIFT 31#define SCTLR_ELx_ITFSB (BIT(37))
@@ -677,6 +670,13 @@#define SCTLR_EL1_EPAN (BIT(57))#define SCTLR_EL1_ATA0 (BIT(42)) +#define SCTLR_EL1_TCF_SHIFT 40 +#define SCTLR_EL1_TCF_NONE (UL(0x0)) +#define SCTLR_EL1_TCF_SYNC (UL(0x1)) +#define SCTLR_EL1_TCF_ASYNC (UL(0x2)) +#define SCTLR_EL1_TCF_ASYMM (UL(0x3)) +#define SCTLR_EL1_TCF_MASK (UL(0x3) << SCTLR_EL1_TCF_SHIFT) +#define SCTLR_EL1_TCF0_SHIFT 38#define SCTLR_EL1_TCF0_NONE (UL(0x0))#define SCTLR_EL1_TCF0_SYNC (UL(0x1))
arch/arm64/kernel/mte.c +5 -4
@@ -106,7 +106,8 @@ int memcmp_pages(struct page *page1, struct page *page2)static inline void __mte_enable_kernel (const char *mode,unsigned long tcf) {/* Enable MTE Sync Mode for EL1. */ -sysreg_clear_set (sctlr_el1, SCTLR_ELx_TCF_MASK, tcf); +sysreg_clear_set (sctlr_el1,SCTLR_EL1_TCF_MASK , +SYS_FIELD_PREP (SCTLR_EL1 ,TCF , tcf));isb ();pr_info_once ("MTE: enabled in %s mode at EL1\n" , mode);
@@ -122,12 +123,12 @@ void mte_enable_kernel_sync(void)WARN_ONCE (system_uses_mte_async_or_asymm_mode (),"MTE async mode enabled system wide!" ); -__mte_enable_kernel ("synchronous" , SCTLR_ELx_TCF_SYNC); +__mte_enable_kernel ("synchronous" ,SCTLR_EL1_TCF_SYNC ); }void mte_enable_kernel_async (void ) { -__mte_enable_kernel ("asynchronous" , SCTLR_ELx_TCF_ASYNC); +__mte_enable_kernel ("asynchronous" ,SCTLR_EL1_TCF_ASYNC );/* * MTE async mode is set system wide by the first PE that
@@ -144,7 +145,7 @@ void mte_enable_kernel_async(void)void mte_enable_kernel_asymm (void ) {if (cpus_have_cap (ARM64_MTE_ASYMM )) { -__mte_enable_kernel ("asymmetric" , SCTLR_ELx_TCF_ASYMM); +__mte_enable_kernel ("asymmetric" ,SCTLR_EL1_TCF_ASYMM );/* * MTE asymm mode behaves as async mode for store
arch/arm64/mm/fault.c +2 -1
@@ -335,7 +335,8 @@ static void do_tag_recovery(unsigned long addr, unsigned int esr,* It will be done lazily on the other CPUs when they will hit a * tag fault. */ -sysreg_clear_set (sctlr_el1, SCTLR_ELx_TCF_MASK, SCTLR_ELx_TCF_NONE); +sysreg_clear_set (sctlr_el1,SCTLR_EL1_TCF_MASK , +SYS_FIELD_PREP_ENUM (SCTLR_EL1 ,TCF ,NONE ));isb (); }
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v6 03/12] arm64/mte: Make TCF field values and naming more standard
Quoted 9 lines · Mark Brown
In preparation for automatic generation of the defines for system registers make the values used for the enumeration in SCTLR_ELx.TCF suitable for use with the newly defined
SYS_FIELD_PREP_ENUMhelper, removing the shift from the define and using the helper to generate it on use instead. Since we only ever interact with this field in EL1 and in preparation for generation of the defines also rename fromSCTLR_ELxtoSCTLR_EL1.SCTLR_EL2is not quite the same asSCTLR_EL1so the conversion does not share the field definitions.
Quoted 3 lines
There should be no functional change from this patch.
Signed-off-by Mark Brown <[email protected]>
Mark.
Quoted 93 lines
--- arch/arm64/include/asm/sysreg.h | 14 +++++++------- arch/arm64/kernel/mte.c | 9 +++++---- arch/arm64/mm/fault.c | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-)arch/arm64/include/asm/sysreg.h +7
-7@@ -631,13 +631,6 @@#define SCTLR_ELx_DSSBS (BIT(44))#define SCTLR_ELx_ATA (BIT(43)) -#define SCTLR_ELx_TCF_SHIFT 40 -#define SCTLR_ELx_TCF_NONE (UL(0x0) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_SYNC (UL(0x1) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_ASYNC (UL(0x2) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_ASYMM (UL(0x3) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_TCF_MASK (UL(0x3) << SCTLR_ELx_TCF_SHIFT) -#define SCTLR_ELx_ENIA_SHIFT 31#define SCTLR_ELx_ITFSB (BIT(37))@@ -677,6 +670,13 @@#define SCTLR_EL1_EPAN (BIT(57))#define SCTLR_EL1_ATA0 (BIT(42)) +#define SCTLR_EL1_TCF_SHIFT 40 +#define SCTLR_EL1_TCF_NONE (UL(0x0)) +#define SCTLR_EL1_TCF_SYNC (UL(0x1)) +#define SCTLR_EL1_TCF_ASYNC (UL(0x2)) +#define SCTLR_EL1_TCF_ASYMM (UL(0x3)) +#define SCTLR_EL1_TCF_MASK (UL(0x3) << SCTLR_EL1_TCF_SHIFT) +#define SCTLR_EL1_TCF0_SHIFT 38#define SCTLR_EL1_TCF0_NONE (UL(0x0))#define SCTLR_EL1_TCF0_SYNC (UL(0x1))arch/arm64/kernel/mte.c +5
-4@@ -106,7 +106,8 @@ int memcmp_pages(struct page *page1, struct page *page2)static inline void __mte_enable_kernel (const char *mode,unsigned long tcf) {/* Enable MTE Sync Mode for EL1. */ -sysreg_clear_set (sctlr_el1, SCTLR_ELx_TCF_MASK, tcf); +sysreg_clear_set (sctlr_el1,SCTLR_EL1_TCF_MASK , +SYS_FIELD_PREP (SCTLR_EL1 ,TCF , tcf));isb ();pr_info_once ("MTE: enabled in %s mode at EL1\n" , mode);@@ -122,12 +123,12 @@ void mte_enable_kernel_sync(void)WARN_ONCE (system_uses_mte_async_or_asymm_mode (),"MTE async mode enabled system wide!" ); -__mte_enable_kernel ("synchronous" , SCTLR_ELx_TCF_SYNC); +__mte_enable_kernel ("synchronous" ,SCTLR_EL1_TCF_SYNC ); }void mte_enable_kernel_async (void ) { -__mte_enable_kernel ("asynchronous" , SCTLR_ELx_TCF_ASYNC); +__mte_enable_kernel ("asynchronous" ,SCTLR_EL1_TCF_ASYNC );/* * MTE async mode is set system wide by the first PE that @@ -144,7 +145,7 @@ void mte_enable_kernel_async(void)void mte_enable_kernel_asymm (void ) {if (cpus_have_cap (ARM64_MTE_ASYMM )) { -__mte_enable_kernel ("asymmetric" , SCTLR_ELx_TCF_ASYMM); +__mte_enable_kernel ("asymmetric" ,SCTLR_EL1_TCF_ASYMM );/* * MTE asymm mode behaves as async mode for store arch/arm64/mm/fault.c +2
-1@@ -335,7 +335,8 @@ static void do_tag_recovery(unsigned long addr, unsigned int esr,* It will be done lazily on the other CPUs when they will hit a * tag fault. */ -sysreg_clear_set (sctlr_el1, SCTLR_ELx_TCF_MASK, SCTLR_ELx_TCF_NONE); +sysreg_clear_set (sctlr_el1,SCTLR_EL1_TCF_MASK , +SYS_FIELD_PREP_ENUM (SCTLR_EL1 ,TCF ,NONE ));isb (); }Signature · 1 line
2.30.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 4/12 arm64/sysreg: Rename SCTLR_EL1_NTWE/TWI to SCTLR_EL1_nTWE/TWI
In reply to Mark BrownWe already use lower case in some defines in sysreg.h, for consistency with the architecture definition do so for SCTLR_EL1.nTWE and SCTLR_EL1.nTWI.
No functional change.
--- arch/arm64/include/asm/sysreg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/sysreg.h +3 -3
@@ -689,8 +689,8 @@#define SCTLR_EL1_UCI (BIT(26))#define SCTLR_EL1_E0E (BIT(24))#define SCTLR_EL1_SPAN (BIT(23)) -#define SCTLR_EL1_NTWE (BIT(18)) -#define SCTLR_EL1_NTWI (BIT(16)) +#define SCTLR_EL1_nTWE (BIT(18)) +#define SCTLR_EL1_nTWI (BIT(16))#define SCTLR_EL1_UCT (BIT(15))#define SCTLR_EL1_DZE (BIT(14))#define SCTLR_EL1_UMA (BIT(9))
@@ -714,7 +714,7 @@#define INIT_SCTLR_EL1_MMU_ON \ (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_SA0 | \ SCTLR_EL1_SED | SCTLR_ELx_I | SCTLR_EL1_DZE | SCTLR_EL1_UCT | \ - SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ + SCTLR_EL1_nTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_EPAN | SCTLR_EL1_RES1)/* MAIR_ELx memory attributes (used by Linux) */
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 5/12 arm64/sysreg: Define bits for previously RES1 fields in SCTLR_EL1
In reply to Mark BrownIn older revisions of the architecture SCTLR_EL1 contained several RES1 fields but in DDI0487H.a these now all have assigned functions. In preparation for automatically generating sysreg.h provide explicit definitions for all these bits and use them in the INIT_SCTLR_EL1_ macros where _RES1 was previously used.
There should be no functional change.
--- arch/arm64/include/asm/sysreg.h | 53 ++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 21 deletions(-)
arch/arm64/include/asm/sysreg.h +32 -21
@@ -633,19 +633,24 @@#define SCTLR_ELx_ENIA_SHIFT 31 -#define SCTLR_ELx_ITFSB (BIT(37)) -#define SCTLR_ELx_ENIA (BIT(SCTLR_ELx_ENIA_SHIFT)) -#define SCTLR_ELx_ENIB (BIT(30)) -#define SCTLR_ELx_ENDA (BIT(27)) -#define SCTLR_ELx_EE (BIT(25)) -#define SCTLR_ELx_IESB (BIT(21)) -#define SCTLR_ELx_WXN (BIT(19)) -#define SCTLR_ELx_ENDB (BIT(13)) -#define SCTLR_ELx_I (BIT(12)) -#define SCTLR_ELx_SA (BIT(3)) -#define SCTLR_ELx_C (BIT(2)) -#define SCTLR_ELx_A (BIT(1)) -#define SCTLR_ELx_M (BIT(0)) +#define SCTLR_ELx_ITFSB (BIT(37)) +#define SCTLR_ELx_ENIA (BIT(SCTLR_ELx_ENIA_SHIFT)) +#define SCTLR_ELx_ENIB (BIT(30)) +#define SCTLR_ELx_LSMAOE (BIT(29)) +#define SCTLR_ELx_nTLSMD (BIT(28)) +#define SCTLR_ELx_ENDA (BIT(27)) +#define SCTLR_ELx_EE (BIT(25)) +#define SCTLR_ELx_EIS (BIT(22)) +#define SCTLR_ELx_IESB (BIT(21)) +#define SCTLR_ELx_TSCXT (BIT(20)) +#define SCTLR_ELx_WXN (BIT(19)) +#define SCTLR_ELx_ENDB (BIT(13)) +#define SCTLR_ELx_I (BIT(12)) +#define SCTLR_ELx_EOS (BIT(11)) +#define SCTLR_ELx_SA (BIT(3)) +#define SCTLR_ELx_C (BIT(2)) +#define SCTLR_ELx_A (BIT(1)) +#define SCTLR_ELx_M (BIT(0))/* SCTLR_EL2 specific flags. */ #define SCTLR_EL2_RES1 ((BIT(4)) | (BIT(5)) | (BIT(11)) | (BIT(16)) | \
@@ -686,22 +691,24 @@#define SCTLR_EL1_BT1 (BIT(36))#define SCTLR_EL1_BT0 (BIT(35)) +#define SCTLR_EL1_LSMAOE (BIT(29)) +#define SCTLR_EL1_nTLSMD (BIT(28))#define SCTLR_EL1_UCI (BIT(26))#define SCTLR_EL1_E0E (BIT(24))#define SCTLR_EL1_SPAN (BIT(23)) +#define SCTLR_EL1_EIS (BIT(22)) +#define SCTLR_EL1_TSCXT (BIT(20))#define SCTLR_EL1_nTWE (BIT(18))#define SCTLR_EL1_nTWI (BIT(16))#define SCTLR_EL1_UCT (BIT(15))#define SCTLR_EL1_DZE (BIT(14)) +#define SCTLR_EL1_EOS (BIT(11))#define SCTLR_EL1_UMA (BIT(9))#define SCTLR_EL1_SED (BIT(8))#define SCTLR_EL1_ITD (BIT(7))#define SCTLR_EL1_CP15BEN (BIT(5))#define SCTLR_EL1_SA0 (BIT(4)) -#define SCTLR_EL1_RES1 ((BIT(11)) | (BIT(20)) | (BIT(22)) | (BIT(28)) | \ - (BIT(29))) -#ifdef CONFIG_CPU_BIG_ENDIAN #define ENDIAN_SET_EL1 (SCTLR_EL1_E0E | SCTLR_ELx_EE)#else
@@ -709,13 +716,17 @@#endif #define INIT_SCTLR_EL1_MMU_OFF \ - (ENDIAN_SET_EL1 | SCTLR_EL1_RES1) + (ENDIAN_SET_EL1 | SCTLR_EL1_LSMAOE | SCTLR_EL1_nTLSMD | \ + SCTLR_EL1_EIS | SCTLR_EL1_TSCXT | SCTLR_EL1_EOS)#define INIT_SCTLR_EL1_MMU_ON \ - (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_SA0 | \ - SCTLR_EL1_SED | SCTLR_ELx_I | SCTLR_EL1_DZE | SCTLR_EL1_UCT | \ - SCTLR_EL1_nTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ - ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_EPAN | SCTLR_EL1_RES1) + (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | \ + SCTLR_EL1_SA0 | SCTLR_EL1_SED | SCTLR_ELx_I | \ + SCTLR_EL1_DZE | SCTLR_EL1_UCT | SCTLR_EL1_nTWE | \ + SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ + ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_EPAN | \ + SCTLR_EL1_LSMAOE | SCTLR_EL1_nTLSMD | SCTLR_EL1_EIS | \ + SCTLR_EL1_TSCXT | SCTLR_EL1_EOS)/* MAIR_ELx memory attributes (used by Linux) */ #define MAIR_ATTR_DEVICE_nGnRnE UL(0x00)
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v6 05/12] arm64/sysreg: Define bits for previously RES1 fields in SCTLR_EL1
Quoted 9 lines · Mark Brown
In older revisions of the architecture
SCTLR_EL1contained several RES1 fields but in DDI0487H.a these now all have assigned functions. In preparation for automatically generatingsysreg.hprovide explicit definitions for all these bits and use them in theINIT_SCTLR_EL1_macros where_RES1was previously used.There should be no functional change.
Signed-off-by Mark Brown <[email protected]>
AFAICT all the bits are good, and there should be no functional change:
Mark.
Quoted 100 lines
--- arch/arm64/include/asm/sysreg.h | 53 ++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 21 deletions(-)arch/arm64/include/asm/sysreg.h +32
-21@@ -633,19 +633,24 @@#define SCTLR_ELx_ENIA_SHIFT 31 -#define SCTLR_ELx_ITFSB (BIT(37)) -#define SCTLR_ELx_ENIA (BIT(SCTLR_ELx_ENIA_SHIFT)) -#define SCTLR_ELx_ENIB (BIT(30)) -#define SCTLR_ELx_ENDA (BIT(27)) -#define SCTLR_ELx_EE (BIT(25)) -#define SCTLR_ELx_IESB (BIT(21)) -#define SCTLR_ELx_WXN (BIT(19)) -#define SCTLR_ELx_ENDB (BIT(13)) -#define SCTLR_ELx_I (BIT(12)) -#define SCTLR_ELx_SA (BIT(3)) -#define SCTLR_ELx_C (BIT(2)) -#define SCTLR_ELx_A (BIT(1)) -#define SCTLR_ELx_M (BIT(0)) +#define SCTLR_ELx_ITFSB (BIT(37)) +#define SCTLR_ELx_ENIA (BIT(SCTLR_ELx_ENIA_SHIFT)) +#define SCTLR_ELx_ENIB (BIT(30)) +#define SCTLR_ELx_LSMAOE (BIT(29)) +#define SCTLR_ELx_nTLSMD (BIT(28)) +#define SCTLR_ELx_ENDA (BIT(27)) +#define SCTLR_ELx_EE (BIT(25)) +#define SCTLR_ELx_EIS (BIT(22)) +#define SCTLR_ELx_IESB (BIT(21)) +#define SCTLR_ELx_TSCXT (BIT(20)) +#define SCTLR_ELx_WXN (BIT(19)) +#define SCTLR_ELx_ENDB (BIT(13)) +#define SCTLR_ELx_I (BIT(12)) +#define SCTLR_ELx_EOS (BIT(11)) +#define SCTLR_ELx_SA (BIT(3)) +#define SCTLR_ELx_C (BIT(2)) +#define SCTLR_ELx_A (BIT(1)) +#define SCTLR_ELx_M (BIT(0))/* SCTLR_EL2 specific flags. */ #define SCTLR_EL2_RES1 ((BIT(4)) | (BIT(5)) | (BIT(11)) | (BIT(16)) | \@@ -686,22 +691,24 @@#define SCTLR_EL1_BT1 (BIT(36))#define SCTLR_EL1_BT0 (BIT(35)) +#define SCTLR_EL1_LSMAOE (BIT(29)) +#define SCTLR_EL1_nTLSMD (BIT(28))#define SCTLR_EL1_UCI (BIT(26))#define SCTLR_EL1_E0E (BIT(24))#define SCTLR_EL1_SPAN (BIT(23)) +#define SCTLR_EL1_EIS (BIT(22)) +#define SCTLR_EL1_TSCXT (BIT(20))#define SCTLR_EL1_nTWE (BIT(18))#define SCTLR_EL1_nTWI (BIT(16))#define SCTLR_EL1_UCT (BIT(15))#define SCTLR_EL1_DZE (BIT(14)) +#define SCTLR_EL1_EOS (BIT(11))#define SCTLR_EL1_UMA (BIT(9))#define SCTLR_EL1_SED (BIT(8))#define SCTLR_EL1_ITD (BIT(7))#define SCTLR_EL1_CP15BEN (BIT(5))#define SCTLR_EL1_SA0 (BIT(4)) -#define SCTLR_EL1_RES1 ((BIT(11)) | (BIT(20)) | (BIT(22)) | (BIT(28)) | \ - (BIT(29))) -#ifdef CONFIG_CPU_BIG_ENDIAN #define ENDIAN_SET_EL1 (SCTLR_EL1_E0E | SCTLR_ELx_EE)#else @@ -709,13 +716,17 @@#endif #define INIT_SCTLR_EL1_MMU_OFF \ - (ENDIAN_SET_EL1 | SCTLR_EL1_RES1) + (ENDIAN_SET_EL1 | SCTLR_EL1_LSMAOE | SCTLR_EL1_nTLSMD | \ + SCTLR_EL1_EIS | SCTLR_EL1_TSCXT | SCTLR_EL1_EOS)#define INIT_SCTLR_EL1_MMU_ON \ - (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_SA0 | \ - SCTLR_EL1_SED | SCTLR_ELx_I | SCTLR_EL1_DZE | SCTLR_EL1_UCT | \ - SCTLR_EL1_nTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ - ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_EPAN | SCTLR_EL1_RES1) + (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | \ + SCTLR_EL1_SA0 | SCTLR_EL1_SED | SCTLR_ELx_I | \ + SCTLR_EL1_DZE | SCTLR_EL1_UCT | SCTLR_EL1_nTWE | \ + SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ + ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_EPAN | \ + SCTLR_EL1_LSMAOE | SCTLR_EL1_nTLSMD | SCTLR_EL1_EIS | \ + SCTLR_EL1_TSCXT | SCTLR_EL1_EOS)/* MAIR_ELx memory attributes (used by Linux) */ #define MAIR_ATTR_DEVICE_nGnRnE UL(0x00)Signature · 1 line
2.30.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 6/12 arm64: Update name of ID_AA64ISAR0_EL1_ATOMIC to reflect ARM
In reply to Mark BrownThe architecture reference manual refers to the field in bits 23:20 of ID_AA64ISAR0_EL1 with the name "atomic" but the kernel defines for this bitfield use the name "atomics". Bring the two into sync to make it easier to cross reference with the specification.
--- arch/arm64/include/asm/sysreg.h | 2 +- arch/arm64/kernel/cpufeature.c | 6 +++--- arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/arm64/include/asm/sysreg.h +1 -1
@@ -749,7 +749,7 @@#define ID_AA64ISAR0_SM3_SHIFT 36#define ID_AA64ISAR0_SHA3_SHIFT 32#define ID_AA64ISAR0_RDM_SHIFT 28 -#define ID_AA64ISAR0_ATOMICS_SHIFT 20 +#define ID_AA64ISAR0_ATOMIC_SHIFT 20#define ID_AA64ISAR0_CRC32_SHIFT 16#define ID_AA64ISAR0_SHA2_SHIFT 12#define ID_AA64ISAR0_SHA1_SHIFT 8
arch/arm64/kernel/cpufeature.c +3 -3
@@ -200,7 +200,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar0[] = {ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_SM3_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_SHA3_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_RDM_SHIFT ,4 ,0 ), -ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_ATOMICS_SHIFT ,4 ,0 ), +ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_ATOMIC_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_CRC32_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR0_SHA2_SHIFT ,4 ,0 ), ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_SHA1_SHIFT, 4, 0),
@@ -2013,7 +2013,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .type = ARM64_CPUCAP_SYSTEM_FEATURE, .matches = has_cpuid_feature, .sys_reg = SYS_ID_AA64ISAR0_EL1, - .field_pos = ID_AA64ISAR0_ATOMICS_SHIFT, + .field_pos = ID_AA64ISAR0_ATOMIC_SHIFT, .field_width = 4, .sign = FTR_UNSIGNED, .min_field_value = 2,
@@ -2520,7 +2520,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_SHA2_SHIFT ,4 ,FTR_UNSIGNED ,1 ,CAP_HWCAP ,KERNEL_HWCAP_SHA2 ),HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_SHA2_SHIFT ,4 ,FTR_UNSIGNED ,2 ,CAP_HWCAP ,KERNEL_HWCAP_SHA512 ),HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_CRC32_SHIFT ,4 ,FTR_UNSIGNED ,1 ,CAP_HWCAP ,KERNEL_HWCAP_CRC32 ), -HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_ATOMICS_SHIFT ,4 ,FTR_UNSIGNED ,2 ,CAP_HWCAP ,KERNEL_HWCAP_ATOMICS ), +HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_ATOMIC_SHIFT ,4 ,FTR_UNSIGNED ,2 ,CAP_HWCAP ,KERNEL_HWCAP_ATOMICS ),HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_RDM_SHIFT ,4 ,FTR_UNSIGNED ,1 ,CAP_HWCAP ,KERNEL_HWCAP_ASIMDRDM ),HWCAP_CAP (SYS_ID_AA64ISAR0_EL1 ,ID_AA64ISAR0_SHA3_SHIFT ,4 ,FTR_UNSIGNED ,1 ,CAP_HWCAP ,KERNEL_HWCAP_SHA3 ), HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_SM3_SHIFT, 4, FTR_UNSIGNED, 1, CAP_HWCAP, KERNEL_HWCAP_SM3),
arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +1 -1
@@ -163,7 +163,7 @@ARM64_FEATURE_MASK (ID_AA64ISAR0_SHA1 ) | \ARM64_FEATURE_MASK (ID_AA64ISAR0_SHA2 ) | \ARM64_FEATURE_MASK (ID_AA64ISAR0_CRC32 ) | \ -ARM64_FEATURE_MASK (ID_AA64ISAR0_ATOMICS ) | \ +ARM64_FEATURE_MASK (ID_AA64ISAR0_ATOMIC ) | \ARM64_FEATURE_MASK (ID_AA64ISAR0_RDM ) | \ARM64_FEATURE_MASK (ID_AA64ISAR0_SHA3 ) | \ ARM64_FEATURE_MASK(ID_AA64ISAR0_SM3) | \
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 7/12 arm64/sysreg: Standardise ID_AA64ISAR0_EL1 macro names
In reply to Mark BrownThe macros for accessing fields in ID_AA64ISAR0_EL1 omit the _EL1 from the name of the register. In preparation for converting this register to be automatically generated update the names to include an _EL1, there should be no functional change.
--- arch/arm64/include/asm/archrandom.h | 2 +- arch/arm64/include/asm/sysreg.h | 34 ++++----- arch/arm64/kernel/cpufeature.c | 70 +++++++++---------- .../arm64/kvm/hyp/include/nvhe/fixed_config.h | 28 ++++---- 4 files changed, 67 insertions(+), 67 deletions(-)
arch/arm64/include/asm/archrandom.h +1 -1
@@ -142,7 +142,7 @@ static inline bool __init __early_cpu_has_rndr(void) {/* Open code as we run prior to the first call to cpufeature. */ unsigned long ftr =read_sysreg_s (SYS_ID_AA64ISAR0_EL1 ); -return (ftr >>ID_AA64ISAR0_RNDR_SHIFT ) &0xf ; +return (ftr >>ID_AA64ISAR0_EL1_RNDR_SHIFT ) &0xf ; } static inline bool __init __must_check
arch/arm64/include/asm/sysreg.h +17 -17
@@ -740,23 +740,23 @@#define MAIR_ATTRIDX (attr, idx) ((attr) << ((idx) * 8))/* id_aa64isar0 */ -#define ID_AA64ISAR0_RNDR_SHIFT 60 -#define ID_AA64ISAR0_TLB_SHIFT 56 -#define ID_AA64ISAR0_TS_SHIFT 52 -#define ID_AA64ISAR0_FHM_SHIFT 48 -#define ID_AA64ISAR0_DP_SHIFT 44 -#define ID_AA64ISAR0_SM4_SHIFT 40 -#define ID_AA64ISAR0_SM3_SHIFT 36 -#define ID_AA64ISAR0_SHA3_SHIFT 32 -#define ID_AA64ISAR0_RDM_SHIFT 28 -#define ID_AA64ISAR0_ATOMIC_SHIFT 20 -#define ID_AA64ISAR0_CRC32_SHIFT 16 -#define ID_AA64ISAR0_SHA2_SHIFT 12 -#define ID_AA64ISAR0_SHA1_SHIFT 8 -#define ID_AA64ISAR0_AES_SHIFT 4 - -#define ID_AA64ISAR0_TLB_RANGE_NI 0x0 -#define ID_AA64ISAR0_TLB_RANGE 0x2 +#define ID_AA64ISAR0_EL1_RNDR_SHIFT 60 +#define ID_AA64ISAR0_EL1_TLB_SHIFT 56 +#define ID_AA64ISAR0_EL1_TS_SHIFT 52 +#define ID_AA64ISAR0_EL1_FHM_SHIFT 48 +#define ID_AA64ISAR0_EL1_DP_SHIFT 44 +#define ID_AA64ISAR0_EL1_SM4_SHIFT 40 +#define ID_AA64ISAR0_EL1_SM3_SHIFT 36 +#define ID_AA64ISAR0_EL1_SHA3_SHIFT 32 +#define ID_AA64ISAR0_EL1_RDM_SHIFT 28 +#define ID_AA64ISAR0_EL1_ATOMIC_SHIFT 20 +#define ID_AA64ISAR0_EL1_CRC32_SHIFT 16 +#define ID_AA64ISAR0_EL1_SHA2_SHIFT 12 +#define ID_AA64ISAR0_EL1_SHA1_SHIFT 8 +#define ID_AA64ISAR0_EL1_AES_SHIFT 4 + +#define ID_AA64ISAR0_EL1_TLB_RANGE_NI 0x0 +#define ID_AA64ISAR0_EL1_TLB_RANGE 0x2/* id_aa64isar1 */ #define ID_AA64ISAR1_I8MM_SHIFT 52
arch/arm64/kernel/cpufeature.c +35 -35
108 lines not on this page · raw message
arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +14 -14
@@ -159,20 +159,20 @@* No restrictions on instructions implemented in AArch64. */ #define PVM_ID_AA64ISAR0_ALLOW (\ - ARM64_FEATURE_MASK(ID_AA64ISAR0_AES) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_SHA1) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_SHA2) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_CRC32) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_ATOMIC) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_RDM) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_SHA3) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_SM3) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_SM4) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_DP) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_FHM) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_TS) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_TLB) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR0_RNDR) \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_AES) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_SHA1) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_SHA2) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_CRC32) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_ATOMIC) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_RDM) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_SHA3) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_SM3) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_SM4) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_DP) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_FHM) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_TS) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_TLB) | \ + ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_RNDR) \ )#define PVM_ID_AA64ISAR1_ALLOW (\
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 8/12 arm64: Add sysreg header generation scripting
In reply to Mark BrownFrom: Mark Rutland <[email protected]>
The arm64 kernel requires some metadata for each system register it may need to access. Currently we have:
* A SYS_<regname> definition which sorresponds to a sys_reg() macro. This is used both to look up a sysreg by encoding (e.g. in KVM), and also to generate code to access a sysreg where the assembler is unaware of the specific sysreg encoding.
Where assemblers support the S3_<op1>_C<crn>_C<crm>_<op2> syntax for system registers, we could use this rather than manually assembling the instructions. However, we don't have consistent definitions for these and we currently still need to handle toolchains that lack this feature.
* A set of <regname>_<fieldname>_SHIFT and <regname>_<fieldname>_MASK definitions, which can be used to extract fields from the register, or to construct a register from a set of fields.
These do not follow the convention used by <linux/bitfield.h>, and the masks are not shifted into place, preventing their use in FIELD_PREP() and FIELD_GET(). We require the SHIFT definitions for inline assembly (and WIDTH definitions would be helpful for UBFX/SBFX), so we cannot only define a shifted MASK. Defining a SHIFT, WIDTH, shifted MASK and unshifted MASK is tedious and error-prone and life is much easier when they can be relied up to exist when writing code.
* A set of <regname>_<fieldname>_<valname> definitions for each enumerated value a field may hold. These are used when identifying the presence of features.
Atop of this, other code has to build up metadata at runtime (e.g. the sets of RES0/RES1 bits in a register).
This patch adds scripting so that we can have an easier-to-manage canonical representation of this metadata, from which we can generate all the definitions necessary for various use-cases, e.g.
| #define REG_ID_AA64ISAR0_EL1 S3_0_C0_C6_0 | #define SYS_ID_AA64ISAR0_EL1 sys_reg(3, 0, 0, 6, 0) | #define SYS_ID_AA64ISAR0_EL1_Op0 3 | #define SYS_ID_AA64ISAR0_EL1_Op1 0 | #define SYS_ID_AA64ISAR0_EL1_CRn 0 | #define SYS_ID_AA64ISAR0_EL1_CRm 6 | #define SYS_ID_AA64ISAR0_EL1_Op2 0
| #define ID_AA64ISAR0_EL1_RNDR GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_MASK GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_SHIFT 60 | #define ID_AA64ISAR0_EL1_RNDR_WIDTH 4 | #define ID_AA64ISAR0_EL1_RNDR_NI UL(0b0000) | #define ID_AA64ISAR0_EL1_RNDR_IMP UL(0b0001)
The script requires that all bits in the register be specified and that there be no overlapping fields. This helps the script spot errors in the input but means that the few registers which change layout at runtime depending on things like virtualisation settings will need some manual handling. No actual register conversions are done here but a header for the register data with some documention of the format is provided.
For cases where multiple registers share a layout (eg, when identical controls are provided at multiple ELs) the register fields can be defined once and referenced from the actual registers, currently we do not generate actual defines for the individual registers.
At the moment this is only intended to express metadata from the architecture, and does not handle policy imposed by the kernel, such as values exposed to userspace or VMs. In future this could be extended to express such information.
This script was mostly written by Mark Rutland but has been extended by Mark Brown to improve validation of input and better integrate with the kernel.
--- arch/arm64/tools/gen-sysreg.awk | 261 ++++++++++++++++++++++++++++++++ arch/arm64/tools/sysreg | 48 ++++++ 2 files changed, 309 insertions(+) create mode 100755 arch/arm64/tools/gen-sysreg.awk create mode 100644 arch/arm64/tools/sysreg
arch/arm64/tools/gen-sysreg.awk new file +261 -0
@@ -0,0 +1,261 @@ +#!/bin/awk -f +# SPDX-License-Identifier: GPL-2.0 +# gen-sysreg.awk: arm64 sysreg header generator +# +# Usage: awk -f gen-sysreg.awk sysregs.txt + +# Log an error and terminate +function fatal(msg) { + print "Error at " NR ": " msg > "/dev/stderr" + exit 1 +} + +# Sanity check that the start or end of a block makes sense at this point in +# the file. If not, produce an error and terminate. +# +# @this - the $Block or $EndBlock +# @prev - the only valid block to already be in (value of @block) +# @new - the new value of @block +function change_block(this, prev, new) { + if (block != prev) + fatal("unexpected " this " (inside " block ")") + + block = new +} + +# Sanity check the number of records for a field makes sense. If not, produce +# an error and terminate. +function expect_fields(nf) { + if (NF != nf) + fatal(NF " fields found where " nf " expected") +} + +# Print a CPP macro definition, padded with spaces so that the macro bodies +# line up in a column +function define(name, val) { + printf "%-48s%s\n", "#define " name, val +} + +# Print standard BITMASK/SHIFT/WIDTH CPP definitions for a field +function define_field(reg, field, msb, lsb) { + define(reg "_" field, "GENMASK(" msb ", " lsb ")") + define(reg "_" field "_MASK", "GENMASK(" msb ", " lsb ")") + define(reg "_" field "_SHIFT", lsb) + define(reg "_" field "_WIDTH", msb - lsb + 1) +} + +# Parse a "<msb>[:<lsb>]" string into the global variables @msb and @lsb +function parse_bitdef(reg, field, bitdef, _bits) +{ + if (bitdef ~ /^[0-9]+$/) { + msb = bitdef + lsb = bitdef + } else if (split(bitdef, _bits, ":") == 2) { + msb = _bits[1] + lsb = _bits[2] + } else { + fatal("invalid bit-range definition '" bitdef "'") + } + + + if (msb != next_bit) + fatal(reg "." field " starts at " msb " not " next_bit) + if (63 < msb || msb < 0) + fatal(reg "." field " invalid high bit in '" bitdef "'") + if (63 < lsb || lsb < 0) + fatal(reg "." field " invalid low bit in '" bitdef "'") + if (msb < lsb) + fatal(reg "." field " invalid bit-range '" bitdef "'") + if (low > high) + fatal(reg "." field " has invalid range " high "-" low) + + next_bit = lsb - 1 +} + +BEGIN { + print "#ifndef __ASM_SYSREG_DEFS_H" + print "#define __ASM_SYSREG_DEFS_H" + print "" + print "/* Generated file - do not edit */" + + block = "None" +} + +END { + print "#endif /* __ASM_SYSREG_DEFS_H */" +} + +# skip blank lines and comment lines +/^$/ { next } +/^#/ { next } + +/^SysregFields/ { + change_block("SysregFields", "None", "SysregFields") + expect_fields(2) + + reg = $2 + + res0 = "UL(0)" + res1 = "UL(0)" + + print "" + + next_bit = 63 + + next +} + +/^EndSysregFields/ { + if (next_bit > 0) + fatal("Unspecified bits in " reg) + + change_block("EndSysregFields", "SysregFields", "None") + + define(reg "_RES0", "(" res0 ")") + define(reg "_RES1", "(" res1 ")") + print "" + + reg = null + res0 = null + res1 = null + + next +} + +/^Sysreg/ { + change_block("Sysreg", "None", "Sysreg") + expect_fields(7) + + reg = $2 + op0 = $3 + op1 = $4 + crn = $5 + crm = $6 + op2 = $7 + + res0 = "UL(0)" + res1 = "UL(0)" + + define("REG_" reg, "S" op0 "_" op1 "_C" crn "_C" crm "_" op2) + define("SYS_" reg, "sys_reg(" op0 ", " op1 ", " crn ", " crm ", " op2 ")") + + define("SYS_" reg "_Op0", op0) + define("SYS_" reg "_Op1", op1) + define("SYS_" reg "_CRn", crn) + define("SYS_" reg "_CRm", crm) + define("SYS_" reg "_Op2", op2) + + print "" + + next_bit = 63 + + next +} + +/^EndSysreg/ { + if (next_bit > 0) + fatal("Unspecified bits in " reg) + + change_block("EndSysreg", "Sysreg", "None") + + if (res0 != null) + define(reg "_RES0", "(" res0 ")") + if (res1 != null) + define(reg "_RES1", "(" res1 ")") + print "" + + reg = null + op0 = null + op1 = null + crn = null + crm = null + op2 = null + res0 = null + res1 = null + + next +} + +# Currently this is effectivey a comment, in future we may want to emit +# defines for the fields. +/^Fields/ && (block == "Sysreg") { + expect_fields(2) + + if (next_bit != 63) + fatal("Some fields already defined for " reg) + + print "/* See " $2 " */" + print "" + + next_bit = 0 + res0 = null + res1 = null + + next +} + + +/^Res0/ && (block == "Sysreg" || block == "SysregFields") { + expect_fields(2) + parse_bitdef(reg, "RES0", $2) + field = "RES0_" msb "_" lsb + + res0 = res0 " | GENMASK_ULL(" msb ", " lsb ")" + + next +} + +/^Res1/ && (block == "Sysreg" || block == "SysregFields") { + expect_fields(2) + parse_bitdef(reg, "RES1", $2) + field = "RES1_" msb "_" lsb + + res1 = res1 " | GENMASK_ULL(" msb ", " lsb ")" + + next +} + +/^Field/ && (block == "Sysreg" || block == "SysregFields") { + expect_fields(3) + field = $3 + parse_bitdef(reg, field, $2) + + define_field(reg, field, msb, lsb) + print "" + + next +} + +/^Enum/ { + change_block("Enum", "Sysreg", "Enum") + expect_fields(3) + field = $3 + parse_bitdef(reg, field, $2) + + define_field(reg, field, msb, lsb) + + next +} + +/^EndEnum/ { + change_block("EndEnum", "Enum", "Sysreg") + field = null + msb = null + lsb = null + print "" + next +} + +/0b[01]+/ && block = "Enum" { + expect_fields(2) + val = $1 + name = $2 + + define(reg "_" field "_" name, "UL(" val ")") + next +} + +# Any lines not handled by previous rules are unexpected +{ + fatal("unhandled statement") +}
arch/arm64/tools/sysreg new file +48 -0
48 lines not on this page · raw message
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 9/12 arm64/sysreg: Enable automatic generation of system register definitions
In reply to Mark BrownNow that we have a script for generating system registers hook it up to the build system similarly to cpucaps. Since we don't currently have any actual register information in the input file this should produce no change in the built kernel. For ease of review the register information will be converted in separate patches.
--- arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/sysreg.h | 8 ++++++++ arch/arm64/tools/Makefile | 8 +++++++- 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm64/include/asm/Kbuild +1 -0
@@ -7,3 +7,4 @@ generic-y += parport.h generic-y += user.h generated-y += cpucaps.h +generated-y += sysreg-defs.h
arch/arm64/include/asm/sysreg.h +8 -0
@@ -114,6 +114,14 @@#define SYS_DC_CSW sys_insn(1, 0, 7, 10, 2)#define SYS_DC_CISW sys_insn(1, 0, 7, 14, 2) +/* +* Automatically generated definitions for system registers, the +* manual encodings below are in the process of being converted to +* come from here. The header relies on the definition of sys_reg() +* earlier in this file. +*/ +#include "asm/sysreg-defs.h" +/* * System registers, organised loosely by encoding but grouped together * where the architected name contains an index. e.g. ID_MMFR<n>_EL1.
arch/arm64/tools/Makefile +7 -1
@@ -3,7 +3,7 @@ gen := arch/$(ARCH)/include/generated kapi := $(gen)/asm -kapi-hdrs-y := $(kapi)/cpucaps.h +kapi-hdrs-y := $(kapi)/cpucaps.h $(kapi)/sysreg-defs.h targets += $(addprefix ../../../, $(kapi-hdrs-y))
@@ -14,5 +14,11 @@ kapi: $(kapi-hdrs-y) quiet_cmd_gen_cpucaps = GEN $@ cmd_gen_cpucaps = mkdir -p $(dir $@); $(AWK) -f $(real-prereqs) > $@ +quiet_cmd_gen_sysreg = GEN $@ + cmd_gen_sysreg = mkdir -p $(dir $@); $(AWK) -f $(real-prereqs) > $@ + $(kapi)/cpucaps.h: $(src)/gen-cpucaps.awk $(src)/cpucaps FORCE $(call if_changed,gen_cpucaps) + +$(kapi)/sysreg-defs.h: $(src)/gen-sysreg.awk $(src)/sysreg FORCE + $(call if_changed,gen_sysreg)
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 10/12 arm64/sysreg: Generate definitions for ID_AA64ISAR0_EL1
In reply to Mark BrownRemove the manual definitions for ID_AA64ISAR0_EL1 in favour of automatic generation. There should be no functional change. The only notable change is that 27:24 TME is defined rather than RES0 reflecting DDI0487H.a.
--- arch/arm64/include/asm/sysreg.h | 20 ---------- arch/arm64/tools/sysreg | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 20 deletions(-)
arch/arm64/include/asm/sysreg.h +0 -20
@@ -196,7 +196,6 @@#define SYS_ID_AA64AFR0_EL1 sys_reg(3, 0, 0, 5, 4)#define SYS_ID_AA64AFR1_EL1 sys_reg(3, 0, 0, 5, 5) -#define SYS_ID_AA64ISAR0_EL1 sys_reg(3, 0, 0, 6, 0)#define SYS_ID_AA64ISAR1_EL1 sys_reg(3, 0, 0, 6, 1)#define SYS_ID_AA64ISAR2_EL1 sys_reg(3, 0, 0, 6, 2)
@@ -747,25 +746,6 @@/* Position the attr at the correct index */ #define MAIR_ATTRIDX (attr, idx) ((attr) << ((idx) * 8)) -/* id_aa64isar0 */ -#define ID_AA64ISAR0_EL1_RNDR_SHIFT 60 -#define ID_AA64ISAR0_EL1_TLB_SHIFT 56 -#define ID_AA64ISAR0_EL1_TS_SHIFT 52 -#define ID_AA64ISAR0_EL1_FHM_SHIFT 48 -#define ID_AA64ISAR0_EL1_DP_SHIFT 44 -#define ID_AA64ISAR0_EL1_SM4_SHIFT 40 -#define ID_AA64ISAR0_EL1_SM3_SHIFT 36 -#define ID_AA64ISAR0_EL1_SHA3_SHIFT 32 -#define ID_AA64ISAR0_EL1_RDM_SHIFT 28 -#define ID_AA64ISAR0_EL1_ATOMIC_SHIFT 20 -#define ID_AA64ISAR0_EL1_CRC32_SHIFT 16 -#define ID_AA64ISAR0_EL1_SHA2_SHIFT 12 -#define ID_AA64ISAR0_EL1_SHA1_SHIFT 8 -#define ID_AA64ISAR0_EL1_AES_SHIFT 4 - -#define ID_AA64ISAR0_EL1_TLB_RANGE_NI 0x0 -#define ID_AA64ISAR0_EL1_TLB_RANGE 0x2 -/* id_aa64isar1 */ #define ID_AA64ISAR1_I8MM_SHIFT 52#define ID_AA64ISAR1_DGH_SHIFT 48
arch/arm64/tools/sysreg +67 -0
70 lines not on this page · raw message
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 11/12 arm64/sysreg: Generate definitions for TTBRn_EL1
In reply to Mark BrownAutomatically generate definitions for accessing the TTBRn_EL1 registers, no functional change.
--- arch/arm64/include/asm/sysreg.h | 2 -- arch/arm64/tools/sysreg | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
arch/arm64/include/asm/sysreg.h +0 -2
@@ -212,8 +212,6 @@#define SYS_ZCR_EL1 sys_reg(3, 0, 1, 2, 0)#define SYS_TRFCR_EL1 sys_reg(3, 0, 1, 2, 1) -#define SYS_TTBR0_EL1 sys_reg(3, 0, 2, 0, 0) -#define SYS_TTBR1_EL1 sys_reg(3, 0, 2, 0, 1)#define SYS_TCR_EL1 sys_reg(3, 0, 2, 0, 2)#define SYS_APIAKEYLO_EL1 sys_reg(3, 0, 2, 1, 0)
arch/arm64/tools/sysreg +14 -0
@@ -113,3 +113,17 @@ Enum 7:4 AES EndEnum Res0 3:0 EndSysreg + +SysregFields TTBRx_EL1 +Field 63:48 ASID +Field 47:1 BADDR +Field 0 CnP +EndSysregFields + +Sysreg TTBR0_EL1 3 0 2 0 0 +Fields TTBRx_EL1 +EndSysreg + +Sysreg TTBR1_EL1 3 0 2 0 1 +Fields TTBRx_EL1 +EndSysreg
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 12/12 arm64/sysreg: Generate definitions for SCTLR_EL1
In reply to Mark BrownAutomatically generate register definitions for SCTLR_EL1. No functional change.
--- arch/arm64/include/asm/sysreg.h | 38 ------------------ arch/arm64/tools/sysreg | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 38 deletions(-)
arch/arm64/include/asm/sysreg.h +0 -38
@@ -203,7 +203,6 @@#define SYS_ID_AA64MMFR1_EL1 sys_reg(3, 0, 0, 7, 1)#define SYS_ID_AA64MMFR2_EL1 sys_reg(3, 0, 0, 7, 2) -#define SYS_SCTLR_EL1 sys_reg(3, 0, 1, 0, 0)#define SYS_ACTLR_EL1 sys_reg(3, 0, 1, 0, 1)#define SYS_CPACR_EL1 sys_reg(3, 0, 1, 0, 2)#define SYS_RGSR_EL1 sys_reg(3, 0, 1, 0, 5)
@@ -677,43 +676,6 @@ (SCTLR_EL2_RES1 |ENDIAN_SET_EL2 ) /* SCTLR_EL1 specific flags. */ -#define SCTLR_EL1_EPAN (BIT(57)) -#define SCTLR_EL1_ATA0 (BIT(42)) - -#define SCTLR_EL1_TCF_SHIFT 40 -#define SCTLR_EL1_TCF_NONE (UL(0x0)) -#define SCTLR_EL1_TCF_SYNC (UL(0x1)) -#define SCTLR_EL1_TCF_ASYNC (UL(0x2)) -#define SCTLR_EL1_TCF_ASYMM (UL(0x3)) -#define SCTLR_EL1_TCF_MASK (UL(0x3) << SCTLR_EL1_TCF_SHIFT) - -#define SCTLR_EL1_TCF0_SHIFT 38 -#define SCTLR_EL1_TCF0_NONE (UL(0x0)) -#define SCTLR_EL1_TCF0_SYNC (UL(0x1)) -#define SCTLR_EL1_TCF0_ASYNC (UL(0x2)) -#define SCTLR_EL1_TCF0_ASYMM (UL(0x3)) -#define SCTLR_EL1_TCF0_MASK (UL(0x3) << SCTLR_EL1_TCF0_SHIFT) - -#define SCTLR_EL1_BT1 (BIT(36)) -#define SCTLR_EL1_BT0 (BIT(35)) -#define SCTLR_EL1_LSMAOE (BIT(29)) -#define SCTLR_EL1_nTLSMD (BIT(28)) -#define SCTLR_EL1_UCI (BIT(26)) -#define SCTLR_EL1_E0E (BIT(24)) -#define SCTLR_EL1_SPAN (BIT(23)) -#define SCTLR_EL1_EIS (BIT(22)) -#define SCTLR_EL1_TSCXT (BIT(20)) -#define SCTLR_EL1_nTWE (BIT(18)) -#define SCTLR_EL1_nTWI (BIT(16)) -#define SCTLR_EL1_UCT (BIT(15)) -#define SCTLR_EL1_DZE (BIT(14)) -#define SCTLR_EL1_EOS (BIT(11)) -#define SCTLR_EL1_UMA (BIT(9)) -#define SCTLR_EL1_SED (BIT(8)) -#define SCTLR_EL1_ITD (BIT(7)) -#define SCTLR_EL1_CP15BEN (BIT(5)) -#define SCTLR_EL1_SA0 (BIT(4)) -#ifdef CONFIG_CPU_BIG_ENDIAN #define ENDIAN_SET_EL1 (SCTLR_EL1_E0E | SCTLR_ELx_EE)#else
arch/arm64/tools/sysreg +71 -0
77 lines not on this page · raw message
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerRe: [PATCH v6 12/12] arm64/sysreg: Generate definitions for SCTLR_EL1
arch/arm64/tools/sysreg EndEnum · line 117
Quoted 6 lines · Mark Brown
Automatically generate register definitions for
SCTLR_EL1. No functional change.arch/arm64/tools/sysreg +1
-1-#define SYS_SCTLR_EL1 sys_reg(3, 0, 1, 0, 0) +Sysreg SCTLR_EL1 3 0 1 9 9
Looks like the 0s got replaced with 9s somehow?
I guess at EL1 we happen to get away with that being completely wrong since we'll use the assembler's version of the register definition, and only KVM notices.
I'll go make my boot scripts test EL2 as well...
Thanks,
Mark.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v6 12/12] arm64/sysreg: Generate definitions for SCTLR_EL1
Quoted 6 lines · Mark Rutland
Quoted 4 lines · Mark Brown
Automatically generate register definitions for
SCTLR_EL1. No functional change.-#define
SYS_SCTLR_EL1sys_reg(3, 0, 1, 0, 0)
Quoted 7 lines
Quoted 1 line
+Sysreg
SCTLR_EL13 0 1 9 9Looks like the 0s got replaced with 9s somehow?
I guess at EL1 we happen to get away with that being completely wrong since we'll use the assembler's version of the register definition, and only KVM notices.
Ah, indeed - that'll just have been a typo when I originally entered things.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerRe: [PATCH v6 12/12] arm64/sysreg: Generate definitions for SCTLR_EL1
Quoted 9 lines · Mark Brown
Quoted 7 lines · Mark Rutland
Quoted 6 lines · Mark Brown
Automatically generate register definitions for
SCTLR_EL1. No functional change.arch/arm64/tools/sysreg +1
-1-#define SYS_SCTLR_EL1 sys_reg(3, 0, 1, 0, 0) +Sysreg SCTLR_EL1 3 0 1 9 9
Quoted 8 lines
Quoted 5 lines
Looks like the 0s got replaced with 9s somehow?
I guess at EL1 we happen to get away with that being completely wrong since we'll use the assembler's version of the register definition, and only KVM notices.
Ah, indeed - that'll just have been a typo when I originally entered things.
I'll fix it in place, I haven't pushed the branch out yet. Thanks both for confirming.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 4 lines · Mark Brown
This patch series introduces a
script which describes registers and the fields within them in a format that is easy to cross reference with the architecture reference manual and uses them to generate the constants we use in a standard format:
Something went wrong since v5, likely some encoding is wrong:
kvm [1]: sys_reg table (____ptrval____) out of order (138)
------------[ cut here ]------------ kernel BUG at arch/arm64/kvm/sys_regs.c:2869! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.18.0-rc3-00012-g0cabf2a94034 #1 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 pstate: 62400005 (nZCv daif +PAN -UAO +TCO -DIT -SSBS BTYPE=--) pc : kvm_sys_reg_table_init+0x138/0x170 lr : kvm_sys_reg_table_init+0x24/0x170
sp : ffff80000801bc90
x29: ffff80000801bc90 x28: 0000000000000000 x27: 0000000000000001
x26: 0000000000000e58 x25: 0000000000000100 x24: 0000000000000004
x23: ffffa2429433d000 x22: ffffa24294879a38 x21: ffffa24294879c80
x20: ffffa24294879a58 x19: ffffa24294bb65e8 x18: ffffffffffffffff
x17: 0000000000000003 x16: 00000000000001f7 x15: ffff80008801b9a7
x14: 0000000000000000 x13: ffffa242948924a0 x12: 0000000000000285
x11: 00000000000000d7 x10: ffffa242948ea4a0 x9 : ffffa242948924a0 x8 : 00000000ffffefff x7 : ffffa242948ea4a0 x6 : 0000000000000000 x5 : 000000000000bff4 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : ffff000000088000 x0 : 0000000000000001
Call trace: kvm_sys_reg_table_init+0x138/0x170 kvm_arch_init+0x904/0xd70 kvm_init+0x38/0x3a4 arm_init+0x20/0x30 do_one_initcall+0x50/0x1c0 kernel_init_freeable+0x208/0x28c kernel_init+0x28/0x13c ret_from_fork+0x10/0x20
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Mark Brown
The arm64 kernel requires some metadata for each system register it may need to access. Currently we have:
* A SYS_<regname> definition which sorresponds to a
sys_reg()macro. This is used both to look up a sysreg by encoding (e.g. in KVM), and also to generate code to access a sysreg where the assembler is unaware of the specific sysreg encoding.[...]
Applied to arm64 (for-next/sysreg-gen), thanks!
[01/12] arm64/sysreg: Introduce helpers for access to sysreg fields
https://git.kernel.org/arm64/c/e6a6b34f97ef [02/12] arm64/mte: Make TCF0 naming and field values more standard https://git.kernel.org/arm64/c/96f101a9eab4 [03/12] arm64/mte: Make TCF field values and naming more standard https://git.kernel.org/arm64/c/bc249e37b933 [04/12] arm64/sysreg: Rename SCTLR_EL1_NTWE/TWI to SCTLR_EL1_nTWE/TWI https://git.kernel.org/arm64/c/e4e6a9d5593c [05/12] arm64/sysreg: Define bits for previously RES1 fields in SCTLR_EL1 https://git.kernel.org/arm64/c/56eb621b8ab6 [06/12] arm64: Update name of ID_AA64ISAR0_EL1_ATOMIC to reflect ARM https://git.kernel.org/arm64/c/6329eb543d99 [07/12] arm64/sysreg: Standardise ID_AA64ISAR0_EL1 macro names https://git.kernel.org/arm64/c/0eda2ec48907 [08/12] arm64: Add sysreg header generation scripting https://git.kernel.org/arm64/c/66847e0618d7 [09/12] arm64/sysreg: Enable automatic generation of system register definitions https://git.kernel.org/arm64/c/c07d8017bceb [10/12] arm64/sysreg: Generate definitions for ID_AA64ISAR0_EL1 https://git.kernel.org/arm64/c/e33bb6461cd6 [11/12] arm64/sysreg: Generate definitions for TTBRn_EL1 https://git.kernel.org/arm64/c/41fde735062d [12/12] arm64/sysreg: Generate definitions for SCTLR_EL1 https://git.kernel.org/arm64/c/7a41a97b65ea
Signature · 7 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel