Skip to contentSkip to conversation

x86: fix off-by-one error when printing memory ranges

PATCH In review Wei Liu 3 participants 9 messages Feb 4, 2020 – Feb 6, 2020

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 x86: fix off-by-one error when printing memory ranges

---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);
         switch (map[i].type) {
         case E820_RAM:
             printk("(usable)\n");
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
In reply to Wei Liu
Quoted 10 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/e820.c +0 -0
index b9f589cac3..d67387f137 100644

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 5 lines
xen/arch/x86/e820.c +1 -1
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Jan

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

author
#3 lore raw
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

Wei.

Quoted 1 line

Jan

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

#4 lore raw
Quoted 29 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Quoted 8 lines

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

I think this would make things less ambiguous, yes. But my primary request here is to have neither "fix" nor "error" nor anything alike in the title or description.

Jan

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

author
#5 lore raw
Quoted 34 lines · Jan Beulich
Quoted 33 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

Quoted 8 lines
Quoted 4 lines

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

I think this would make things less ambiguous, yes. But my primary request here is to have neither "fix" nor "error" nor anything alike in the title or description.

OK. I can certainly change the subject line to

x86: subtract 1 when printing e820 ranges

Wei.

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

author
#6 lore raw
Quoted 40 lines · Wei Liu
Quoted 39 lines · Jan Beulich
Quoted 37 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

Quoted 7 lines
Quoted 3 lines

I think this would make things less ambiguous, yes. But my primary request here is to have neither "fix" nor "error" nor anything alike in the title or description.

OK. I can certainly change the subject line to

x86: subtract 1 when printing e820 ranges

If I hear no further objections I will commit this patch with the above subject line today.

Wei.

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

#7 lore raw
Quoted 45 lines · Wei Liu
Quoted 44 lines · Wei Liu
Quoted 42 lines · Jan Beulich
Quoted 29 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Quoted 8 lines

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

I think this would make things less ambiguous, yes. But my primary request here is to have neither "fix" nor "error" nor anything alike in the title or description.

Quoted 6 lines
Quoted 3 lines

OK. I can certainly change the subject line to

x86: subtract 1 when printing e820 ranges

If I hear no further objections I will commit this patch with the above subject line today.

And with the presentation changed to [,]?

Jan

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

author
#8 lore raw
Quoted 46 lines · Jan Beulich
Quoted 45 lines · Wei Liu
Quoted 44 lines · Wei Liu
Quoted 42 lines · Jan Beulich
Quoted 29 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Wei Liu
---
 xen/arch/x86/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

xen/arch/x86/e820.c static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent · line 97

Quoted 10 lines
xen/arch/x86/e820.c +1 -1
index b9f589cac3..d67387f137 100644
@@ -94,7 +94,7 @@ static void __init print_e820_memory_map(struct e820entry *map, unsigned int ent
     for (i = 0; i < entries; i++) {
         printk(" %016Lx - %016Lx ",
                (unsigned long long)(map[i].addr),
-               (unsigned long long)(map[i].addr + map[i].size));
+               (unsigned long long)(map[i].addr + map[i].size) - 1);

Why was this an error? If we used [,] like Linux does - sure. But we don't. The presentation, without looking at the source, simply leaves open whether this was meant to be [,] or [,). And it continues to be left open with the adjustment made.

Well, Linux's representation is not what is normally done in math either.

It is like

Quoted 8 lines

Xen: [mem 0x0000000000000000-0x000000000009efff] usable

Note it is using '-', not ','. And there is "mem" at the beginning.

I have always interpreted the [] pair as something to enclose the range, not of mathematically meaning.

If you want, I can change Xen's format string to "[%016Lx, %016Lx]".

I think this would make things less ambiguous, yes. But my primary request here is to have neither "fix" nor "error" nor anything alike in the title or description.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK. I can certainly change the subject line to

x86: subtract 1 when printing e820 ranges

If I hear no further objections I will commit this patch with the above subject line today.

And with the presentation changed to [,]?

Fine by me too. I will post a new patch shortly.

Wei.

Quoted 2 lines

Jan

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