aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/pci_sun4v.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-02-13 02:49:18 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-03-20 04:12:36 -0500
commit059833eb817fec3a5a7f62fba9592749c4cebc73 (patch)
tree5de088b9200956458ca83afe33335d6ea87c63d6 /arch/sparc64/kernel/pci_sun4v.c
parent0b522497a176f222ae4cf7e6733a5357352224b2 (diff)
[SPARC64]: Range check bus number in SUN4V PCI controller driver.
It has to be somewhere in the range from pbm->pci_first_busno to pbm->pci_last_busno, inclusive. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_sun4v.c')
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 7055616e083..dc79b748fea 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -514,19 +514,31 @@ struct pci_iommu_ops pci_sun4v_iommu_ops = {
514 514
515/* SUN4V PCI configuration space accessors. */ 515/* SUN4V PCI configuration space accessors. */
516 516
517static inline int pci_sun4v_out_of_range(struct pci_pbm_info *pbm, unsigned int bus)
518{
519 if (bus < pbm->pci_first_busno ||
520 bus > pbm->pci_last_busno)
521 return 1;
522 return 0;
523}
524
517static int pci_sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, 525static int pci_sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
518 int where, int size, u32 *value) 526 int where, int size, u32 *value)
519{ 527{
520 struct pci_pbm_info *pbm = bus_dev->sysdata; 528 struct pci_pbm_info *pbm = bus_dev->sysdata;
521 unsigned long devhandle = pbm->devhandle; 529 u32 devhandle = pbm->devhandle;
522 unsigned int bus = bus_dev->number; 530 unsigned int bus = bus_dev->number;
523 unsigned int device = PCI_SLOT(devfn); 531 unsigned int device = PCI_SLOT(devfn);
524 unsigned int func = PCI_FUNC(devfn); 532 unsigned int func = PCI_FUNC(devfn);
525 unsigned long ret; 533 unsigned long ret;
526 534
527 ret = pci_sun4v_config_get(devhandle, 535 if (pci_sun4v_out_of_range(pbm, bus)) {
528 HV_PCI_DEVICE_BUILD(bus, device, func), 536 ret = ~0UL;
529 where, size); 537 } else {
538 ret = pci_sun4v_config_get(devhandle,
539 HV_PCI_DEVICE_BUILD(bus, device, func),
540 where, size);
541 }
530 switch (size) { 542 switch (size) {
531 case 1: 543 case 1:
532 *value = ret & 0xff; 544 *value = ret & 0xff;
@@ -547,16 +559,19 @@ static int pci_sun4v_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
547 int where, int size, u32 value) 559 int where, int size, u32 value)
548{ 560{
549 struct pci_pbm_info *pbm = bus_dev->sysdata; 561 struct pci_pbm_info *pbm = bus_dev->sysdata;
550 unsigned long devhandle = pbm->devhandle; 562 u32 devhandle = pbm->devhandle;
551 unsigned int bus = bus_dev->number; 563 unsigned int bus = bus_dev->number;
552 unsigned int device = PCI_SLOT(devfn); 564 unsigned int device = PCI_SLOT(devfn);
553 unsigned int func = PCI_FUNC(devfn); 565 unsigned int func = PCI_FUNC(devfn);
554 unsigned long ret; 566 unsigned long ret;
555 567
556 ret = pci_sun4v_config_put(devhandle, 568 if (pci_sun4v_out_of_range(pbm, bus)) {
557 HV_PCI_DEVICE_BUILD(bus, device, func), 569 /* Do nothing. */
558 where, size, value); 570 } else {
559 571 ret = pci_sun4v_config_put(devhandle,
572 HV_PCI_DEVICE_BUILD(bus, device, func),
573 where, size, value);
574 }
560 return PCIBIOS_SUCCESSFUL; 575 return PCIBIOS_SUCCESSFUL;
561} 576}
562 577