From: ddugger@redhat.com <ddugger@redhat.com> Date: Mon, 23 Mar 2009 10:23:37 -0600 Subject: [xen] add hypercall for adding and removing PCI devices Message-id: 200903231623.n2NGNbB0022161@sobek.n0ano.com O-Subject: [RHEL5.4 PATCH 21/21 V2] xen: add hypercall for adding and removing PCI devices Bugzilla: 484227 RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com> The add hypercall will add a new PCI device and register it. The remove hypercall will remove the pci_dev strucure for the device. diff --git a/arch/x86/physdev.c b/arch/x86/physdev.c index 88cc9dd..7872e82 100644 --- a/arch/x86/physdev.c +++ b/arch/x86/physdev.c @@ -342,6 +342,32 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) break; } + case PHYSDEVOP_manage_pci_add: { + struct physdev_manage_pci manage_pci; + ret = -EPERM; + if ( !IS_PRIV(current->domain) ) + break; + ret = -EFAULT; + if ( copy_from_guest(&manage_pci, arg, 1) != 0 ) + break; + + ret = pci_add_device(manage_pci.bus, manage_pci.devfn); + break; + } + + case PHYSDEVOP_manage_pci_remove: { + struct physdev_manage_pci manage_pci; + ret = -EPERM; + if ( !IS_PRIV(current->domain) ) + break; + ret = -EFAULT; + if ( copy_from_guest(&manage_pci, arg, 1) != 0 ) + break; + + ret = pci_remove_device(manage_pci.bus, manage_pci.devfn); + break; + } + default: ret = -ENOSYS; break; diff --git a/include/public/physdev.h b/include/public/physdev.h index a710907..c27644e 100644 --- a/include/public/physdev.h +++ b/include/public/physdev.h @@ -153,6 +153,17 @@ struct physdev_unmap_pirq { typedef struct physdev_unmap_pirq physdev_unmap_pirq_t; DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t); +#define PHYSDEVOP_manage_pci_add 15 +#define PHYSDEVOP_manage_pci_remove 16 +struct physdev_manage_pci { + /* IN */ + uint8_t bus; + uint8_t devfn; +}; + +typedef struct physdev_manage_pci physdev_manage_pci_t; +DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); + /* * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() * hypercall since 0x00030202.