Skip to contentSkip to conversation

arm64: pass machine size to sparse

PATCH New Luc Van Oostenryck 2 participants 7 messages Jun 20, 2017 – Jun 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: pass machine size to sparse

When using sparse on the arm64 tree we get many thousands of warnings like 'constant ... is so big it is unsigned long long' or 'shift too big (32) for type unsigned long'. This happens because by default sparse considers the machine as 32bit and defines the size of the types accordingly.

Fix this by passing the '-m64' flag to sparse so that sparse can correctly define longs as being 64bit.

CC Catalin Marinas <[email protected]>
CC Will Deacon <[email protected]>
CC linux-arm-kernel at lists.infradead.org
---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/Makefile +1 -1
index f839ecd91..15d6c1476 100644
@@ -62,7 +62,7 @@ LD		+= -EL
 UTS_MACHINE	:= aarch64
 endif
 
-CHECKFLAGS	+= -D__aarch64__
+CHECKFLAGS	+= -D__aarch64__ -m64
 
 ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
 KBUILD_CFLAGS_MODULE	+= -mcmodel=large
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 22 lines · Luc Van Oostenryck

When using sparse on the arm64 tree we get many thousands of warnings like 'constant ... is so big it is unsigned long long' or 'shift too big (32) for type unsigned long'. This happens because by default sparse considers the machine as 32bit and defines the size of the types accordingly.

Fix this by passing the '-m64' flag to sparse so that sparse can correctly define longs as being 64bit.

CC Catalin Marinas <[email protected]>
CC Will Deacon <[email protected]>
CC linux-arm-kernel at lists.infradead.org
---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/Makefile +0 -0
index f839ecd91..15d6c1476 100644

arch/arm64/Makefile LD += -EL · line 65

Quoted 5 lines
arch/arm64/Makefile +1 -1
@@ -62,7 +62,7 @@ LD		+= -EL
 UTS_MACHINE	:= aarch64
 endif
 
-CHECKFLAGS	+= -D__aarch64__
+CHECKFLAGS	+= -D__aarch64__ -m64

Looks fine to me, but just wondering whether or not we should also be passing something to indicate the endianness of the target. Does sparse care about that?

Will

#2 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 26 lines · Will Deacon
Quoted 25 lines · Luc Van Oostenryck

When using sparse on the arm64 tree we get many thousands of warnings like 'constant ... is so big it is unsigned long long' or 'shift too big (32) for type unsigned long'. This happens because by default sparse considers the machine as 32bit and defines the size of the types accordingly.

Fix this by passing the '-m64' flag to sparse so that sparse can correctly define longs as being 64bit.

CC Catalin Marinas <[email protected]>
CC Will Deacon <[email protected]>
CC linux-arm-kernel at lists.infradead.org
---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/Makefile +0 -0
index f839ecd91..15d6c1476 100644
@@ -62,7 +62,7 @@ LD		+= -EL
 UTS_MACHINE	:= aarch64
 endif
 
Quoted 6 lines

arch/arm64/Makefile LD += -EL · line 65

Quoted 2 lines
arch/arm64/Makefile +1 -1
-CHECKFLAGS	+= -D__aarch64__
+CHECKFLAGS	+= -D__aarch64__ -m64

Looks fine to me, but just wondering whether or not we should also be passing something to indicate the endianness of the target. Does sparse care about that?

Yes, we should. sparse doesn't care per-se but some macros, structures or whole portion of code may depends on '__{LITTLE,BIG}_ENDIAN__' being defined or not, for example (but I don't think it will make a big difference, at least nothing like the 629904 'constant is so big' warnings we have now due to the missing -m64).

For this, you have two possibilities:
1) just doing something like PPC:

	+ifdef CONFIG_CPU_BIG_ENDIAN
	+CHECKFLAGS     += -D__BIG_ENDIAN__
	+else
	+CHECKFLAGS     += -D__LITTLE_ENDIAN__
	+endif

This will work now. I can't send you a proper patch if you wish.

2) a cleaner solution, IMO, would be to teach sparse about -mlittle-endian/-mbig-endian. In fact I already wrote the patch earlier today. But of course, you will need to wait for the patch to reach sparse's master and then compile sparse yourself or wait for a new release (which shouldn't take much long, though).

Regards,
-- Luc Van Oostenryck

#3 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 47 lines · Luc Van Oostenryck
Quoted 26 lines · Will Deacon
Quoted 25 lines · Luc Van Oostenryck

When using sparse on the arm64 tree we get many thousands of warnings like 'constant ... is so big it is unsigned long long' or 'shift too big (32) for type unsigned long'. This happens because by default sparse considers the machine as 32bit and defines the size of the types accordingly.

Fix this by passing the '-m64' flag to sparse so that sparse can correctly define longs as being 64bit.

---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/Makefile +0 -0
index f839ecd91..15d6c1476 100644
@@ -62,7 +62,7 @@ LD		+= -EL
 UTS_MACHINE	:= aarch64
 endif
 
Quoted 6 lines

arch/arm64/Makefile LD += -EL · line 65

Quoted 2 lines
arch/arm64/Makefile +1 -1
-CHECKFLAGS	+= -D__aarch64__
+CHECKFLAGS	+= -D__aarch64__ -m64

Looks fine to me, but just wondering whether or not we should also be passing something to indicate the endianness of the target. Does sparse care about that?

Yes, we should. sparse doesn't care per-se but some macros, structures or whole portion of code may depends on '__{LITTLE,BIG}_ENDIAN__' being defined or not, for example (but I don't think it will make a big difference, at least nothing like the 629904 'constant is so big' warnings we have now due to the missing -m64).

For this, you have two possibilities:
1) just doing something like PPC:

	+ifdef CONFIG_CPU_BIG_ENDIAN
	+CHECKFLAGS     += -D__BIG_ENDIAN__
	+else
	+CHECKFLAGS     += -D__LITTLE_ENDIAN__
	+endif
Quoted 7 lines

This will work now. I can't send you a proper patch if you wish.

2) a cleaner solution, IMO, would be to teach sparse about -mlittle-endian/-mbig-endian. In fact I already wrote the patch earlier today. But of course, you will need to wait for the patch to reach sparse's master and then compile sparse yourself or wait for a new release (which shouldn't take much long, though).

If you do that, you could also teach it that AArch64 is 64-bit ;)

Will

#4 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 21 lines · Will Deacon
Quoted 20 lines · Luc Van Oostenryck
Quoted 3 lines · Will Deacon

Looks fine to me, but just wondering whether or not we should also be passing something to indicate the endianness of the target. Does sparse care about that?

Yes, we should. sparse doesn't care per-se but some macros, structures or whole portion of code may depends on '__{LITTLE,BIG}_ENDIAN__' being defined or not, for example (but I don't think it will make a big difference, at least nothing like the 629904 'constant is so big' warnings we have now due to the missing -m64).

For this, you have two possibilities:
1) just doing something like PPC:

	+ifdef CONFIG_CPU_BIG_ENDIAN
	+CHECKFLAGS     += -D__BIG_ENDIAN__
	+else
	+CHECKFLAGS     += -D__LITTLE_ENDIAN__
	+endif

This will work now. I can't send you a proper patch if you wish.

Quoted 7 lines
Quoted 5 lines

2) a cleaner solution, IMO, would be to teach sparse about -mlittle-endian/-mbig-endian. In fact I already wrote the patch earlier today. But of course, you will need to wait for the patch to reach sparse's master and then compile sparse yourself or wait for a new release (which shouldn't take much long, though).

If you do that, you could also teach it that AArch64 is 64-bit ;)

Well, currently sparse is arch agnostic and I think it's a good thing. For the few arch specifities you have to use some of the '-m' flags (like -m32/-m64, -msize-long). So, for the moment the '-m64' flag is needed, thus the patch.

-- Luc

#5 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 28 lines · Luc Van Oostenryck
Quoted 27 lines · Will Deacon
Quoted 25 lines · Luc Van Oostenryck
Quoted 3 lines · Will Deacon

Looks fine to me, but just wondering whether or not we should also be passing something to indicate the endianness of the target. Does sparse care about that?

Yes, we should. sparse doesn't care per-se but some macros, structures or whole portion of code may depends on '__{LITTLE,BIG}_ENDIAN__' being defined or not, for example (but I don't think it will make a big difference, at least nothing like the 629904 'constant is so big' warnings we have now due to the missing -m64).

For this, you have two possibilities:
1) just doing something like PPC:

	+ifdef CONFIG_CPU_BIG_ENDIAN
	+CHECKFLAGS     += -D__BIG_ENDIAN__
	+else
	+CHECKFLAGS     += -D__LITTLE_ENDIAN__
	+endif

This will work now. I can't send you a proper patch if you wish.

2) a cleaner solution, IMO, would be to teach sparse about -mlittle-endian/-mbig-endian. In fact I already wrote the patch earlier today. But of course, you will need to wait for the patch to reach sparse's master and then compile sparse yourself or wait for a new release (which shouldn't take much long, though).

Quoted 6 lines
Quoted 1 line

If you do that, you could also teach it that AArch64 is 64-bit ;)

Well, currently sparse is arch agnostic and I think it's a good thing. For the few arch specifities you have to use some of the '-m' flags (like -m32/-m64, -msize-long). So, for the moment the '-m64' flag is needed, thus the patch.

Ok, I'll pick your patch up then. The endianness case is more interesting, because I don't think __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are the defines to use; the kernel seems to omit the trailing underscores afaict.

Will

#6 lore raw

PATCH 1/1 arm64: pass machine size to sparse

Quoted 9 lines · Will Deacon
Quoted 4 lines · Luc Van Oostenryck

Well, currently sparse is arch agnostic and I think it's a good thing. For the few arch specifities you have to use some of the '-m' flags (like -m32/-m64, -msize-long). So, for the moment the '-m64' flag is needed, thus the patch.

Ok, I'll pick your patch up then. The endianness case is more interesting, because I don't think __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are the defines to use; the kernel seems to omit the trailing underscores afaict.

I just checked, it's a bit messy.
The kernel seems to rely, at least partly, maybe mostly, on CONFIG_CPU_{BIG,LITTLE}_ENDIAN and then __{BIG,LITTLE}_ENDIAN is defined via include/uapi/linux/byteorder/{big,little}_endian.h

Otherwise, from the compiler side it seems that __BYTE_ORDER__ & __ORDER_{BIG,LITTLE}_ENDIAN__ is defined consistently. But, for example for arm64, 'gcc -mlittle-endian' gives

	#define __LITTLE_ENDIAN__ 1
while 'gcc -mbig-endian' doesn't define __BIG_ENDIAN__ but
	#define __ARM_BIG_ENDIAN 1

*shrugh*

I've added support for the -m{big,little}-endian flag to sparse but it seems it will be more complicated for the defines.

-- Luc