debuggers.hg
changeset 10881:4f6d858ea570
[PCI] Per-device permissive flag (replaces global permissive flag).
Signed-off-by: Chris Bookholt <hap10@tycho.ncsc.mil>
Signed-off-by: Chris Bookholt <hap10@tycho.ncsc.mil>
author | kfraser@localhost.localdomain |
---|---|
date | Fri Jul 28 12:56:10 2006 +0100 (2006-07-28) |
parents | 4c97599398fe |
children | 8cd577110904 |
files | linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Fri Jul 28 12:54:58 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Fri Jul 28 12:56:10 2006 +0100 1.3 @@ -15,9 +15,6 @@ 1.4 #include "conf_space.h" 1.5 #include "conf_space_quirks.h" 1.6 1.7 -static int permissive = 0; 1.8 -module_param(permissive, bool, 0644); 1.9 - 1.10 #define DEFINE_PCI_CONFIG(op,size,type) \ 1.11 int pciback_##op##_config_##size \ 1.12 (struct pci_dev *dev, int offset, type value, void *data) \ 1.13 @@ -258,7 +255,7 @@ int pciback_config_write(struct pci_dev 1.14 * This means that some fields may still be read-only because 1.15 * they have entries in the config_field list that intercept 1.16 * the write and do nothing. */ 1.17 - if (permissive) { 1.18 + if (dev_data->permissive) { 1.19 switch (size) { 1.20 case 1: 1.21 err = pci_write_config_byte(dev, offset,
2.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Fri Jul 28 12:54:58 2006 +0100 2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Fri Jul 28 12:56:10 2006 +0100 2.3 @@ -739,6 +739,72 @@ static ssize_t pcistub_quirk_show(struct 2.4 2.5 DRIVER_ATTR(quirks, S_IRUSR | S_IWUSR, pcistub_quirk_show, pcistub_quirk_add); 2.6 2.7 +static ssize_t permissive_add(struct device_driver *drv, const char *buf, 2.8 + size_t count) 2.9 +{ 2.10 + int domain, bus, slot, func; 2.11 + int err; 2.12 + struct pcistub_device *psdev; 2.13 + struct pciback_dev_data *dev_data; 2.14 + err = str_to_slot(buf, &domain, &bus, &slot, &func); 2.15 + if (err) 2.16 + goto out; 2.17 + psdev = pcistub_device_find(domain, bus, slot, func); 2.18 + if (!psdev) { 2.19 + err = -ENODEV; 2.20 + goto out; 2.21 + } 2.22 + if (!psdev->dev) { 2.23 + err = -ENODEV; 2.24 + goto release; 2.25 + } 2.26 + dev_data = pci_get_drvdata(psdev->dev); 2.27 + /* the driver data for a device should never be null at this point */ 2.28 + if (!dev_data) { 2.29 + err = -ENXIO; 2.30 + goto release; 2.31 + } 2.32 + if (!dev_data->permissive) { 2.33 + dev_data->permissive = 1; 2.34 + /* Let user know that what they're doing could be unsafe */ 2.35 + dev_warn(&psdev->dev->dev, 2.36 + "enabling permissive mode configuration space accesses!\n"); 2.37 + dev_warn(&psdev->dev->dev, 2.38 + "permissive mode is potentially unsafe!\n"); 2.39 + } 2.40 + release: 2.41 + pcistub_device_put(psdev); 2.42 + out: 2.43 + if (!err) 2.44 + err = count; 2.45 + return err; 2.46 +} 2.47 + 2.48 +static ssize_t permissive_show(struct device_driver *drv, char *buf) 2.49 +{ 2.50 + struct pcistub_device *psdev; 2.51 + struct pciback_dev_data *dev_data; 2.52 + size_t count = 0; 2.53 + unsigned long flags; 2.54 + spin_lock_irqsave(&pcistub_devices_lock, flags); 2.55 + list_for_each_entry(psdev, &pcistub_devices, dev_list) { 2.56 + if (count >= PAGE_SIZE) 2.57 + break; 2.58 + if (!psdev->dev) 2.59 + continue; 2.60 + dev_data = pci_get_drvdata(psdev->dev); 2.61 + if (!dev_data || !dev_data->permissive) 2.62 + continue; 2.63 + count += 2.64 + scnprintf(buf + count, PAGE_SIZE - count, "%s\n", 2.65 + pci_name(psdev->dev)); 2.66 + } 2.67 + spin_unlock_irqrestore(&pcistub_devices_lock, flags); 2.68 + return count; 2.69 +} 2.70 + 2.71 +DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show, permissive_add); 2.72 + 2.73 static int __init pcistub_init(void) 2.74 { 2.75 int pos = 0; 2.76 @@ -784,6 +850,7 @@ static int __init pcistub_init(void) 2.77 &driver_attr_remove_slot); 2.78 driver_create_file(&pciback_pci_driver.driver, &driver_attr_slots); 2.79 driver_create_file(&pciback_pci_driver.driver, &driver_attr_quirks); 2.80 + driver_create_file(&pciback_pci_driver.driver, &driver_attr_permissive); 2.81 2.82 out: 2.83 return err; 2.84 @@ -834,6 +901,7 @@ static void __exit pciback_cleanup(void) 2.85 &driver_attr_remove_slot); 2.86 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots); 2.87 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks); 2.88 + driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive); 2.89 2.90 pci_unregister_driver(&pciback_pci_driver); 2.91 }
3.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h Fri Jul 28 12:54:58 2006 +0100 3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h Fri Jul 28 12:56:10 2006 +0100 3.3 @@ -44,6 +44,7 @@ struct pciback_device { 3.4 3.5 struct pciback_dev_data { 3.6 struct list_head config_fields; 3.7 + int permissive; 3.8 int warned_on_write; 3.9 }; 3.10