ia64/xen-unstable

changeset 6607:ec11c5cca195

Fix preemption-check race in memory_op hypercall.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 02 17:02:08 2005 +0000 (2005-09-02)
parents 7c2afbad0188
children b715a9f4dba0
files xen/common/memory.c
line diff
     1.1 --- a/xen/common/memory.c	Fri Sep 02 16:51:55 2005 +0000
     1.2 +++ b/xen/common/memory.c	Fri Sep 02 17:02:08 2005 +0000
     1.3 @@ -25,7 +25,8 @@ increase_reservation(
     1.4      unsigned long *extent_list, 
     1.5      unsigned int   nr_extents,
     1.6      unsigned int   extent_order,
     1.7 -    unsigned int   flags)
     1.8 +    unsigned int   flags,
     1.9 +    int           *preempted)
    1.10  {
    1.11      struct pfn_info *page;
    1.12      unsigned long    i;
    1.13 @@ -43,7 +44,10 @@ increase_reservation(
    1.14      for ( i = 0; i < nr_extents; i++ )
    1.15      {
    1.16          if ( hypercall_preempt_check() )
    1.17 +        {
    1.18 +            *preempted = 1;
    1.19              return i;
    1.20 +        }
    1.21  
    1.22          if ( unlikely((page = alloc_domheap_pages(
    1.23              d, extent_order, flags)) == NULL) )
    1.24 @@ -67,7 +71,8 @@ decrease_reservation(
    1.25      unsigned long *extent_list, 
    1.26      unsigned int   nr_extents,
    1.27      unsigned int   extent_order,
    1.28 -    unsigned int   flags)
    1.29 +    unsigned int   flags,
    1.30 +    int           *preempted)
    1.31  {
    1.32      struct pfn_info *page;
    1.33      unsigned long    i, j, mpfn;
    1.34 @@ -78,7 +83,10 @@ decrease_reservation(
    1.35      for ( i = 0; i < nr_extents; i++ )
    1.36      {
    1.37          if ( hypercall_preempt_check() )
    1.38 +        {
    1.39 +            *preempted = 1;
    1.40              return i;
    1.41 +        }
    1.42  
    1.43          if ( unlikely(__get_user(mpfn, &extent_list[i]) != 0) )
    1.44              return i;
    1.45 @@ -124,7 +132,7 @@ decrease_reservation(
    1.46  long do_memory_op(int cmd, void *arg)
    1.47  {
    1.48      struct domain *d;
    1.49 -    int rc, start_extent, op, flags = 0;
    1.50 +    int rc, start_extent, op, flags = 0, preempted = 0;
    1.51      struct xen_memory_reservation reservation;
    1.52  
    1.53      op = cmd & ((1 << START_EXTENT_SHIFT) - 1);
    1.54 @@ -165,19 +173,18 @@ long do_memory_op(int cmd, void *arg)
    1.55                    reservation.extent_start,
    1.56                    reservation.nr_extents,
    1.57                    reservation.extent_order,
    1.58 -                  flags);
    1.59 +                  flags,
    1.60 +                  &preempted);
    1.61  
    1.62          if ( unlikely(reservation.domid != DOMID_SELF) )
    1.63              put_domain(d);
    1.64  
    1.65          rc += start_extent;
    1.66  
    1.67 -        if ( (rc != reservation.nr_extents) && hypercall_preempt_check() )
    1.68 +        if ( preempted )
    1.69              return hypercall2_create_continuation(
    1.70 -                __HYPERVISOR_memory_op,
    1.71 -                op | (rc << START_EXTENT_SHIFT),
    1.72 -                arg);
    1.73 -        
    1.74 +                __HYPERVISOR_memory_op, op | (rc << START_EXTENT_SHIFT), arg);
    1.75 +
    1.76          break;
    1.77  
    1.78      case XENMEM_maximum_ram_page: