ia64/xen-unstable

changeset 534:49232d5003e6

bitkeeper revision 1.295 (3f0aa9beS_4RaA-JxGiBF8BRtuik6Q)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/sos22/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/sos22/tmp/xeno.bk
author sos22@labyrinth.cl.cam.ac.uk
date Tue Jul 08 11:23:42 2003 +0000 (2003-07-08)
parents 4ebe3235a8f3 35727deb8b0a
children 75772169ac6c 07d15d2fc6b7
files .rootkeys tools/internal/Makefile tools/internal/hypervisor_defs.h tools/internal/physdev.h tools/internal/xi_build.c tools/internal/xi_create.c tools/internal/xi_phys_grant.c tools/internal/xi_phys_probe.c tools/internal/xi_phys_revoke.c tools/internal/xi_start.c tools/internal/xi_stop.c xen/drivers/block/xen_physdisk.c xen/drivers/block/xen_segment.c xen/include/hypervisor-ifs/block.h xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c xenolinux-2.4.21-sparse/fs/partitions/xeno.c
line diff
     1.1 --- a/.rootkeys	Tue Jul 08 10:38:14 2003 +0000
     1.2 +++ b/.rootkeys	Tue Jul 08 11:23:42 2003 +0000
     1.3 @@ -118,9 +118,7 @@ 3eb781fc6vgq5yhkJRGDLY9gWWRY2A tools/con
     1.4  3eb781fdl4lXWYZzmqDDUAYhAThRqQ tools/internal/Makefile
     1.5  3eb781fdc539MQQm47rYRCCR3N5i-Q tools/internal/dom0_defs.h
     1.6  3ee609b3Yr4aggmLSKmhiIzT8-nURA tools/internal/dom0_ops.h
     1.7 -3eb781fddjylXbsepjppUyIXa5lcaQ tools/internal/hypervisor_defs.h
     1.8  3eb781fdKiQbgozBsgs_zzJQ9ubehw tools/internal/mem_defs.h
     1.9 -3f04589dFbtsbWWwAXq3I92UiAogCg tools/internal/physdev.h
    1.10  3ec61e1bJCeJJu0SsptmDpA1xKvwvw tools/internal/rpm.spec
    1.11  3eb781fdgbSkh2O6JQS-65Dz4n0ItQ tools/internal/xi_build.c
    1.12  3eb781fdW1SAyiaC4mTsXq_9fRHh-A tools/internal/xi_create.c
     2.1 --- a/tools/internal/Makefile	Tue Jul 08 10:38:14 2003 +0000
     2.2 +++ b/tools/internal/Makefile	Tue Jul 08 11:23:42 2003 +0000
     2.3 @@ -1,4 +1,5 @@
     2.4  CC = gcc
     2.5 +CFLAGS = -Wall -I../../xen/include
     2.6  XI_CREATE = xi_create
     2.7  XI_START = xi_start
     2.8  XI_STOP = xi_stop
     2.9 @@ -19,29 +20,29 @@ all: $(XI_CREATE).o $(XI_START).o $(XI_S
    2.10  	$(CC) -o $(XI_PHYS_REVOKE) $(XI_PHYS_REVOKE).o
    2.11  	$(CC) -o $(XI_PHYS_PROBE) $(XI_PHYS_PROBE).o
    2.12  
    2.13 -$(XI_CREATE).o: $(XI_CREATE).c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
    2.14 -	$(CC) -c $(XI_CREATE).c 
    2.15 +$(XI_CREATE).o: $(XI_CREATE).c dom0_defs.h dom0_ops.h mem_defs.h
    2.16 +	$(CC) $(CFLAGS) -c $(XI_CREATE).c 
    2.17  
    2.18 -internal_domain_build.o: internal_domain_build.c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
    2.19 -	$(CC) -c internal_domain_build.c 
    2.20 +internal_domain_build.o: internal_domain_build.c dom0_defs.h dom0_ops.h mem_defs.h
    2.21 +	$(CC) $(CFLAGS) -c internal_domain_build.c 
    2.22  
    2.23 -$(XI_START).o: $(XI_START).c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
    2.24 -	$(CC) -c $(XI_START).c 
    2.25 +$(XI_START).o: $(XI_START).c dom0_defs.h dom0_ops.h mem_defs.h
    2.26 +	$(CC) $(CFLAGS) -c $(XI_START).c 
    2.27  
    2.28 -$(XI_STOP).o: $(XI_STOP).c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
    2.29 -	$(CC) -c $(XI_STOP).c 
    2.30 +$(XI_STOP).o: $(XI_STOP).c dom0_defs.h dom0_ops.h mem_defs.h
    2.31 +	$(CC) $(CFLAGS) -c $(XI_STOP).c 
    2.32  
    2.33  $(XI_DESTROY).o: $(XI_DESTROY).c dom0_ops.h dom0_defs.h
    2.34 -	$(CC) -c $(XI_DESTROY).c 
    2.35 +	$(CC) $(CFLAGS) -c $(XI_DESTROY).c 
    2.36  
    2.37 -$(XI_PHYS_GRANT).o: $(XI_PHYS_GRANT).c physdev.h
    2.38 -	$(CC) -c $(XI_PHYS_GRANT).c 
    2.39 +$(XI_PHYS_GRANT).o: $(XI_PHYS_GRANT).c 
    2.40 +	$(CC) $(CFLAGS) -c $(XI_PHYS_GRANT).c 
    2.41  
    2.42 -$(XI_PHYS_REVOKE).o: $(XI_PHYS_REVOKE).c physdev.h
    2.43 -	$(CC) -c $(XI_PHYS_REVOKE).c 
    2.44 +$(XI_PHYS_REVOKE).o: $(XI_PHYS_REVOKE).c
    2.45 +	$(CC) $(CFLAGS) -c $(XI_PHYS_REVOKE).c 
    2.46  
    2.47 -$(XI_PHYS_PROBE).o: $(XI_PHYS_PROBE).c physdev.h
    2.48 -	$(CC) -c $(XI_PHYS_PROBE).c 
    2.49 +$(XI_PHYS_PROBE).o: $(XI_PHYS_PROBE).c
    2.50 +	$(CC) $(CFLAGS) -c $(XI_PHYS_PROBE).c 
    2.51  
    2.52  install: all
    2.53  	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
     3.1 --- a/tools/internal/hypervisor_defs.h	Tue Jul 08 10:38:14 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,36 +0,0 @@
     3.4 -/******************************************************************************
     3.5 - * hypervisor_defs.h
     3.6 - * 
     3.7 - * This needs to be kept in sync with Xen's pagetable update interface!
     3.8 - * 
     3.9 - * Copyright (c) 2002-2003, Keir Fraser & Boris Dragovic 
    3.10 - */
    3.11 -
    3.12 -/* taken from include/hypervisor-ifs/hypervisor-if.h */
    3.13 -typedef struct
    3.14 -{
    3.15 -/*
    3.16 - * PGREQ_XXX: specified in least-significant bits of 'ptr' field. All requests 
    3.17 - * specify relevent PTE or PT address in 'ptr'. Normal requests specify update 
    3.18 - * value in 'value'. Extended requests specify command in least 8 bits of 
    3.19 - * 'value'.
    3.20 - */
    3.21 -    unsigned long ptr, val; /* *ptr = val */
    3.22 -} page_update_request_t;
    3.23 -
    3.24 -/* A normal page-table update request. */
    3.25 -#define PGREQ_NORMAL           0
    3.26 -#define PGREQ_MPT_UPDATE 1
    3.27 -/* An extended command. */
    3.28 -#define PGREQ_EXTENDED_COMMAND 2
    3.29 -/* Announce a new top-level page table. */
    3.30 -#define PGEXT_PIN_L1_TABLE      0
    3.31 -#define PGEXT_PIN_L2_TABLE      1
    3.32 -#define PGEXT_PIN_L3_TABLE      2
    3.33 -#define PGEXT_PIN_L4_TABLE      3
    3.34 -#define PGEXT_UNPIN_TABLE       4
    3.35 -#define PGEXT_NEW_BASEPTR       5
    3.36 -#define PGEXT_TLB_FLUSH         6
    3.37 -#define PGEXT_INVLPG            7
    3.38 -#define PGEXT_CMD_MASK        255
    3.39 -#define PGEXT_CMD_SHIFT         8
     4.1 --- a/tools/internal/physdev.h	Tue Jul 08 10:38:14 2003 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,27 +0,0 @@
     4.4 -#define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
     4.5 -#define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
     4.6 -				      accesses */
     4.7 -
     4.8 -#define PHYSDISK_MODE_R 1
     4.9 -#define PHYSDISK_MODE_W 2
    4.10 -typedef struct xp_disk
    4.11 -{
    4.12 -  int mode; /* PHYSDISK_MODEs or 0 for revoke. */
    4.13 -  int domain;
    4.14 -  unsigned short device;
    4.15 -  unsigned long start_sect;
    4.16 -  unsigned long n_sectors;
    4.17 -} xp_disk_t;
    4.18 -
    4.19 -#define PHYSDISK_MAX_ACES_PER_REQUEST 254
    4.20 -typedef struct {
    4.21 -  int n_aces;
    4.22 -  int domain;
    4.23 -  int start_ind;
    4.24 -  struct {
    4.25 -    unsigned short device;
    4.26 -    unsigned long start_sect;
    4.27 -    unsigned long n_sectors;
    4.28 -    unsigned mode;
    4.29 -  } entries[PHYSDISK_MAX_ACES_PER_REQUEST];
    4.30 -} physdisk_probebuf_t;
     5.1 --- a/tools/internal/xi_build.c	Tue Jul 08 10:38:14 2003 +0000
     5.2 +++ b/tools/internal/xi_build.c	Tue Jul 08 11:23:42 2003 +0000
     5.3 @@ -14,7 +14,8 @@
     5.4  #include <stdlib.h>
     5.5  #include <sys/ioctl.h>
     5.6  
     5.7 -#include "hypervisor_defs.h"
     5.8 +#include "asm-i386/types.h"
     5.9 +#include "hypervisor-ifs/hypervisor-if.h"
    5.10  #include "dom0_ops.h"
    5.11  #include "dom0_defs.h"
    5.12  #include "mem_defs.h"
     6.1 --- a/tools/internal/xi_create.c	Tue Jul 08 10:38:14 2003 +0000
     6.2 +++ b/tools/internal/xi_create.c	Tue Jul 08 11:23:42 2003 +0000
     6.3 @@ -16,7 +16,6 @@
     6.4  #include <errno.h>
     6.5  #include <string.h>
     6.6  
     6.7 -#include "hypervisor_defs.h"
     6.8  #include "dom0_ops.h"
     6.9  #include "dom0_defs.h"
    6.10  #include "mem_defs.h"
     7.1 --- a/tools/internal/xi_phys_grant.c	Tue Jul 08 10:38:14 2003 +0000
     7.2 +++ b/tools/internal/xi_phys_grant.c	Tue Jul 08 11:23:42 2003 +0000
     7.3 @@ -1,9 +1,12 @@
     7.4 +#define _GNU_SOURCE
     7.5  #include <unistd.h>
     7.6  #include <stdio.h>
     7.7  #include <errno.h>
     7.8  #include <sys/fcntl.h>
     7.9 +#include <string.h>
    7.10 +#include <stdlib.h>
    7.11  
    7.12 -#include "physdev.h"
    7.13 +#include "hypervisor-ifs/block.h"
    7.14  
    7.15  int main(int argc, char *argv[])
    7.16  {
    7.17 @@ -26,9 +29,10 @@ int main(int argc, char *argv[])
    7.18    else if (argv[1][1] == 'w')
    7.19      buf.mode |= 2;
    7.20    
    7.21 -  buf.device = atol(argv[3]) + atol(argv[6]);
    7.22 +  buf.device = atol(argv[3]);
    7.23    buf.start_sect = atol(argv[4]);
    7.24    buf.n_sectors = atol(argv[5]);
    7.25 +  buf.partition = atol(argv[6]);
    7.26  
    7.27    asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[2]);
    7.28    fd = open(strbuf, O_WRONLY);
     8.1 --- a/tools/internal/xi_phys_probe.c	Tue Jul 08 10:38:14 2003 +0000
     8.2 +++ b/tools/internal/xi_phys_probe.c	Tue Jul 08 11:23:42 2003 +0000
     8.3 @@ -1,10 +1,12 @@
     8.4 +#define _GNU_SOURCE
     8.5  #include <stdio.h>
     8.6  #include <sys/fcntl.h>
     8.7  #include <errno.h>
     8.8  #include <unistd.h>
     8.9  #include <string.h>
    8.10 +#include <stdlib.h>
    8.11  
    8.12 -#include "physdev.h"
    8.13 +#include "hypervisor-ifs/block.h"
    8.14  
    8.15  int main(int argc, char *argv[])
    8.16  {
    8.17 @@ -37,7 +39,8 @@ int main(int argc, char *argv[])
    8.18      for (x = 0; x < buf.n_aces; x++) {
    8.19        char read = ( buf.entries[x].mode & 1 ? 'r' : ' ' );
    8.20        char write = ( buf.entries[x].mode & 2 ? 'w' : ' ' );
    8.21 -      printf("%x %x %x %c%c\n", buf.entries[x].device,
    8.22 +      printf("%x %x %lx %lx %c%c\n", buf.entries[x].device,
    8.23 +	     buf.entries[x].partition,
    8.24  	     buf.entries[x].start_sect,
    8.25  	     buf.entries[x].n_sectors,
    8.26  	     read,
     9.1 --- a/tools/internal/xi_phys_revoke.c	Tue Jul 08 10:38:14 2003 +0000
     9.2 +++ b/tools/internal/xi_phys_revoke.c	Tue Jul 08 11:23:42 2003 +0000
     9.3 @@ -1,9 +1,12 @@
     9.4 +#define _GNU_SOURCE
     9.5  #include <unistd.h>
     9.6  #include <errno.h>
     9.7  #include <stdio.h>
     9.8  #include <sys/fcntl.h>
     9.9 +#include <string.h>
    9.10 +#include <stdlib.h>
    9.11  
    9.12 -#include "physdev.h"
    9.13 +#include "hypervisor-ifs/block.h"
    9.14  
    9.15  int main(int argc, char *argv[])
    9.16  {
    10.1 --- a/tools/internal/xi_start.c	Tue Jul 08 10:38:14 2003 +0000
    10.2 +++ b/tools/internal/xi_start.c	Tue Jul 08 11:23:42 2003 +0000
    10.3 @@ -6,8 +6,8 @@
    10.4  #include <sys/types.h>
    10.5  #include <sys/stat.h>
    10.6  #include <stdlib.h>
    10.7 +#include <string.h>
    10.8  
    10.9 -#include "hypervisor_defs.h"
   10.10  #include "dom0_ops.h"
   10.11  #include "dom0_defs.h"
   10.12  #include "mem_defs.h"
   10.13 @@ -32,12 +32,9 @@ static void PERROR (char *message)
   10.14  
   10.15  static int start_domain(int id)
   10.16  {
   10.17 -    dom0_newdomain_t * dom_data;
   10.18      char cmd_path[MAX_PATH];
   10.19 -    char dom_id_path[MAX_PATH];
   10.20      dom0_op_t dop;
   10.21      int cmd_fd;
   10.22 -    int id_fd;
   10.23  
   10.24      /* Set up the DOM0_STARTDOMAIN command */
   10.25      dop.cmd = DOM0_STARTDOMAIN;
    11.1 --- a/tools/internal/xi_stop.c	Tue Jul 08 10:38:14 2003 +0000
    11.2 +++ b/tools/internal/xi_stop.c	Tue Jul 08 11:23:42 2003 +0000
    11.3 @@ -7,7 +7,6 @@
    11.4  #include <sys/stat.h>
    11.5  #include <stdlib.h>
    11.6  
    11.7 -#include "hypervisor_defs.h"
    11.8  #include "dom0_ops.h"
    11.9  #include "dom0_defs.h"
   11.10  #include "mem_defs.h"
    12.1 --- a/xen/drivers/block/xen_physdisk.c	Tue Jul 08 10:38:14 2003 +0000
    12.2 +++ b/xen/drivers/block/xen_physdisk.c	Tue Jul 08 11:23:42 2003 +0000
    12.3 @@ -25,6 +25,7 @@ struct physdisk_ace {
    12.4    struct list_head list;
    12.5  
    12.6    unsigned short device;
    12.7 +  unsigned short partition;
    12.8    unsigned long start_sect;
    12.9    unsigned long n_sectors;
   12.10    int mode;
   12.11 @@ -40,8 +41,6 @@ static struct physdisk_ace *find_ace(con
   12.12    struct list_head *cur_ace_head;
   12.13    struct physdisk_ace *cur_ace;
   12.14  
   12.15 -  dev &= ~0x1f; /* ignore the partition part */
   12.16 -
   12.17    list_for_each(cur_ace_head, &p->physdisk_aces) {
   12.18      cur_ace = list_entry(cur_ace_head, struct physdisk_ace,
   12.19  			 list);
   12.20 @@ -50,7 +49,7 @@ static struct physdisk_ace *find_ace(con
   12.21  	    sect);
   12.22      if (sect >= cur_ace->start_sect &&
   12.23  	sect < cur_ace->start_sect + cur_ace->n_sectors &&
   12.24 -	dev == (cur_ace->device & ~0x1f) && /* ignore partition part */
   12.25 +	dev == cur_ace->device &&
   12.26  	((operation == READ && (cur_ace->mode & PHYSDISK_MODE_R)) ||
   12.27  	 (operation == WRITE && (cur_ace->mode & PHYSDISK_MODE_W)))) {
   12.28        DPRINTK("Yes.\n");
   12.29 @@ -85,7 +84,7 @@ static void xen_physdisk_revoke_access(u
   12.30      ace_end = cur_ace->start_sect + cur_ace->n_sectors;
   12.31      if (cur_ace->start_sect >= kill_zone_end ||
   12.32  	ace_end <= start_sect ||
   12.33 -	(cur_ace->device & ~0x1f) != (dev & ~0x1f))
   12.34 +	cur_ace->device != dev)
   12.35        continue;
   12.36      
   12.37      DPRINTK("Killing ace [%lx, %lx) against kill zone [%lx, %lx)\n",
   12.38 @@ -111,7 +110,7 @@ static void xen_physdisk_revoke_access(u
   12.39        /* Cut the current ace down to just the bit before the kzone,
   12.40  	 create a new ace for the bit just after it. */ 
   12.41        new_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
   12.42 -      new_ace->device = dev & ~0x1f;
   12.43 +      new_ace->device = dev;
   12.44        new_ace->start_sect = kill_zone_end;
   12.45        new_ace->n_sectors = ace_end - kill_zone_end;
   12.46        new_ace->mode = cur_ace->mode;
   12.47 @@ -125,6 +124,7 @@ static void xen_physdisk_revoke_access(u
   12.48  
   12.49  /* Hold the lock on entry, it remains held on exit. */
   12.50  static int xen_physdisk_grant_access(unsigned short dev,
   12.51 +				     unsigned short partition,
   12.52  				     unsigned long start_sect,
   12.53  				     unsigned long n_sectors,
   12.54  				     int mode,
   12.55 @@ -143,6 +143,7 @@ static int xen_physdisk_grant_access(uns
   12.56      cur_ace->start_sect = start_sect;
   12.57      cur_ace->n_sectors = n_sectors;
   12.58      cur_ace->mode = mode;
   12.59 +    cur_ace->partition = partition;
   12.60  
   12.61      list_add_tail(&cur_ace->list, &p->physdisk_aces);
   12.62    }
   12.63 @@ -167,6 +168,7 @@ static void xen_physdisk_probe_access(ph
   12.64        cur_ace = list_entry(cur_ace_head, struct physdisk_ace,
   12.65  			   list);
   12.66        buf->entries[n_aces].device = cur_ace->device;
   12.67 +      buf->entries[n_aces].partition = cur_ace->partition;
   12.68        buf->entries[n_aces].start_sect = cur_ace->start_sect;
   12.69        buf->entries[n_aces].n_sectors = cur_ace->n_sectors;
   12.70        buf->entries[n_aces].mode = cur_ace->mode;
   12.71 @@ -188,21 +190,21 @@ int xen_physdisk_grant(xp_disk_t *xpd_in
   12.72    DPRINTK("Have current.\n");
   12.73    DPRINTK("Target domain %x\n", xpd->domain);
   12.74  
   12.75 -  do {
   12.76 -    p = p->next_task;
   12.77 -  } while (p != current && p->domain != xpd->domain);
   12.78 -  if (p->domain != xpd->domain) {
   12.79 +  p = find_domain_by_id(xpd->domain);
   12.80 +  if (p == NULL) {
   12.81      DPRINTK("Bad domain!\n");
   12.82      res = 1;
   12.83      goto out;
   12.84    }
   12.85    spin_lock(&p->physdev_lock);
   12.86    res = xen_physdisk_grant_access(xpd->device,
   12.87 +				  xpd->partition,
   12.88  				  xpd->start_sect,
   12.89  				  xpd->n_sectors,
   12.90  				  xpd->mode,
   12.91  				  p);
   12.92    spin_unlock(&p->physdev_lock);
   12.93 +  put_task_struct(p);
   12.94  
   12.95   out:
   12.96    unmap_domain_mem(xpd);
   12.97 @@ -216,16 +218,14 @@ int xen_physdisk_probe(struct task_struc
   12.98    physdisk_probebuf_t *buf = map_domain_mem(virt_to_phys(buf_in));
   12.99    int res;
  12.100  
  12.101 -  p = current;
  12.102 -  do {
  12.103 -    p = p->next_task;
  12.104 -  } while (p != current && p->domain != buf->domain);  
  12.105 -  if (p->domain != buf->domain) {
  12.106 +  if (requesting_domain->domain != 0 &&
  12.107 +      requesting_domain->domain != buf->domain) {
  12.108      res = 1;
  12.109      goto out;
  12.110    }
  12.111 -  if (requesting_domain->domain != 0 &&
  12.112 -      requesting_domain->domain != buf->domain) {
  12.113 +
  12.114 +  p = find_domain_by_id(buf->domain);
  12.115 +  if (p == NULL) {
  12.116      res = 1;
  12.117      goto out;
  12.118    }
  12.119 @@ -233,6 +233,8 @@ int xen_physdisk_probe(struct task_struc
  12.120    spin_lock(&p->physdev_lock);
  12.121    xen_physdisk_probe_access(buf, p);
  12.122    spin_unlock(&p->physdev_lock);
  12.123 +  put_task_struct(p);
  12.124 +
  12.125    res = 0;
  12.126   out:
  12.127    unmap_domain_mem(buf);
    13.1 --- a/xen/drivers/block/xen_segment.c	Tue Jul 08 10:38:14 2003 +0000
    13.2 +++ b/xen/drivers/block/xen_segment.c	Tue Jul 08 11:23:42 2003 +0000
    13.3 @@ -250,15 +250,11 @@ int xen_segment_create(xv_disk_t *xvd_in
    13.4      }
    13.5  
    13.6      /* if the domain exists, assign the segment to the domain */
    13.7 -    p = current;
    13.8 -    do
    13.9 -    {
   13.10 -        p = p->next_task;
   13.11 -    } while (p != current && p->domain != xvd->domain);
   13.12 -
   13.13 -    if (p->domain == xvd->domain)
   13.14 +    p = find_domain_by_id(xvd->domain);
   13.15 +    if (p != NULL)
   13.16      {
   13.17          p->segment_list[xvd->segment] = &xsegments[idx];
   13.18 +        put_task_struct(p);
   13.19      }
   13.20  
   13.21      unmap_domain_mem(xvd);
    14.1 --- a/xen/include/hypervisor-ifs/block.h	Tue Jul 08 10:38:14 2003 +0000
    14.2 +++ b/xen/include/hypervisor-ifs/block.h	Tue Jul 08 11:23:42 2003 +0000
    14.3 @@ -149,18 +149,20 @@ typedef struct xp_disk
    14.4    int mode; /* 0 -> revoke existing access, otherwise bitmask of
    14.5  	       PHYSDISK_MODE_? constants */
    14.6    int domain;
    14.7 -  unsigned short device;
    14.8 +  unsigned short device; /* XENDEV_??? + idx */
    14.9 +  unsigned short partition; /* partition number */
   14.10    unsigned long start_sect;
   14.11    unsigned long n_sectors;
   14.12  } xp_disk_t;
   14.13  
   14.14 -#define PHYSDISK_MAX_ACES_PER_REQUEST 254
   14.15 +#define PHYSDISK_MAX_ACES_PER_REQUEST 254 /* Make it fit in one page */
   14.16  typedef struct {
   14.17    int n_aces;
   14.18    int domain;
   14.19    int start_ind;
   14.20    struct {
   14.21 -    unsigned short device;
   14.22 +    unsigned short device; /* XENDEV_??? + idx */
   14.23 +    unsigned short partition; /* partition number */
   14.24      unsigned long start_sect;
   14.25      unsigned long n_sectors;
   14.26      unsigned mode;
    15.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c	Tue Jul 08 10:38:14 2003 +0000
    15.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c	Tue Jul 08 11:23:42 2003 +0000
    15.3 @@ -8,7 +8,35 @@
    15.4  #include <asm/uaccess.h>
    15.5  #include <linux/proc_fs.h>
    15.6  
    15.7 +#include "xl_block.h"
    15.8 +
    15.9  extern int xenolinux_control_msg(int operration, char *buffer, int size);
   15.10 +extern unsigned short xldev_to_physdev(kdev_t xldev);
   15.11 +
   15.12 +static dev_t physdev_to_xldev(unsigned short physdev)
   15.13 +{
   15.14 +  switch (physdev & XENDEV_TYPE_MASK) {
   15.15 +  case XENDEV_IDE:
   15.16 +    switch (physdev & XENDEV_IDX_MASK) {
   15.17 +    case 0 ... (XLIDE_DEVS_PER_MAJOR-1):
   15.18 +      return MKDEV(XLIDE_MAJOR_0,
   15.19 +		   (physdev & XENDEV_IDX_MASK) << XLIDE_PARTN_SHIFT);
   15.20 +    case XLIDE_DEVS_PER_MAJOR ... (XLIDE_DEVS_PER_MAJOR * 2 - 1):
   15.21 +      return MKDEV(XLIDE_MAJOR_1,
   15.22 +		   (physdev & XENDEV_IDX_MASK) << XLIDE_PARTN_SHIFT);
   15.23 +    }
   15.24 +    break;
   15.25 +  case XENDEV_SCSI:
   15.26 +    return MKDEV(XLSCSI_MAJOR,
   15.27 +		 (physdev & XENDEV_IDX_MASK) << XLSCSI_PARTN_SHIFT);
   15.28 +  case XENDEV_VIRTUAL:
   15.29 +    return MKDEV(XLVIRT_MAJOR,
   15.30 +		 (physdev & XENDEV_IDX_MASK) << XLVIRT_PARTN_SHIFT);
   15.31 +  }
   15.32 +  printk(KERN_ALERT "Unrecognised xl device: %x\n", physdev);
   15.33 +  BUG();
   15.34 +  return -1;
   15.35 +}
   15.36  
   15.37  static ssize_t proc_read_phd(struct file * file, char * buff, size_t size,
   15.38  			     loff_t * off)
   15.39 @@ -16,6 +44,7 @@ static ssize_t proc_read_phd(struct file
   15.40    physdisk_probebuf_t *buf;
   15.41    int res;
   15.42    struct proc_dir_entry *pde;
   15.43 +  int x;
   15.44  
   15.45    if (size != sizeof(physdisk_probebuf_t))
   15.46      return -EINVAL;
   15.47 @@ -24,11 +53,6 @@ static ssize_t proc_read_phd(struct file
   15.48    if (!buf)
   15.49      return -ENOMEM;
   15.50  
   15.51 -  if (copy_from_user(buf, buff, size)) {
   15.52 -    kfree(buf);
   15.53 -    return -EFAULT;
   15.54 -  }
   15.55 -
   15.56    pde = file->f_dentry->d_inode->u.generic_ip;
   15.57    buf->domain = (int)pde->data;
   15.58  
   15.59 @@ -43,6 +67,8 @@ static ssize_t proc_read_phd(struct file
   15.60    if (res)
   15.61      res = -EINVAL;
   15.62    else {
   15.63 +    for (x = 0; x < buf->n_aces; x++)
   15.64 +      buf->entries[x].device = physdev_to_xldev(buf->entries[x].device);
   15.65      res = sizeof(physdisk_probebuf_t);
   15.66      if (copy_to_user(buff, buf, sizeof(physdisk_probebuf_t))) {
   15.67        res = -EFAULT;
   15.68 @@ -75,6 +101,7 @@ static int proc_write_phd(struct file *f
   15.69  
   15.70    pde = file->f_dentry->d_inode->u.generic_ip;
   15.71    xpd->domain = (int)pde->data;
   15.72 +  xpd->device = xldev_to_physdev(xpd->device);
   15.73  
   15.74    res = xenolinux_control_msg(XEN_BLOCK_PHYSDEV_GRANT, local, count);
   15.75    if (res == 0)
    16.1 --- a/xenolinux-2.4.21-sparse/fs/partitions/xeno.c	Tue Jul 08 10:38:14 2003 +0000
    16.2 +++ b/xenolinux-2.4.21-sparse/fs/partitions/xeno.c	Tue Jul 08 11:23:42 2003 +0000
    16.3 @@ -47,18 +47,18 @@ int xeno_partition(struct gendisk *hd,
    16.4    count = 0;
    16.5  
    16.6    for (i = 0; i < buf->n_aces; i++) {
    16.7 -    if ((buf->entries[i].device & 0x1f) == 0)
    16.8 +    if (buf->entries[i].partition == 0)
    16.9        continue;
   16.10      /* Make sure the partition is actually supposed to be on this
   16.11         disk.  This assumes that Xen and XenoLinux block device
   16.12         numbers match up. */
   16.13 -    if ((buf->entries[i].device & ~0x1f) != bdev->bd_dev)
   16.14 +    if (buf->entries[i].device != bdev->bd_dev)
   16.15        continue;
   16.16      /* This is a bit of a hack - the partition numbers are specified
   16.17         by the hypervisor, and if we want them to match up, this is
   16.18         what we need to do. */
   16.19      count ++;
   16.20 -    minor = (buf->entries[i].device & 0x1f) + first_part_minor - 1;
   16.21 +    minor = buf->entries[i].partition + first_part_minor - 1;
   16.22      add_gd_partition(hd,
   16.23  		     minor,
   16.24  		     buf->entries[i].start_sect,