arm64: Define name for the original RES1 bit but now functinal bit
cover arm64: Define name for the original RES1 bit but now functinal bit
According the talk[1], because the architecture get updated, what used to be a RES1 bit becomes a functinal bit. So we can define the name for these bits, this also increase the readability.
[1] lore.kernel.org/[email protected]
Shaoqin Huang (2):
arm64: Replace the SCTLR_EL1 filed definition by _BITUL()
arm64: Define name for the bits used in SCTLR_EL1_RES1
lib/arm64/asm/sysreg.h | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/2 arm64: Replace the SCTLR_EL1 filed definition by _BITUL()
Currently the SCTLR_EL1_* is defined by (1 << x), all of them can be replaced by the _BITUL() macro to make the format consistent with the SCTLR_EL1_RES1 definition.
--- lib/arm64/asm/sysreg.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/arm64/asm/sysreg.h +8 -8
@@ -80,14 +80,14 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ -#define SCTLR_EL1_EE (1 << 25) -#define SCTLR_EL1_WXN (1 << 19) -#define SCTLR_EL1_I (1 << 12) -#define SCTLR_EL1_SA0 (1 << 4) -#define SCTLR_EL1_SA (1 << 3) -#define SCTLR_EL1_C (1 << 2) -#define SCTLR_EL1_A (1 << 1) -#define SCTLR_EL1_M (1 << 0) +#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_WXN _BITUL(19) +#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_SA0 _BITUL(4) +#define SCTLR_EL1_SA _BITUL(3) +#define SCTLR_EL1_C _BITUL(2) +#define SCTLR_EL1_A _BITUL(1) +#define SCTLR_EL1_M _BITUL(0)#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29))
Signature · 1 line
2.39.1
Re: [kvm-unit-tests PATCH v1 1/2] arm64: Replace the SCTLR_EL1 filed definition by _BITUL()
Hi Shaoqin,
Quoted 3 lines · Shaoqin Huang
Currently the SCTLR_EL1_* is defined by (1 << x), all of them can be replaced by the
_BITUL()macro to make the format consistent with theSCTLR_EL1_RES1definition.
I would rephrase the commit title into arm64: Use _BITUL() to define SCTLR_EL1 bit fields
Besides, since SCTLR_EL1 is 64b shouldn't we have _BITULL() everywhere instead?
Eric
Quoted 33 lines
Signed-off-by Shaoqin Huang <[email protected]>--- lib/arm64/asm/sysreg.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)lib/arm64/asm/sysreg.h +8
-8@@ -80,14 +80,14 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ -#define SCTLR_EL1_EE (1 << 25) -#define SCTLR_EL1_WXN (1 << 19) -#define SCTLR_EL1_I (1 << 12) -#define SCTLR_EL1_SA0 (1 << 4) -#define SCTLR_EL1_SA (1 << 3) -#define SCTLR_EL1_C (1 << 2) -#define SCTLR_EL1_A (1 << 1) -#define SCTLR_EL1_M (1 << 0) +#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_WXN _BITUL(19) +#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_SA0 _BITUL(4) +#define SCTLR_EL1_SA _BITUL(3) +#define SCTLR_EL1_C _BITUL(2) +#define SCTLR_EL1_A _BITUL(1) +#define SCTLR_EL1_M _BITUL(0)#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29))
Re: [kvm-unit-tests PATCH v1 1/2] arm64: Replace the SCTLR_EL1 filed definition by _BITUL()
Hi Eric,
Quoted 10 lines · Eric Auger
Hi Shaoqin,
Quoted 3 lines · Shaoqin Huang
Currently the SCTLR_EL1_* is defined by (1 << x), all of them can be replaced by the
_BITUL()macro to make the format consistent with theSCTLR_EL1_RES1definition.I would rephrase the commit title into arm64: Use
_BITUL()to defineSCTLR_EL1bit fields
This would be good. I will change the title to it.
Quoted 2 lines
Besides, since
SCTLR_EL1is 64b shouldn't we have_BITULL()everywhere instead?
Yeah. Although the _BITUL() can cover the 64 bit value, it would be clear to use the _BITULL(), let me change it in next version.
Thanks,
Shaoqin
Quoted 36 lines
Eric
Quoted 33 lines
Signed-off-by Shaoqin Huang <[email protected]>--- lib/arm64/asm/sysreg.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)lib/arm64/asm/sysreg.h +8
-8@@ -80,14 +80,14 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ -#define SCTLR_EL1_EE (1 << 25) -#define SCTLR_EL1_WXN (1 << 19) -#define SCTLR_EL1_I (1 << 12) -#define SCTLR_EL1_SA0 (1 << 4) -#define SCTLR_EL1_SA (1 << 3) -#define SCTLR_EL1_C (1 << 2) -#define SCTLR_EL1_A (1 << 1) -#define SCTLR_EL1_M (1 << 0) +#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_WXN _BITUL(19) +#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_SA0 _BITUL(4) +#define SCTLR_EL1_SA _BITUL(3) +#define SCTLR_EL1_C _BITUL(2) +#define SCTLR_EL1_A _BITUL(1) +#define SCTLR_EL1_M _BITUL(0)#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29))
Signature · 1 line
Shaoqin
PATCH 2/2 arm64: Define name for the bits used in SCTLR_EL1_RES1
In reply to Shaoqin HuangCurrently some fields in SCTLR_EL1 don't define a name and directly used in the SCTLR_EL1_RES1, that's not good now since these fields have been functional and have a name.
According to the ARM DDI 0487J.a, define the name related to these fields.
--- lib/arm64/asm/sysreg.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
lib/arm64/asm/sysreg.h +11 -2
@@ -80,17 +80,26 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ +#define SCTLR_EL1_LSMAOE _BITUL(29) +#define SCTLR_EL1_NTLSMD _BITUL(28)#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_SPAN _BITUL(23) +#define SCTLR_EL1_EIS _BITUL(22) +#define SCTLR_EL1_TSCXT _BITUL(20)#define SCTLR_EL1_WXN _BITUL(19)#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_EOS _BITUL(11) +#define SCTLR_EL1_SED _BITUL(8) +#define SCTLR_EL1_ITD _BITUL(7)#define SCTLR_EL1_SA0 _BITUL(4)#define SCTLR_EL1_SA _BITUL(3)#define SCTLR_EL1_C _BITUL(2)#define SCTLR_EL1_A _BITUL(1)#define SCTLR_EL1_M _BITUL(0) -#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ - _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29)) +#define SCTLR_EL1_RES1 (SCTLR_EL1_ITD | SCTLR_EL1_SED | SCTLR_EL1_EOS | \ + SCTLR_EL1_TSCXT | SCTLR_EL1_EIS | SCTLR_EL1_SPAN | \ + SCTLR_EL1_NTLSMD | SCTLR_EL1_LSMAOE)#define INIT_SCTLR_EL1_MMU_OFF \ SCTLR_EL1_RES1
Signature · 1 line
2.39.1
Re: [kvm-unit-tests PATCH v1 2/2] arm64: Define name for the bits used in SCTLR_EL1_RES1
Quoted 8 lines · Shaoqin Huang
Currently some fields in
SCTLR_EL1don't define a name and directly used in theSCTLR_EL1_RES1, that's not good now since these fields have been functional and have a name.
Quoted 5 lines
According to the ARM DDI 0487J.a, define the name related to these fields.
Suggested-by Alexandru Elisei <[email protected]>Signed-off-by Shaoqin Huang <[email protected]>
Thanks for doing that!
While I debugged my SCTLR issue on EFI, I did try to grep “SPAN", and this patch would’ve certainly helped.
Re: [kvm-unit-tests PATCH v1 2/2] arm64: Define name for the bits used in SCTLR_EL1_RES1
In reply to Shaoqin HuangHi Shaoqin,
Quoted 36 lines · Shaoqin Huang
Currently some fields in
SCTLR_EL1don't define a name and directly used in theSCTLR_EL1_RES1, that's not good now since these fields have been functional and have a name.According to the ARM DDI 0487J.a, define the name related to these fields.
Suggested-by Alexandru Elisei <[email protected]>Signed-off-by Shaoqin Huang <[email protected]>--- lib/arm64/asm/sysreg.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)lib/arm64/asm/sysreg.h +8
-0@@ -80,17 +80,26 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ +#define SCTLR_EL1_LSMAOE _BITUL(29) +#define SCTLR_EL1_NTLSMD _BITUL(28)#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_SPAN _BITUL(23) +#define SCTLR_EL1_EIS _BITUL(22) +#define SCTLR_EL1_TSCXT _BITUL(20)#define SCTLR_EL1_WXN _BITUL(19)#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_EOS _BITUL(11) +#define SCTLR_EL1_SED _BITUL(8) +#define SCTLR_EL1_ITD _BITUL(7)#define SCTLR_EL1_SA0 _BITUL(4)#define SCTLR_EL1_SA _BITUL(3)#define SCTLR_EL1_C _BITUL(2)#define SCTLR_EL1_A _BITUL(1)
lib/arm64/asm/sysreg.h asm( · line 105
Quoted 10 lines
lib/arm64/asm/sysreg.h +3
-2#define SCTLR_EL1_M _BITUL(0) -#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ - _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29)) +#define SCTLR_EL1_RES1 (SCTLR_EL1_ITD | SCTLR_EL1_SED | SCTLR_EL1_EOS | \ + SCTLR_EL1_TSCXT | SCTLR_EL1_EIS | SCTLR_EL1_SPAN | \ + SCTLR_EL1_NTLSMD | SCTLR_EL1_LSMAOE)#define INIT_SCTLR_EL1_MMU_OFF \ SCTLR_EL1_RES1
The change looks good to me (although _BITULL remark still holds).
Independently on this patch the _RES1 terminology looks odd to me. For example ESO bit is RES1 only if FEAT_ExS is not implemented. Maybe I misunderstand why it was named that way but to me RES1 means another thing. If confirmed we could simply drop SCTLR_EL1_RES1 which is not used elsewhere and directly define INIT_SCTLR_EL1_MMU_OF.
Thanks
Eric
Re: [kvm-unit-tests PATCH v1 2/2] arm64: Define name for the bits used in SCTLR_EL1_RES1
Hi Eric,
Quoted 51 lines · Eric Auger
Hi Shaoqin,
Quoted 36 lines · Shaoqin Huang
Currently some fields in
SCTLR_EL1don't define a name and directly used in theSCTLR_EL1_RES1, that's not good now since these fields have been functional and have a name.According to the ARM DDI 0487J.a, define the name related to these fields.
Suggested-by Alexandru Elisei <[email protected]>Signed-off-by Shaoqin Huang <[email protected]>--- lib/arm64/asm/sysreg.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)lib/arm64/asm/sysreg.h +8
-0@@ -80,17 +80,26 @@ asm(#define ICC_GRPEN1_EL1 sys_reg(3, 0, 12, 12, 7)/* System Control Register (SCTLR_EL1) bits */ +#define SCTLR_EL1_LSMAOE _BITUL(29) +#define SCTLR_EL1_NTLSMD _BITUL(28)#define SCTLR_EL1_EE _BITUL(25) +#define SCTLR_EL1_SPAN _BITUL(23) +#define SCTLR_EL1_EIS _BITUL(22) +#define SCTLR_EL1_TSCXT _BITUL(20)#define SCTLR_EL1_WXN _BITUL(19)#define SCTLR_EL1_I _BITUL(12) +#define SCTLR_EL1_EOS _BITUL(11) +#define SCTLR_EL1_SED _BITUL(8) +#define SCTLR_EL1_ITD _BITUL(7)#define SCTLR_EL1_SA0 _BITUL(4)#define SCTLR_EL1_SA _BITUL(3)#define SCTLR_EL1_C _BITUL(2)#define SCTLR_EL1_A _BITUL(1)lib/arm64/asm/sysreg.h asm( · line 105
Quoted 10 lines
lib/arm64/asm/sysreg.h +3
-2#define SCTLR_EL1_M _BITUL(0) -#define SCTLR_EL1_RES1 (_BITUL(7) | _BITUL(8) | _BITUL(11) | _BITUL(20) | \ - _BITUL(22) | _BITUL(23) | _BITUL(28) | _BITUL(29)) +#define SCTLR_EL1_RES1 (SCTLR_EL1_ITD | SCTLR_EL1_SED | SCTLR_EL1_EOS | \ + SCTLR_EL1_TSCXT | SCTLR_EL1_EIS | SCTLR_EL1_SPAN | \ + SCTLR_EL1_NTLSMD | SCTLR_EL1_LSMAOE)#define INIT_SCTLR_EL1_MMU_OFF \ SCTLR_EL1_RES1The change looks good to me (although
_BITULLremark still holds).
Quoted 5 lines
Independently on this patch the
_RES1terminology looks odd to me. For example ESO bit is RES1 only ifFEAT_ExSis not implemented. Maybe I misunderstand why it was named that way but to me RES1 means another thing. If confirmed we could simply dropSCTLR_EL1_RES1which is not used elsewhere and directly defineINIT_SCTLR_EL1_MMU_OF.
The SCTLR_EL1_RES1 was originally defined by commit 10b65ce ("arm64: Configure SCTLR_EL1 at boot"). It seems at that time the BIT(11), yes the EOS bit is undefined, and must be reserved for 1, but now it has a definition which is EOS. It should have no effect if set EOS bit to 1 since its originally res to 1.
SCTLR_EL1_RES1 can simply be dropped since it has no other user.
Thanks,
Shaoqin
Quoted 5 lines
Thanks
Eric
Signature · 1 line
Shaoqin