George Dunlap
2012-Jul-26 17:02 UTC
[PATCH] libxc: Don''t call set_pod_target in case of previous memory failure
# HG changeset patch # User George Dunlap <george.dunlap@eu.citrix.com> # Date 1343320554 -3600 # Node ID f7997e838585d4f40ae5dc14541f8efe71ce3c55 # Parent b63d4890d15e74b4c8ca45607563245076b3e770 libxc: Don''t call set_pod_target in case of previous memory failure The while() loop in the memory allocation section of the hvm builder is where the actual check for failure of memory alloction happens. If the domain is being built in PoD mode, however, this value may be clobbered by a call to xc_domain_set_pod_target() before erroring out. There is a very small chance that after xc_domain_populate_physmap() fails, that somehow set_pod_target() will succeed, leaving a domain with only a partially created address space. This patch modifies the builder to check that there have not been any errors so far before calling xc_domain_set_pod_target(). Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> diff --git a/tools/libxc/xc_hvm_build_x86.c b/tools/libxc/xc_hvm_build_x86.c --- a/tools/libxc/xc_hvm_build_x86.c +++ b/tools/libxc/xc_hvm_build_x86.c @@ -311,7 +311,7 @@ static int setup_guest(xc_interface *xch /* Subtract 0x20 from target_pages for the VGA "hole". Xen will * adjust the PoD cache size so that domain tot_pages will be * target_pages - 0x20 after this call. */ - if ( pod_mode ) + if ( rc != 0 && pod_mode ) rc = xc_domain_set_pod_target(xch, dom, target_pages - 0x20, NULL, NULL, NULL);
George Dunlap
2012-Jul-26 17:05 UTC
Re: [PATCH] libxc: Don''t call set_pod_target in case of previous memory failure
On 26/07/12 18:02, George Dunlap wrote:> # HG changeset patch > # User George Dunlap <george.dunlap@eu.citrix.com> > # Date 1343320554 -3600 > # Node ID f7997e838585d4f40ae5dc14541f8efe71ce3c55 > # Parent b63d4890d15e74b4c8ca45607563245076b3e770 > libxc: Don''t call set_pod_target in case of previous memory failure > > The while() loop in the memory allocation section of the hvm builder > is where the actual check for failure of memory alloction happens. If > the domain is being built in PoD mode, however, this value may be > clobbered by a call to xc_domain_set_pod_target() before erroring out. > There is a very small chance that after xc_domain_populate_physmap() > fails, that somehow set_pod_target() will succeed, leaving a domain > with only a partially created address space. > > This patch modifies the builder to check that there have not been any > errors so far before calling xc_domain_set_pod_target(). > > Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> > > diff --git a/tools/libxc/xc_hvm_build_x86.c b/tools/libxc/xc_hvm_build_x86.c > --- a/tools/libxc/xc_hvm_build_x86.c > +++ b/tools/libxc/xc_hvm_build_x86.c > @@ -311,7 +311,7 @@ static int setup_guest(xc_interface *xch > /* Subtract 0x20 from target_pages for the VGA "hole". Xen will > * adjust the PoD cache size so that domain tot_pages will be > * target_pages - 0x20 after this call. */ > - if ( pod_mode ) > + if ( rc != 0 && pod_mode )Gah, sorry -- got the polarity wrong on this one... please ignore... -George> rc = xc_domain_set_pod_target(xch, dom, target_pages - 0x20, > NULL, NULL, NULL); >