Skip to contentSkip to conversation

x86/MCFG: fix off-by-one in E820 check

PATCH In review Jan Beulich 3 participants 4 messages Feb 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/MCFG: fix off-by-one in E820 check

Also adjust the comment ahead of e820_all_mapped() to clarify that the range is not inclusive at its end.

xen/arch/x86/e820.c +1 -1
@@ -38,7 +38,7 @@ struct e820map e820;
 struct e820map __initdata e820_raw;
 
 /*
- * This function checks if the entire range <start,end> is mapped with type.
+ * This function checks if the entire range [start,end) is mapped with type.
  *
  * Note: this function only works correct if the e820 table is sorted and
  * not-overlapping, which is the case
xen/arch/x86/x86_64/mmconfig-shared.c +1 -1
@@ -337,7 +337,7 @@ static int __init is_mmconf_reserved(
     u64 old_size = size;
     int valid = 0;
 
-    while (!e820_all_mapped(addr, addr + size - 1, E820_RESERVED)) {
+    while (!e820_all_mapped(addr, addr + size, E820_RESERVED)) {
         size >>= 1;
         if (size < (16UL<<20))
             break;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

Also adjust the comment ahead of e820_all_mapped() to clarify that the range is not inclusive at its end.

xen/arch/x86/e820.c struct e820map e820; · line 41

Quoted 9 lines
xen/arch/x86/e820.c +1 -1
@@ -38,7 +38,7 @@ struct e820map e820;
 struct e820map __initdata e820_raw;
 
 /*
- * This function checks if the entire range <start,end> is mapped with type.
+ * This function checks if the entire range [start,end) is mapped with type.

There is another instance of <> inside e820_all_mapped. It would be good if that's fixed too.

Quoted 6 lines
xen/arch/x86/e820.c +0 -0
  *
  * Note: this function only works correct if the e820 table is sorted and
  * not-overlapping, which is the case

xen/arch/x86/x86_64/mmconfig-shared.c static int __init is_mmconf_reserved( · line 343

Quoted 8 lines
xen/arch/x86/x86_64/mmconfig-shared.c +1 -1
@@ -337,7 +337,7 @@ static int __init is_mmconf_reserved(
     u64 old_size = size;
     int valid = 0;
 
-    while (!e820_all_mapped(addr, addr + size - 1, E820_RESERVED)) {
+    while (!e820_all_mapped(addr, addr + size, E820_RESERVED)) {
         size >>= 1;
         if (size < (16UL<<20))
             break;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 8 lines · Wei Liu
Quoted 5 lines · Jan Beulich

Also adjust the comment ahead of e820_all_mapped() to clarify that the range is not inclusive at its end.

Thanks.

Quoted 11 lines

xen/arch/x86/e820.c struct e820map e820; · line 41

Quoted 8 lines
xen/arch/x86/e820.c +1 -1
@@ -38,7 +38,7 @@ struct e820map e820;
 struct e820map __initdata e820_raw;
 
 /*
- * This function checks if the entire range <start,end> is mapped with type.
+ * This function checks if the entire range [start,end) is mapped with type.

There is another instance of <> inside e820_all_mapped. It would be good if that's fixed too.

That one isn't misleading (talking about just the start of the region), so I left it alone. But since you've asked for it - fixed.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jan Beulich
Quoted 9 lines · Jan Beulich

Also adjust the comment ahead of e820_all_mapped() to clarify that the range is not inclusive at its end.

xen/arch/x86/e820.c struct e820map e820; · line 43

Quoted 7 lines
xen/arch/x86/e820.c +1 -1
@@ -38,7 +38,7 @@ struct e820map e820;
 struct e820map __initdata e820_raw;
 
 /*
- * This function checks if the entire range <start,end> is mapped with type.
+ * This function checks if the entire range [start,end) is mapped with type.
  *
  * Note: this function only works correct if the e820 table is sorted and

Wouldn't mind if you took the opportunity to also s/correct/correctly/ in the sentence above.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel