Skip to contentSkip to conversation

x86/PVH: Use unsigned int for dom0 e820 index

PATCH In review Jason Andryuk 2 participants 2 messages Apr 18, 2024 – Apr 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/PVH: Use unsigned int for dom0 e820 index

Switch to unsigned int for the dom0 e820 index. This eliminates the potential for array underflows, and the compiler might be able to generate better code.

---
 xen/arch/x86/hvm/dom0_build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/dom0_build.c +2 -2
index d158f4d241..ac71d43a6b 100644
@@ -569,7 +569,7 @@ static paddr_t __init find_kernel_memory(
 {
     paddr_t kernel_size = elf->dest_size;
     unsigned int align;
-    int i;
+    unsigned int i;
 
     if ( parms->phys_align != UNSET_ADDR32 )
         align = parms->phys_align;
@@ -579,7 +579,7 @@ static paddr_t __init find_kernel_memory(
         align = MB(2);
 
     /* Search backwards to find the highest address. */
-    for ( i = d->arch.nr_e820 - 1; i >= 0 ; i-- )
+    for ( i = d->arch.nr_e820; i--; )
     {
         paddr_t start = d->arch.e820[i].addr;
         paddr_t end = start + d->arch.e820[i].size;
Signature · 1 line
2.44.0