ia64/xen-unstable

changeset 494:1786bde3fc7e

bitkeeper revision 1.266 (3f054ea7i0rAG6Iai3U1MfAFEUMAMQ)

Numerous bug fixes, and a slightly less perverted /proc interface.
author sos22@labyrinth.cl.cam.ac.uk
date Fri Jul 04 09:53:43 2003 +0000 (2003-07-04)
parents dd54946a335b
children 7363ede764ed
files tools/internal/Makefile tools/internal/physdev.h tools/internal/xi_phys_grant.c tools/internal/xi_phys_probe.c tools/internal/xi_phys_revoke.c xen/drivers/block/xen_block.c xen/drivers/block/xen_physdisk.c xen/include/hypervisor-ifs/block.h xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c xenolinux-2.4.21-sparse/drivers/block/ll_rw_blk.c
line diff
     1.1 --- a/tools/internal/Makefile	Thu Jul 03 16:37:59 2003 +0000
     1.2 +++ b/tools/internal/Makefile	Fri Jul 04 09:53:43 2003 +0000
     1.3 @@ -6,9 +6,10 @@ XI_DESTROY = xi_destroy
     1.4  XI_BUILD = xi_build
     1.5  XI_PHYS_GRANT = xi_phys_grant
     1.6  XI_PHYS_REVOKE = xi_phys_revoke
     1.7 +XI_PHYS_PROBE = xi_phys_probe
     1.8  
     1.9  all: $(XI_CREATE).o $(XI_START).o $(XI_STOP).o $(XI_DESTROY).o $(XI_BUILD).o \
    1.10 -	$(XI_PHYS_GRANT).o $(XI_PHYS_REVOKE).o
    1.11 +	$(XI_PHYS_GRANT).o $(XI_PHYS_REVOKE).o $(XI_PHYS_PROBE).o
    1.12  	$(CC) -o $(XI_CREATE) $(XI_CREATE).o
    1.13  	$(CC) -o $(XI_BUILD) $(XI_BUILD).o
    1.14  	$(CC) -o $(XI_START) $(XI_START).o
    1.15 @@ -16,6 +17,7 @@ all: $(XI_CREATE).o $(XI_START).o $(XI_S
    1.16  	$(CC) -o $(XI_DESTROY) $(XI_DESTROY).o
    1.17  	$(CC) -o $(XI_PHYS_GRANT) $(XI_PHYS_GRANT).o
    1.18  	$(CC) -o $(XI_PHYS_REVOKE) $(XI_PHYS_REVOKE).o
    1.19 +	$(CC) -o $(XI_PHYS_PROBE) $(XI_PHYS_PROBE).o
    1.20  
    1.21  $(XI_CREATE).o: $(XI_CREATE).c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
    1.22  	$(CC) -c $(XI_CREATE).c 
    1.23 @@ -38,8 +40,11 @@ internal_domain_build.o: internal_domain
    1.24  $(XI_PHYS_REVOKE).o: $(XI_PHYS_REVOKE).c physdev.h
    1.25  	$(CC) -c $(XI_PHYS_REVOKE).c 
    1.26  
    1.27 +$(XI_PHYS_PROBE).o: $(XI_PHYS_PROBE).c physdev.h
    1.28 +	$(CC) -c $(XI_PHYS_PROBE).c 
    1.29 +
    1.30  install: all
    1.31 -	cp -a xi_list xi_vifinit xi_helper $(XI_CREATE) $(XI_BUILD) $(XI_START) $(XI_STOP) $(XI_DESTROY) $(XI_PHYSDEV_GRANT) $(XI_PHYS_REVOKE) ../../../install/bin
    1.32 +	cp -a xi_list xi_vifinit xi_helper $(XI_CREATE) $(XI_BUILD) $(XI_START) $(XI_STOP) $(XI_DESTROY) $(XI_PHYSDEV_GRANT) $(XI_PHYS_REVOKE) $(XI_PHYS_PROBE).o../../../install/bin
    1.33  	chmod 755 ../../../install/bin/xi_list
    1.34  	chmod 755 ../../../install/bin/xi_vifinit
    1.35  	chmod 755 ../../../install/bin/xi_helper
     2.1 --- a/tools/internal/physdev.h	Thu Jul 03 16:37:59 2003 +0000
     2.2 +++ b/tools/internal/physdev.h	Fri Jul 04 09:53:43 2003 +0000
     2.3 @@ -1,11 +1,12 @@
     2.4  #define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
     2.5 -#define XEN_BLOCK_PHYSDEV_REVOKE 11 /* revoke access to range of disk blocks */
     2.6 -#define XEN_BLOCK_PHYSDEV_PROBE 12 /* probe for a domain's physdev
     2.7 +#define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
     2.8  				      accesses */
     2.9  
    2.10 +#define PHYSDISK_MODE_R 1
    2.11 +#define PHYSDISK_MODE_W 2
    2.12  typedef struct xp_disk
    2.13  {
    2.14 -  int mode;
    2.15 +  int mode; /* PHYSDISK_MODEs or 0 for revoke. */
    2.16    int domain;
    2.17    unsigned short device;
    2.18    unsigned long start_sect;
     3.1 --- a/tools/internal/xi_phys_grant.c	Thu Jul 03 16:37:59 2003 +0000
     3.2 +++ b/tools/internal/xi_phys_grant.c	Fri Jul 04 09:53:43 2003 +0000
     3.3 @@ -9,6 +9,7 @@ int main(int argc, char *argv[])
     3.4  {
     3.5    xp_disk_t buf;
     3.6    int fd;
     3.7 +  char *strbuf;
     3.8  
     3.9    if (argc != 6) {
    3.10      fprintf(stderr, "Usage: xi_physdev_grant <r/rw> <domain> <device> <start sector> <n_sectors>\n");
    3.11 @@ -25,16 +26,17 @@ int main(int argc, char *argv[])
    3.12    else if (argv[1][1] == 'w')
    3.13      buf.mode |= 2;
    3.14    
    3.15 -  buf.domain = atol(argv[2]);
    3.16    buf.device = atol(argv[3]);
    3.17    buf.start_sect = atol(argv[4]);
    3.18    buf.n_sectors = atol(argv[5]);
    3.19  
    3.20 -  fd = open("/proc/xeno/dom0/phd", O_WRONLY);
    3.21 +  asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[2]);
    3.22 +  fd = open(strbuf, O_WRONLY);
    3.23    if (fd < 0) {
    3.24 -    fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n", strerror(errno));
    3.25 +    fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
    3.26      return 1;
    3.27    }
    3.28 +  free(strbuf);
    3.29  
    3.30    write(fd, &buf, sizeof(buf));
    3.31    close(fd);
     4.1 --- a/tools/internal/xi_phys_probe.c	Thu Jul 03 16:37:59 2003 +0000
     4.2 +++ b/tools/internal/xi_phys_probe.c	Fri Jul 04 09:53:43 2003 +0000
     4.3 @@ -11,31 +11,29 @@ int main(int argc, char *argv[])
     4.4    physdisk_probebuf_t buf;
     4.5    int fd;
     4.6    int x;
     4.7 +  char *strbuf;
     4.8  
     4.9    if (argc != 2) {
    4.10      fprintf(stderr, "Usage: xi_phys_probe <domain_nr>\n");
    4.11      return 1;
    4.12    }
    4.13  
    4.14 -  fd = open("/proc/xeno/dom0/phd", O_RDONLY);
    4.15 +  asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[1]);
    4.16 +  fd = open(strbuf, O_RDONLY);
    4.17    if (fd < 0) {
    4.18 -    fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n",
    4.19 -	    strerror(errno));
    4.20 +    fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
    4.21      return 1;
    4.22    }
    4.23 +  free(strbuf);
    4.24  
    4.25    memset(&buf, 0, sizeof(buf));
    4.26    buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
    4.27 -  while (buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST ||
    4.28 -	 buf.n_aces == 0) {
    4.29 +  do {
    4.30      buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
    4.31 -    buf.domain = atol(argv[1]);
    4.32      read(fd, &buf, sizeof(buf));
    4.33      if (!buf.n_aces)
    4.34        break;
    4.35  
    4.36 -    printf("Found %d ACEs\n", buf.n_aces);
    4.37 -
    4.38      for (x = 0; x < buf.n_aces; x++) {
    4.39        printf("%x:[%x,%x) : %x\n", buf.entries[x].device,
    4.40  	     buf.entries[x].start_sect,
    4.41 @@ -43,6 +41,6 @@ int main(int argc, char *argv[])
    4.42  	     buf.entries[x].mode);
    4.43      }
    4.44      buf.start_ind += buf.n_aces;
    4.45 -  }
    4.46 +  } while (buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST);
    4.47    return 0;
    4.48  }
     5.1 --- a/tools/internal/xi_phys_revoke.c	Thu Jul 03 16:37:59 2003 +0000
     5.2 +++ b/tools/internal/xi_phys_revoke.c	Fri Jul 04 09:53:43 2003 +0000
     5.3 @@ -9,22 +9,25 @@ int main(int argc, char *argv[])
     5.4  {
     5.5    xp_disk_t buf;
     5.6    int fd;
     5.7 +  char *strbuf;
     5.8  
     5.9    if (argc != 5) {
    5.10      fprintf(stderr, "Usage: xi_physdev_revoke <domain> <device> <start sector> <n_sectors>\n");
    5.11      return 1;
    5.12    }
    5.13  
    5.14 -  buf.domain = atol(argv[1]);
    5.15    buf.device = atol(argv[2]);
    5.16 +  buf.mode = 0;
    5.17    buf.start_sect = atol(argv[3]);
    5.18    buf.n_sectors = atol(argv[4]);
    5.19  
    5.20 -  fd = open("/proc/xeno/dom0/phd", O_WRONLY);
    5.21 +  asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[1]);
    5.22 +  fd = open(strbuf, O_WRONLY);
    5.23    if (fd < 0) {
    5.24 -    fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n", strerror(errno));
    5.25 +    fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
    5.26      return 1;
    5.27    }
    5.28 +  free(strbuf);
    5.29  
    5.30    write(fd, &buf, sizeof(buf));
    5.31    close(fd);
     6.1 --- a/xen/drivers/block/xen_block.c	Thu Jul 03 16:37:59 2003 +0000
     6.2 +++ b/xen/drivers/block/xen_block.c	Fri Jul 04 09:53:43 2003 +0000
     6.3 @@ -105,7 +105,6 @@ static void dispatch_debug_block_io(stru
     6.4  static void dispatch_create_segment(struct task_struct *p, int index);
     6.5  static void dispatch_delete_segment(struct task_struct *p, int index);
     6.6  static void dispatch_grant_physdev(struct task_struct *p, int index);
     6.7 -static void dispatch_revoke_physdev(struct task_struct *p, int index);
     6.8  static void dispatch_probe_physdev(struct task_struct *p, int index);
     6.9  static void make_response(struct task_struct *p, unsigned long id, 
    6.10                            unsigned short op, unsigned long st);
    6.11 @@ -403,10 +402,6 @@ static int do_block_io_op_domain(struct 
    6.12    	    dispatch_grant_physdev(p, i);
    6.13  	    break;
    6.14  
    6.15 -	case XEN_BLOCK_PHYSDEV_REVOKE:
    6.16 - 	    dispatch_revoke_physdev(p, i);
    6.17 -	    break;
    6.18 -
    6.19  	case XEN_BLOCK_PHYSDEV_PROBE:
    6.20   	    dispatch_probe_physdev(p, i);
    6.21  	    break;
    6.22 @@ -501,43 +496,6 @@ static void dispatch_grant_physdev(struc
    6.23                    XEN_BLOCK_PHYSDEV_GRANT, result); 
    6.24  }
    6.25    
    6.26 -static void dispatch_revoke_physdev(struct task_struct *p, int index)
    6.27 -{
    6.28 -    blk_ring_t *blk_ring = p->blk_ring_base;
    6.29 -    unsigned long flags, buffer;
    6.30 -    xp_disk_t *xpd;
    6.31 -    int result;
    6.32 -
    6.33 -    if ( p->domain != 0 )
    6.34 -    {
    6.35 -        DPRINTK("dispatch_grant_physdev called by dom%d\n", p->domain);
    6.36 -        result = 1;
    6.37 -        goto out;
    6.38 -    }
    6.39 -
    6.40 -    buffer = blk_ring->ring[index].req.buffer_and_sects[0] & ~0x1FF;
    6.41 -
    6.42 -    spin_lock_irqsave(&p->page_lock, flags);
    6.43 -    if ( !__buffer_is_valid(p, buffer, sizeof(xv_disk_t), 1) )
    6.44 -    {
    6.45 -        DPRINTK("Bad buffer in dispatch_grant_physdev\n");
    6.46 -        spin_unlock_irqrestore(&p->page_lock, flags);
    6.47 -        result = 1;
    6.48 -        goto out;
    6.49 -    }
    6.50 -    __lock_buffer(buffer, sizeof(xv_disk_t), 1);
    6.51 -    spin_unlock_irqrestore(&p->page_lock, flags);
    6.52 -
    6.53 -    xpd = phys_to_virt(buffer);
    6.54 -    result = xen_physdisk_revoke(xpd);
    6.55 -
    6.56 -    unlock_buffer(p, buffer, sizeof(xp_disk_t), 1);
    6.57 -
    6.58 - out:
    6.59 -    make_response(p, blk_ring->ring[index].req.id, 
    6.60 -                  XEN_BLOCK_PHYSDEV_REVOKE, result); 
    6.61 -}
    6.62 -
    6.63  static void dispatch_create_segment(struct task_struct *p, int index)
    6.64  {
    6.65      blk_ring_t *blk_ring = p->blk_ring_base;
     7.1 --- a/xen/drivers/block/xen_physdisk.c	Thu Jul 03 16:37:59 2003 +0000
     7.2 +++ b/xen/drivers/block/xen_physdisk.c	Fri Jul 04 09:53:43 2003 +0000
     7.3 @@ -9,7 +9,7 @@
     7.4  
     7.5  #define MAX(a,b) ((a) > (b) ? (a) : (b))
     7.6  
     7.7 -#if 0
     7.8 +#if 1
     7.9  #define DPRINTK printk
    7.10  #else
    7.11  #define DPRINTK(...)
    7.12 @@ -26,8 +26,6 @@ struct physdisk_ace {
    7.13    unsigned short device;
    7.14    unsigned long start_sect;
    7.15    unsigned long n_sectors;
    7.16 -#define PHYSDISK_MODE_R 1
    7.17 -#define PHYSDISK_MODE_W 2
    7.18    int mode;
    7.19  };
    7.20  
    7.21 @@ -82,17 +80,20 @@ static void xen_physdisk_revoke_access(u
    7.22      cur_ace = list_entry(cur_ace_head, struct physdisk_ace,
    7.23  			 list);
    7.24      ace_end = cur_ace->start_sect + cur_ace->n_sectors;
    7.25 -    if (cur_ace->start_sect > kill_zone_end ||
    7.26 -	ace_end < start_sect)
    7.27 +    if (cur_ace->start_sect >= kill_zone_end ||
    7.28 +	ace_end <= start_sect)
    7.29        continue;
    7.30      
    7.31 +    DPRINTK("Killing ace [%x, %x) against kill zone [%x, %x)\n",
    7.32 +	    cur_ace->start_sect, ace_end, start_sect, kill_zone_end);
    7.33 +
    7.34      if (cur_ace->start_sect >= start_sect &&
    7.35 -	ace_end < kill_zone_end) {
    7.36 +	ace_end <= kill_zone_end) {
    7.37        /* ace entirely within kill zone -> kill it */
    7.38        list_del(cur_ace_head);
    7.39 -      cur_ace_head = cur_ace_head->next;
    7.40 +      cur_ace_head = cur_ace_head->prev;
    7.41        kfree(cur_ace);
    7.42 -    } else if (ace_end < kill_zone_end) {
    7.43 +    } else if (ace_end <= kill_zone_end) {
    7.44        /* ace start before kill start, ace end in kill zone, 
    7.45  	 move ace end. */
    7.46        cur_ace->n_sectors = start_sect - cur_ace->start_sect;
    7.47 @@ -102,9 +103,9 @@ static void xen_physdisk_revoke_access(u
    7.48        cur_ace->start_sect = kill_zone_end;
    7.49        cur_ace->n_sectors = ace_end - cur_ace->start_sect;
    7.50      } else {
    7.51 -      /* The fun one: the kill zone entirely includes the ace. */
    7.52 +      /* The fun one: the ace entirely includes the kill zone. */
    7.53        /* Cut the current ace down to just the bit before the kzone,
    7.54 -	 create a new ace for the bit just after it. */
    7.55 +	 create a new ace for the bit just after it. */ 
    7.56        new_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
    7.57        new_ace->device = dev;
    7.58        new_ace->start_sect = kill_zone_end;
    7.59 @@ -114,7 +115,6 @@ static void xen_physdisk_revoke_access(u
    7.60        cur_ace->n_sectors = start_sect - cur_ace->start_sect;
    7.61  
    7.62        list_add(&new_ace->list, cur_ace_head);
    7.63 -      cur_ace_head = new_ace->list.next;
    7.64      }
    7.65    }
    7.66  }
    7.67 @@ -133,13 +133,15 @@ static int xen_physdisk_grant_access(uns
    7.68       and we try to grant write access, or vice versa. */
    7.69    xen_physdisk_revoke_access(dev, start_sect, n_sectors, p);
    7.70    
    7.71 -  cur_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
    7.72 -  cur_ace->device = dev;
    7.73 -  cur_ace->start_sect = start_sect;
    7.74 -  cur_ace->n_sectors = n_sectors;
    7.75 -  cur_ace->mode = mode;
    7.76 +  if (mode) {
    7.77 +    cur_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
    7.78 +    cur_ace->device = dev;
    7.79 +    cur_ace->start_sect = start_sect;
    7.80 +    cur_ace->n_sectors = n_sectors;
    7.81 +    cur_ace->mode = mode;
    7.82  
    7.83 -  list_add_tail(&cur_ace->list, &p->physdisk_aces);
    7.84 +    list_add_tail(&cur_ace->list, &p->physdisk_aces);
    7.85 +  }
    7.86  
    7.87    return 0;
    7.88  }
    7.89 @@ -151,27 +153,25 @@ static void xen_physdisk_probe_access(ph
    7.90    int n_aces;
    7.91    struct list_head *cur_ace_head;
    7.92    struct physdisk_ace *cur_ace;
    7.93 -  int x;
    7.94 +  int x = 0;
    7.95  
    7.96    max_aces = buf->n_aces;
    7.97    n_aces = 0;
    7.98    list_for_each(cur_ace_head, &p->physdisk_aces) {
    7.99 -    if (x < buf->start_ind) {
   7.100 -      x++;
   7.101 -      continue;
   7.102 +    x++;
   7.103 +    if (x >= buf->start_ind) {
   7.104 +      cur_ace = list_entry(cur_ace_head, struct physdisk_ace,
   7.105 +			   list);
   7.106 +      buf->entries[n_aces].device = cur_ace->device;
   7.107 +      buf->entries[n_aces].start_sect = cur_ace->start_sect;
   7.108 +      buf->entries[n_aces].n_sectors = cur_ace->n_sectors;
   7.109 +      buf->entries[n_aces].mode = cur_ace->mode;
   7.110 +      n_aces++;
   7.111 +      if (n_aces >= max_aces)
   7.112 +	break;
   7.113      }
   7.114 -    cur_ace = list_entry(cur_ace_head, struct physdisk_ace,
   7.115 -			 list);
   7.116 -    buf->entries[n_aces].device = cur_ace->device;
   7.117 -    buf->entries[n_aces].start_sect = cur_ace->start_sect;
   7.118 -    buf->entries[n_aces].n_sectors = cur_ace->n_sectors;
   7.119 -    buf->entries[n_aces].mode = cur_ace->mode;
   7.120 -    n_aces++;
   7.121 -    if (n_aces >= max_aces)
   7.122 -      break;
   7.123    }
   7.124    buf->n_aces = n_aces;
   7.125 -  printk("Found a total of %x aces (max %x).\n", n_aces, max_aces);
   7.126  }
   7.127  
   7.128  int xen_physdisk_grant(xp_disk_t *xpd_in)
   7.129 @@ -188,7 +188,7 @@ int xen_physdisk_grant(xp_disk_t *xpd_in
   7.130      p = p->next_task;
   7.131    } while (p != current && p->domain != xpd->domain);
   7.132    if (p->domain != xpd->domain) {
   7.133 -    DPRINTK("Bad domain! No biscuit!\n");
   7.134 +    DPRINTK("Bad domain!\n");
   7.135      res = 1;
   7.136      goto out;
   7.137    }
   7.138 @@ -205,33 +205,6 @@ int xen_physdisk_grant(xp_disk_t *xpd_in
   7.139    return res;
   7.140  }
   7.141  
   7.142 -int xen_physdisk_revoke(xp_disk_t *xpd_in)
   7.143 -{
   7.144 -  struct task_struct *p;
   7.145 -  xp_disk_t *xpd = map_domain_mem(virt_to_phys(xpd_in));
   7.146 -  int res;
   7.147 -
   7.148 -  p = current;
   7.149 -
   7.150 -  do {
   7.151 -    p = p->next_task;
   7.152 -  } while (p != current && p->domain != xpd->domain);
   7.153 -  if (p->domain != xpd->domain) {
   7.154 -    res = 1;
   7.155 -    goto out;
   7.156 -  }
   7.157 -  spin_lock(&p->physdev_lock);
   7.158 -  xen_physdisk_revoke_access(xpd->device,
   7.159 -			     xpd->start_sect,
   7.160 -			     xpd->n_sectors,
   7.161 -			     p);
   7.162 -  spin_unlock(&p->physdev_lock);
   7.163 -  res = 0;
   7.164 - out:
   7.165 -  unmap_domain_mem(xpd);
   7.166 -  return res;
   7.167 -}
   7.168 -
   7.169  int xen_physdisk_probe(physdisk_probebuf_t *buf_in)
   7.170  {
   7.171    struct task_struct *p;
   7.172 @@ -241,16 +214,14 @@ int xen_physdisk_probe(physdisk_probebuf
   7.173    p = current;
   7.174    do {
   7.175      p = p->next_task;
   7.176 -  } while (p != current && p->domain != buf->domain);
   7.177 +  } while (p != current && p->domain != buf->domain);  
   7.178    if (p->domain != buf->domain) {
   7.179      res = 1;
   7.180      goto out;
   7.181    }
   7.182 -  printk("initially %x aces.\n", buf->n_aces);
   7.183    spin_lock(&p->physdev_lock);
   7.184    xen_physdisk_probe_access(buf, p);
   7.185    spin_unlock(&p->physdev_lock);
   7.186 -  printk("%x aces.\n", buf->n_aces);
   7.187    res = 0;
   7.188   out:
   7.189    unmap_domain_mem(buf);
     8.1 --- a/xen/include/hypervisor-ifs/block.h	Thu Jul 03 16:37:59 2003 +0000
     8.2 +++ b/xen/include/hypervisor-ifs/block.h	Fri Jul 04 09:53:43 2003 +0000
     8.3 @@ -48,8 +48,7 @@
     8.4  #define XEN_BLOCK_SEG_DELETE   8  /* delete segment (vhd) */
     8.5  #define XEN_BLOCK_PROBE_SEG    9  /* get vhd config from hypervisor */
     8.6  #define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
     8.7 -#define XEN_BLOCK_PHYSDEV_REVOKE 11 /* revoke access to range of disk blocks */
     8.8 -#define XEN_BLOCK_PHYSDEV_PROBE 12 /* probe for a domain's physdev
     8.9 +#define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
    8.10  				      accesses */
    8.11  
    8.12  /* NB. Ring size must be small enough for sizeof(blk_ring_t) <= PAGE_SIZE. */
    8.13 @@ -143,9 +142,12 @@ typedef struct xv_disk
    8.14    xv_extent_t extents[XEN_MAX_DISK_COUNT];    /* arbitrary reuse of constant */
    8.15  } xv_disk_t;
    8.16  
    8.17 +#define PHYSDISK_MODE_R 1
    8.18 +#define PHYSDISK_MODE_W 2
    8.19  typedef struct xp_disk
    8.20  {
    8.21 -  int mode;
    8.22 +  int mode; /* 0 -> revoke existing access, otherwise bitmask of
    8.23 +	       PHYSDISK_MODE_? constants */
    8.24    int domain;
    8.25    unsigned short device;
    8.26    unsigned long start_sect;
     9.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c	Thu Jul 03 16:37:59 2003 +0000
     9.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c	Fri Jul 04 09:53:43 2003 +0000
     9.3 @@ -308,7 +308,6 @@ static int hypervisor_request(unsigned l
     9.4      case XEN_BLOCK_SEG_CREATE:
     9.5      case XEN_BLOCK_SEG_DELETE:
     9.6      case XEN_BLOCK_PHYSDEV_GRANT:
     9.7 -    case XEN_BLOCK_PHYSDEV_REVOKE:
     9.8      case XEN_BLOCK_PHYSDEV_PROBE:
     9.9      case XEN_BLOCK_PROBE_BLK:
    9.10      case XEN_BLOCK_PROBE_SEG:
    9.11 @@ -482,7 +481,6 @@ static void xlblk_response_int(int irq, 
    9.12          case XEN_BLOCK_PROBE_SEG:
    9.13          case XEN_BLOCK_PROBE_BLK:
    9.14  	case XEN_BLOCK_PHYSDEV_GRANT:
    9.15 -	case XEN_BLOCK_PHYSDEV_REVOKE:
    9.16  	case XEN_BLOCK_PHYSDEV_PROBE:
    9.17              if ( bret->status )
    9.18                  printk(KERN_ALERT "Bad return from blkdev control request\n");
    10.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c	Thu Jul 03 16:37:59 2003 +0000
    10.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c	Fri Jul 04 09:53:43 2003 +0000
    10.3 @@ -1,3 +1,4 @@
    10.4 +/* We stuff the domain number into the proc_dir_entry data pointer. */
    10.5  #include <linux/kernel.h>
    10.6  #include <linux/module.h>
    10.7  #include <linux/fs.h>
    10.8 @@ -7,14 +8,14 @@
    10.9  #include <asm/uaccess.h>
   10.10  #include <linux/proc_fs.h>
   10.11  
   10.12 -static struct proc_dir_entry *phd;
   10.13 -
   10.14  extern int xenolinux_control_msg(int operration, char *buffer, int size);
   10.15  
   10.16 -static ssize_t proc_read_phd(struct file * file, char * buff, size_t size, loff_t * off)
   10.17 +static ssize_t proc_read_phd(struct file * file, char * buff, size_t size,
   10.18 +			     loff_t * off)
   10.19  {
   10.20    physdisk_probebuf_t *buf;
   10.21    int res;
   10.22 +  struct proc_dir_entry *pde;
   10.23  
   10.24    if (size != sizeof(physdisk_probebuf_t))
   10.25      return -EINVAL;
   10.26 @@ -28,12 +29,16 @@ static ssize_t proc_read_phd(struct file
   10.27      return -EFAULT;
   10.28    }
   10.29  
   10.30 -  printk("max aces 1 %x\n", buf->n_aces);
   10.31 +  pde = file->f_dentry->d_inode->u.generic_ip;
   10.32 +  buf->domain = (int)pde->data;
   10.33  
   10.34 +  /* The offset reported by lseek and friends doesn't have to be in
   10.35 +     bytes, and it's marginally easier to say that it's in records, so
   10.36 +     that's what we do. */
   10.37 +  buf->start_ind = *off;
   10.38    res = xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (void *)buf,
   10.39  			      sizeof(physdisk_probebuf_t));
   10.40 -
   10.41 -  printk("max aces %x\n", buf->n_aces);
   10.42 +  *off += buf->n_aces;
   10.43  
   10.44    if (res)
   10.45      res = -EINVAL;
   10.46 @@ -52,6 +57,8 @@ static int proc_write_phd(struct file *f
   10.47  {
   10.48    char *local;
   10.49    int res;
   10.50 +  xp_disk_t *xpd;
   10.51 +  struct proc_dir_entry *pde;
   10.52  
   10.53    if (count != sizeof(xp_disk_t))
   10.54      return -EINVAL;
   10.55 @@ -63,7 +70,11 @@ static int proc_write_phd(struct file *f
   10.56      res = -EFAULT;
   10.57      goto out;
   10.58    }
   10.59 -  local[count] = 0;
   10.60 +
   10.61 +  xpd = (xp_disk_t *)local;
   10.62 +
   10.63 +  pde = file->f_dentry->d_inode->u.generic_ip;
   10.64 +  xpd->domain = (int)pde->data;
   10.65  
   10.66    res = xenolinux_control_msg(XEN_BLOCK_PHYSDEV_GRANT, local, count);
   10.67    if (res == 0)
   10.68 @@ -75,20 +86,7 @@ static int proc_write_phd(struct file *f
   10.69    return res;
   10.70  }
   10.71  
   10.72 -static struct file_operations proc_phd_fops = {
   10.73 +struct file_operations dom0_phd_fops = {
   10.74    read : proc_read_phd,
   10.75    write : proc_write_phd
   10.76  };
   10.77 -
   10.78 -int __init xlphysdisk_proc_init(void)
   10.79 -{
   10.80 -  phd = create_proc_entry("xeno/dom0/phd", 0644, NULL);
   10.81 -  if (!phd) {
   10.82 -    panic("Can\'t create phd proc entry!\n");
   10.83 -  }
   10.84 -  phd->data = NULL;
   10.85 -  phd->proc_fops = &proc_phd_fops;
   10.86 -  phd->owner = THIS_MODULE;
   10.87 -
   10.88 -  return 0;
   10.89 -}
    11.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Thu Jul 03 16:37:59 2003 +0000
    11.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Fri Jul 04 09:53:43 2003 +0000
    11.3 @@ -56,9 +56,12 @@ typedef struct proc_mem_data {
    11.4  #define DOM_MEM         "mem"
    11.5  #define DOM_VIF         "vif"
    11.6  #define DOM_USAGE       "usage"
    11.7 +#define DOM_PHD         "phd"
    11.8  
    11.9  #define MAP_DISCONT     1
   11.10  
   11.11 +extern struct file_operations dom0_phd_fops;
   11.12 +
   11.13  struct proc_dir_entry *xeno_base;
   11.14  static struct proc_dir_entry *dom0_cmd_intf;
   11.15  static struct proc_dir_entry *proc_ft;
   11.16 @@ -219,6 +222,15 @@ static void create_proc_dom_entries(int 
   11.17          file->proc_fops     = &dom_usage_ops;
   11.18          file->data          = (void *) dom;
   11.19      }
   11.20 +
   11.21 +    file = create_proc_entry(DOM_PHD, 0600, dir);
   11.22 +    if (file != NULL)
   11.23 +    {
   11.24 +        file->owner         = THIS_MODULE;
   11.25 +        file->nlink         = 1;
   11.26 +        file->proc_fops     = &dom0_phd_fops;
   11.27 +        file->data          = (void *) dom;
   11.28 +    }
   11.29  }
   11.30  
   11.31  static ssize_t dom_mem_write(struct file * file, const char * buff, 
    12.1 --- a/xenolinux-2.4.21-sparse/drivers/block/ll_rw_blk.c	Thu Jul 03 16:37:59 2003 +0000
    12.2 +++ b/xenolinux-2.4.21-sparse/drivers/block/ll_rw_blk.c	Fri Jul 04 09:53:43 2003 +0000
    12.3 @@ -1505,7 +1505,6 @@ int __init blk_dev_init(void)
    12.4      xlblk_init();
    12.5      xlseg_init();
    12.6      xlseg_proc_init();
    12.7 -    xlphysdisk_proc_init();
    12.8  #endif
    12.9  
   12.10  	return 0;