Message ID | 20240418160713.27101-1-jason.andryuk@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | x86/PVH: Use unsigned int for dom0 e820 index | expand |
On 18.04.2024 18:07, Jason Andryuk wrote: > 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. > > Requested-by: Jan Beulich <jbeulich@suse.com> > Signed-off-by: Jason Andryuk <jason.andryuk@amd.com> Acked-by: Jan Beulich <jbeulich@suse.com>
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index d158f4d241..ac71d43a6b 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -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;
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. Requested-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com> --- xen/arch/x86/hvm/dom0_build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)