All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] arm64: Use defines instead of magic numbers
@ 2019-04-05 10:20 Alexandru Elisei
  2019-04-05 11:07 ` Dave Martin
  2019-04-05 12:41 ` Will Deacon
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandru Elisei @ 2019-04-05 10:20 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: marc.zyngier, catalin.marinas, will.deacon, dave.martin

Following assembly code is not trivial; make it slightly easier to read by
replacing some of the magic numbers with the defines which are already
present in sysreg.h.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/include/asm/assembler.h |  4 ++--
 arch/arm64/kernel/head.S           | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index c5308d01e228..621212196871 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -442,8 +442,8 @@ USER(\label, ic	ivau, \tmp2)			// invalidate I line PoU
  * reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
  */
 	.macro	reset_pmuserenr_el0, tmpreg
-	mrs	\tmpreg, id_aa64dfr0_el1	// Check ID_AA64DFR0_EL1 PMUVer
-	sbfx	\tmpreg, \tmpreg, #8, #4
+	mrs	\tmpreg, id_aa64dfr0_el1
+	sbfx	\tmpreg, \tmpreg, #ID_AA64DFR0_PMUVER_SHIFT, #4
 	cmp	\tmpreg, #1			// Skip if no PMU present
 	b.lt	9000f
 	msr	pmuserenr_el0, xzr		// Disable PMU access from EL0
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index eecf7927dab0..f533305849d7 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -505,7 +505,7 @@ ENTRY(el2_setup)
 	 * kernel is intended to run at EL2.
 	 */
 	mrs	x2, id_aa64mmfr1_el1
-	ubfx	x2, x2, #8, #4
+	ubfx	x2, x2, #ID_AA64MMFR1_VHE_SHIFT, #4
 #else
 	mov	x2, xzr
 #endif
@@ -538,7 +538,7 @@ set_hcr:
 #ifdef CONFIG_ARM_GIC_V3
 	/* GICv3 system register access */
 	mrs	x0, id_aa64pfr0_el1
-	ubfx	x0, x0, #24, #4
+	ubfx	x0, x0, #ID_AA64PFR0_GIC_SHIFT, #4
 	cbz	x0, 3f
 
 	mrs_s	x0, SYS_ICC_SRE_EL2
@@ -564,8 +564,8 @@ set_hcr:
 #endif
 
 	/* EL2 debug */
-	mrs	x1, id_aa64dfr0_el1		// Check ID_AA64DFR0_EL1 PMUVer
-	sbfx	x0, x1, #8, #4
+	mrs	x1, id_aa64dfr0_el1
+	sbfx	x0, x1, #ID_AA64DFR0_PMUVER_SHIFT, #4
 	cmp	x0, #1
 	b.lt	4f				// Skip if no PMU present
 	mrs	x0, pmcr_el0			// Disable debug access traps
@@ -574,7 +574,7 @@ set_hcr:
 	csel	x3, xzr, x0, lt			// all PMU counters from EL1
 
 	/* Statistical profiling */
-	ubfx	x0, x1, #32, #4			// Check ID_AA64DFR0_EL1 PMSVer
+	ubfx	x0, x1, #ID_AA64DFR0_PMSVER_SHIFT, #4
 	cbz	x0, 7f				// Skip if SPE not present
 	cbnz	x2, 6f				// VHE?
 	mrs_s	x4, SYS_PMBIDR_EL1		// If SPE available at EL2,
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm64: Use defines instead of magic numbers
  2019-04-05 10:20 [PATCH 1/1] arm64: Use defines instead of magic numbers Alexandru Elisei
@ 2019-04-05 11:07 ` Dave Martin
  2019-04-05 12:41 ` Will Deacon
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Martin @ 2019-04-05 11:07 UTC (permalink / raw)
  To: Alexandru Elisei
  Cc: marc.zyngier, catalin.marinas, will.deacon, linux-arm-kernel

On Fri, Apr 05, 2019 at 11:20:12AM +0100, Alexandru Elisei wrote:
> Following assembly code is not trivial; make it slightly easier to read by
> replacing some of the magic numbers with the defines which are already
> present in sysreg.h.
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>

Looks like a sensible cleanup.  We use symbolic values for some ID
register fields in head.S already, so it makes sense to be consistent
(and readable).

Reviewed-by: Dave Martin <Dave.Martin@arm.com>

> ---
>  arch/arm64/include/asm/assembler.h |  4 ++--
>  arch/arm64/kernel/head.S           | 10 +++++-----
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
> index c5308d01e228..621212196871 100644
> --- a/arch/arm64/include/asm/assembler.h
> +++ b/arch/arm64/include/asm/assembler.h
> @@ -442,8 +442,8 @@ USER(\label, ic	ivau, \tmp2)			// invalidate I line PoU
>   * reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
>   */
>  	.macro	reset_pmuserenr_el0, tmpreg
> -	mrs	\tmpreg, id_aa64dfr0_el1	// Check ID_AA64DFR0_EL1 PMUVer
> -	sbfx	\tmpreg, \tmpreg, #8, #4
> +	mrs	\tmpreg, id_aa64dfr0_el1
> +	sbfx	\tmpreg, \tmpreg, #ID_AA64DFR0_PMUVER_SHIFT, #4
>  	cmp	\tmpreg, #1			// Skip if no PMU present
>  	b.lt	9000f
>  	msr	pmuserenr_el0, xzr		// Disable PMU access from EL0
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index eecf7927dab0..f533305849d7 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -505,7 +505,7 @@ ENTRY(el2_setup)
>  	 * kernel is intended to run at EL2.
>  	 */
>  	mrs	x2, id_aa64mmfr1_el1
> -	ubfx	x2, x2, #8, #4
> +	ubfx	x2, x2, #ID_AA64MMFR1_VHE_SHIFT, #4
>  #else
>  	mov	x2, xzr
>  #endif
> @@ -538,7 +538,7 @@ set_hcr:
>  #ifdef CONFIG_ARM_GIC_V3
>  	/* GICv3 system register access */
>  	mrs	x0, id_aa64pfr0_el1
> -	ubfx	x0, x0, #24, #4
> +	ubfx	x0, x0, #ID_AA64PFR0_GIC_SHIFT, #4
>  	cbz	x0, 3f
>  
>  	mrs_s	x0, SYS_ICC_SRE_EL2
> @@ -564,8 +564,8 @@ set_hcr:
>  #endif
>  
>  	/* EL2 debug */
> -	mrs	x1, id_aa64dfr0_el1		// Check ID_AA64DFR0_EL1 PMUVer
> -	sbfx	x0, x1, #8, #4
> +	mrs	x1, id_aa64dfr0_el1
> +	sbfx	x0, x1, #ID_AA64DFR0_PMUVER_SHIFT, #4
>  	cmp	x0, #1
>  	b.lt	4f				// Skip if no PMU present
>  	mrs	x0, pmcr_el0			// Disable debug access traps
> @@ -574,7 +574,7 @@ set_hcr:
>  	csel	x3, xzr, x0, lt			// all PMU counters from EL1
>  
>  	/* Statistical profiling */
> -	ubfx	x0, x1, #32, #4			// Check ID_AA64DFR0_EL1 PMSVer
> +	ubfx	x0, x1, #ID_AA64DFR0_PMSVER_SHIFT, #4
>  	cbz	x0, 7f				// Skip if SPE not present
>  	cbnz	x2, 6f				// VHE?
>  	mrs_s	x4, SYS_PMBIDR_EL1		// If SPE available at EL2,
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm64: Use defines instead of magic numbers
  2019-04-05 10:20 [PATCH 1/1] arm64: Use defines instead of magic numbers Alexandru Elisei
  2019-04-05 11:07 ` Dave Martin
@ 2019-04-05 12:41 ` Will Deacon
  2019-04-05 14:10   ` Dave Martin
  1 sibling, 1 reply; 4+ messages in thread
From: Will Deacon @ 2019-04-05 12:41 UTC (permalink / raw)
  To: Alexandru Elisei
  Cc: marc.zyngier, catalin.marinas, dave.martin, linux-arm-kernel

On Fri, Apr 05, 2019 at 11:20:12AM +0100, Alexandru Elisei wrote:
> Following assembly code is not trivial; make it slightly easier to read by
> replacing some of the magic numbers with the defines which are already
> present in sysreg.h.
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arch/arm64/include/asm/assembler.h |  4 ++--
>  arch/arm64/kernel/head.S           | 10 +++++-----
>  2 files changed, 7 insertions(+), 7 deletions(-)

How dare you make our early assembly code easier to understand! This brings
us one step closer to being replaced by robots... which can't come soon
enough.

Applied for 5.2.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm64: Use defines instead of magic numbers
  2019-04-05 12:41 ` Will Deacon
@ 2019-04-05 14:10   ` Dave Martin
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Martin @ 2019-04-05 14:10 UTC (permalink / raw)
  To: Will Deacon
  Cc: marc.zyngier, catalin.marinas, Alexandru Elisei, linux-arm-kernel

On Fri, Apr 05, 2019 at 01:41:36PM +0100, Will Deacon wrote:
> On Fri, Apr 05, 2019 at 11:20:12AM +0100, Alexandru Elisei wrote:
> > Following assembly code is not trivial; make it slightly easier to read by
> > replacing some of the magic numbers with the defines which are already
> > present in sysreg.h.
> > 
> > Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> > ---
> >  arch/arm64/include/asm/assembler.h |  4 ++--
> >  arch/arm64/kernel/head.S           | 10 +++++-----
> >  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> How dare you make our early assembly code easier to understand! This brings
> us one step closer to being replaced by robots... which can't come soon
> enough.

[...]

Nah, robots love magic numbers.

Cheers
---Dave

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-05 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05 10:20 [PATCH 1/1] arm64: Use defines instead of magic numbers Alexandru Elisei
2019-04-05 11:07 ` Dave Martin
2019-04-05 12:41 ` Will Deacon
2019-04-05 14:10   ` Dave Martin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.