#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LSI_HACK "0.1" MODULE_AUTHOR("Konrad Rzeszutek Wilk "); MODULE_DESCRIPTION("lsi hack"); MODULE_LICENSE("GPL"); MODULE_VERSION(LSI_HACK); /* Want to link to the device passed in the guest */ int bus = 8; module_param(bus, int, 0644); MODULE_PARM_DESC(bus, "bus"); int slot = 3; module_param(slot, int, 0644); MODULE_PARM_DESC(slot, "slot"); int func = 0; module_param(func, int, 0644); MODULE_PARM_DESC(func, "slot"); #define XEN_PCI_DEV_LINK 0x8 static int __init lsi_hack_init(void) { int r = 0; struct physdev_pci_device_add add = { .seg = 0, .bus = 0x8, /* The phantom bridge */ .devfn = PCI_DEVFN(0,0), /* And its slot and function */ .physfn.bus = bus, /* The device we want to link too. */ .physfn.devfn = PCI_DEVFN(slot,func), .flags = XEN_PCI_DEV_LINK, }; printk("%s: %02x:%02x.%u, %02x:%02x.%u, %x\n", __func__, add.bus, PCI_SLOT(add.devfn), PCI_FUNC(add.devfn), add.physfn.bus, PCI_SLOT(add.physfn.devfn), PCI_FUNC(add.physfn.devfn), add.flags); r = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add); return r; } static void __exit lsi_hack_exit(void) { int r = 0; struct physdev_manage_pci manage_pci; manage_pci.bus = 0x7; manage_pci.devfn = PCI_DEVFN(0,0); r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove, &manage_pci); if (r) printk(KERN_ERR "%s: %d\n", __FUNCTION__, r); } module_init(lsi_hack_init); module_exit(lsi_hack_exit);