All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
@ 2017-08-02 22:51 ` Matthias Kaehlcke
  0 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 22:51 UTC (permalink / raw)
  To: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott
  Cc: linux-kernel, linux-arm-kernel, Doug Anderson, Nick Desaulniers,
	Greg Hackmann, Matthias Kaehlcke

GENMASK_ULL performs a left-shift of (~0ULL), which technically
results in an integer overflow. clang raises a warning about
this if the overflow occurs in a preprocessor expression. To
avoid the overflow first perform a right-shift to clear the
bits that are shifted out.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 include/linux/bitops.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a83c822c35c2..21dfe63001e3 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -22,7 +22,7 @@
 	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
 #define GENMASK_ULL(h, l) \
-	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
 
 extern unsigned int __sw_hweight8(unsigned int w);
 extern unsigned int __sw_hweight16(unsigned int w);
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
@ 2017-08-02 22:51 ` Matthias Kaehlcke
  0 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 22:51 UTC (permalink / raw)
  To: linux-arm-kernel

GENMASK_ULL performs a left-shift of (~0ULL), which technically
results in an integer overflow. clang raises a warning about
this if the overflow occurs in a preprocessor expression. To
avoid the overflow first perform a right-shift to clear the
bits that are shifted out.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 include/linux/bitops.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a83c822c35c2..21dfe63001e3 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -22,7 +22,7 @@
 	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
 #define GENMASK_ULL(h, l) \
-	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
 
 extern unsigned int __sw_hweight8(unsigned int w);
 extern unsigned int __sw_hweight16(unsigned int w);
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 22:51 ` Matthias Kaehlcke
@ 2017-08-02 22:51   ` Matthias Kaehlcke
  -1 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 22:51 UTC (permalink / raw)
  To: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott
  Cc: linux-kernel, linux-arm-kernel, Doug Anderson, Nick Desaulniers,
	Greg Hackmann, Matthias Kaehlcke

As is the definition causes an integer overflow, which is expected,
however clang raises the following warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
                                      ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~

Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
of avoiding the overflow.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 arch/arm64/include/asm/memory.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..732d4eed8edd 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -65,7 +65,7 @@
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
 #define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-02 22:51   ` Matthias Kaehlcke
  0 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 22:51 UTC (permalink / raw)
  To: linux-arm-kernel

As is the definition causes an integer overflow, which is expected,
however clang raises the following warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
                                      ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~

Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
of avoiding the overflow.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 arch/arm64/include/asm/memory.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..732d4eed8edd 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -65,7 +65,7 @@
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
 #define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 22:51   ` Matthias Kaehlcke
@ 2017-08-02 23:13     ` Nick Desaulniers
  -1 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-02 23:13 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, linux-kernel, linux-arm-kernel,
	Doug Anderson, Greg Hackmann

don't forget to include linux/bitops.h now in memory.h

/usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
error:
      function-like macro 'GENMASK_ULL' is not defined
#elif (PAGE_OFFSET & 0x1fffff) != 0
       ^
/usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
note:

      expanded from macro 'PAGE_OFFSET'
#define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
                                ^
1 error generated.

On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> As is the definition causes an integer overflow, which is expected,
> however clang raises the following warning:
>
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
>
> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> of avoiding the overflow.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  arch/arm64/include/asm/memory.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..732d4eed8edd 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -65,7 +65,7 @@
>   */
>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>  #define KIMAGE_VADDR           (MODULES_END)
>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> --
> 2.14.0.rc1.383.gd1ce394fe2-goog
>



-- 
Thanks,
~Nick Desaulniers

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-02 23:13     ` Nick Desaulniers
  0 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-02 23:13 UTC (permalink / raw)
  To: linux-arm-kernel

don't forget to include linux/bitops.h now in memory.h

/usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
error:
      function-like macro 'GENMASK_ULL' is not defined
#elif (PAGE_OFFSET & 0x1fffff) != 0
       ^
/usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
note:

      expanded from macro 'PAGE_OFFSET'
#define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
                                ^
1 error generated.

On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> As is the definition causes an integer overflow, which is expected,
> however clang raises the following warning:
>
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
>
> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> of avoiding the overflow.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  arch/arm64/include/asm/memory.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..732d4eed8edd 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -65,7 +65,7 @@
>   */
>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>  #define KIMAGE_VADDR           (MODULES_END)
>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> --
> 2.14.0.rc1.383.gd1ce394fe2-goog
>



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 23:13     ` Nick Desaulniers
@ 2017-08-02 23:19       ` Nick Desaulniers
  -1 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-02 23:19 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, linux-kernel, linux-arm-kernel,
	Doug Anderson, Greg Hackmann

hmm, seems including the definition of GENMASK_ULL causes tons of issues
see definition of UL() macro
defines _AC
token pastes UL on literal when not assembly
so looks like GENMASK_ULL is not ready to be used from assembly

On Wed, Aug 2, 2017 at 4:13 PM, Nick Desaulniers
<ndesaulniers@google.com> wrote:
> don't forget to include linux/bitops.h now in memory.h
>
> /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
> error:
>       function-like macro 'GENMASK_ULL' is not defined
> #elif (PAGE_OFFSET & 0x1fffff) != 0
>        ^
> /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
> note:
>
>       expanded from macro 'PAGE_OFFSET'
> #define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>                                 ^
> 1 error generated.
>
> On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
>> As is the definition causes an integer overflow, which is expected,
>> however clang raises the following warning:
>>
>> arch/arm64/kernel/head.S:47:8: warning:
>>       integer overflow in preprocessor expression
>>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>>          ^~~~~~~~~~~
>> arch/arm64/include/asm/memory.h:52:46: note:
>>       expanded from macro 'PAGE_OFFSET'
>>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
>>
>> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
>> of avoiding the overflow.
>>
>> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>> ---
>>  arch/arm64/include/asm/memory.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index 32f82723338a..732d4eed8edd 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -65,7 +65,7 @@
>>   */
>>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
>>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
>> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
>> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>>  #define KIMAGE_VADDR           (MODULES_END)
>>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
>> --
>> 2.14.0.rc1.383.gd1ce394fe2-goog
>>
>
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-02 23:19       ` Nick Desaulniers
  0 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-02 23:19 UTC (permalink / raw)
  To: linux-arm-kernel

hmm, seems including the definition of GENMASK_ULL causes tons of issues
see definition of UL() macro
defines _AC
token pastes UL on literal when not assembly
so looks like GENMASK_ULL is not ready to be used from assembly

On Wed, Aug 2, 2017 at 4:13 PM, Nick Desaulniers
<ndesaulniers@google.com> wrote:
> don't forget to include linux/bitops.h now in memory.h
>
> /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
> error:
>       function-like macro 'GENMASK_ULL' is not defined
> #elif (PAGE_OFFSET & 0x1fffff) != 0
>        ^
> /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
> note:
>
>       expanded from macro 'PAGE_OFFSET'
> #define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>                                 ^
> 1 error generated.
>
> On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
>> As is the definition causes an integer overflow, which is expected,
>> however clang raises the following warning:
>>
>> arch/arm64/kernel/head.S:47:8: warning:
>>       integer overflow in preprocessor expression
>>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>>          ^~~~~~~~~~~
>> arch/arm64/include/asm/memory.h:52:46: note:
>>       expanded from macro 'PAGE_OFFSET'
>>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
>>
>> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
>> of avoiding the overflow.
>>
>> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>> ---
>>  arch/arm64/include/asm/memory.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index 32f82723338a..732d4eed8edd 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -65,7 +65,7 @@
>>   */
>>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
>>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
>> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
>> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
>>  #define KIMAGE_VADDR           (MODULES_END)
>>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
>> --
>> 2.14.0.rc1.383.gd1ce394fe2-goog
>>
>
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 23:19       ` Nick Desaulniers
@ 2017-08-02 23:44         ` Matthias Kaehlcke
  -1 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 23:44 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, linux-kernel, linux-arm-kernel,
	Doug Anderson, Greg Hackmann

El Wed, Aug 02, 2017 at 04:19:11PM -0700 Nick Desaulniers ha dit:

> hmm, seems including the definition of GENMASK_ULL causes tons of issues
> see definition of UL() macro
> defines _AC
> token pastes UL on literal when not assembly
> so looks like GENMASK_ULL is not ready to be used from assembly

sorry, it seems I only did a partial build when testing this :/

> On Wed, Aug 2, 2017 at 4:13 PM, Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> > don't forget to include linux/bitops.h now in memory.h
> >
> > /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
> > error:
> >       function-like macro 'GENMASK_ULL' is not defined
> > #elif (PAGE_OFFSET & 0x1fffff) != 0
> >        ^
> > /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
> > note:
> >
> >       expanded from macro 'PAGE_OFFSET'
> > #define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
> >                                 ^
> > 1 error generated.
> >
> > On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> >> As is the definition causes an integer overflow, which is expected,
> >> however clang raises the following warning:
> >>
> >> arch/arm64/kernel/head.S:47:8: warning:
> >>       integer overflow in preprocessor expression
> >>   #elif (PAGE_OFFSET & 0x1fffff) != 0
> >>          ^~~~~~~~~~~
> >> arch/arm64/include/asm/memory.h:52:46: note:
> >>       expanded from macro 'PAGE_OFFSET'
> >>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
> >>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
> >>
> >> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> >> of avoiding the overflow.
> >>
> >> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> >> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> >> ---
> >>  arch/arm64/include/asm/memory.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> >> index 32f82723338a..732d4eed8edd 100644
> >> --- a/arch/arm64/include/asm/memory.h
> >> +++ b/arch/arm64/include/asm/memory.h
> >> @@ -65,7 +65,7 @@
> >>   */
> >>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
> >>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> >> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> >> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
> >>  #define KIMAGE_VADDR           (MODULES_END)
> >>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
> >>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> >>
> >
> >
> >
> 
> 
> 

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-02 23:44         ` Matthias Kaehlcke
  0 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-02 23:44 UTC (permalink / raw)
  To: linux-arm-kernel

El Wed, Aug 02, 2017 at 04:19:11PM -0700 Nick Desaulniers ha dit:

> hmm, seems including the definition of GENMASK_ULL causes tons of issues
> see definition of UL() macro
> defines _AC
> token pastes UL on literal when not assembly
> so looks like GENMASK_ULL is not ready to be used from assembly

sorry, it seems I only did a partial build when testing this :/

> On Wed, Aug 2, 2017 at 4:13 PM, Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> > don't forget to include linux/bitops.h now in memory.h
> >
> > /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/kernel/head.S:47:8:
> > error:
> >       function-like macro 'GENMASK_ULL' is not defined
> > #elif (PAGE_OFFSET & 0x1fffff) != 0
> >        ^
> > /usr/local/google/home/ndesaulniers/android/kernel-wahoo/private/msm-google/arch/arm64/include/asm/memory.h:52:22:
> > note:
> >
> >       expanded from macro 'PAGE_OFFSET'
> > #define PAGE_OFFSET             GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
> >                                 ^
> > 1 error generated.
> >
> > On Wed, Aug 2, 2017 at 3:51 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> >> As is the definition causes an integer overflow, which is expected,
> >> however clang raises the following warning:
> >>
> >> arch/arm64/kernel/head.S:47:8: warning:
> >>       integer overflow in preprocessor expression
> >>   #elif (PAGE_OFFSET & 0x1fffff) != 0
> >>          ^~~~~~~~~~~
> >> arch/arm64/include/asm/memory.h:52:46: note:
> >>       expanded from macro 'PAGE_OFFSET'
> >>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
> >>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
> >>
> >> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> >> of avoiding the overflow.
> >>
> >> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> >> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> >> ---
> >>  arch/arm64/include/asm/memory.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> >> index 32f82723338a..732d4eed8edd 100644
> >> --- a/arch/arm64/include/asm/memory.h
> >> +++ b/arch/arm64/include/asm/memory.h
> >> @@ -65,7 +65,7 @@
> >>   */
> >>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
> >>  #define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> >> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> >> +#define PAGE_OFFSET            GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
> >>  #define KIMAGE_VADDR           (MODULES_END)
> >>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
> >>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> >>
> >
> >
> >
> 
> 
> 

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

* Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 22:51   ` Matthias Kaehlcke
@ 2017-08-03 13:20     ` Yury Norov
  -1 siblings, 0 replies; 26+ messages in thread
From: Yury Norov @ 2017-08-03 13:20 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, Nick Desaulniers, linux-kernel,
	Greg Hackmann, Doug Anderson, linux-arm-kernel

Hi Matthias,

On Wed, Aug 02, 2017 at 03:51:59PM -0700, Matthias Kaehlcke wrote:
> As is the definition causes an integer overflow, which is expected,
> however clang raises the following warning:
> 
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
> 
> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> of avoiding the overflow.
> 
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  arch/arm64/include/asm/memory.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..732d4eed8edd 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -65,7 +65,7 @@
>   */
>  #define VA_BITS			(CONFIG_ARM64_VA_BITS)
>  #define VA_START		(UL(0xffffffffffffffff) << VA_BITS)

IIUC VA_START should also produce warnings and should be also reworked.

> -#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)

The original type of PAGE_OFFSET is UL, and after your patch becomes ULL.
This is the same for arm64. But it would be less questionable if you
will specify it explicitly, or use GENMASK() instead of GENMASK_ULL().

>  #define KIMAGE_VADDR		(MODULES_END)
>  #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
> -- 
> 2.14.0.rc1.383.gd1ce394fe2-goog
> 
> 
> _______________________________________________
> 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] 26+ messages in thread

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-03 13:20     ` Yury Norov
  0 siblings, 0 replies; 26+ messages in thread
From: Yury Norov @ 2017-08-03 13:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,

On Wed, Aug 02, 2017 at 03:51:59PM -0700, Matthias Kaehlcke wrote:
> As is the definition causes an integer overflow, which is expected,
> however clang raises the following warning:
> 
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS - 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^  ~~~~~~~~~~~~~
> 
> Use GENMASK_ULL() instead of shifting explicitly, the macro takes care
> of avoiding the overflow.
> 
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  arch/arm64/include/asm/memory.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..732d4eed8edd 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -65,7 +65,7 @@
>   */
>  #define VA_BITS			(CONFIG_ARM64_VA_BITS)
>  #define VA_START		(UL(0xffffffffffffffff) << VA_BITS)

IIUC VA_START should also produce warnings and should be also reworked.

> -#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)

The original type of PAGE_OFFSET is UL, and after your patch becomes ULL.
This is the same for arm64. But it would be less questionable if you
will specify it explicitly, or use GENMASK() instead of GENMASK_ULL().

>  #define KIMAGE_VADDR		(MODULES_END)
>  #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
> -- 
> 2.14.0.rc1.383.gd1ce394fe2-goog
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
  2017-08-02 22:51 ` Matthias Kaehlcke
@ 2017-08-03 13:24   ` Yury Norov
  -1 siblings, 0 replies; 26+ messages in thread
From: Yury Norov @ 2017-08-03 13:24 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, Nick Desaulniers, linux-kernel,
	Greg Hackmann, Doug Anderson, linux-arm-kernel

On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote:
> GENMASK_ULL performs a left-shift of (~0ULL), which technically
> results in an integer overflow. clang raises a warning about
> this if the overflow occurs in a preprocessor expression. To
> avoid the overflow first perform a right-shift to clear the
> bits that are shifted out.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  include/linux/bitops.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index a83c822c35c2..21dfe63001e3 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -22,7 +22,7 @@
>  	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))

Once you touche GENMASK_ULL, why not to fix also GENMASK.

>  
>  #define GENMASK_ULL(h, l) \
> -	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
> +	((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
>  
>  extern unsigned int __sw_hweight8(unsigned int w);
>  extern unsigned int __sw_hweight16(unsigned int w);
> -- 
> 2.14.0.rc1.383.gd1ce394fe2-goog
> 
> 
> _______________________________________________
> 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] 26+ messages in thread

* [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
@ 2017-08-03 13:24   ` Yury Norov
  0 siblings, 0 replies; 26+ messages in thread
From: Yury Norov @ 2017-08-03 13:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote:
> GENMASK_ULL performs a left-shift of (~0ULL), which technically
> results in an integer overflow. clang raises a warning about
> this if the overflow occurs in a preprocessor expression. To
> avoid the overflow first perform a right-shift to clear the
> bits that are shifted out.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  include/linux/bitops.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index a83c822c35c2..21dfe63001e3 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -22,7 +22,7 @@
>  	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))

Once you touche GENMASK_ULL, why not to fix also GENMASK.

>  
>  #define GENMASK_ULL(h, l) \
> -	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
> +	((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
>  
>  extern unsigned int __sw_hweight8(unsigned int w);
>  extern unsigned int __sw_hweight16(unsigned int w);
> -- 
> 2.14.0.rc1.383.gd1ce394fe2-goog
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
  2017-08-03 13:24   ` Yury Norov
@ 2017-08-03 17:03     ` Matthias Kaehlcke
  -1 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-03 17:03 UTC (permalink / raw)
  To: Yury Norov
  Cc: zijun_hu, Andrew Morton, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, Nick Desaulniers, linux-kernel,
	Greg Hackmann, Doug Anderson, linux-arm-kernel

El Thu, Aug 03, 2017 at 04:24:56PM +0300 Yury Norov ha dit:

> On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote:
> > GENMASK_ULL performs a left-shift of (~0ULL), which technically
> > results in an integer overflow. clang raises a warning about
> > this if the overflow occurs in a preprocessor expression. To
> > avoid the overflow first perform a right-shift to clear the
> > bits that are shifted out.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> >  include/linux/bitops.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> > index a83c822c35c2..21dfe63001e3 100644
> > --- a/include/linux/bitops.h
> > +++ b/include/linux/bitops.h
> > @@ -22,7 +22,7 @@
> >  	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
> 
> Once you touche GENMASK_ULL, why not to fix also GENMASK.

Will do, thanks.

Even though GENMASK_ULL can't be used (as is) to define the arm64
PAGE_OFFSET as initially intended it seems the change is still
worthwhile since there are a few other preprocessor expressions using
GENMASK_ULL.

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

* [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
@ 2017-08-03 17:03     ` Matthias Kaehlcke
  0 siblings, 0 replies; 26+ messages in thread
From: Matthias Kaehlcke @ 2017-08-03 17:03 UTC (permalink / raw)
  To: linux-arm-kernel

El Thu, Aug 03, 2017 at 04:24:56PM +0300 Yury Norov ha dit:

> On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote:
> > GENMASK_ULL performs a left-shift of (~0ULL), which technically
> > results in an integer overflow. clang raises a warning about
> > this if the overflow occurs in a preprocessor expression. To
> > avoid the overflow first perform a right-shift to clear the
> > bits that are shifted out.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> >  include/linux/bitops.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> > index a83c822c35c2..21dfe63001e3 100644
> > --- a/include/linux/bitops.h
> > +++ b/include/linux/bitops.h
> > @@ -22,7 +22,7 @@
> >  	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
> 
> Once you touche GENMASK_ULL, why not to fix also GENMASK.

Will do, thanks.

Even though GENMASK_ULL can't be used (as is) to define the arm64
PAGE_OFFSET as initially intended it seems the change is still
worthwhile since there are a few other preprocessor expressions using
GENMASK_ULL.

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

* [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
  2017-08-03 13:20     ` Yury Norov
@ 2017-08-03 17:11       ` Nick Desaulniers
  -1 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 17:11 UTC (permalink / raw)
  Cc: zijun_hu, akpm, ghackmann, dianders, srhines, pirama,
	Nick Desaulniers, Catalin Marinas, Will Deacon, Mark Rutland,
	Laura Abbott, Ard Biesheuvel, Oleksandr Andrushchenko,
	Alexander Popov, Neeraj Upadhyay, linux-arm-kernel, linux-kernel

The bitmask used to define these values produces overflow, as seen by
this compiler warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
1))
                                      ~~~~~~~~~~~~~~~~~~  ^

It would be preferrable to use GENMASK_ULL() instead, but it's not set
up to be used from assembly (the UL() macro token pastes UL suffixes
when not included in assembly sources).

Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
Suggested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm64/include/asm/memory.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..dde717a31dee 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -64,8 +64,9 @@
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
-#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define VA_START		((UL(0xffffffffffffffff) >> VA_BITS) << VA_BITS)
+#define PAGE_OFFSET		((UL(0xffffffffffffffff) >> (VA_BITS - 1)) \
+	<< (VA_BITS - 1))
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
@ 2017-08-03 17:11       ` Nick Desaulniers
  0 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 17:11 UTC (permalink / raw)
  To: linux-arm-kernel

The bitmask used to define these values produces overflow, as seen by
this compiler warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
1))
                                      ~~~~~~~~~~~~~~~~~~  ^

It would be preferrable to use GENMASK_ULL() instead, but it's not set
up to be used from assembly (the UL() macro token pastes UL suffixes
when not included in assembly sources).

Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
Suggested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm64/include/asm/memory.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..dde717a31dee 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -64,8 +64,9 @@
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
-#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define VA_START		((UL(0xffffffffffffffff) >> VA_BITS) << VA_BITS)
+#define PAGE_OFFSET		((UL(0xffffffffffffffff) >> (VA_BITS - 1)) \
+	<< (VA_BITS - 1))
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* Re: [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
  2017-08-03 17:11       ` Nick Desaulniers
@ 2017-08-03 17:20         ` Ard Biesheuvel
  -1 siblings, 0 replies; 26+ messages in thread
From: Ard Biesheuvel @ 2017-08-03 17:20 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: zijun_hu, Andrew Morton, Greg Hackmann, Doug Anderson, srhines,
	pirama, Catalin Marinas, Will Deacon, Mark Rutland, Laura Abbott,
	Oleksandr Andrushchenko, Alexander Popov, Neeraj Upadhyay,
	linux-arm-kernel, linux-kernel

On 3 August 2017 at 18:11, Nick Desaulniers <ndesaulniers@google.com> wrote:
> The bitmask used to define these values produces overflow, as seen by
> this compiler warning:
>
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
> 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^
>
> It would be preferrable to use GENMASK_ULL() instead, but it's not set
> up to be used from assembly (the UL() macro token pastes UL suffixes
> when not included in assembly sources).
>
> Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
> Suggested-by: Matthias Kaehlcke <mka@chromium.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  arch/arm64/include/asm/memory.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..dde717a31dee 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -64,8 +64,9 @@
>   * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
>   */
>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
> -#define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define VA_START               ((UL(0xffffffffffffffff) >> VA_BITS) << VA_BITS)
> +#define PAGE_OFFSET            ((UL(0xffffffffffffffff) >> (VA_BITS - 1)) \
> +       << (VA_BITS - 1))
>  #define KIMAGE_VADDR           (MODULES_END)
>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> --
> 2.14.0.rc1.383.gd1ce394fe2-goog
>

Would

#define VA_START (UL(0xffffffffffffffff) - (1 << VA_BITS) + 1)

also work?

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

* [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
@ 2017-08-03 17:20         ` Ard Biesheuvel
  0 siblings, 0 replies; 26+ messages in thread
From: Ard Biesheuvel @ 2017-08-03 17:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 3 August 2017 at 18:11, Nick Desaulniers <ndesaulniers@google.com> wrote:
> The bitmask used to define these values produces overflow, as seen by
> this compiler warning:
>
> arch/arm64/kernel/head.S:47:8: warning:
>       integer overflow in preprocessor expression
>   #elif (PAGE_OFFSET & 0x1fffff) != 0
>          ^~~~~~~~~~~
> arch/arm64/include/asm/memory.h:52:46: note:
>       expanded from macro 'PAGE_OFFSET'
>   #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
> 1))
>                                       ~~~~~~~~~~~~~~~~~~  ^
>
> It would be preferrable to use GENMASK_ULL() instead, but it's not set
> up to be used from assembly (the UL() macro token pastes UL suffixes
> when not included in assembly sources).
>
> Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
> Suggested-by: Matthias Kaehlcke <mka@chromium.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  arch/arm64/include/asm/memory.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index 32f82723338a..dde717a31dee 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -64,8 +64,9 @@
>   * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
>   */
>  #define VA_BITS                        (CONFIG_ARM64_VA_BITS)
> -#define VA_START               (UL(0xffffffffffffffff) << VA_BITS)
> -#define PAGE_OFFSET            (UL(0xffffffffffffffff) << (VA_BITS - 1))
> +#define VA_START               ((UL(0xffffffffffffffff) >> VA_BITS) << VA_BITS)
> +#define PAGE_OFFSET            ((UL(0xffffffffffffffff) >> (VA_BITS - 1)) \
> +       << (VA_BITS - 1))
>  #define KIMAGE_VADDR           (MODULES_END)
>  #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
>  #define MODULES_VADDR          (VA_START + KASAN_SHADOW_SIZE)
> --
> 2.14.0.rc1.383.gd1ce394fe2-goog
>

Would

#define VA_START (UL(0xffffffffffffffff) - (1 << VA_BITS) + 1)

also work?

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

* Re: [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
  2017-08-03 17:20         ` Ard Biesheuvel
@ 2017-08-03 17:53           ` Nick Desaulniers
  -1 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 17:53 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: zijun_hu, Andrew Morton, Greg Hackmann, Doug Anderson,
	Stephen Hines, Pirama Arumuga Nainar, Catalin Marinas,
	Will Deacon, Mark Rutland, Laura Abbott, Oleksandr Andrushchenko,
	Alexander Popov, Neeraj Upadhyay, linux-arm-kernel, linux-kernel

> Would
>
> #define VA_START (UL(0xffffffffffffffff) - (1 << VA_BITS) + 1)
>
> also work?

I think you'd have to wrap the 1 in a UL(), ex:

#define VA_START (UL(0xffffffffffffffff) - (UL(1) << VA_BITS) + 1)

Otherwise IIUC a integral literal (`1`) is treated as an int, which on
arm64 is LP64 making it 32b, where most configs set VA_BITS
to larger than 32b.  Shifting by more than the width is undefined
behavior. And without it, I get compile errors.

I'll send v2 with your suggestion, thanks.
-- 
Thanks,
~Nick Desaulniers

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

* [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET
@ 2017-08-03 17:53           ` Nick Desaulniers
  0 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 17:53 UTC (permalink / raw)
  To: linux-arm-kernel

> Would
>
> #define VA_START (UL(0xffffffffffffffff) - (1 << VA_BITS) + 1)
>
> also work?

I think you'd have to wrap the 1 in a UL(), ex:

#define VA_START (UL(0xffffffffffffffff) - (UL(1) << VA_BITS) + 1)

Otherwise IIUC a integral literal (`1`) is treated as an int, which on
arm64 is LP64 making it 32b, where most configs set VA_BITS
to larger than 32b.  Shifting by more than the width is undefined
behavior. And without it, I get compile errors.

I'll send v2 with your suggestion, thanks.
-- 
Thanks,
~Nick Desaulniers

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

* [PATCH v2] arm64: avoid overflow in VA_START and PAGE_OFFSET
  2017-08-03 17:53           ` Nick Desaulniers
@ 2017-08-03 18:03             ` Nick Desaulniers
  -1 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 18:03 UTC (permalink / raw)
  Cc: zijun_hu, akpm, ghackmann, dianders, srhines, pirama, mka,
	ard.biesheuvel, Nick Desaulniers, Catalin Marinas, Will Deacon,
	Mark Rutland, Laura Abbott, Neeraj Upadhyay,
	Oleksandr Andrushchenko, Alexander Popov, linux-arm-kernel,
	linux-kernel

The bitmask used to define these values produces overflow, as seen by
this compiler warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
1))
                                      ~~~~~~~~~~~~~~~~~~  ^

It would be preferrable to use GENMASK_ULL() instead, but it's not set
up to be used from assembly (the UL() macro token pastes UL suffixes
when not included in assembly sources).

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
Suggested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm64/include/asm/memory.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..ef39dcb9ca6a 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -64,8 +64,10 @@
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
-#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define VA_START		(UL(0xffffffffffffffff) - \
+	(UL(1) << VA_BITS) + 1)
+#define PAGE_OFFSET		(UL(0xffffffffffffffff) - \
+	(UL(1) << (VA_BITS - 1)) + 1)
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH v2] arm64: avoid overflow in VA_START and PAGE_OFFSET
@ 2017-08-03 18:03             ` Nick Desaulniers
  0 siblings, 0 replies; 26+ messages in thread
From: Nick Desaulniers @ 2017-08-03 18:03 UTC (permalink / raw)
  To: linux-arm-kernel

The bitmask used to define these values produces overflow, as seen by
this compiler warning:

arch/arm64/kernel/head.S:47:8: warning:
      integer overflow in preprocessor expression
  #elif (PAGE_OFFSET & 0x1fffff) != 0
         ^~~~~~~~~~~
arch/arm64/include/asm/memory.h:52:46: note:
      expanded from macro 'PAGE_OFFSET'
  #define PAGE_OFFSET             (UL(0xffffffffffffffff) << (VA_BITS -
1))
                                      ~~~~~~~~~~~~~~~~~~  ^

It would be preferrable to use GENMASK_ULL() instead, but it's not set
up to be used from assembly (the UL() macro token pastes UL suffixes
when not included in assembly sources).

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Suggested-by: Yury Norov <ynorov@caviumnetworks.com>
Suggested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm64/include/asm/memory.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 32f82723338a..ef39dcb9ca6a 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -64,8 +64,10 @@
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
  */
 #define VA_BITS			(CONFIG_ARM64_VA_BITS)
-#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
-#define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
+#define VA_START		(UL(0xffffffffffffffff) - \
+	(UL(1) << VA_BITS) + 1)
+#define PAGE_OFFSET		(UL(0xffffffffffffffff) - \
+	(UL(1) << (VA_BITS - 1)) + 1)
 #define KIMAGE_VADDR		(MODULES_END)
 #define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
  2017-08-02 22:51   ` Matthias Kaehlcke
@ 2017-08-04  2:26     ` kbuild test robot
  -1 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-08-04  2:26 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: kbuild-all, zijun_hu, Andrew Morton, Catalin Marinas,
	Will Deacon, Mark Rutland, Laura Abbott, linux-kernel,
	linux-arm-kernel, Doug Anderson, Nick Desaulniers, Greg Hackmann,
	Matthias Kaehlcke

[-- Attachment #1: Type: text/plain, Size: 13831 bytes --]

Hi Matthias,

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.13-rc3 next-20170803]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/bitops-Avoid-integer-overflow-warning-in-GENMASK_ULL/20170803-230211
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from arch/arm64/include/asm/pgtable.h:22:0,
                    from arch/arm64/include/asm/kernel-pgtable.h:22,
                    from arch/arm64/kernel/head.S:34:
>> arch/arm64/include/asm/memory.h:68:33: error: missing binary operator before token "("
    #define PAGE_OFFSET  GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
                                    ^
>> arch/arm64/kernel/head.S:51:8: note: in expansion of macro 'PAGE_OFFSET'
    #elif (PAGE_OFFSET & 0x1fffff) != 0
           ^~~~~~~~~~~
--
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from arch/arm64/mm/init.c:20:
   arch/arm64/mm/init.c: In function 'mem_init':
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
>> arch/arm64/mm/init.c:614:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
>> arch/arm64/mm/init.c:614:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:637:2: note: in expansion of macro 'pr_notice'
     pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:637:2: note: in expansion of macro 'pr_notice'
     pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
--
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from include/asm-generic/bug.h:15,
                    from arch/arm64/include/asm/bug.h:66,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/mm.h:8,
                    from include/linux/mman.h:4,
                    from arch/arm64/kvm/../../../virt/kvm/arm/mmu.c:19:
   arch/arm64/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_mmu_init':
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:13:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:308:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> include/linux/kvm_host.h:446:2: note: in expansion of macro 'pr_info'
     pr_info("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
     ^~~~~~~
>> arch/arm64/kvm/../../../virt/kvm/arm/mmu.c:1754:2: note: in expansion of macro 'kvm_info'
     kvm_info("HYP VA range: %lx:%lx\n",
     ^~~~~~~~

vim +68 arch/arm64/include/asm/memory.h

    56	
    57	/*
    58	 * PAGE_OFFSET - the virtual address of the start of the linear map (top
    59	 *		 (VA_BITS - 1))
    60	 * KIMAGE_VADDR - the virtual address of the start of the kernel image
    61	 * VA_BITS - the maximum number of bits for virtual addresses.
    62	 * VA_START - the first kernel virtual address.
    63	 * TASK_SIZE - the maximum size of a user space task.
    64	 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
    65	 */
    66	#define VA_BITS			(CONFIG_ARM64_VA_BITS)
    67	#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
  > 68	#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
    69	#define KIMAGE_VADDR		(MODULES_END)
    70	#define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
    71	#define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
    72	#define MODULES_VSIZE		(SZ_128M)
    73	#define VMEMMAP_START		(PAGE_OFFSET - VMEMMAP_SIZE)
    74	#define PCI_IO_END		(VMEMMAP_START - SZ_2M)
    75	#define PCI_IO_START		(PCI_IO_END - PCI_IO_SIZE)
    76	#define FIXADDR_TOP		(PCI_IO_START - SZ_2M)
    77	#define TASK_SIZE_64		(UL(1) << VA_BITS)
    78	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35216 bytes --]

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

* [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL
@ 2017-08-04  2:26     ` kbuild test robot
  0 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-08-04  2:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.13-rc3 next-20170803]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/bitops-Avoid-integer-overflow-warning-in-GENMASK_ULL/20170803-230211
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from arch/arm64/include/asm/pgtable.h:22:0,
                    from arch/arm64/include/asm/kernel-pgtable.h:22,
                    from arch/arm64/kernel/head.S:34:
>> arch/arm64/include/asm/memory.h:68:33: error: missing binary operator before token "("
    #define PAGE_OFFSET  GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
                                    ^
>> arch/arm64/kernel/head.S:51:8: note: in expansion of macro 'PAGE_OFFSET'
    #elif (PAGE_OFFSET & 0x1fffff) != 0
           ^~~~~~~~~~~
--
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from arch/arm64/mm/init.c:20:
   arch/arm64/mm/init.c: In function 'mem_init':
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
>> arch/arm64/mm/init.c:614:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
>> arch/arm64/mm/init.c:614:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:626:2: note: in expansion of macro 'pr_notice'
     pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:628:2: note: in expansion of macro 'pr_notice'
     pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:631:2: note: in expansion of macro 'pr_notice'
     pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
     ^~~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:637:2: note: in expansion of macro 'pr_notice'
     pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
>> include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:12:21: note: in expansion of macro 'KERN_SOH'
    #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
                        ^~~~~~~~
>> include/linux/printk.h:306:9: note: in expansion of macro 'KERN_NOTICE'
     printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~~~
   arch/arm64/mm/init.c:637:2: note: in expansion of macro 'pr_notice'
     pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
     ^~~~~~~~~
--
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from include/asm-generic/bug.h:15,
                    from arch/arm64/include/asm/bug.h:66,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/mm.h:8,
                    from include/linux/mman.h:4,
                    from arch/arm64/kvm/../../../virt/kvm/arm/mmu.c:19:
   arch/arm64/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_mmu_init':
   include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:13:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:308:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> include/linux/kvm_host.h:446:2: note: in expansion of macro 'pr_info'
     pr_info("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
     ^~~~~~~
>> arch/arm64/kvm/../../../virt/kvm/arm/mmu.c:1754:2: note: in expansion of macro 'kvm_info'
     kvm_info("HYP VA range: %lx:%lx\n",
     ^~~~~~~~

vim +68 arch/arm64/include/asm/memory.h

    56	
    57	/*
    58	 * PAGE_OFFSET - the virtual address of the start of the linear map (top
    59	 *		 (VA_BITS - 1))
    60	 * KIMAGE_VADDR - the virtual address of the start of the kernel image
    61	 * VA_BITS - the maximum number of bits for virtual addresses.
    62	 * VA_START - the first kernel virtual address.
    63	 * TASK_SIZE - the maximum size of a user space task.
    64	 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
    65	 */
    66	#define VA_BITS			(CONFIG_ARM64_VA_BITS)
    67	#define VA_START		(UL(0xffffffffffffffff) << VA_BITS)
  > 68	#define PAGE_OFFSET		GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1)
    69	#define KIMAGE_VADDR		(MODULES_END)
    70	#define MODULES_END		(MODULES_VADDR + MODULES_VSIZE)
    71	#define MODULES_VADDR		(VA_START + KASAN_SHADOW_SIZE)
    72	#define MODULES_VSIZE		(SZ_128M)
    73	#define VMEMMAP_START		(PAGE_OFFSET - VMEMMAP_SIZE)
    74	#define PCI_IO_END		(VMEMMAP_START - SZ_2M)
    75	#define PCI_IO_START		(PCI_IO_END - PCI_IO_SIZE)
    76	#define FIXADDR_TOP		(PCI_IO_START - SZ_2M)
    77	#define TASK_SIZE_64		(UL(1) << VA_BITS)
    78	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 35216 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170804/36183971/attachment-0001.gz>

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

end of thread, other threads:[~2017-08-04  2:27 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-02 22:51 [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Matthias Kaehlcke
2017-08-02 22:51 ` Matthias Kaehlcke
2017-08-02 22:51 ` [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Matthias Kaehlcke
2017-08-02 22:51   ` Matthias Kaehlcke
2017-08-02 23:13   ` Nick Desaulniers
2017-08-02 23:13     ` Nick Desaulniers
2017-08-02 23:19     ` Nick Desaulniers
2017-08-02 23:19       ` Nick Desaulniers
2017-08-02 23:44       ` Matthias Kaehlcke
2017-08-02 23:44         ` Matthias Kaehlcke
2017-08-03 13:20   ` Yury Norov
2017-08-03 13:20     ` Yury Norov
2017-08-03 17:11     ` [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET Nick Desaulniers
2017-08-03 17:11       ` Nick Desaulniers
2017-08-03 17:20       ` Ard Biesheuvel
2017-08-03 17:20         ` Ard Biesheuvel
2017-08-03 17:53         ` Nick Desaulniers
2017-08-03 17:53           ` Nick Desaulniers
2017-08-03 18:03           ` [PATCH v2] " Nick Desaulniers
2017-08-03 18:03             ` Nick Desaulniers
2017-08-04  2:26   ` [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL kbuild test robot
2017-08-04  2:26     ` kbuild test robot
2017-08-03 13:24 ` [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Yury Norov
2017-08-03 13:24   ` Yury Norov
2017-08-03 17:03   ` Matthias Kaehlcke
2017-08-03 17:03     ` Matthias Kaehlcke

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.