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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 18 Apr 2024 12:07:13 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zp89nXlE484aF/SogIXg0jLTRzLzbU7LFmPbCM15Q2Q=; b=f71kx4YcOwnkFU8PwxvQUJ4h8ZcF1movja17W02naDKslLkbKWBpDkMohinBjwjnC2FGmfwkP+VzqaUl4RQBOtkMe3lDEPpju5J1tFa2PIqqePyh7T00zJ2BFYfj/LSnWufxSwmn1Lx0s9XWEDmHRcNIBdwk4R96JNXXKX+GxJr0k9aIWOXB5QfwXH3IkV9xY3+RGoZagwxUd7CqW2551NLqyqqz59Yjwn0y4TCWZ9xsm0v+WqgDlRxik4xdRttRlaw6jV1itS1qKRTdO8CGuoO5nMVX4cFkOOCWF2wl4Ol7blARntBuh0ujAOa0GijusOrD52Vdn9BkXlMMPIvW5w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VScJpLV3JLMnIf08jRVQ8tC+896hfqB/HBfK4m3V3Sjegol8TPgvvI2dgOCHj0ejTTQ3/XOa/CuAtUliSV7gW+ctEqKvylywYBdIXTUSUIKfxKKpbzMvIFXAv3nwSpozgX5yxOPjNLT/CoZyl5rfZTHEnrH5isqBM7qFNLlRz5n+FRQ7HF5BmP3HBsN9pkItWyTB9htgCKqnD0MVS9MAwWmmsasyf+EEf6JHZpwLfu2zYuWYGkWBCWVsfpC9RQJ6XpCS0H8OYh71vWfTWn+GQfntaWcHckWPf6jALJeyNJFfua8RKMsubzSGbaUDJbxzzuv9LuW1PW/6H0hgOmFRFA==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 18 Apr 2024 16:07:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
 xen/arch/x86/hvm/dom0_build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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;
-- 
2.44.0




 


Rackspace

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