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

[xen master] x86/NUMA: correct off-by-1 in node map size calculation



commit b1f4b45d02cac2bf704c2fcc61c70c3567cfaa5b
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Sep 30 09:55:34 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Sep 30 09:55:34 2022 +0200

    x86/NUMA: correct off-by-1 in node map size calculation
    
    extract_lsb_from_nodes() accumulates "memtop" from all PDXes one past
    the covered ranges. Hence the maximum address which can validly by used
    to index the node map is one below this value, and we may currently set
    up a node map with an unused (and never initialized) trailing entry. In
    boundary cases this may also mean we dynamically allocate a page when
    the static (64-entry) map would suffice.
    
    While there also correct the comment ahead of the function, for it to
    match the actual code: Linux commit 54413927f022 ("x86-64:
    x86_64-make-the-numa-hash-function-nodemap-allocation fix fix") removed
    the ORing in of the end address before we actually cloned their code.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Wei Chen <Wei.Chen@xxxxxxx>
---
 xen/arch/x86/numa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 1bc82c60aa..4f742414b0 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -111,7 +111,7 @@ static int __init allocate_cachealigned_memnodemap(void)
 }
 
 /*
- * The LSB of all start and end addresses in the node map is the value of the
+ * The LSB of all start addresses in the node map is the value of the
  * maximum possible shift.
  */
 static int __init extract_lsb_from_nodes(const struct node *nodes,
@@ -137,7 +137,7 @@ static int __init extract_lsb_from_nodes(const struct node 
*nodes,
         i = BITS_PER_LONG - 1;
     else
         i = find_first_bit(&bitfield, sizeof(unsigned long)*8);
-    memnodemapsize = (memtop >> i) + 1;
+    memnodemapsize = ((memtop - 1) >> i) + 1;
     return i;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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