Skip to contentSkip to conversation

arm: fix clang build warning in include/asm/memory.h

PATCH-next Yipeng Zou 4 participants 10 messages Mar 14, 2024 – Mar 19, 2024 Arm (32-bit)

lore
Share & tools
lore

Yipeng Zou

author
#0 lore raw

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]

                             if (addr > (u32)~0)
                                 ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
---
 arch/arm/include/asm/memory.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +4 -0
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
 	return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
 }
 
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
 #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
 
 static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
 		addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
 		if (addr > (u32)~0)
 			addr = IDMAP_INVALID_ADDR;
+#endif
 	}
 	return addr;
 }
Signature · 7 lines
2.34.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 42 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]

                             if (addr > (u32)~0)
                                 ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
---
 arch/arm/include/asm/memory.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +4 -0
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
 	return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
 }
 
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
 #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
 
 static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
 		addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
 		if (addr > (u32)~0)
 			addr = IDMAP_INVALID_ADDR;
+#endif
 	}
 	return addr;
 }
Signature · 1 line
2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +1 -1
index ef2aa79ece5a..fbff07bc3b28 100644
@@ -353,7 +353,7 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
 		addr += arch_phys_to_idmap_offset;
-		if (addr > (u32)~0)
+		if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
 			addr = IDMAP_INVALID_ADDR;
 	}
 	return addr;

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
Quoted 52 lines · Nathan Chancellor
Quoted 40 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]

                             if (addr > (u32)~0)
                                 ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
---
 arch/arm/include/asm/memory.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +4 -1
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
      return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
 }
 
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
 #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
 
 static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
      if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
              addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
              if (addr > (u32)~0)
                      addr = IDMAP_INVALID_ADDR;
+#endif
      }
      return addr;
 }
--
Quoted 2 lines

2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +0 -0
index ef2aa79ece5a..fbff07bc3b28 100644

arch/arm/include/asm/memory.h static inline unsigned long phys_to_idmap(phys_addr_t addr) · line 357

Quoted 6 lines
arch/arm/include/asm/memory.h +1 -1
@@ -353,7 +353,7 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
        if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
                addr += arch_phys_to_idmap_offset;
-               if (addr > (u32)~0)
+               if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
                        addr = IDMAP_INVALID_ADDR;

+1 and I would probably use this as well:

<linux/limits.h>

#define IDMAP_INVALID_ADDR PHYS_ADDR_MAX

if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)

    addr = IDMAP_INVALID_ADDR;

Because then it is clear what is going on: we are capping to the max physical address.

PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on ARM is (~(u32)0).

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 6 lines · Linus Walleij

+1 and I would probably use this as well:

<linux/limits.h>

#define IDMAP_INVALID_ADDR PHYS_ADDR_MAX

Quoted 8 lines

if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)

    addr = IDMAP_INVALID_ADDR;

Because then it is clear what is going on: we are capping to the max physical address.

PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on ARM is (~(u32)0).

... which is _not_ the same as (u32)~0, so using PHYS_ADDR_MAX is not appropriate.

Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 10 lines · Russell King (Oracle)
Quoted 9 lines · Linus Walleij

+1 and I would probably use this as well:

<linux/limits.h>

#define IDMAP_INVALID_ADDR PHYS_ADDR_MAX

if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)

    addr = IDMAP_INVALID_ADDR;
Quoted 8 lines
Quoted 5 lines

Because then it is clear what is going on: we are capping to the max physical address.

PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on ARM is (~(u32)0).

... which is _not_ the same as (u32)~0, so using PHYS_ADDR_MAX is not appropriate.

Attention to detail! Thanks Russell.

However U32_MAX is
#define U32_MAX ((u32)~0U)

So that should work and also convey the attention I think?

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 21 lines · Linus Walleij
Quoted 10 lines · Russell King (Oracle)
Quoted 9 lines · Linus Walleij

+1 and I would probably use this as well:

<linux/limits.h>

#define IDMAP_INVALID_ADDR PHYS_ADDR_MAX

if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)

    addr = IDMAP_INVALID_ADDR;
Quoted 8 lines
Quoted 5 lines

Because then it is clear what is going on: we are capping to the max physical address.

PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on ARM is (~(u32)0).

... which is _not_ the same as (u32)~0, so using PHYS_ADDR_MAX is not appropriate.

Quoted 6 lines

Attention to detail! Thanks Russell.

However U32_MAX is
#define U32_MAX ((u32)~0U)

So that should work and also convey the attention I think?

If you want to use that to define IDMAP_INVALID_ADDR then yes. If you're thinking about getting rid of IDMAP_INVALID_ADDR, then I think that would reduce code readability, because the idea here is that addresses above the 32-bit virtual space are invalid for IDMAP, and just using U32_MAX is a rather opaque way to convey that.

Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#6 lore raw
In reply to Linus Walleij
Quoted 62 lines · Linus Walleij
Quoted 51 lines · Nathan Chancellor
Quoted 40 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]

                              if (addr > (u32)~0)
                                  ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
---
  arch/arm/include/asm/memory.h | 4 ++++
  1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +4 -1
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
       return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
  }
 
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
  #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
 
  static inline unsigned long phys_to_idmap(phys_addr_t addr)
  {
       if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
               addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
               if (addr > (u32)~0)
                       addr = IDMAP_INVALID_ADDR;
+#endif
       }
       return addr;
  }
--
Quoted 2 lines

2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +0 -0
index ef2aa79ece5a..fbff07bc3b28 100644

arch/arm/include/asm/memory.h static inline unsigned long phys_to_idmap(phys_addr_t addr) · line 357

Quoted 6 lines
arch/arm/include/asm/memory.h +1 -1
@@ -353,7 +353,7 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)
  {
         if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
                 addr += arch_phys_to_idmap_offset;
-               if (addr > (u32)~0)
+               if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
                         addr = IDMAP_INVALID_ADDR;

+1 and I would probably use this as well:

<linux/limits.h>

Quoted 7 lines

#define IDMAP_INVALID_ADDR PHYS_ADDR_MAX

if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)

     addr = IDMAP_INVALID_ADDR;

Because then it is clear what is going on: we are capping to the max physical address.

Yes, indeed, It's clearer to indicate what is going on.

Will fix it in that way.

Quoted 10 lines

PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on ARM is (~(u32)0).

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 8 lines
Regards,
Yipeng Zou


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#7 lore raw
In reply to Nathan Chancellor
Quoted 51 lines · Nathan Chancellor
Quoted 42 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]

                              if (addr > (u32)~0)
                                  ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
---
  arch/arm/include/asm/memory.h | 4 ++++
  1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +4 -0
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
  	return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
  }
 
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
  #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
 
  static inline unsigned long phys_to_idmap(phys_addr_t addr)
  {
  	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
  		addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
  		if (addr > (u32)~0)
  			addr = IDMAP_INVALID_ADDR;
+#endif
  	}
  	return addr;
  }
Signature · 1 line
2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +0 -0
index ef2aa79ece5a..fbff07bc3b28 100644

arch/arm/include/asm/memory.h static inline unsigned long phys_to_idmap(phys_addr_t addr) · line 359

Quoted 8 lines
arch/arm/include/asm/memory.h +1 -1
@@ -353,7 +353,7 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)
  {
  	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
  		addr += arch_phys_to_idmap_offset;
-		if (addr > (u32)~0)
+		if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
  			addr = IDMAP_INVALID_ADDR;
  	}
  	return addr;

It absolutely works for it and yes, It's a better way to avoiding that.

Will fix it in that way.

Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 8 lines
Regards,
Yipeng Zou


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#8 lore raw
Quoted 63 lines · Yipeng Zou
Quoted 57 lines · Nathan Chancellor
Quoted 29 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare] if (addr > (u32)~0)
                                  ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")

---
  arch/arm/include/asm/memory.h | 4 ++++

  1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +0 -0
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
       return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
   }

  +#ifdef CONFIG_PHYS_ADDR_T_64BIT
  #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
    static inline unsigned long phys_to_idmap(phys_addr_t addr) {
      if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {

Quoted 11 lines

          addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
          if (addr > (u32)~0)
              addr = IDMAP_INVALID_ADDR;
+#endif
      }
      return addr;
  }

Signature · 1 line
2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +1 -1
index ef2aa79ece5a..fbff07bc3b28 100644
@@ -353,7 +353,7 @@ static inline unsigned long 
 phys_to_idmap(phys_addr_t addr)
   {
       if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
           addr += arch_phys_to_idmap_offset;
-        if (addr > (u32)~0)
+        if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
               addr = IDMAP_INVALID_ADDR;
       }
Quoted 1 line

      return addr;

It absolutely works for it and yes, It's a better way to avoiding that.

Quoted 2 lines

Will fix it in that way.

But I notice that, this way can not silence it when compile, it only can avoid it in running time.

So, maybe we still need to silence it in ifdef's.

Other than that, IDMAP_INVALID_ADDR was used in other place, need to keep it defined.

arch/arm/include/asm/memory.h +0 -0
index 158ad13e9f6a..7143147cd7cc 100644
@@ -351,8 +351,10 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)

 {
        if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) { addr += arch_phys_to_idmap_offset; +#ifdef CONFIG_PHYS_ADDR_T_64BIT
                if (addr > (u32)~0)
                        addr = IDMAP_INVALID_ADDR; +#endif
        }
        return addr;
 }

Quoted 5 lines
Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 8 lines
Regards,
Yipeng Zou


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#9 lore raw
Quoted 70 lines · Yipeng Zou
Quoted 68 lines · Yipeng Zou
Quoted 62 lines · Nathan Chancellor
Quoted 33 lines · Yipeng Zou

There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare] if (addr > (u32)~0) ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes 981b6714dbd2 ("ARM: provide improved virt_to_idmap()

functionality")

---
  arch/arm/include/asm/memory.h | 4 ++++

  1 file changed, 4 insertions(+)
arch/arm/include/asm/memory.h +0 -0
index ef2aa79ece5a..64ced9eb42ff 100644
@@ -347,14 +347,18 @@ static inline bool arm_has_idmap_alias(void)
       return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
   }

  +#ifdef CONFIG_PHYS_ADDR_T_64BIT
  #define IDMAP_INVALID_ADDR ((u32)~0)
+#endif
    static inline unsigned long phys_to_idmap(phys_addr_t addr) {
      if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {

Quoted 11 lines

          addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
          if (addr > (u32)~0)
              addr = IDMAP_INVALID_ADDR;
+#endif
      }
      return addr;
  }

Signature · 1 line
2.34.1

Would it be better to avoid the ifdef's here and just use IS_ENABLED()? I can't see why this would not work for avoiding that warning.

arch/arm/include/asm/memory.h +1 -1
index ef2aa79ece5a..fbff07bc3b28 100644
@@ -353,7 +353,7 @@ static inline unsigned long
 phys_to_idmap(phys_addr_t addr)
   {
       if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
           addr += arch_phys_to_idmap_offset;
-        if (addr > (u32)~0)
+        if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > (u32)~0)
               addr = IDMAP_INVALID_ADDR;
       }
Quoted 1 line

      return addr;

It absolutely works for it and yes, It's a better way to avoiding that.

Quoted 4 lines
Quoted 2 lines

Will fix it in that way.

But I notice that, this way can not silence it when compile, it only can avoid it in running time.

Yeah, I actually tested my suggestion and saw the same thing. Sometimes diagnostics will be hidden by '0 &&' but it seems like that is not the case here. It is not the end of the world, I think that diff looks fine for the issue at hand.

Quoted 22 lines

So, maybe we still need to silence it in ifdef's.

Other than that, IDMAP_INVALID_ADDR was used in other place, need to keep it defined.

arch/arm/include/asm/memory.h +2 -0
index 158ad13e9f6a..7143147cd7cc 100644
@@ -351,8 +351,10 @@ static inline unsigned long phys_to_idmap(phys_addr_t
 addr)
  {
         if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
                 addr += arch_phys_to_idmap_offset;
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
                 if (addr > (u32)~0)
                         addr = IDMAP_INVALID_ADDR;
+#endif
         }
         return addr;

 }

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 2 lines
Regards,
Yipeng Zou

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel