ChangeSet 1.1324, 2005/03/19 20:37:32+00:00, kaf24@xxxxxxxxxxxxxxxxxxxx
Merge firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-2.0-testing.bk
into firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig | 14 -
xen/common/physdev.c | 221 ++++++++++------
2 files changed, 162 insertions(+), 73 deletions(-)
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig
b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig
--- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig 2005-03-19
16:04:07 -05:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig 2005-03-19
16:04:07 -05:00
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.11-xen0
-# Fri Mar 11 01:02:42 2005
+# Sat Mar 19 19:42:39 2005
#
CONFIG_XEN=y
CONFIG_ARCH_XEN=y
@@ -13,10 +13,12 @@
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PHYSDEV_ACCESS=y
CONFIG_XEN_BLKDEV_BACKEND=y
+# CONFIG_XEN_BLKDEV_TAP_BE is not set
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
+# CONFIG_XEN_BLKDEV_TAP is not set
CONFIG_XEN_WRITABLE_PAGETABLES=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_X86=y
@@ -886,6 +888,16 @@
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+# CONFIG_INFINIBAND is not set
#
# MMC/SD Card support
diff -Nru a/xen/common/physdev.c b/xen/common/physdev.c
--- a/xen/common/physdev.c 2005-03-19 16:04:07 -05:00
+++ b/xen/common/physdev.c 2005-03-19 16:04:07 -05:00
@@ -1,5 +1,4 @@
-/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
- ****************************************************************************
+/****************************************************************************
* (c) 2004 - Rolf Neugebauer - Intel Research Cambridge
* (c) 2004 - Keir Fraser - University of Cambridge
****************************************************************************
@@ -86,31 +85,93 @@
}
/* Add a device to a per-domain device-access list. */
-static void add_dev_to_task(struct domain *p,
- struct pci_dev *dev, int acc)
+static int add_dev_to_task(struct domain *p, struct pci_dev *dev,
+ int acc)
{
- phys_dev_t *pdev;
+ phys_dev_t *physdev;
- if ( (pdev = find_pdev(p, dev)) )
- {
- /* Sevice already on list: update access permissions. */
- pdev->flags = acc;
- return;
- }
-
- if ( (pdev = xmalloc(sizeof(phys_dev_t))) == NULL )
+ if ( (physdev = xmalloc(phys_dev_t)) == NULL )
{
INFO("Error allocating pdev structure.\n");
- return;
+ return -ENOMEM;
}
- pdev->dev = dev;
- pdev->flags = acc;
- pdev->state = 0;
- list_add(&pdev->node, &p->pcidev_list);
+ physdev->dev = dev;
+ physdev->flags = acc;
+ physdev->state = 0;
+ list_add(&physdev->node, &p->pcidev_list);
if ( acc == ACC_WRITE )
- pdev->owner = p;
+ physdev->owner = p;
+
+ return 0;
+}
+
+/* Remove a device from a per-domain device-access list. */
+static void remove_dev_from_task(struct domain *p, struct pci_dev *dev)
+{
+ phys_dev_t *physdev = find_pdev(p, dev);
+
+ if ( physdev == NULL )
+ BUG();
+
+ list_del(&physdev->node);
+
+ xfree(physdev);
+}
+
+static int setup_ioport_memory_access(domid_t dom, struct domain* p,
+ struct exec_domain* ed,
+ struct pci_dev *pdev)
+{
+ struct exec_domain* edc;
+ int i, j;
+
+ /* Now, setup access to the IO ports and memory regions for the device. */
+ if ( ed->arch.io_bitmap == NULL )
+ {
+ if ( (ed->arch.io_bitmap = xmalloc_array(u8, IOBMP_BYTES)) == NULL )
+ return -ENOMEM;
+
+ memset(ed->arch.io_bitmap, 0xFF, IOBMP_BYTES);
+
+ ed->arch.io_bitmap_sel = ~0ULL;
+
+ for_each_exec_domain(p, edc) {
+ if (edc == ed)
+ continue;
+ edc->arch.io_bitmap = ed->arch.io_bitmap;
+ }
+ }
+
+ for ( i = 0; i < DEVICE_COUNT_RESOURCE; i++ )
+ {
+ struct resource *r = &pdev->resource[i];
+
+ if ( r->flags & IORESOURCE_IO )
+ {
+ /* Give the domain access to the IO ports it needs. Currently,
+ * this will allow all processes in that domain access to those
+ * ports as well. This will do for now, since driver domains don't
+ * run untrusted processes! */
+ INFO("Giving domain %u IO resources (%lx - %lx) "
+ "for device %s\n", dom, r->start, r->end, pdev->slot_name);
+ for ( j = r->start; j < r->end + 1; j++ )
+ {
+ clear_bit(j, ed->arch.io_bitmap);
+ clear_bit(j / IOBMP_BITS_PER_SELBIT, &ed->arch.io_bitmap_sel);
+ }
+ }
+ /* rights to IO memory regions are checked when the domain maps them */
+ }
+
+ for_each_exec_domain(p, edc) {
+ if (edc == ed)
+ continue;
+ edc->arch.io_bitmap_sel = ed->arch.io_bitmap_sel;
+ }
+
+ return 0;
}
/*
@@ -121,14 +182,17 @@
* bridge, then the domain should get access to all the leaf devices below
* that bridge (XXX this is unimplemented!).
*/
-int physdev_pci_access_modify(
- domid_t dom, int bus, int dev, int func, int enable)
+int physdev_pci_access_modify(domid_t dom, int bus, int dev, int func,
+ int enable)
{
struct domain *p;
+ struct exec_domain *ed;
struct pci_dev *pdev;
- int i, j, rc = 0;
-
- if ( !IS_PRIV(current) )
+ phys_dev_t *physdev;
+ int rc = 0;
+ int oldacc = -1, allocated_physdev = 0;
+
+ if ( !IS_PRIV(current->domain) )
BUG();
if ( (bus > PCI_BUSMAX) || (dev > PCI_DEVMAX) || (func > PCI_FUNCMAX) )
@@ -145,64 +209,60 @@
if ( (p = find_domain_by_id(dom)) == NULL )
return -ESRCH;
+ ed = p->exec_domain[0]; /* XXX */
+
/* Make the domain privileged. */
- set_bit(DF_PHYSDEV, &p->flags);
+ set_bit(DF_PHYSDEV, &p->d_flags);
/* FIXME: MAW for now make the domain REALLY privileged so that it
* can run a backend driver (hw access should work OK otherwise) */
- set_bit(DF_PRIVILEGED, &p->flags);
+ set_bit(DF_PRIVILEGED, &p->d_flags);
/* Grant write access to the specified device. */
if ( (pdev = pci_find_slot(bus, PCI_DEVFN(dev, func))) == NULL )
{
INFO(" dev does not exist\n");
rc = -ENODEV;
- goto out;
+ goto clear_privilege;
+ }
+
+ if ( (physdev = find_pdev(p, pdev)) != NULL) {
+ /* Sevice already on list: update access permissions. */
+ oldacc = physdev->flags;
+ physdev->flags = ACC_WRITE;
+ } else {
+ if ( (rc = add_dev_to_task(p, pdev, ACC_WRITE)) < 0)
+ goto clear_privilege;
+ allocated_physdev = 1;
}
- add_dev_to_task(p, pdev, ACC_WRITE);
INFO(" add RW %02x:%02x:%02x\n", pdev->bus->number,
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
/* Is the device a bridge or cardbus? */
- if ( pdev->hdr_type != PCI_HEADER_TYPE_NORMAL )
+ if ( pdev->hdr_type != PCI_HEADER_TYPE_NORMAL ) {
INFO("XXX can't give access to bridge devices yet\n");
-
- /* Now, setup access to the IO ports and memory regions for the device. */
-
- if ( p->thread.io_bitmap == NULL )
- {
- if ( (p->thread.io_bitmap = xmalloc(IOBMP_BYTES)) == NULL )
- {
- rc = -ENOMEM;
- goto out;
- }
- memset(p->thread.io_bitmap, 0xFF, IOBMP_BYTES);
-
- p->thread.io_bitmap_sel = ~0ULL;
+ rc = -EPERM;
+ goto remove_dev;
}
- for ( i = 0; i < DEVICE_COUNT_RESOURCE; i++ )
- {
- struct resource *r = &pdev->resource[i];
-
- if ( r->flags & IORESOURCE_IO )
- {
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog
|