|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 1/7] libxc: fix uninitialized variable in xc_cpuid_pv_policy()
On 01/07/15 18:37, Jennifer Herbert wrote:
> If xc_domain_get_guest_width were to fail, guest_width is not set, and
> hence guest_64bit becomes undefined.
> Fix is to initialise to 0, and report error if call fails.
>
> Signed-off-by: Jennifer Herbert <jennifer.herbert@xxxxxxxxxx>
> ---
> tools/libxc/xc_cpuid_x86.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
> index c97f91a..847b701 100644
> --- a/tools/libxc/xc_cpuid_x86.c
> +++ b/tools/libxc/xc_cpuid_x86.c
> @@ -437,14 +437,16 @@ static void xc_cpuid_pv_policy(
Urgh - let another libxc function which can fail hard in several ways,
yet is void.
> {
> DECLARE_DOMCTL;
> unsigned int guest_width;
> - int guest_64bit;
> + int guest_64bit = 0;
The default in Xen is that a PV guest is 64bit until explicitly
converted to being compat. The better default therefore is 1.
> char brand[13];
> uint64_t xfeature_mask;
>
> xc_cpuid_brand_get(brand);
>
> - xc_domain_get_guest_width(xch, domid, &guest_width);
> - guest_64bit = (guest_width == 8);
> + if (xc_domain_get_guest_width(xch, domid, &guest_width) == 0)
> + guest_64bit = (guest_width == 8);
> + else
> + ERROR("Could not read guest word width.");
No full stop please.
>
> /* Detecting Xen's atitude towards XSAVE */
> memset(&domctl, 0, sizeof(domctl));
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |