common/memory: Fix ABI breakage for XENMEM_add_to_physmap
PATCH 1/1 common/memory: Fix ABI breakage for XENMEM_add_to_physmap
caused by c/s 4be86bb194e25e46b6cbee900601bfee76e8090a
In public/memory.h, struct xen_add_to_physmap has 'space' as an unsigned int, but struct xen_add_to_physmap_batch has 'space' as a uint16_t.
By defining xenmem_add_to_physmap_one() with space defined as uint16_t, the now-common xenmem_add_to_physmap() implicitly truncates xatp->space from unsigned int to uint16_t, which changes the space switch()'d upon.
This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make XENMEM_add_to_physmap hypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
---
As this breakage was caused between 4.4-rc1 and -rc2, I request a release ack for the fix.
This was caught by a compile failure rather than a functional test. I have encountered a different compile error which turns out to be a bug in the cross compiler we are currently using, so I need to fix that before I can functionally test a 4.4-rc2 based XenServer. (Which will be a rather better test of whether the functionality of XENMEM_add_to_physmap is actually still the same. If anyone dares look,
https://github.com/xenserver/xen-4.3.pg/blob/master/xen-legacy-win-xenmapspace-quirks.patch
are the hacks required to make the legacy drivers work on modern Xen.)
--- xen/arch/arm/mm.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/include/xen/mm.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/mm.c +1 -1
@@ -970,7 +970,7 @@ void share_xen_page_with_privileged_guests(int xenmem_add_to_physmap_one (struct domain *d, -uint16_t space, +unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn)
xen/arch/x86/mm.c +1 -1
@@ -4522,7 +4522,7 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)int xenmem_add_to_physmap_one (struct domain *d, -uint16_t space, +unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn)
xen/include/xen/mm.h +1 -1
@@ -356,7 +356,7 @@ static inline unsigned int get_order_from_pages(unsigned long nr_pages)void scrub_one_page (struct page_info *); -int xenmem_add_to_physmap_one (struct domain *d,uint16_t space, +int xenmem_add_to_physmap_one (struct domain *d,unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn);
Signature · 1 line
1.7.10.4
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int,
but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was
discovered because of the XenServer support for legacy Windows PV drivers, which makeXENMEM_add_to_physmaphypercalls using spaces with the top bit set.
The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>
Quoted 4 lines
---
As this breakage was caused between 4.4-rc1 and -rc2, I request a release ack for the fix.
Seconded.
Jan
Quoted 59 lines
This was caught by a compile failure rather than a functional test. I have encountered a different compile error which turns out to be a bug in the cross
compiler we are currently using, so I need to fix that before I can functionally test a 4.4-rc2 based XenServer. (Which will be a rather better test of whether the functionality ofXENMEM_add_to_physmapis actually still the same. If anyone dares look,
https://github.com/xenserver/xen-4.3.pg/blob/master/xen-legacy-win-xenmapspace-qu
irks.patch
are the hacks required to make the legacy drivers work on modern Xen.)--- xen/arch/arm/mm.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/include/xen/mm.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/mm.c +1
-1@@ -970,7 +970,7 @@ void share_xen_page_with_privileged_guests(int xenmem_add_to_physmap_one (struct domain *d, -uint16_t space, +unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn)xen/arch/x86/mm.c +1
-1@@ -4522,7 +4522,7 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p) int xenmem_add_to_physmap_one( struct domain *d, - uint16_t space, + unsigned int space, domid_t foreign_domid, unsigned long idx,
xen_pfn_tgpfn)xen/include/xen/mm.h +1
-1@@ -356,7 +356,7 @@ static inline unsigned int get_order_from_pages(unsigned long nr_pages)void scrub_one_page (struct page_info *); -int xenmem_add_to_physmap_one (struct domain *d,uint16_t space, +int xenmem_add_to_physmap_one (struct domain *d,unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn);Signature · 2 lines
-- 1.7.10.4
Quoted 15 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int, but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
Quoted 8 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_code_freeze
Please can you do so.
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int, but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>
Quoted 10 lines
Quoted 3 lines
---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_code_freezePlease can you do so.
Contributes towards #1 "Bug-free release"
Risks:
* We now know we have an ABI regression
* It is a fairly obvious fix which is unlikely to have hidden issues
itself.
Rewards:
* We keep the hypervisor ABI compatible with Xen 4.3
Alternatives:
* Revert the patch which introduced the regression, but that is very
undesirable as it was fixing another long-running Xen operation, and common-ifying some code between x86 and arm
~Andrew
Quoted 35 lines · Andrew Cooper
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int, but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>Quoted 10 lines
Quoted 3 lines
---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_code_freezePlease can you do so.
Contributes towards #1 "Bug-free release"
Quoted 7 lines
Risks:
* We now know we have an ABI regression
* It is a fairly obvious fix which is unlikely to have hidden issues
itself.Rewards:
* We keep the hypervisor ABI compatible with Xen 4.3
IMHO it already is -- the 4.4 ABI is not broken because the truncated bits are not used in the Xen ABI, 4.4 accepts everything which 4.3 does. We still very much have the option of deferring this change to 4.5 and/or when the bits become used, with no risk to the Xen 4.4 release.
Please try and consider the guidelines exceptions with an unbiased eye, rather than just as a mechanism for reconfirming your existing belief that the patch should go in.
I was tempted to reject this patch just to make a point, but I think if I'm being honest it probably should go in, so IFF Jan concurs with "fairly obvious fix which is unlikely to have hidden issues":
Release-Ack: Ian Campbell
Next time I might be in a worse mood.
Ian.
Quoted 6 lines
Alternatives:
* Revert the patch which introduced the regression, but that is very
undesirable as it was fixing another long-running Xen operation, and common-ifying some code between x86 and arm~Andrew
Quoted 47 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsignedint,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
but struct
xen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but
was
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bitset.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_c
ode_freezeQuoted 12 lines
Quoted 4 lines
Please can you do so.
Contributes towards #1 "Bug-free release"
Risks:
* We now know we have an ABI regression
* It is a fairly obvious fix which is unlikely to have hidden issues
itself.
Quoted 5 lines
Quoted 2 lines
Rewards:
* We keep the hypervisor ABI compatible with Xen 4.3IMHO it already is -- the 4.4 ABI is not broken because the truncated bits are not used in the Xen ABI, 4.4 accepts everything which 4.3 does.
Not exactly: 4.4 now also accepts what 4.3 would reject.
Quoted 10 lines
We still very much have the option of deferring this change to 4.5 and/or when the bits become used, with no risk to the Xen 4.4 release.
Please try and consider the guidelines exceptions with an unbiased eye, rather than just as a mechanism for reconfirming your existing belief that the patch should go in.
I was tempted to reject this patch just to make a point, but I think if I'm being honest it probably should go in, so IFF Jan concurs with "fairly obvious fix which is unlikely to have hidden issues":
I already did in an earlier reply (or at least it was meant to be that way).
Quoted 1 line
Release-Ack: Ian Campbell
Thanks.
Quoted 1 line
Next time I might be in a worse mood.
Hopefully not too much worse ;-)
Jan
Quoted 47 lines · Jan Beulich
Quoted 47 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsignedint,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
but struct
xen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but
was
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bitset.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_c
ode_freezeQuoted 12 lines
Quoted 4 lines
Please can you do so.
Contributes towards #1 "Bug-free release"
Risks:
* We now know we have an ABI regression
* It is a fairly obvious fix which is unlikely to have hidden issues
itself.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Rewards:
* We keep the hypervisor ABI compatible with Xen 4.3IMHO it already is -- the 4.4 ABI is not broken because the truncated bits are not used in the Xen ABI, 4.4 accepts everything which 4.3 does.
Not exactly: 4.4 now also accepts what 4.3 would reject.
That is a valid point, thanks. With that having been pointed out I think it is pretty obvious that this should go in.
Quoted 2 lines
I already did in an earlier reply (or at least it was meant to be that way).
I saw your reviewed by but didn't know if it applied to 4.4 or 4.5 so I wanted check.
Ian.
Quoted 41 lines · Ian Campbell
Quoted 40 lines · Andrew Cooper
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int, but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>Quoted 10 lines
Quoted 3 lines
---
As this breakage was caused between 4.4-rc1 and -rc2,
That's certainly a good indicator, but you've not covered the actual risks and rewards of making this change now:
http://wiki.xen.org/wiki/Xen_Roadmap/4.4#Exception_guidelines_for_after_the_code_freezePlease can you do so.
Contributes towards #1 "Bug-free release"
Risks:
* We now know we have an ABI regression
* It is a fairly obvious fix which is unlikely to have hidden issues
itself.
Quoted 7 lines
Quoted 2 lines
Rewards:
* We keep the hypervisor ABI compatible with Xen 4.3IMHO it already is -- the 4.4 ABI is not broken because the truncated bits are not used in the Xen ABI, 4.4 accepts everything which 4.3 does. We still very much have the option of deferring this change to 4.5 and/or when the bits become used, with no risk to the Xen 4.4 release.
It is a guest visible change as it changes the behaviour if the guest supplies space >= 0x1000. e.g., space == 0x1000 would be truncated and it would operate on space == 0x0000 and (potentially) return sucesss instead of an -EINVAL error.
David
Quoted 15 lines · Andrew Cooper
caused by c/s
4be86bb194e25e46b6cbee900601bfee76e8090aIn
public/memory.h, structxen_add_to_physmaphas 'space' as an unsigned int, but structxen_add_to_physmap_batchhas 'space' as auint16_t.By defining
xenmem_add_to_physmap_one()with space defined asuint16_t, the now-commonxenmem_add_to_physmap()implicitly truncatesxatp->spacefrom unsigned int touint16_t, which changes the space switch()'d upon.This wouldn't be noticed with any upstream code (of which I am aware), but was discovered because of the XenServer support for legacy Windows PV drivers, which make
XENMEM_add_to_physmaphypercalls using spaces with the top bit set. The current Windows PV drivers don't do this any more, but we 'fix' Xen to support running VMs with out-of-date tools.
Quoted 4 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>
Quoted 61 lines
---
As this breakage was caused between 4.4-rc1 and -rc2, I request a release ack for the fix.
This was caught by a compile failure rather than a functional test. I have encountered a different compile error which turns out to be a bug in the cross compiler we are currently using, so I need to fix that before I can functionally test a 4.4-rc2 based XenServer. (Which will be a rather better test of whether the functionality of
XENMEM_add_to_physmapis actually still the same. If anyone dares look,
https://github.com/xenserver/xen-4.3.pg/blob/master/xen-legacy-win-xenmapspace
-quirks.patch
are the hacks required to make the legacy drivers work on modern Xen.)--- xen/arch/arm/mm.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/include/xen/mm.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/mm.c +1
-1@@ -970,7 +970,7 @@ void share_xen_page_with_privileged_guests(int xenmem_add_to_physmap_one (struct domain *d, -uint16_t space, +unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn)xen/arch/x86/mm.c +1
-1@@ -4522,7 +4522,7 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p) int xenmem_add_to_physmap_one( struct domain *d, - uint16_t space, + unsigned int space, domid_t foreign_domid, unsigned long idx,
xen_pfn_tgpfn)xen/include/xen/mm.h +1
-1@@ -356,7 +356,7 @@ static inline unsigned int get_order_from_pages(unsigned long nr_pages)void scrub_one_page (struct page_info *); -int xenmem_add_to_physmap_one (struct domain *d,uint16_t space, +int xenmem_add_to_physmap_one (struct domain *d,unsigned int space,domid_t foreign_domid,unsigned long idx,xen_pfn_t gpfn);