All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pdx: cast PAGE_SIZE value ahead of shifting
@ 2025-08-13 12:55 Roger Pau Monne
  2025-08-13 12:58 ` Andrew Cooper
  2025-08-14  7:18 ` Jan Beulich
  0 siblings, 2 replies; 10+ messages in thread
From: Roger Pau Monne @ 2025-08-13 12:55 UTC (permalink / raw)
  To: xen-devel
  Cc: Roger Pau Monne, Andrew Cooper, Anthony PERARD, Michal Orzel,
	Jan Beulich, Julien Grall, Stefano Stabellini

Coverity complains that:

277    ma_va_bottom_mask   = (PAGE_SIZE << bottom_shift) - 1;
 In expression 0x1000 << bottom_shift, left shifting by more than 31 bits
 has undefined behavior. The shift amount, bottom_shift, is as much as 63.

Cast PAGE_SIZE to paddr_t so it has the right width.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Coverity ID: 1662707
Fixes: bac2000063ba ('x86-64: reduce range spanned by 1:1 mapping and frame table indexes')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/common/pdx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/pdx.c b/xen/common/pdx.c
index 7e070ff962e8..5f54dd18f90d 100644
--- a/xen/common/pdx.c
+++ b/xen/common/pdx.c
@@ -288,7 +288,7 @@ bool __init pfn_pdx_compression_setup(paddr_t base)
 
     pfn_pdx_hole_shift  = hole_shift;
     pfn_pdx_bottom_mask = (1UL << bottom_shift) - 1;
-    ma_va_bottom_mask   = (PAGE_SIZE << bottom_shift) - 1;
+    ma_va_bottom_mask   = ((paddr_t)PAGE_SIZE << bottom_shift) - 1;
     pfn_hole_mask       = ((1UL << hole_shift) - 1) << bottom_shift;
     pfn_top_mask        = ~(pfn_pdx_bottom_mask | pfn_hole_mask);
     ma_top_mask         = pfn_top_mask << PAGE_SHIFT;
-- 
2.49.0



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

end of thread, other threads:[~2025-08-14 15:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 12:55 [PATCH] pdx: cast PAGE_SIZE value ahead of shifting Roger Pau Monne
2025-08-13 12:58 ` Andrew Cooper
2025-08-14  7:18 ` Jan Beulich
2025-08-14 10:28   ` Roger Pau Monné
2025-08-14 10:45     ` Jan Beulich
2025-08-14 13:01       ` Roger Pau Monné
2025-08-14 13:15         ` Jan Beulich
2025-08-14 14:57           ` Roger Pau Monné
2025-08-14 15:04             ` Jan Beulich
2025-08-14 13:19         ` Andrew Cooper

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.