libxc: Don't call set_pod_target in case of previous memory failure
PATCH 1/1 libxc: Don't call set_pod_target in case of previous memory failure
# HG changeset patch
# User George Dunlap <[email protected]>
# 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().
tools/libxc/xc_hvm_build_x86.c +1 -1
@@ -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 );
Quoted 24 lines · George Dunlap
# HG changeset patch
# User George Dunlap <[email protected]>
# Date 1343320554 -3600
# Node IDf7997e838585d4f40ae5dc14541f8efe71ce3c55
# Parentb63d4890d15e74b4c8ca45607563245076b3e770
libxc: Don't callset_pod_targetin case of previous memory failureThe
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 toxc_domain_set_pod_target()before erroring out. There is a very small chance that afterxc_domain_populate_physmap()fails, that somehowset_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 <[email protected]>
tools/libxc/xc_hvm_build_x86.c static int setup_guest(xc_interface *xch · line 314
Quoted 5 lines
tools/libxc/xc_hvm_build_x86.c +1
-1@@ -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
Quoted 3 lines
tools/libxc/xc_hvm_build_x86.c +0
-0rc =xc_domain_set_pod_target (xch, dom, target_pages -0x20 ,NULL ,NULL ,NULL );