xl, e820_host, PV passthrough: Fix guests crashing when memory == maxmem
PATCH 1/1 xl, e820_host, PV passthrough: Fix guests crashing when memory == maxmem
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an E820_RAM entry at the end of the E820 array. The added E820_RAM would contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only one E820_RAM entry that is of 512MB size on many Intel systems.
--- tools/libxl/libxl_x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxl/libxl_x86.c +1 -1
@@ -182,7 +182,7 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[], idx++; }/* At this point we have the mapped RAM + E820 entries from src. */ -if (balloon_kb) { +if (balloon_kb || delta_kb) {/* and if we truncated the RAM region, then add it to the end. */ e820[idx].type =E820_RAM ; e820[idx].addr = (uint64_t)(1ULL << 32) > last ?
Signature · 1 line
1.7.7.6
Quoted 10 lines · Konrad Rzeszutek Wilk
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an
E820_RAMentry at the end of the E820 array. The addedE820_RAMwould contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only oneE820_RAMentry that is of 512MB size on many Intel systems.
Quoted 2 lines
Reported-by Christian Holpert <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>
Quoted 17 lines
--- tools/libxl/libxl_x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/libxl/libxl_x86.c +1
-1@@ -182,7 +182,7 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[], idx++; }/* At this point we have the mapped RAM + E820 entries from src. */ -if (balloon_kb) { +if (balloon_kb || delta_kb) {/* and if we truncated the RAM region, then add it to the end. */ e820[idx].type =E820_RAM ; e820[idx].addr = (uint64_t)(1ULL << 32) > last ?
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Konrad Rzeszutek Wilk
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an
E820_RAMentry at the end of the E820 array. The addedE820_RAMwould contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only oneE820_RAMentry that is of 512MB size on many Intel systems.
Quoted 4 lines
Quoted 2 lines
Reported-by Christian Holpert <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>Acked-by Ian Campbell <[email protected]>
George,
Would you be OK putting this in Xen 4.3? It is only exposed if a user
1) launches a PV guest
2). Has in the guest config: pci=['blabla']\ne820_host=1 3). Is not that freq used as only a couple of people seem to use it
Quoted 20 lines
Quoted 18 lines
--- tools/libxl/libxl_x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/libxl/libxl_x86.c +1
-1@@ -182,7 +182,7 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[], idx++; }/* At this point we have the mapped RAM + E820 entries from src. */ -if (balloon_kb) { +if (balloon_kb || delta_kb) {/* and if we truncated the RAM region, then add it to the end. */ e820[idx].type =E820_RAM ; e820[idx].addr = (uint64_t)(1ULL << 32) > last ?
Quoted 15 lines · Konrad Rzeszutek Wilk
Quoted 14 lines · Ian Campbell
Quoted 12 lines · Konrad Rzeszutek Wilk
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an
E820_RAMentry at the end of the E820 array. The addedE820_RAMwould contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only oneE820_RAMentry that is of 512MB size on many Intel systems.Reported-by Christian Holpert <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>
Quoted 7 lines
Quoted 1 line
Acked-by Ian Campbell <[email protected]>George,
Would you be OK putting this in Xen 4.3? It is only exposed if a user
1) launches a PV guest
2). Has in the guest config: pci=['blabla']\ne820_host=1 3). Is not that freq used as only a couple of people seem to use it
TBH I was just going to commit it as an obvious bug fix in my next sweep of my queue (probably on Tuesday at this rate...)
I guess George has until then to object ;-)
Ian
Quoted 21 lines · Ian Campbell
Quoted 12 lines · Konrad Rzeszutek Wilk
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Konrad Rzeszutek Wilk
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an
E820_RAMentry at the end of the E820 array. The addedE820_RAMwould contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only oneE820_RAMentry that is of 512MB size on many Intel systems.Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Reported-by Christian Holpert <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>Acked-by Ian Campbell <[email protected]>George,
Would you be OK putting this in Xen 4.3? It is only exposed if a user
1) launches a PV guest
2). Has in the guest config: pci=['blabla']\ne820_host=1 3). Is not that freq used as only a couple of people seem to use it
Quoted 4 lines
TBH I was just going to commit it as an obvious bug fix in my next sweep of my queue (probably on Tuesday at this rate...)
I guess George has until then to object ;-)
Sounds like a bug fix -- no objections. :-)
-George
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Konrad Rzeszutek Wilk
The code had an obvious bug where it would assume that the balloon amount would always be _something_ and add an
E820_RAMentry at the end of the E820 array. The addedE820_RAMwould contain the balloon amount plus the delta of memory that had to be subtracted b/c of the various E820 entries. That assumption is certainly true when maxmem != mem, but if guest config has maxmem = memory that is incorrect (as balloon value is zero). The end result is that the E820 that is constructed is missing a swath of "delta" memory and in most cases ends up with only oneE820_RAMentry that is of 512MB size on many Intel systems.
Quoted 4 lines
Quoted 2 lines
Reported-by Christian Holpert <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>Acked-by Ian Campbell <[email protected]>
And applied.