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

[PATCH][4.17] x86/NUMA: correct off-by-1 in node map population


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 4 Oct 2022 12:13:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=cW3dUW2PhLY9fHD9lB+xnYzINvkpKb/gaU4i2IiPwHY=; b=TY/lJuYkwgejo5p0OX1TVRh6FCD/dZtKokRRcT8i3QP/t8KMr+a0BiOtAIj2Ab/f/sySFag7s7leX/uWhFuuqoFASYCcIzVeHDPCXk3cmWdEdSlIrTP7xEo0eaB1liW5BYneuE7Fv9wwO2nYjbSqhk84F1hax0cokO84NLvZrCmixMwMjp4lqpAKjVO5YvUW7M698ry20xk3D8A5oWPVQc3zpQIzSyc+tum9/pY8xZXMtSC4TYOOUlUzMHqUOifGfhow/Tn7SMxPsbKAh/PEkMPJ1m+lQcbHme1p/19vfyk1ir4oSIzho46T+NZjn9U4jf03EUXPLTuolGB/LaROUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mjflINUVDFitznvAQD23KnY6sS2pM6DUq7TY0TVZKeqF53+aGkIJNLtUvbqlu3Cc56QQq16NUNw16z5IjQSaQQtfNenaHkcW5pbxcOFIUyCTui4burJydzMbJkxUJtJSvVD8O6Aoxs/N+Hd74UB/sOFyzEZFU96aJs4vb/19lunkPaI6Lm+05MFWN9QvqS2lT0maBWGENYOBBEI/L0lpQBhxYsY9nwke7r/aP730G19VX2ZKAy0yb6pRxhtYv5iScGpuvzKWFKNYhrA3ZvTxIkMpqu7u/SViXr0iUqSFigG0JYos2NMe00s2qcpnItaWWAVS6FOfFQyB/8gFnI2PQg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Tue, 04 Oct 2022 10:14:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

As it turns out populate_memnodemap() so far "relied" on
extract_lsb_from_nodes() setting memnodemapsize one too high in edge
cases. Correct the issue there as well, by changing "epdx" to be an
inclusive PDX and adjusting the respective relational operators.

While there also limit the scope of both related variables.

Fixes: b1f4b45d02ca ("x86/NUMA: correct off-by-1 in node map size calculation")
Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
For symmetry it might be helpful to change "epdx" to be inclusive in
extract_lsb_from_nodes() as well. I actually had it that way first in
the earlier change, but then thought the smaller diff would be better.

--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -65,15 +65,15 @@ int srat_disabled(void)
 static int __init populate_memnodemap(const struct node *nodes,
                                       int numnodes, int shift, nodeid_t 
*nodeids)
 {
-    unsigned long spdx, epdx;
     int i, res = -1;
 
     memset(memnodemap, NUMA_NO_NODE, memnodemapsize * sizeof(*memnodemap));
     for ( i = 0; i < numnodes; i++ )
     {
-        spdx = paddr_to_pdx(nodes[i].start);
-        epdx = paddr_to_pdx(nodes[i].end - 1) + 1;
-        if ( spdx >= epdx )
+        unsigned long spdx = paddr_to_pdx(nodes[i].start);
+        unsigned long epdx = paddr_to_pdx(nodes[i].end - 1);
+
+        if ( spdx > epdx )
             continue;
         if ( (epdx >> shift) >= memnodemapsize )
             return 0;
@@ -88,7 +88,7 @@ static int __init populate_memnodemap(co
                 memnodemap[spdx >> shift] = nodeids[i];
 
             spdx += (1UL << shift);
-        } while ( spdx < epdx );
+        } while ( spdx <= epdx );
         res = 1;
     }
 



 


Rackspace

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