NULL dereference in schizo error handler
I understand there is a bug in earlier revisions of Schizo PCI bridge (that I have in my V480) and we do not have a workaround for that. Now when I happen to hit it, I get a crash in the handler and that seems a bug whether or not we have the workaround.
In particular, it seems that pbm->pci_bus->self is NULL and that causes a NULL pointer dereference in schizo_pcierr_intr_other:
pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
Since the error happens during PCI scanning, maybe we just do not have this field initialized yet - in pci_scan_one_pbm() or in something it calls?
This dmesg excerpt from annotated source, mostly for background.
[ 61.300577] PCI: Scanning PBM /pci@9,600000
[ 61.304867] schizo f009b070: PCI host bridge to bus 0003:00
[ 61.310385] pci_bus 0003:00: root bus resource [io 0x7ffe9000000-0x7ffe9ffffff] (bus address [0x0000-0xffffff])
[ 61.320515] pci_bus 0003:00: root bus resource [mem 0x7fb00000000-0x7fbffffffff] (bus address [0x00000000-0xffffffff])
[ 61.331173] pci_bus 0003:00: root bus resource [bus 00]
[ 61.337539] schizo_pcierr_intr, pbmÿf000b0fdb34000
[ 61.342444] schizo_pcierr_intr, afarA94496
[ 61.346690] schizo_pcierr_intr, afsr421772800
[ 61.351280] schizo_pcierr_intr, calling schizo_pcierr_intr_other
[ 61.357259] schizo_pcierr_intr_other: start
[ 61.361421] schizo_pcierr_intr_other, csr88858467696703
[ 61.366879] schizo_pcierr_intr_other, pbmÿf000b0fdb34000
[ 61.372339] schizo_pcierr_intr_other, pbm->pci_busÿf000b0fdb34800
[ 61.378580] schizo_pcierr_intr_other, pbm->pci_bus->self= (null)
[ 61.385344] Unable to handle kernel NULL pointer dereference
[ 61.390970] tsk->{mm,active_mm}->context = 0000000000000000
[ 61.396515] tsk->{mm,active_mm}->pgd = fff000b000002000
[ 61.401716] \|/ ____ \|/
[ 61.401716] "@'/ .. \`@"
[ 61.401716] /_| \__/ |_\
[ 61.401716] \__U_/
[ 61.416362] swapper/0(0): Oops [#1]
[ 61.419837] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-rc1-00422-g2cc9188-dirty #24
[ 61.427975] task: fff000b0fd8e9c40 ti: fff000b0fd928000 task.ti: fff000b0fd928000
[ 61.435426] TSTATE: 0000004480e01602 TPC: 00000000004455e4 TNPC: 00000000004455e8 Y: 00000000 Not tainted
[ 61.445230] TPC: <schizo_pcierr_intr+0x104/0x560>
[ 61.449897] g0: 0000000000000000 g1: 0000000000000000 g2: 0000000000a10f78 g3: 000000000000000a
[ 61.458563] g4: fff000b0fd8e9c40 g5: fff000b0fdd82000 g6: fff000b0fd928000 g7: 000000000000000a
[ 61.467229] o0: 000000000000003d o1: 0000000000000000 o2: 0000000000000006 o3: fff000b0ffa5fc7e
[ 61.475894] o4: 0000000000060000 o5: c000000000000000 sp: fff000b0ffa5f3c1 ret_pc: 00000000004455cc
[ 61.484909] RPC: <schizo_pcierr_intr+0xec/0x560>
[ 61.489500] l0: fff000b0fd8e9c40 l1: 0000000000a20800 l2: 0000000000000000 l3: 000000000119a430
[ 61.498164] l4: 0000000001742400 l5: 00000000011cfbe0 l6: 00000000011319c0 l7: fff000b0fd8ea348
[ 61.506830] i0: 0000000000000000 i1: fff000b0fdb34000 i2: 0000000320000000 i3: 0000000000000000
[ 61.515497] i4: 00060002010b003f i5: 0000040004e02000 i6: fff000b0ffa5f481 i7: 00000000004a9920
[ 61.524175] I7: <handle_irq_event_percpu+0x40/0x140>
[ 61.529099] Call Trace:
[ 61.531531] [00000000004a9920] handle_irq_event_percpu+0x40/0x140
[ 61.537681] [00000000004a9a58] handle_irq_event+0x38/0x80
[ 61.543145] [00000000004ac77c] handle_fasteoi_irq+0xbc/0x200
[ 61.548860] [00000000004a9084] generic_handle_irq+0x24/0x40
[ 61.554500] [000000000042be0c] handler_irq+0xac/0x100Signature · 1 line
Meelis Roos ([email protected])
David Miller
maintainerFrom: Meelis Roos <[email protected]>
Date: Sun, 26 Oct 2014 00:35:28 +0300 (EEST)
Quoted 5 lines
I understand there is a bug in earlier revisions of Schizo PCI bridge (that I have in my V480) and we do not have a workaround for that. Now when I happen to hit it, I get a crash in the handler and that seems a bug whether or not we have the workaround.
Quoted 8 lines
In particular, it seems that
pbm->pci_bus->selfis NULL and that causes a NULL pointer dereference inschizo_pcierr_intr_other:
pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);Since the error happens during PCI scanning, maybe we just do not have this field initialized yet - in
pci_scan_one_pbm()or in something it calls?
I am looking into this now. Any chance I can get a prtconf dump?
This schizo error handler definitely needs to be adjusted. The bus->self value is not necessarily going to be there. In fact often it won't be.
The PCI controller's themselves don't show up in the device tree as bonafide PCI devices, so we don't instantiate them with the PCI subsystem, and therefore bus->self never takes on a non-NULL value.
If you look at arch/sparc/kernel/psycho_common.c:psycho_pcierr_intr_other() it addresses this by doing the PCI config space access by hand, thus avoiding the bus->self dereference.
Meanwhile, this patch might allow things to get further:
arch/sparc/kernel/pci_schizo.c +3 -3
@@ -581,7 +581,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm) {unsigned long csr_reg, csr, csr_error_bits;irqreturn_t ret =IRQ_NONE ; -u16 stat; +u32 stat; csr_reg = pbm->pbm_regs +SCHIZO_PCI_CTRL ; csr =upa_readq (csr_reg);
@@ -617,7 +617,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm) pbm->name); ret =IRQ_HANDLED ; } -pci_read_config_word (pbm->pci_bus->self,PCI_STATUS , &stat); + pbm->pci_ops->read (pbm->pci_bus,0 ,PCI_STATUS ,2 , &stat); if (stat & (PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT | PCI_STATUS_REC_TARGET_ABORT |
@@ -625,7 +625,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm) PCI_STATUS_SIG_SYSTEM_ERROR)) {printk ("%s: PCI bus error, PCI_STATUS[%04x]\n" , pbm->name, stat); -pci_write_config_word (pbm->pci_bus->self,PCI_STATUS ,0xffff ); + pbm->pci_ops->write (pbm->pci_bus,0 ,PCI_STATUS ,2 ,0xffff ); ret =IRQ_HANDLED ; }return ret;
Quoted 8 lines
Quoted 8 lines
I understand there is a bug in earlier revisions of Schizo PCI bridge (that I have in my V480) and we do not have a workaround for that. Now when I happen to hit it, I get a crash in the handler and that seems a bug whether or not we have the workaround.
In particular, it seems that
pbm->pci_bus->selfis NULL and that causes a NULL pointer dereference inschizo_pcierr_intr_other:
Quoted 7 lines
Quoted 5 lines
pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);Since the error happens during PCI scanning, maybe we just do not have this field initialized yet - in
pci_scan_one_pbm()or in something it calls?I am looking into this now. Any chance I can get a prtconf dump?
Sent privately.
Quoted 8 lines
This schizo error handler definitely needs to be adjusted. The
bus->selfvalue is not necessarily going to be there. In fact often it won't be.The PCI controller's themselves don't show up in the device tree as bonafide PCI devices, so we don't instantiate them with the PCI subsystem, and therefore
bus->selfnever takes on a non-NULL value.
Quoted 5 lines
If you look at arch/sparc/kernel/psycho_common.c:psycho_pcierr_intr_other() it addresses this by doing the PCI config space access by hand, thus avoiding the
bus->selfdereference.Meanwhile, this patch might allow things to get further:
It seems to work - no crash but this in dmesg, and it continues booting fine:
[ 69.137735] /pci@9,600000: PCI Error, primary error type[Master Abort] [ 69.144196] /pci@9,600000: bytemask[0003] was_block(0) space(Memory) [ 69.150520] /pci@9,600000: PCI AFAR [00000000004000c0] [ 69.155632] /pci@9,600000: PCI Secondary errors [(none)] [ 69.160984] /pci@9,600000: PCI bus error, PCI_STATUS[22a0]
So at least this instance of the crash is gone. I seem to remember getting some crashes later too occassionally, so that I had some first lines of the error printed and then crash, but I do not seem to have preserved the console logs from them. I will keep an eye open.
Thank you!
Signature · 1 line
Meelis Roos ([email protected])
David Miller
maintainerFrom: Meelis Roos <[email protected]>
Date: Fri, 31 Oct 2014 23:03:28 +0200 (EET)
Quoted 13 lines
Quoted 13 lines
This schizo error handler definitely needs to be adjusted. The
bus->selfvalue is not necessarily going to be there. In fact often it won't be.The PCI controller's themselves don't show up in the device tree as bonafide PCI devices, so we don't instantiate them with the PCI subsystem, and therefore
bus->selfnever takes on a non-NULL value.If you look at arch/sparc/kernel/psycho_common.c:psycho_pcierr_intr_other() it addresses this by doing the PCI config space access by hand, thus avoiding the
bus->selfdereference.
Quoted 4 lines
Quoted 1 line
Meanwhile, this patch might allow things to get further:
It seems to work - no crash but this in dmesg, and it continues booting fine:
Thanks for testing, I'll push this upstream and to -stable.
Quoted 6 lines
[ 69.137735] /pci@9,600000: PCI Error, primary error type[Master Abort] [ 69.144196] /pci@9,600000: bytemask[0003] was_block(0) space(Memory) [ 69.150520] /pci@9,600000: PCI AFAR [00000000004000c0] [ 69.155632] /pci@9,600000: PCI Secondary errors [(none)] [ 69.160984] /pci@9,600000: PCI bus error, PCI_STATUS[22a0]
Ok, the PCI status register has these bits set:
PCI_STATUS_REC_MASTER_ABORT
PCI_STATUS_DEVSEL_MEDIUM
PCI_STATUS_FAST_BACK
PCI_STATUS_66MHZ
The only error condition is that it received a master abort.
I wonder if this happend during firmware init or something before Linux even booted.
I'll see if there is some way we can track down if there is something specific that Linux is doing at this moment that might have triggered this.