ia64/xen-unstable

changeset 16519:62451388f630

Fix xenctl_cpumap_to_cpumask.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 04 11:52:10 2007 +0000 (2007-12-04)
parents 6706934cdf9d
children a583f3a7eafc
files xen/common/domctl.c
line diff
     1.1 --- a/xen/common/domctl.c	Tue Dec 04 11:23:05 2007 +0000
     1.2 +++ b/xen/common/domctl.c	Tue Dec 04 11:52:10 2007 +0000
     1.3 @@ -43,7 +43,8 @@ void cpumask_to_xenctl_cpumap(
     1.4  
     1.5      bitmap_long_to_byte(bytemap, cpus_addr(*cpumask), NR_CPUS);
     1.6  
     1.7 -    copy_to_guest(xenctl_cpumap->bitmap, bytemap, copy_bytes);
     1.8 +    if ( copy_bytes != 0 )
     1.9 +        copy_to_guest(xenctl_cpumap->bitmap, bytemap, copy_bytes);
    1.10  
    1.11      for ( i = copy_bytes; i < guest_bytes; i++ )
    1.12          copy_to_guest_offset(xenctl_cpumap->bitmap, i, &zero, 1);
    1.13 @@ -55,15 +56,20 @@ void xenctl_cpumap_to_cpumask(
    1.14      unsigned int guest_bytes, copy_bytes;
    1.15      uint8_t bytemap[(NR_CPUS + 7) / 8];
    1.16  
    1.17 +    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
    1.18 +        return;
    1.19 +
    1.20      guest_bytes = (xenctl_cpumap->nr_cpus + 7) / 8;
    1.21      copy_bytes  = min_t(unsigned int, guest_bytes, sizeof(bytemap));
    1.22  
    1.23 -    cpus_clear(*cpumask);
    1.24 +    memset(bytemap, 0, sizeof(bytemap));
    1.25  
    1.26 -    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
    1.27 -        return;
    1.28 -
    1.29 -    copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes);
    1.30 +    if ( copy_bytes != 0 )
    1.31 +    {
    1.32 +        copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes);
    1.33 +        if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <= sizeof(bytemap)) )
    1.34 +            bytemap[guest_bytes-1] &= ~(0xff << (xenctl_cpumap->nr_cpus & 7));
    1.35 +    }
    1.36  
    1.37      bitmap_byte_to_long(cpus_addr(*cpumask), bytemap, NR_CPUS);
    1.38  }