GIC irq_start detection breaks 3.2 boot on platforms without PPIs
Hi Rob,
In commit 4294f8baa ("ARM: gic: add irq_domain support"), you define irq_start as irq_start = (irq_start & ~31) + 16; (later this was predicated on irq_start > 0).
For platforms without any PPIs (i.e. irq_start is passed as a multiple of
32) then this leads to IRQs being off by 16. Something like this fixes it:
arch/arm/common/gic.c +8 -5
@@ -581,13 +581,16 @@ void __init gic_init(unsigned int gic_nr, int irq_start,* For primary GICs, skip over SGIs. * For secondary GICs, skip over PPIs, too. */ + domain->hwirq_base =32 ;if (gic_nr ==0 ) { gic_cpu_base_addr = cpu_base; - domain->hwirq_base =16 ; -if (irq_start >0 ) - irq_start = (irq_start & ~31 ) +16 ; - }else - domain->hwirq_base =32 ; + +if ((irq_start &31 ) >0 ) { + domain->hwirq_base =16 ; +if (irq_start !=-1 ) + irq_start = (irq_start & ~31 ) +16 ; + } + }/* * Find out how many interrupts are supported.
which I can't say I'm especially pleased with but this code is really hard to get right!
Will
Will,
Quoted 9 lines · Will Deacon
Hi Rob,
In commit
4294f8baa("ARM: gic: addirq_domainsupport"), you defineirq_startasirq_start= (irq_start& ~31) + 16; (later this was predicated onirq_start> 0).For platforms without any PPIs (i.e.
irq_startis passed as a multiple of
32) then this leads to IRQs being off by 16. Something like this fixes it:
Which platform? I thought I surveyed all the users. I was assuming we only skip over PPIs on secondary GICs and primary GICs alway have PPIs allocated. There's not really any cost to always allocating PPIs.
Quoted 25 lines
arch/arm/common/gic.c +0
-0@@ -581,13 +581,16 @@ void __init gic_init(unsigned int gic_nr, int irq_start,? ? ? ? * For primary GICs, skip over SGIs.
? ? ? ? * For secondary GICs, skip over PPIs, too.
? ? ? ? */
+ ? ? ?domain->hwirq_base= 32;
? ? ? ?if (gic_nr== 0) {
? ? ? ? ? ? ? ?gic_cpu_base_addr =cpu_base;
- ? ? ? ? ? ? ?domain->hwirq_base= 16;
- ? ? ? ? ? ? ? if (irq_start> 0)
- ? ? ? ? ? ? ? ? ? ? ?irq_start= (irq_start& ~31) + 16;
- ? ? ? } else
- ? ? ? ? ? ? ?domain->hwirq_base= 32;
+
+ ? ? ? ? ? ? ? if ((irq_start& 31) > 0) {
+ ? ? ? ? ? ? ? ? ? ? ?domain->hwirq_base= 16;
+ ? ? ? ? ? ? ? ? ? ? ? if (irq_start!= -1)
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?irq_start= (irq_start& ~31) + 16;
+ ? ? ? ? ? ? ? }
+ ? ? ? }
Quoted 7 lines
? ? ? ?/*
? ? ? ? * Find out how many interrupts are supported.which I can't say I'm especially pleased with but this code is really hard to get right!
Obviously! The problem is the meaning of irq_start is overloaded. It defines the number of PPIs and the Linux irq # base.
Otherwise, looks fine.
Rob
Quoted 1 line · Rob Herring
Will,
Hello Rob,
Quoted 5 lines · Will Deacon
Quoted 4 lines
In commit
4294f8baa("ARM: gic: addirq_domainsupport"), you defineirq_startasirq_start= (irq_start& ~31) + 16; (later this was predicated onirq_start> 0).
Quoted 7 lines
Quoted 3 lines
For platforms without any PPIs (i.e.
irq_startis passed as a multiple of
32) then this leads to IRQs being off by 16. Something like this fixes it:Which platform? I thought I surveyed all the users. I was assuming we only skip over PPIs on secondary GICs and primary GICs alway have PPIs allocated. There's not really any cost to always allocating PPIs.
This showed problems on Realview PB1176 and PBA8. If irq_start is passed as 32, then we set it to irq_start = (32 & ~31) + 16, so it ends up being 48 and everything goes wrong.
Quoted 29 lines
Quoted 29 lines
arch/arm/common/gic.c +0
-0@@ -581,13 +581,16 @@ void __init gic_init(unsigned int gic_nr, int irq_start,? ? ? ? * For primary GICs, skip over SGIs.
? ? ? ? * For secondary GICs, skip over PPIs, too.
? ? ? ? */
+ ? ? ?domain->hwirq_base= 32;
? ? ? ?if (gic_nr== 0) {
? ? ? ? ? ? ? ?gic_cpu_base_addr =cpu_base;
- ? ? ? ? ? ? ?domain->hwirq_base= 16;
- ? ? ? ? ? ? ? if (irq_start> 0)
- ? ? ? ? ? ? ? ? ? ? ?irq_start= (irq_start& ~31) + 16;
- ? ? ? } else
- ? ? ? ? ? ? ?domain->hwirq_base= 32;
+
+ ? ? ? ? ? ? ? if ((irq_start& 31) > 0) {
+ ? ? ? ? ? ? ? ? ? ? ?domain->hwirq_base= 16;
+ ? ? ? ? ? ? ? ? ? ? ? if (irq_start!= -1)
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?irq_start= (irq_start& ~31) + 16;
+ ? ? ? ? ? ? ? }
+ ? ? ? }? ? ? ?/*
? ? ? ? * Find out how many interrupts are supported.
Quoted 6 lines
Quoted 3 lines
which I can't say I'm especially pleased with but this code is really hard to get right!
Obviously! The problem is the meaning of
irq_startis overloaded. It defines the number of PPIs and the Linux irq # base.
Indeed, and there's the magic -1 for SPARSE_IRQ as well...
Quoted 1 line
Otherwise, looks fine.
Ok, if you're happy with my logic then I can put the patch into Russell's patch system.
Cheers,
Will
Quoted 2 lines · Will Deacon
Ok, if you're happy with my logic then I can put the patch into Russell's patch system.
I've merged this into my fixes branch, but when I re-merge this with Marc's irqchip consolidation, I get conflicts. I think I've fixed it correctly, but please check the result, which you'll find in my for-next branch.
Thanks.
Hi Russell,
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Will Deacon
Ok, if you're happy with my logic then I can put the patch into Russell's patch system.
I've merged this into my fixes branch, but when I re-merge this with Marc's irqchip consolidation, I get conflicts. I think I've fixed it correctly, but please check the result, which you'll find in my for-next branch.
Thanks for merging this. I've just had a quick look and the resolution looks functionally correct to me (I'll try booting your for-next branch tomorrow). I think that Marc's patches allow that bit of code to be rewritten in a cleaner way, but I guess that can always be handled later on:
arch/arm/common/gic.c +6 -7
@@ -697,13 +697,12 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,* For primary GICs, skip over SGIs. * For secondary GICs, skip over PPIs, too. */ - domain->hwirq_base =32 ; -if (gic_nr ==0 ) { -if ((irq_start &31 ) >0 ) { - domain->hwirq_base =16 ; -if (irq_start !=-1 ) - irq_start = (irq_start & ~31 ) +16 ; - } +if (gic_nr ==0 && (irq_start &31 ) >0 ) { + domain->hwirq_base =16 ; +if (irq_start !=-1 ) + irq_start = (irq_start & ~31 ) +16 ; + }else { + domain->hwirq_base =32 ; }/*
Cheers,
Will
Quoted 8 lines · Will Deacon
Quoted 4 lines · Russell King - ARM Linux
I've merged this into my fixes branch, but when I re-merge this with Marc's irqchip consolidation, I get conflicts. I think I've fixed it correctly, but please check the result, which you'll find in my for-next branch.
Thanks for merging this. I've just had a quick look and the resolution looks functionally correct to me (I'll try booting your for-next branch tomorrow).
I've tested on 1176, A8 and A9 platforms and your for-next branch seems to be ok. I do get these compilation warnings on the UP CPUs:
arch/arm/mm/ioremap.c: In function ?unmap_area_sections?:arch/arm/mm/ioremap.c:80:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type /home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?struct pud_t *? but argument is of type ?pmdval_t (*)[2]? arch/arm/mm/ioremap.c: In function ?remap_area_sections?:arch/arm/mm/ioremap.c:130:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type /home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?struct pud_t *? but argument is of type ?pmdval_t (*)[2]? arch/arm/mm/ioremap.c: In function ?remap_area_supersections?:arch/arm/mm/ioremap.c:167:4: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type /home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?struct pud_t *? but argument is of type ?pmdval_t (*)[2]?
and if I cat /proc/self/net/dev_mcast, then I get an OOPs:
[ 41.771296] Unable to handle kernel NULL pointer dereference at virtual address 00000010 [ 41.797076] pgd = c797c000 [ 41.806863] [00000010] *pgd=070e7831, *pte=00000000, *ppte=00000000 [ 41.827111] Internal error: Oops: 17 [#1] PREEMPT [ 41.841221] Modules linked in: [ 41.850392] CPU: 0 Tainted: G W (3.2.0-rc2+ #3) [ 41.867681] PC is at dev_seq_next+0x14c/0x1dc [ 41.880763] LR is at seq_read+0x43c/0x494 [ 41.892798] pc : [<c024d564>] lr : [<c00cee54>] psr: 60000013 [ 41.892826] sp : c79f3ed4 ip : 00006405 fp : 00008000 [ 41.927254] r10: 00000010 r9 : c79f3f80 r8 : 00000010 [ 41.942927] r7 : 00000000 r6 : 00000001 r5 : c041d100 r4 : 00000001 [ 41.962512] r3 : c024d418 r2 : c79f3f08 r1 : 00000001 r0 : c70e5640 [ 41.982100] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 42.003512] Control: 00c5387d Table: 0797c008 DAC: 00000015 [ 42.020750] Process cat (pid: 764, stack limit = 0xc79f22f0) [ 42.037728] Stack: (0xc79f3ed4 to 0xc79f4000) [ 42.050805] 3ec0: 00000000 00000001 c70e5640 [ 42.075369] 3ee0: c7091b00 00000000 c79f3f80 c79f3f08 c03f07c4 0138a000 c70e5668 00000000 [ 42.099931] 3f00: 00000000 400f1000 00000001 00000000 00000025 c7862000 c00cea18 0138a000 [ 42.124493] 3f20: c79f3f80 c79f2000 c79f2000 00000000 00000000 c00f6c2c 000000c5 c7091b00 [ 42.149059] 3f40: 0138a000 0138a000 c79f3f80 c7091b00 00008000 c00b0be8 00000003 c00a8124 [ 42.173621] 3f60: 00000001 c7091b00 0138a000 00000000 00000000 00008000 00000000 c00b0cf8 [ 42.198181] 3f80: 00000000 00000000 00000025 00000000 00008000 0138a000 00000003 00000003 [ 42.222745] 3fa0: c000e344 c000e1c0 00008000 0138a000 00000003 0138a000 00008000 0138a000 [ 42.247307] 3fc0: 00008000 0138a000 00000003 00000003 0138a000 00000000 400f1000 00000000 [ 42.271869] 3fe0: 7fffe000 be951b50 0000dea0 401f8a7c 60000010 00000003 00000000 00000000 [ 42.296468] [<c024d564>] (dev_seq_next+0x14c/0x1dc) from [<c03f07c4>] (0xc03f07c4) [ 42.319206] Code: eaffffee e590803c e59f508c e1a0a008 (e5984000) [ 42.343526] ---[ end trace 1b75b31a2719ed1f ]---
but I don't think that's your fault (excuse the pun)!
Will
Quoted 13 lines · Will Deacon
Quoted 8 lines · Will Deacon
Quoted 4 lines · Russell King - ARM Linux
I've merged this into my fixes branch, but when I re-merge this with Marc's irqchip consolidation, I get conflicts. I think I've fixed it correctly, but please check the result, which you'll find in my for-next branch.
Thanks for merging this. I've just had a quick look and the resolution looks functionally correct to me (I'll try booting your for-next branch tomorrow).
I've tested on 1176, A8 and A9 platforms and your for-next branch seems to be ok. I do get these compilation warnings on the UP CPUs:
Quoted 9 lines
arch/arm/mm/ioremap.c: In function ?unmap_area_sections?:arch/arm/mm/ioremap.c:80:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?arch/arm/mm/ioremap.c: In function ?remap_area_sections?:arch/arm/mm/ioremap.c:130:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?arch/arm/mm/ioremap.c: In function ?remap_area_supersections?:arch/arm/mm/ioremap.c:167:4: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?
Welcome to those warnings.
This is something that I've been complaining about for the last year, and is one of the reasons I've not been all that eager to merge the LPAE patches until it's properly resolved.
The problem is caused by my "ARM: pgtable: switch to use pgtable-nopud.h" commit, which fixes up everywhere we access a small page table to use the standard pgd-pud-pmd-pte stuff. However, section support makes the conversion completely awful.
Quoted 33 lines
and if I cat
/proc/self/net/dev_mcast, then I get an OOPs:[ 41.771296] Unable to handle kernel NULL pointer dereference at virtual address 00000010 [ 41.797076] pgd = c797c000 [ 41.806863] [00000010] *pgd=070e7831, *pte=00000000, *ppte=00000000 [ 41.827111] Internal error: Oops: 17 [#1] PREEMPT [ 41.841221] Modules linked in: [ 41.850392] CPU: 0 Tainted: G W (3.2.0-rc2+ #3) [ 41.867681] PC is at dev_seq_next+0x14c/0x1dc [ 41.880763] LR is at seq_read+0x43c/0x494 [ 41.892798] pc : [<c024d564>] lr : [<c00cee54>] psr: 60000013 [ 41.892826] sp : c79f3ed4 ip : 00006405 fp : 00008000 [ 41.927254] r10: 00000010 r9 : c79f3f80 r8 : 00000010 [ 41.942927] r7 : 00000000 r6 : 00000001 r5 : c041d100 r4 : 00000001 [ 41.962512] r3 : c024d418 r2 : c79f3f08 r1 : 00000001 r0 : c70e5640 [ 41.982100] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 42.003512] Control: 00c5387d Table: 0797c008 DAC: 00000015 [ 42.020750] Process cat (pid: 764, stack limit = 0xc79f22f0) [ 42.037728] Stack: (0xc79f3ed4 to 0xc79f4000) [ 42.050805] 3ec0: 00000000 00000001 c70e5640 [ 42.075369] 3ee0: c7091b00 00000000 c79f3f80 c79f3f08 c03f07c4 0138a000 c70e5668 00000000 [ 42.099931] 3f00: 00000000 400f1000 00000001 00000000 00000025 c7862000 c00cea18 0138a000 [ 42.124493] 3f20: c79f3f80 c79f2000 c79f2000 00000000 00000000 c00f6c2c 000000c5 c7091b00 [ 42.149059] 3f40: 0138a000 0138a000 c79f3f80 c7091b00 00008000 c00b0be8 00000003 c00a8124 [ 42.173621] 3f60: 00000001 c7091b00 0138a000 00000000 00000000 00008000 00000000 c00b0cf8 [ 42.198181] 3f80: 00000000 00000000 00000025 00000000 00008000 0138a000 00000003 00000003 [ 42.222745] 3fa0: c000e344 c000e1c0 00008000 0138a000 00000003 0138a000 00008000 0138a000 [ 42.247307] 3fc0: 00008000 0138a000 00000003 00000003 0138a000 00000000 400f1000 00000000 [ 42.271869] 3fe0: 7fffe000 be951b50 0000dea0 401f8a7c 60000010 00000003 00000000 00000000 [ 42.296468] [<c024d564>] (dev_seq_next+0x14c/0x1dc) from [<c03f07c4>] (0xc03f07c4) [ 42.319206] Code: eaffffee e590803c e59f508c e1a0a008 (e5984000) [ 42.343526] ---[ end trace 1b75b31a2719ed1f ]---
Quoted 1 line
but I don't think that's your fault (excuse the pun)!
It is showing another problem - that's an incomplete backtrace, presumably because c03f07c4 is not within the kernel text. Either the stack has been corrupted or some other badness has happened, or maybe the unwinder isn't working properly.
Quoted 26 lines · Russell King - ARM Linux
Quoted 13 lines · Will Deacon
Quoted 8 lines · Will Deacon
Quoted 4 lines · Russell King - ARM Linux
I've merged this into my fixes branch, but when I re-merge this with Marc's irqchip consolidation, I get conflicts. ?I think I've fixed it correctly, but please check the result, which you'll find in my for-next branch.
Thanks for merging this. I've just had a quick look and the resolution looks functionally correct to me (I'll try booting your for-next branch tomorrow).
I've tested on 1176, A8 and A9 platforms and your for-next branch seems to be ok. I do get these compilation warnings on the UP CPUs:
Quoted 9 lines
arch/arm/mm/ioremap.c: In function ?unmap_area_sections?:arch/arm/mm/ioremap.c:80:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?arch/arm/mm/ioremap.c: In function ?remap_area_sections?:arch/arm/mm/ioremap.c:130:3: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?arch/arm/mm/ioremap.c: In function ?remap_area_supersections?:arch/arm/mm/ioremap.c:167:4: warning: passing argument 1 of ?pmd_offset? from incompatible pointer type/home/will/work/aarch32/linux/linux/arch/arm/include/asm/pgtable.h:181:22: note: expected ?structpud_t*? but argument is of type ?pmdval_t (*)[2]?Welcome to those warnings.
Quoted 8 lines
This is something that I've been complaining about for the last year, and is one of the reasons I've not been all that eager to merge the LPAE patches until it's properly resolved.
The problem is caused by my "ARM: pgtable: switch to use
pgtable-nopud.h" commit, which fixes up everywhere we access a small page table to use the standard pgd-pud-pmd-pte stuff. ?However, section support makes the conversion completely awful.
I've had a fix around for a while (and I agree, there are many other ways to solve this but that's the least intrusive):
Signature · 1 line
Catalin
Quoted 34 lines · Russell King - ARM Linux
Quoted 33 lines · Will Deacon
and if I cat
/proc/self/net/dev_mcast, then I get an OOPs:[ 41.771296] Unable to handle kernel NULL pointer dereference at virtual address 00000010 [ 41.797076] pgd = c797c000 [ 41.806863] [00000010] *pgd=070e7831, *pte=00000000, *ppte=00000000 [ 41.827111] Internal error: Oops: 17 [#1] PREEMPT [ 41.841221] Modules linked in: [ 41.850392] CPU: 0 Tainted: G W (3.2.0-rc2+ #3) [ 41.867681] PC is at dev_seq_next+0x14c/0x1dc [ 41.880763] LR is at seq_read+0x43c/0x494 [ 41.892798] pc : [<c024d564>] lr : [<c00cee54>] psr: 60000013 [ 41.892826] sp : c79f3ed4 ip : 00006405 fp : 00008000 [ 41.927254] r10: 00000010 r9 : c79f3f80 r8 : 00000010 [ 41.942927] r7 : 00000000 r6 : 00000001 r5 : c041d100 r4 : 00000001 [ 41.962512] r3 : c024d418 r2 : c79f3f08 r1 : 00000001 r0 : c70e5640 [ 41.982100] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 42.003512] Control: 00c5387d Table: 0797c008 DAC: 00000015 [ 42.020750] Process cat (pid: 764, stack limit = 0xc79f22f0) [ 42.037728] Stack: (0xc79f3ed4 to 0xc79f4000) [ 42.050805] 3ec0: 00000000 00000001 c70e5640 [ 42.075369] 3ee0: c7091b00 00000000 c79f3f80 c79f3f08 c03f07c4 0138a000 c70e5668 00000000 [ 42.099931] 3f00: 00000000 400f1000 00000001 00000000 00000025 c7862000 c00cea18 0138a000 [ 42.124493] 3f20: c79f3f80 c79f2000 c79f2000 00000000 00000000 c00f6c2c 000000c5 c7091b00 [ 42.149059] 3f40: 0138a000 0138a000 c79f3f80 c7091b00 00008000 c00b0be8 00000003 c00a8124 [ 42.173621] 3f60: 00000001 c7091b00 0138a000 00000000 00000000 00008000 00000000 c00b0cf8 [ 42.198181] 3f80: 00000000 00000000 00000025 00000000 00008000 0138a000 00000003 00000003 [ 42.222745] 3fa0: c000e344 c000e1c0 00008000 0138a000 00000003 0138a000 00008000 0138a000 [ 42.247307] 3fc0: 00008000 0138a000 00000003 00000003 0138a000 00000000 400f1000 00000000 [ 42.271869] 3fe0: 7fffe000 be951b50 0000dea0 401f8a7c 60000010 00000003 00000000 00000000 [ 42.296468] [<c024d564>] (dev_seq_next+0x14c/0x1dc) from [<c03f07c4>] (0xc03f07c4) [ 42.319206] Code: eaffffee e590803c e59f508c e1a0a008 (e5984000) [ 42.343526] ---[ end trace 1b75b31a2719ed1f ]---
Quoted 6 lines
Quoted 1 line
but I don't think that's your fault (excuse the pun)!
It is showing another problem - that's an incomplete backtrace, presumably because
c03f07c4is not within the kernel text. Either the stack has been corrupted or some other badness has happened, or maybe the unwinder isn't working properly.
I've debugged this down to a problem with the net dev name hashing introduced in f04565dd ("dev: use name hash for dev_seq_ops"). I've also posted a fix to LKML so I think we can safely ignore it for now.
As for the backtrace, I guess the unwinder had gone wrong since removing the static inline from the hashing functions suddenly gave me a full backtrace back to the syscall entry.
Will