[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] pdx: cast PAGE_SIZE value ahead of shifting



commit 4dd323029094d93dbc8d174fe744fd7f54f0a7a4
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Wed Aug 13 14:48:08 2025 +0200
Commit:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
CommitDate: Wed Aug 13 15:03:19 2025 +0200

    pdx: cast PAGE_SIZE value ahead of shifting
    
    Coverity complains that:
    
     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@xxxxxxxxxx>
    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@xxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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 9e6b36086f..06536cc639 100644
--- a/xen/common/pdx.c
+++ b/xen/common/pdx.c
@@ -274,7 +274,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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.