diff mbox

[2/9] arm64: Fix INVALID_HWID definition

Message ID 6f84108ac880ef48548208738cbb169fba2fa51a.1408736066.git.geoff@infradead.org (mailing list archive)
State New, archived
Headers show

Commit Message

Geoff Levand Aug. 22, 2014, 7:49 p.m. UTC
Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
to allow INVALID_HWID to be used within assembly source files.

Commit 3e98fdacc59bbbdbb659be1a144ccc48ed4860fa (arm64: kernel: make the pen of
the secondary a 64-bit unsigned value) added the preprocessor macro INVALID_HWID
to asm/cputype.h with it defined to be ULONG_MAX.  Use of INVALID_HWID in an
assembly source file that includes cputype.h will generate an assembler
undefined symbol ULONG_MAX build error.  The kernel does define a ULONG_MAX in
kernel.h, but that file not setup to be included in assembly files.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/arm64/include/asm/cputype.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Catalin Marinas Aug. 26, 2014, 3:57 p.m. UTC | #1
On Fri, Aug 22, 2014 at 08:49:16PM +0100, Geoff Levand wrote:
> Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
> to allow INVALID_HWID to be used within assembly source files.
> 
> Commit 3e98fdacc59bbbdbb659be1a144ccc48ed4860fa (arm64: kernel: make the pen of
> the secondary a 64-bit unsigned value) added the preprocessor macro INVALID_HWID
> to asm/cputype.h with it defined to be ULONG_MAX.  Use of INVALID_HWID in an
> assembly source file that includes cputype.h will generate an assembler
> undefined symbol ULONG_MAX build error.  The kernel does define a ULONG_MAX in
> kernel.h, but that file not setup to be included in assembly files.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  arch/arm64/include/asm/cputype.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
> index 379d0b8..6b68380 100644
> --- a/arch/arm64/include/asm/cputype.h
> +++ b/arch/arm64/include/asm/cputype.h
> @@ -16,7 +16,7 @@
>  #ifndef __ASM_CPUTYPE_H
>  #define __ASM_CPUTYPE_H
>  
> -#define INVALID_HWID		ULONG_MAX
> +#define INVALID_HWID		UL(~0)

Does it actually expand to ULONG_MAX? ~0 is an int.
Mark Rutland Aug. 26, 2014, 4:31 p.m. UTC | #2
On Fri, Aug 22, 2014 at 08:49:16PM +0100, Geoff Levand wrote:
> Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
> to allow INVALID_HWID to be used within assembly source files.
> 
> Commit 3e98fdacc59bbbdbb659be1a144ccc48ed4860fa (arm64: kernel: make the pen of
> the secondary a 64-bit unsigned value) added the preprocessor macro INVALID_HWID
> to asm/cputype.h with it defined to be ULONG_MAX.  Use of INVALID_HWID in an
> assembly source file that includes cputype.h will generate an assembler
> undefined symbol ULONG_MAX build error.  The kernel does define a ULONG_MAX in
> kernel.h, but that file not setup to be included in assembly files.

We don't seem to be using INVALID_HWID in any assembly at the moment,
and I'm not sure I follow what we'd need it for.

Why do we need this in assembly?

Thanks,
Mark.

> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  arch/arm64/include/asm/cputype.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
> index 379d0b8..6b68380 100644
> --- a/arch/arm64/include/asm/cputype.h
> +++ b/arch/arm64/include/asm/cputype.h
> @@ -16,7 +16,7 @@
>  #ifndef __ASM_CPUTYPE_H
>  #define __ASM_CPUTYPE_H
>  
> -#define INVALID_HWID		ULONG_MAX
> +#define INVALID_HWID		UL(~0)
>  
>  #define MPIDR_UP_BITMASK	(0x1 << 30)
>  #define MPIDR_MT_BITMASK	(0x1 << 24)
> -- 
> 1.9.1
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Geoff Levand Aug. 26, 2014, 5:38 p.m. UTC | #3
Hi Mark,

On Tue, 2014-08-26 at 17:31 +0100, Mark Rutland wrote:
> On Fri, Aug 22, 2014 at 08:49:16PM +0100, Geoff Levand wrote:
> > Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
> > to allow INVALID_HWID to be used within assembly source files.
> > 
> > Commit 3e98fdacc59bbbdbb659be1a144ccc48ed4860fa (arm64: kernel: make the pen of
> > the secondary a 64-bit unsigned value) added the preprocessor macro INVALID_HWID
> > to asm/cputype.h with it defined to be ULONG_MAX.  Use of INVALID_HWID in an
> > assembly source file that includes cputype.h will generate an assembler
> > undefined symbol ULONG_MAX build error.  The kernel does define a ULONG_MAX in
> > kernel.h, but that file not setup to be included in assembly files.
> 
> We don't seem to be using INVALID_HWID in any assembly at the moment,
> and I'm not sure I follow what we'd need it for.
> 
> Why do we need this in assembly?

We currently don't use INVALID_HWID in any assembly files, but I wanted
to use it for some testing and found the current definition gave an
error.

-Geoff
Geoff Levand Aug. 26, 2014, 6:18 p.m. UTC | #4
Hi Catalin,

On Tue, 2014-08-26 at 16:57 +0100, Catalin Marinas wrote:
> On Fri, Aug 22, 2014 at 08:49:16PM +0100, Geoff Levand wrote:
> > Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
> > to allow INVALID_HWID to be used within assembly source files.
> > 
> > --- a/arch/arm64/include/asm/cputype.h
> > +++ b/arch/arm64/include/asm/cputype.h
> > @@ -16,7 +16,7 @@
> >  #ifndef __ASM_CPUTYPE_H
> >  #define __ASM_CPUTYPE_H
> >  
> > -#define INVALID_HWID		ULONG_MAX
> > +#define INVALID_HWID		UL(~0)
> 
> Does it actually expand to ULONG_MAX? ~0 is an int.

It seems to be OK, in C:

volatile unsigned long secondary_holding_pen_release = INVALID_HWID;

Disassembly of section .data:

0000000000000000 <secondary_holding_pen_release>:
   0:   ffffffff        .word   0xffffffff
   4:   ffffffff        .word   0xffffffff

In .S:

        mov     x10, INVALID_HWID               // clear secondary_holding_pen_release
 2b0:   9280000a        mov     x10, #0xffffffffffffffff        // #-1

-Geoff
Catalin Marinas Aug. 27, 2014, 8:21 a.m. UTC | #5
On Tue, Aug 26, 2014 at 07:18:00PM +0100, Geoff Levand wrote:
> On Tue, 2014-08-26 at 16:57 +0100, Catalin Marinas wrote:
> > On Fri, Aug 22, 2014 at 08:49:16PM +0100, Geoff Levand wrote:
> > > Change the preprocessor macro INVALID_HWID definition from ULONG_MAX to (~0)
> > > to allow INVALID_HWID to be used within assembly source files.
> > > 
> > > --- a/arch/arm64/include/asm/cputype.h
> > > +++ b/arch/arm64/include/asm/cputype.h
> > > @@ -16,7 +16,7 @@
> > >  #ifndef __ASM_CPUTYPE_H
> > >  #define __ASM_CPUTYPE_H
> > >  
> > > -#define INVALID_HWID		ULONG_MAX
> > > +#define INVALID_HWID		UL(~0)
> > 
> > Does it actually expand to ULONG_MAX? ~0 is an int.
> 
> It seems to be OK, in C:
> 
> volatile unsigned long secondary_holding_pen_release = INVALID_HWID;
> 
> Disassembly of section .data:
> 
> 0000000000000000 <secondary_holding_pen_release>:
>    0:   ffffffff        .word   0xffffffff
>    4:   ffffffff        .word   0xffffffff

OK, it looks like it's sign-extending from int to unsigned long (an
alternative would have been to write (~UL(0)) but the above should do as
well).

Anyway, the patch should come with the series that makes use of such
change.
diff mbox

Patch

diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index 379d0b8..6b68380 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -16,7 +16,7 @@ 
 #ifndef __ASM_CPUTYPE_H
 #define __ASM_CPUTYPE_H
 
-#define INVALID_HWID		ULONG_MAX
+#define INVALID_HWID		UL(~0)
 
 #define MPIDR_UP_BITMASK	(0x1 << 30)
 #define MPIDR_MT_BITMASK	(0x1 << 24)