Thread (3 messages) 3 messages, 3 authors, 2022-02-15

[PATCH] powerpc/ptdump: Fix sparse warning in hashpagetable.c

STALE1690d

From: Christophe Leroy <hidden>
Date: 2022-01-30 18:39:28
Also in: lkml
Subsystem: linux for powerpc (32-bit and 64-bit), the rest · Maintainers: Madhavan Srinivasan, Linus Torvalds

  arch/powerpc/mm/ptdump/hashpagetable.c:264:29: warning: restricted __be64 degrades to integer
  arch/powerpc/mm/ptdump/hashpagetable.c:265:49: warning: restricted __be64 degrades to integer
  arch/powerpc/mm/ptdump/hashpagetable.c:267:36: warning: incorrect type in assignment (different base types)
  arch/powerpc/mm/ptdump/hashpagetable.c:267:36:    expected unsigned long long [usertype]
  arch/powerpc/mm/ptdump/hashpagetable.c:267:36:    got restricted __be64 [usertype] v
  arch/powerpc/mm/ptdump/hashpagetable.c:268:36: warning: incorrect type in assignment (different base types)
  arch/powerpc/mm/ptdump/hashpagetable.c:268:36:    expected unsigned long long [usertype]
  arch/powerpc/mm/ptdump/hashpagetable.c:268:36:    got restricted __be64 [usertype] r

struct hash_pte fields have type __be64. Convert them to
regular long before using them.

Reported-by: kernel test robot <redacted>
Signed-off-by: Christophe Leroy <redacted>
---
 arch/powerpc/mm/ptdump/hashpagetable.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/mm/ptdump/hashpagetable.c b/arch/powerpc/mm/ptdump/hashpagetable.c
index c7f824d294b2..bf60ab1bedb9 100644
--- a/arch/powerpc/mm/ptdump/hashpagetable.c
+++ b/arch/powerpc/mm/ptdump/hashpagetable.c
@@ -261,11 +261,11 @@ static int pseries_find(unsigned long ea, int psize, bool primary, u64 *v, u64 *
 		if (lpar_rc)
 			continue;
 		for (j = 0; j < 4; j++) {
-			if (HPTE_V_COMPARE(ptes[j].v, want_v) &&
-					(ptes[j].v & HPTE_V_VALID)) {
+			if (HPTE_V_COMPARE(be64_to_cpu(ptes[j].v), want_v) &&
+			    (be64_to_cpu(ptes[j].v) & HPTE_V_VALID)) {
 				/* HPTE matches */
-				*v = ptes[j].v;
-				*r = ptes[j].r;
+				*v = be64_to_cpu(ptes[j].v);
+				*r = be64_to_cpu(ptes[j].r);
 				return 0;
 			}
 		}
-- 
2.33.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help