ia64/xen-unstable

changeset 3154:0373a9f51f2a

bitkeeper revision 1.1159.1.458 (41a64b70b30rc4PElJkf-HBn1RT5xQ)

sync w/ head.
author cl349@arcadians.cl.cam.ac.uk
date Thu Nov 25 21:15:28 2004 +0000 (2004-11-25)
parents 8b8852411a96 12702b4773e2
children f93bf7c01b09
files linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.9-xen-sparse/drivers/xen/console/console.c xen/arch/x86/domain.c xen/arch/x86/memory.c xen/arch/x86/traps.c xen/common/dom_mem_ops.c xen/common/multicall.c xen/include/xen/sched.h
line diff
     1.1 --- a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Nov 25 18:12:31 2004 +0000
     1.2 +++ b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Nov 25 21:15:28 2004 +0000
     1.3 @@ -74,12 +74,6 @@ static char * blkif_status_name[] = {
     1.4      [BLKIF_INTERFACE_STATUS_CHANGED]      = "changed",
     1.5  };
     1.6  
     1.7 -#if 1
     1.8 -#define dprintf(fmt, args...) \
     1.9 -printk(KERN_ALERT "[XEN:%s:%s:%d] " fmt, \
    1.10 -__FUNCTION__, __FILE__, __LINE__, ##args)
    1.11 -#endif
    1.12 -
    1.13  #define WPRINTK(fmt, args...) printk(KERN_WARNING "xen_blk: " fmt, ##args)
    1.14  
    1.15  static int blkif_handle = 0;
    1.16 @@ -190,10 +184,8 @@ static inline void flush_requests(void)
    1.17  __initcall(xlblk_init);
    1.18  
    1.19  #if ENABLE_VBD_UPDATE
    1.20 -static void vbd_update()
    1.21 +static void vbd_update(void)
    1.22  {
    1.23 -    dprintf(">\n");
    1.24 -    dprintf("<\n");
    1.25  }
    1.26  #endif /* ENABLE_VBD_UPDATE */
    1.27  
    1.28 @@ -413,7 +405,7 @@ void do_blkif_request(request_queue_t *r
    1.29              blk_stop_queue(rq);
    1.30              break;
    1.31          }
    1.32 -        DPRINTK("do_blkif_request %p: cmd %p, sec %lx, (%u/%li) buffer:%p [%s]\n",
    1.33 +        DPRINTK("do_blk_req %p: cmd %p, sec %lx, (%u/%li) buffer:%p [%s]\n",
    1.34                  req, req->cmd, req->sector, req->current_nr_sectors,
    1.35                  req->nr_sectors, req->buffer,
    1.36                  rq_data_dir(req) ? "write" : "read");
    1.37 @@ -529,10 +521,8 @@ static void update_vbds_task(void *unuse
    1.38  static void vbd_update(void)
    1.39  {
    1.40      static struct tq_struct update_tq;
    1.41 -    dprintf(">\n");
    1.42      update_tq.routine = update_vbds_task;
    1.43      schedule_task(&update_tq);
    1.44 -    dprintf("<\n");
    1.45  }
    1.46  
    1.47  #endif /* ENABLE_VBD_UPDATE */
    1.48 @@ -776,8 +766,6 @@ int blkif_revalidate(kdev_t dev)
    1.49  }
    1.50  
    1.51  
    1.52 -
    1.53 -
    1.54  /*
    1.55   * blkif_queue_request
    1.56   *
    1.57 @@ -897,8 +885,6 @@ static int blkif_queue_request(unsigned 
    1.58      /* Keep a private copy so we can reissue requests when recovering. */    
    1.59      translate_req_to_pfn(&rec_ring[xid], req );
    1.60  
    1.61 -
    1.62 -
    1.63      return 0;
    1.64  }
    1.65  
    1.66 @@ -1126,8 +1112,6 @@ static void blkif_send_interface_connect
    1.67  
    1.68  static void blkif_free(void)
    1.69  {
    1.70 -    printk(KERN_INFO "xen_blk: Recovering virtual block device driver\n");
    1.71 -
    1.72      /* Prevent new requests being issued until we fix things up. */
    1.73      spin_lock_irq(&blkif_io_lock);
    1.74      recovery = 1;
    1.75 @@ -1154,7 +1138,8 @@ static void blkif_close(void)
    1.76  /* Move from CLOSED to DISCONNECTED state. */
    1.77  static void blkif_disconnect(void)
    1.78  {
    1.79 -    if(blk_ring) free_page((unsigned long)blk_ring);
    1.80 +    if ( blk_ring != NULL )
    1.81 +        free_page((unsigned long)blk_ring);
    1.82      blk_ring = (blkif_ring_t *)__get_free_page(GFP_KERNEL);
    1.83      blk_ring->req_prod = blk_ring->resp_prod = resp_cons = req_prod = 0;
    1.84      blkif_state  = BLKIF_STATE_DISCONNECTED;
    1.85 @@ -1163,7 +1148,6 @@ static void blkif_disconnect(void)
    1.86  
    1.87  static void blkif_reset(void)
    1.88  {
    1.89 -    printk(KERN_INFO "xen_blk: Recovering virtual block device driver\n");
    1.90      blkif_free();
    1.91      blkif_disconnect();
    1.92  }
    1.93 @@ -1186,8 +1170,6 @@ static void blkif_recover(void)
    1.94          }
    1.95      }
    1.96  
    1.97 -    printk(KERN_ALERT"blkfront: recovered %d descriptors\n",req_prod);
    1.98 -	    
    1.99      /* Stage 2 : Set up shadow list. */
   1.100      for ( i = 0; i < req_prod; i++ ) 
   1.101      {
   1.102 @@ -1254,9 +1236,9 @@ static void blkif_connect(blkif_fe_inter
   1.103  
   1.104  static void unexpected(blkif_fe_interface_status_t *status)
   1.105  {
   1.106 -    WPRINTK(" Unexpected blkif status %s in state %s\n", 
   1.107 -           blkif_status_name[status->status],
   1.108 -           blkif_state_name[blkif_state]);
   1.109 +    DPRINTK(" Unexpected blkif status %s in state %s\n", 
   1.110 +            blkif_status_name[status->status],
   1.111 +            blkif_state_name[blkif_state]);
   1.112  }
   1.113  
   1.114  static void blkif_status(blkif_fe_interface_status_t *status)
   1.115 @@ -1292,7 +1274,7 @@ static void blkif_status(blkif_fe_interf
   1.116              break;
   1.117          case BLKIF_STATE_DISCONNECTED:
   1.118          case BLKIF_STATE_CONNECTED:
   1.119 -            unexpected(status);
   1.120 +            /* unexpected(status); */ /* occurs during suspend/resume */
   1.121              blkif_reset();
   1.122              break;
   1.123          }
     2.1 --- a/linux-2.6.9-xen-sparse/drivers/xen/console/console.c	Thu Nov 25 18:12:31 2004 +0000
     2.2 +++ b/linux-2.6.9-xen-sparse/drivers/xen/console/console.c	Thu Nov 25 21:15:28 2004 +0000
     2.3 @@ -658,6 +658,8 @@ const struct consw xennull_con = {
     2.4  
     2.5  static int __init xencons_init(void)
     2.6  {
     2.7 +    int rc;
     2.8 +
     2.9      if ( xc_mode == XC_OFF )
    2.10          return 0;
    2.11  
    2.12 @@ -713,9 +715,12 @@ static int __init xencons_init(void)
    2.13      xencons_driver.wait_until_sent = xencons_wait_until_sent;
    2.14  #endif
    2.15  
    2.16 -    if ( tty_register_driver(DRV(xencons_driver)) )
    2.17 -        panic("Couldn't register Xen virtual console driver as %s\n",
    2.18 -              DRV(xencons_driver)->name);
    2.19 +    if ( (rc = tty_register_driver(DRV(xencons_driver))) != 0 )
    2.20 +    {
    2.21 +        printk("Couldn't register Xen virtual console driver as %s\n",
    2.22 +               DRV(xencons_driver)->name);
    2.23 +        return rc;
    2.24 +    }
    2.25  
    2.26  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    2.27      tty_register_device(xencons_driver, 0, NULL);
     3.1 --- a/xen/arch/x86/domain.c	Thu Nov 25 18:12:31 2004 +0000
     3.2 +++ b/xen/arch/x86/domain.c	Thu Nov 25 21:15:28 2004 +0000
     3.3 @@ -430,7 +430,8 @@ long do_iopl(domid_t domain, unsigned in
     3.4      return 0;
     3.5  }
     3.6  
     3.7 -void hypercall_create_continuation(unsigned int op, unsigned int nr_args, ...)
     3.8 +unsigned long hypercall_create_continuation(
     3.9 +    unsigned int op, unsigned int nr_args, ...)
    3.10  {
    3.11      struct mc_state *mcs = &mc_state[smp_processor_id()];
    3.12      execution_context_t *ec;
    3.13 @@ -458,6 +459,8 @@ void hypercall_create_continuation(unsig
    3.14      }
    3.15  
    3.16      va_end(args);
    3.17 +
    3.18 +    return op;
    3.19  }
    3.20  
    3.21  #endif
    3.22 @@ -526,8 +529,6 @@ void domain_relinquish_memory(struct dom
    3.23  {
    3.24      struct exec_domain *ed;
    3.25  
    3.26 -    audit_domain(d);
    3.27 -
    3.28      /* Ensure that noone is running over the dead domain's page tables. */
    3.29      synchronise_pagetables(~0UL);
    3.30  
     4.1 --- a/xen/arch/x86/memory.c	Thu Nov 25 18:12:31 2004 +0000
     4.2 +++ b/xen/arch/x86/memory.c	Thu Nov 25 21:15:28 2004 +0000
     4.3 @@ -126,10 +126,9 @@ static int mod_l1_entry(l1_pgentry_t *, 
     4.4  static struct {
     4.5  #define DOP_FLUSH_TLB   (1<<0) /* Flush the TLB.                 */
     4.6  #define DOP_RELOAD_LDT  (1<<1) /* Reload the LDT shadow mapping. */
     4.7 -    unsigned long       deferred_ops;
     4.8 -    unsigned long       cr0;
     4.9 +    unsigned long  deferred_ops;
    4.10      /* If non-NULL, specifies a foreign subject domain for some operations. */
    4.11 -    struct domain      *foreign;
    4.12 +    struct domain *foreign;
    4.13  } __cacheline_aligned percpu_info[NR_CPUS];
    4.14  
    4.15  /*
    4.16 @@ -1285,19 +1284,23 @@ int do_mmu_update(
    4.17  /*
    4.18   * We steal the m.s.b. of the @count parameter to indicate whether this
    4.19   * invocation of do_mmu_update() is resuming a previously preempted call.
    4.20 + * We steal the next 15 bits to remember the current FOREIGNDOM.
    4.21   */
    4.22 -#define MMU_UPDATE_PREEMPTED  (~(~0U>>1))
    4.23 +#define MMU_UPDATE_PREEMPTED          (~(~0U>>1))
    4.24 +#define MMU_UPDATE_PREEMPT_FDOM_SHIFT ((sizeof(int)*8)-16)
    4.25 +#define MMU_UPDATE_PREEMPT_FDOM_MASK  (0x7FFFU<<MMU_UPDATE_PREEMPT_FDOM_SHIFT)
    4.26  
    4.27      mmu_update_t req;
    4.28      unsigned long va = 0, deferred_ops, pfn, prev_pfn = 0;
    4.29      struct pfn_info *page;
    4.30 -    int rc = 0, okay = 1, i, cpu = smp_processor_id();
    4.31 +    int rc = 0, okay = 1, i = 0, cpu = smp_processor_id();
    4.32      unsigned int cmd, done = 0;
    4.33      unsigned long prev_spfn = 0;
    4.34      l1_pgentry_t *prev_spl1e = 0;
    4.35      struct exec_domain *ed = current;
    4.36      struct domain *d = ed->domain;
    4.37      u32 type_info;
    4.38 +    domid_t domid;
    4.39  
    4.40      perfc_incrc(calls_to_mmu_update); 
    4.41      perfc_addc(num_page_updates, count);
    4.42 @@ -1309,27 +1312,45 @@ int do_mmu_update(
    4.43      /*
    4.44       * If we are resuming after preemption, read how much work we have already
    4.45       * done. This allows us to set the @done output parameter correctly.
    4.46 +     * We also reset FOREIGNDOM here.
    4.47       */
    4.48 -    if ( unlikely(count & MMU_UPDATE_PREEMPTED) )
    4.49 +    if ( unlikely(count&(MMU_UPDATE_PREEMPTED|MMU_UPDATE_PREEMPT_FDOM_MASK)) )
    4.50      {
    4.51 +        if ( !(count & MMU_UPDATE_PREEMPTED) )
    4.52 +        {
    4.53 +            /* Count overflow into private FOREIGNDOM field. */
    4.54 +            MEM_LOG("do_mmu_update count is too large");
    4.55 +            rc = -EINVAL;
    4.56 +            goto out;
    4.57 +        }
    4.58          count &= ~MMU_UPDATE_PREEMPTED;
    4.59 +        domid = count >> MMU_UPDATE_PREEMPT_FDOM_SHIFT;
    4.60 +        count &= ~MMU_UPDATE_PREEMPT_FDOM_MASK;
    4.61          if ( unlikely(pdone != NULL) )
    4.62              (void)get_user(done, pdone);
    4.63 +        if ( (domid != current->id) &&
    4.64 +             !do_extended_command(0, MMUEXT_SET_FOREIGNDOM | (domid << 16)) )
    4.65 +        {
    4.66 +            rc = -EINVAL;
    4.67 +            goto out;
    4.68 +        }
    4.69      }
    4.70  
    4.71      if ( unlikely(!array_access_ok(VERIFY_READ, ureqs, count, sizeof(req))) ) {
    4.72 -        UNLOCK_BIGLOCK(d);
    4.73 -        return -EFAULT;
    4.74 +    {
    4.75 +        rc = -EFAULT;
    4.76 +        goto out;
    4.77      }
    4.78  
    4.79      for ( i = 0; i < count; i++ )
    4.80      {
    4.81          if ( hypercall_preempt_check() )
    4.82          {
    4.83 -            hypercall_create_continuation(
    4.84 +            rc = hypercall_create_continuation(
    4.85                  __HYPERVISOR_mmu_update, 3, ureqs, 
    4.86 -                (count - i) | MMU_UPDATE_PREEMPTED, pdone);
    4.87 -            rc = __HYPERVISOR_mmu_update;
    4.88 +                (count - i) |
    4.89 +                (FOREIGNDOM->id << MMU_UPDATE_PREEMPT_FDOM_SHIFT) | 
    4.90 +                MMU_UPDATE_PREEMPTED, pdone);
    4.91              break;
    4.92          }
    4.93  
    4.94 @@ -1466,6 +1487,7 @@ int do_mmu_update(
    4.95          ureqs++;
    4.96      }
    4.97  
    4.98 + out:
    4.99      if ( prev_pfn != 0 )
   4.100          unmap_domain_mem((void *)va);
   4.101  
     5.1 --- a/xen/arch/x86/traps.c	Thu Nov 25 18:12:31 2004 +0000
     5.2 +++ b/xen/arch/x86/traps.c	Thu Nov 25 21:15:28 2004 +0000
     5.3 @@ -818,10 +818,9 @@ long do_set_trap_table(trap_info_t *trap
     5.4      {
     5.5          if ( hypercall_preempt_check() )
     5.6          {
     5.7 -            hypercall_create_continuation(
     5.8 +            UNLOCK_BIGLOCK(current->domain);
     5.9 +            return hypercall_create_continuation(
    5.10                  __HYPERVISOR_set_trap_table, 1, traps);
    5.11 -            UNLOCK_BIGLOCK(current->domain);
    5.12 -            return __HYPERVISOR_set_trap_table;
    5.13          }
    5.14  
    5.15          if ( copy_from_user(&cur, traps, sizeof(cur)) ) return -EFAULT;
     6.1 --- a/xen/common/dom_mem_ops.c	Thu Nov 25 18:12:31 2004 +0000
     6.2 +++ b/xen/common/dom_mem_ops.c	Thu Nov 25 21:15:28 2004 +0000
     6.3 @@ -22,15 +22,13 @@
     6.4   */
     6.5  #define START_EXTENT_SHIFT 4 /* op[:4] == start_extent */
     6.6  
     6.7 -#define PREEMPT_CHECK(_op)                                  \
     6.8 -    if ( hypercall_preempt_check() ) {                      \
     6.9 -        hypercall_create_continuation(                      \
    6.10 -            __HYPERVISOR_dom_mem_op, 5,                     \
    6.11 -            (_op) | (i << START_EXTENT_SHIFT),              \
    6.12 -            extent_list, nr_extents, extent_order,          \
    6.13 -            (d == current->domain) ? DOMID_SELF : d->id);   \
    6.14 -        return __HYPERVISOR_dom_mem_op;                     \
    6.15 -    }
    6.16 +#define PREEMPT_CHECK(_op)                          \
    6.17 +    if ( hypercall_preempt_check() )                \
    6.18 +        return hypercall_create_continuation(       \
    6.19 +            __HYPERVISOR_dom_mem_op, 5,             \
    6.20 +            (_op) | (i << START_EXTENT_SHIFT),      \
    6.21 +            extent_list, nr_extents, extent_order,  \
    6.22 +            (d == current->domain) ? DOMID_SELF : d->id);
    6.23  
    6.24  static long
    6.25  alloc_dom_mem(struct domain *d, 
     7.1 --- a/xen/common/multicall.c	Thu Nov 25 18:12:31 2004 +0000
     7.2 +++ b/xen/common/multicall.c	Thu Nov 25 21:15:28 2004 +0000
     7.3 @@ -60,9 +60,8 @@ long do_multicall(multicall_entry_t *cal
     7.4              if ( i < nr_calls )
     7.5              {
     7.6                  mcs->flags = 0;
     7.7 -                hypercall_create_continuation(
     7.8 +                return hypercall_create_continuation(
     7.9                      __HYPERVISOR_multicall, 2, &call_list[i], nr_calls-i);
    7.10 -                return __HYPERVISOR_multicall;
    7.11              }
    7.12          }
    7.13      }
     8.1 --- a/xen/include/xen/sched.h	Thu Nov 25 18:12:31 2004 +0000
     8.2 +++ b/xen/include/xen/sched.h	Thu Nov 25 21:15:28 2004 +0000
     8.3 @@ -257,7 +257,8 @@ void continue_cpu_idle_loop(void);
     8.4  
     8.5  void continue_nonidle_task(void);
     8.6  
     8.7 -void hypercall_create_continuation(unsigned int op, unsigned int nr_args, ...);
     8.8 +unsigned long hypercall_create_continuation(
     8.9 +    unsigned int op, unsigned int nr_args, ...);
    8.10  #define hypercall_preempt_check() \
    8.11      (unlikely(softirq_pending(smp_processor_id())))
    8.12