Skip to contentSkip to conversation

ARM: decompressor: Flush tlb before swiching domain 0 to client mode

PATCH In review Arve Hjønnevåg 2 participants 4 messages Dec 12, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: decompressor: Flush tlb before swiching domain 0 to client mode

If the bootloader used a page table that is incompatible with domain 0 in client mode, then swithing domain 0 to client mode causes a fault if we don't flush the tlb after updating the page table pointer.

---
 arch/arm/boot/compressed/head.S |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/compressed/head.S +1 -0
index 90275f0..9c8034c 100644
@@ -704,6 +704,7 @@ __armv7_mmu_cache_on:
 		bic     r6, r6, #1 << 31        @ 32-bit translation system
 		bic     r6, r6, #3 << 0         @ use only ttbr0
 		mcrne	p15, 0, r3, c2, c0, 0	@ load page table pointer
+		mcrne	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
 		mcrne	p15, 0, r1, c3, c0, 0	@ load domain access control
 		mcrne   p15, 0, r6, c2, c0, 2   @ load ttb control
 #endif
Signature · 1 line
1.7.7.3
#1 lore raw
Quoted 15 lines · Arve Hjønnevåg

If the bootloader used a page table that is incompatible with domain 0 in client mode, then swithing domain 0 to client mode causes a fault if we don't flush the tlb after updating the page table pointer.

---
  arch/arm/boot/compressed/head.S |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/compressed/head.S +0 -0
index 90275f0..9c8034c 100644

arch/arm/boot/compressed/head.S __armv7_mmu_cache_on: · line 710

Quoted 7 lines
arch/arm/boot/compressed/head.S +1 -0
@@ -704,6 +704,7 @@ __armv7_mmu_cache_on:
  		bic     r6, r6, #1 << 31        @ 32-bit translation system
  		bic     r6, r6, #3 << 0         @ use only ttbr0
  		mcrne	p15, 0, r3, c2, c0, 0	@ load page table pointer
+		mcrne	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
  		mcrne	p15, 0, r1, c3, c0, 0	@ load domain access control
  		mcrne   p15, 0, r6, c2, c0, 2   @ load ttb control
  #endif

The TLB's are already flushed few lines above so above patching shouldn't help if it was really dirty TLB entry issue. I suspect that your boot-loader clean-up [1] function may not be taking care of flushing caches which could potetially lead to the issue.

Have you checked that ?

Regards
Santosh

[1] http://www.arm.linux.org.uk/developer/noboot-checklist/

#2 lore raw
Quoted 32 lines · Santosh Shilimkar
Quoted 18 lines · Arve Hj?nnev?g

If the bootloader used a page table that is incompatible with domain 0 in client mode, then swithing domain 0 to client mode causes a fault if we don't flush the tlb after updating the page table pointer.

---
  arch/arm/boot/compressed/head.S |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/compressed/head.S +0 -0
index 90275f0..9c8034c 100644
@@ -704,6 +704,7 @@ __armv7_mmu_cache_on:
                bic     r6, r6, #1 << 31        @ 32-bit translation

system

Quoted 8 lines
                bic     r6, r6, #3 << 0         @ use only ttbr0
                mcrne   p15, 0, r3, c2, c0, 0   @ load page table pointer
+               mcrne   p15, 0, r0, c8, c7, 0   @ flush I,D TLBs
                mcrne   p15, 0, r1, c3, c0, 0   @ load domain access
control
                mcrne   p15, 0, r6, c2, c0, 2   @ load ttb control

#endif

The TLB's are already flushed few lines above so above patching shouldn't help if it was really dirty TLB entry issue. I suspect that your boot-loader clean-up [1] function may not be taking care of flushing caches which could potetially lead to the issue.

Quoted 2 lines

Have you checked that ?

No, the problem is that the mmu is on when that first tlb flush happens so the tlb entry for the code that is executing gets reloaded from the old page table. This is probably a bootloader bug, but I don't have the bootloader source and 3.4 boots with the same bootloader.

Signature · 1 line
Arve Hj?nnev?g
#3 lore raw
Quoted 34 lines · Arve Hjønnevåg
Quoted 32 lines · Santosh Shilimkar
Quoted 18 lines · Arve Hjønnevåg

If the bootloader used a page table that is incompatible with domain 0 in client mode, then swithing domain 0 to client mode causes a fault if we don't flush the tlb after updating the page table pointer.

---
   arch/arm/boot/compressed/head.S |    1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/compressed/head.S +0 -0
index 90275f0..9c8034c 100644
@@ -704,6 +704,7 @@ __armv7_mmu_cache_on:
                 bic     r6, r6, #1 << 31        @ 32-bit translation

system

Quoted 8 lines
                 bic     r6, r6, #3 << 0         @ use only ttbr0
                 mcrne   p15, 0, r3, c2, c0, 0   @ load page table pointer
+               mcrne   p15, 0, r0, c8, c7, 0   @ flush I,D TLBs
                 mcrne   p15, 0, r1, c3, c0, 0   @ load domain access
control
                 mcrne   p15, 0, r6, c2, c0, 2   @ load ttb control

#endif

The TLB's are already flushed few lines above so above patching shouldn't help if it was really dirty TLB entry issue. I suspect that your boot-loader clean-up [1] function may not be taking care of flushing caches which could potetially lead to the issue.

Quoted 9 lines
Quoted 2 lines

Have you checked that ?

No, the problem is that the mmu is on when that first tlb flush happens so the tlb entry for the code that is executing gets reloaded from the old page table. This is probably a bootloader bug, but I don't have the bootloader source and 3.4 boots with the same bootloader.

Yes. The MMU is suppose to be turned off by boot-loader before jumping to the kernel. That explains the problem. No need to patch the kernel here.

Regards
Santosh