Skip to contentSkip to conversation

ARM: mmu: fix access to illegal address when using earlycon & memblock=debug

PATCH Superseded Victor Hassan 5 participants 12 messages Mar 16, 2022 – Sep 3, 2022 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mmu: fix access to illegal address when using earlycon & memblock=debug

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

---
 arch/arm/mm/mmu.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +7 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
+#include <linux/console.h>
 
 #include <asm/cp15.h>
 #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
 	pmd_clear(fixmap_pmd(va));
 	local_flush_tlb_kernel_page(va);
 
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_stop(console_drivers);
+#endif
 	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
 		pte_t *pte;
 		struct map_desc map;
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
 
 		create_mapping(&map);
 	}
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_start(console_drivers);
+#endif
 }
 
 /*
Signature · 1 line
2.29.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

I think noone really noticed this because everyone on Arm systems use CONFIG_DEBUG_LL, and that makes printascii hammer out stuff on the console very early, it even accounts for whether we have MMU on or not.

How are you using this on Arm even? What system and what serial driver?

That said, it looks correct.

Yours,
Linus Walleij

#2 lore raw
Quoted 7 lines · Linus Walleij
Quoted 5 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

Quoted 7 lines
Quoted 1 line

I think noone really noticed this because everyone on Arm systems use CONFIG_DEBUG_LL, and that makes printascii hammer out stuff on the console very early, it even accounts for whether we have MMU on or not.

Hi Linus,
Thank you for the reply. I used earlycon, in early_fixmap_shutdown, the base address of earlycon is in the critical stage of release and reassignment, so early_fixmap_shutdown -> create_mapping should not call earlycon in this process, and create_mapping has a lot of conditions that trigger print, memblock=debug just makes it easier to expose problems.

Quoted 2 lines

How are you using this on Arm even? What system and what serial driver?

I'm using serial driver 8250 on arm32, with cmdline: memblock=debug. CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8520_CONSOLE=y

Quoted 3 lines

That said, it looks correct.

Thank you.

Quoted 3 lines

Yours,
Linus Walleij

Sincerely,
Victor Hassan

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 15 lines · Victor Hassan
Quoted 7 lines · Linus Walleij
Quoted 5 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

Quoted 7 lines
Quoted 1 line

I think noone really noticed this because everyone on Arm systems use CONFIG_DEBUG_LL, and that makes printascii hammer out stuff on the console very early, it even accounts for whether we have MMU on or not.

Quoted 11 lines

Hi Linus,
Thank you for the reply. I used earlycon, in early_fixmap_shutdown, the base address of earlycon is in the critical stage of release and reassignment, so early_fixmap_shutdown -> create_mapping should not call earlycon in this process, and create_mapping has a lot of conditions that trigger print, memblock=debug just makes it easier to expose problems.

Quoted 2 lines

How are you using this on Arm even? What system and what serial driver?

I'm using serial driver 8250 on arm32, with cmdline: memblock=debug. CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8520_CONSOLE=y

Quoted 3 lines

That said, it looks correct.

Hi Linus,
Sorry to disturb. Is there any question about this issue? Thank you :)

#4 lore raw
Quoted 30 lines · Victor Hassan
Quoted 29 lines · Victor Hassan
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

Quoted 7 lines
Quoted 1 line

I think noone really noticed this because everyone on Arm systems use CONFIG_DEBUG_LL, and that makes printascii hammer out stuff on the console very early, it even accounts for whether we have MMU on or not.

Hi Linus,
Thank you for the reply. I used earlycon, in early_fixmap_shutdown, the base address of earlycon is in the critical stage of release and reassignment, so early_fixmap_shutdown -> create_mapping should not call earlycon in this process, and create_mapping has a lot of conditions that trigger print, memblock=debug just makes it easier to expose problems.

Quoted 2 lines

How are you using this on Arm even? What system and what serial driver?

I'm using serial driver 8250 on arm32, with cmdline: memblock=debug. CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8520_CONSOLE=y

Quoted 1 line
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

That said, it looks correct.

Hi Linus,
Sorry to disturb. Is there any question about this issue? Thank you :)

No, I understand the problem, I provided my ACK.

Maybe you wanna add the patch to Russell's patch tracker so he can apply it?
https://www.arm.linux.org.uk/developer/patches/

Yours,
Linus Walleij

#5 lore raw
In reply to Victor Hassan

Hi Victor,

Quoted 6 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append 
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append 
"console=ttyAMA0" -M virt -smp 2 -m 512
Quoted 27 lines
---
  arch/arm/mm/mmu.c | 7 +++++++
  1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +4 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
  #include <linux/fs.h>
  #include <linux/vmalloc.h>
  #include <linux/sizes.h>
+#include <linux/console.h>
 
  #include <asm/cp15.h>
  #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
  	pmd_clear(fixmap_pmd(va));
  	local_flush_tlb_kernel_page(va);
 
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_stop(console_drivers);
+#endif
  	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
  		pte_t *pte;
  		struct map_desc map;

arch/arm/mm/mmu.c static void __init early_fixmap_shutdown(void) · line 1725

Quoted 9 lines
arch/arm/mm/mmu.c +3 -0
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
 
  		create_mapping(&map);
  	}
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_start(console_drivers);
+#endif
  }
 
  /*

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#6 lore raw
Quoted 61 lines · Marek Szyprowski

Hi Victor,

Quoted 6 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0" -M virt -smp 2 -m 512
Quoted 35 lines
---
   arch/arm/mm/mmu.c | 7 +++++++
   1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +7 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
   #include <linux/fs.h>
   #include <linux/vmalloc.h>
   #include <linux/sizes.h>
+#include <linux/console.h>
 
   #include <asm/cp15.h>
   #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
   	pmd_clear(fixmap_pmd(va));
   	local_flush_tlb_kernel_page(va);
 
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_stop(console_drivers);
+#endif
   	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
   		pte_t *pte;
   		struct map_desc map;
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
 
   		create_mapping(&map);
   	}
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	console_start(console_drivers);
+#endif
   }
 
Quoted 3 lines

arch/arm/mm/mmu.c static void __init early_fixmap_shutdown(void) · line 1725

Quoted 1 line
arch/arm/mm/mmu.c +0 -0
   /*

Best regards

Dear Marek,
Thank you for the notice. I'll figure it out and feed back to you as soon as possible.

Regards,
Victor

#11 lore raw
In reply to Marek Szyprowski
Quoted 17 lines · Marek Szyprowski

Hi Victor,

Quoted 6 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

Quoted 7 lines
$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append 
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append 
"console=ttyAMA0" -M virt -smp 2 -m 512

That's the second patch to drop from my merge yesterday... not good.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#7 lore raw
In reply to Victor Hassan
Quoted 62 lines · Victor Hassan
Quoted 52 lines · Marek Szyprowski

Hi Victor,

Quoted 6 lines · Victor Hassan

earlycon uses fixmap to create a memory map,
So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses. After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0" -M virt -smp 2 -m 512
Quoted 26 lines

---
   arch/arm/mm/mmu.c | 7 +++++++

   1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +4 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
    #include <linux/fs.h>
    #include <linux/vmalloc.h>
    #include <linux/sizes.h>
+#include <linux/console.h>
    #include <asm/cp15.h>
    #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
        pmd_clear(fixmap_pmd(va));
        local_flush_tlb_kernel_page(va);
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_stop(console_drivers);
+#endif
        for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
            pte_t *pte;
            struct map_desc map;
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
            create_mapping(&map);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init early_fixmap_shutdown(void) · line 1723

Quoted 6 lines
arch/arm/mm/mmu.c +3 -0
        }
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_start(console_drivers);
+#endif
    }
    /*

Best regards

Quoted 5 lines

Dear Marek,
Thank you for the notice. I'll figure it out and feed back to you as soon as possible.

Regards,
Victor

Hi Marek,

Sorry, didn't take into account that console_drivers is NULL when earlycon is not used.

Here is the patch-v2. Please review:

arch/arm/mm/mmu.c +9 -0
index a49f0b9..a240f38 100644
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
+#include <linux/console.h>
 
 #include <asm/cp15.h>
 #include <asm/cputype.h>
@@ -1730,6 +1731,10 @@
 	pmd_clear(fixmap_pmd(va));
 	local_flush_tlb_kernel_page(va);
 
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	if (console_drivers)
+		console_stop(console_drivers);
+#endif
 	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
 		pte_t *pte;
 		struct map_desc map;
@@ -1748,6 +1753,10 @@
 
 		create_mapping(&map);
 	}
+#ifdef CONFIG_FIX_EARLYCON_MEM
+	if (console_drivers)
+		console_start(console_drivers);
+#endif
 }
 

BTW, should I resend the patch-v2 through the site (https://www.armlinux.org.uk/developer/patches/add.php), or should I send the patch-v2 through E-mail to Linux-Mainline?

Thanks you.

Regards,
Victor

#8 lore raw
Quoted 11 lines · Victor Hassan
Quoted 7 lines · Victor Hassan
Quoted 6 lines · Marek Szyprowski

Hi Victor,

Quoted 3 lines · Victor Hassan

earlycon uses fixmap to create a memory map, So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses.

How? Due to recent changes in how printk and the consoles work or just because create_mapping() can print? In the latter case, the only variable input is the phys address. I think most if not all prints cannot occur.

Quoted 82 lines
Quoted 55 lines
Quoted 46 lines
Quoted 3 lines

After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0" -M virt -smp 2 -m 512
Quoted 26 lines
---
   arch/arm/mm/mmu.c | 7 +++++++
   1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +4 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
   #include <linux/fs.h>
   #include <linux/vmalloc.h>
   #include <linux/sizes.h>
+#include <linux/console.h>
   #include <asm/cp15.h>
   #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
       pmd_clear(fixmap_pmd(va));
       local_flush_tlb_kernel_page(va);
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_stop(console_drivers);
+#endif
       for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
           pte_t *pte;
           struct map_desc map;
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
           create_mapping(&map);
Quoted 8 lines

arch/arm/mm/mmu.c

Quoted 6 lines
arch/arm/mm/mmu.c +3 -0
       }
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_start(console_drivers);
+#endif
   }
   /*

Best regards

Quoted 6 lines

Dear Marek,
Thank you for the notice. I'll figure it out and feed back to you as soon as possible.

Regards,
Victor

Hi Marek,

Sorry, didn't take into account that console_drivers is NULL when earlycon is not used.

Here is the patch-v2. Please review:

arch/arm/mm/mmu.c +1 -0
index a49f0b9..a240f38 100644
@@ -14,6 +14,7 @@
  #include <linux/fs.h>
  #include <linux/vmalloc.h>
  #include <linux/sizes.h>
+#include <linux/console.h>
 
  #include <asm/cp15.h>
  #include <asm/cputype.h>

arch/arm/mm/mmu.c line 1734

Quoted 4 lines
arch/arm/mm/mmu.c +1 -0
@@ -1730,6 +1731,10 @@
        pmd_clear(fixmap_pmd(va));
        local_flush_tlb_kernel_page(va);
 
+#ifdef CONFIG_FIX_EARLYCON_MEM

This is always true for CONFIG_MMU and this file is only built for CONFIG_MMU. So you don't need it.

arch/arm/mm/mmu.c line 1736

Quoted 2 lines
arch/arm/mm/mmu.c +2 -0
+       if (console_drivers)
+               console_stop(console_drivers);

console_drivers is a list, so you are only stopping the 1st one. Couldn't console_lock() be used here?

Also, this should be before pmd_clear().

Quoted 27 lines
arch/arm/mm/mmu.c +5 -0
+#endif
        for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
                pte_t *pte;
                struct map_desc map;
@@ -1748,6 +1753,10 @@
 
                create_mapping(&map);
        }
+#ifdef CONFIG_FIX_EARLYCON_MEM
+       if (console_drivers)
+               console_start(console_drivers);
+#endif
  }
 

BTW, should I resend the patch-v2 through the site
(https://www.armlinux.org.uk/developer/patches/add.php), or should I send the patch-v2 through E-mail to Linux-Mainline?

Thanks you.

Regards,
Victor

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#9 lore raw
Quoted 10 lines · Rob Herring
Quoted 8 lines · Victor Hassan
Quoted 4 lines · Victor Hassan
Quoted 3 lines · Marek Szyprowski

Hi Victor,

On 16.03.2022 03:33, Victor Hassan wrote:

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

earlycon uses fixmap to create a memory map, So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses.

How? Due to recent changes in how printk and the consoles work or just because create_mapping() can print? In the latter case, the only variable input is the phys address. I think most if not all prints cannot occur.

Ah, I missed the memblock debug part on the subject...

Rob

#10 lore raw
In reply to Rob Herring

Dear Rob,

Quoted 103 lines · Rob Herring
Quoted 11 lines · Victor Hassan
Quoted 7 lines · Victor Hassan
Quoted 6 lines · Marek Szyprowski

Hi Victor,

Quoted 3 lines · Victor Hassan

earlycon uses fixmap to create a memory map, So we need to close earlycon before closing fixmap, otherwise printk will access illegal addresses.

How? Due to recent changes in how printk and the consoles work or just because create_mapping() can print? In the latter case, the only variable input is the phys address. I think most if not all prints cannot occur.

Quoted 85 lines
Quoted 55 lines
Quoted 46 lines
Quoted 3 lines

After creating a new memory map, we open earlycon again.

This patch landed in linux next-20220831 as commit a76886d117cb ("ARM:
9223/1: mmu: fix access to illegal address when using earlycon & memblock=debug"). Unfortunately it breaks booting of all my test boards which *do not* use earlycon. It can be easily reproduced even with QEMU.

With kernel compiled from multi_v7_defconfig the following setup boots:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0 earlycon" -M virt -smp 2 -m 512

while this one doesn't:

$ qemu-system-arm -nographic -kernel arch/arm/boot/zImage -append
"console=ttyAMA0" -M virt -smp 2 -m 512
Quoted 26 lines
---
    arch/arm/mm/mmu.c | 7 +++++++
    1 file changed, 7 insertions(+)
arch/arm/mm/mmu.c +4 -0
index 274e4f73fd33..f3511f07a7d0 100644
@@ -14,6 +14,7 @@
    #include <linux/fs.h>
    #include <linux/vmalloc.h>
    #include <linux/sizes.h>
+#include <linux/console.h>
    #include <asm/cp15.h>
    #include <asm/cputype.h>
@@ -1695,6 +1696,9 @@ static void __init early_fixmap_shutdown(void)
        pmd_clear(fixmap_pmd(va));
        local_flush_tlb_kernel_page(va);
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_stop(console_drivers);
+#endif
        for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
            pte_t *pte;
            struct map_desc map;
@@ -1713,6 +1717,9 @@ static void __init early_fixmap_shutdown(void)
            create_mapping(&map);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init early_fixmap_shutdown(void) · line 1723

Quoted 6 lines
arch/arm/mm/mmu.c +3 -0
        }
+#ifdef CONFIG_FIX_EARLYCON_MEM
+    console_start(console_drivers);
+#endif
    }
    /*

Best regards

Quoted 6 lines

Dear Marek,
Thank you for the notice. I'll figure it out and feed back to you as soon as possible.

Regards,
Victor

Hi Marek,

Sorry, didn't take into account that console_drivers is NULL when earlycon is not used.

Here is the patch-v2. Please review:

arch/arm/mm/mmu.c +1 -0
index a49f0b9..a240f38 100644
@@ -14,6 +14,7 @@
   #include <linux/fs.h>
   #include <linux/vmalloc.h>
   #include <linux/sizes.h>
+#include <linux/console.h>
 
   #include <asm/cp15.h>
   #include <asm/cputype.h>
@@ -1730,6 +1731,10 @@
         pmd_clear(fixmap_pmd(va));
         local_flush_tlb_kernel_page(va);
 
Quoted 4 lines

arch/arm/mm/mmu.c line 1734

Quoted 1 line
arch/arm/mm/mmu.c +1 -0
+#ifdef CONFIG_FIX_EARLYCON_MEM

This is always true for CONFIG_MMU and this file is only built for CONFIG_MMU. So you don't need it.

Yes, you are right.

Quoted 7 lines

arch/arm/mm/mmu.c line 1736

Quoted 3 lines
arch/arm/mm/mmu.c +2 -0
+       if (console_drivers)
+               console_stop(console_drivers);

console_drivers is a list, so you are only stopping the 1st one. Couldn't console_lock() be used here?

Thanks for the suggestion: console_lock is actually the same as console_stop in the test, and the code is more compact.

Quoted 1 line

Also, this should be before pmd_clear().

During the test, I found that the console failed after executing local_flush_tlb_kernel_page, so I think the pmd_clear function can output in time if there is printing. This doesn't seem possible, so before pmd_clear it's not bad either.

Quoted 21 lines
Quoted 21 lines
arch/arm/mm/mmu.c +5 -0
+#endif
         for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
                 pte_t *pte;
                 struct map_desc map;
@@ -1748,6 +1753,10 @@
 
                 create_mapping(&map);
         }
+#ifdef CONFIG_FIX_EARLYCON_MEM
+       if (console_drivers)
+               console_start(console_drivers);
+#endif
   }
 

BTW, should I resend the patch-v2 through the site
(https://www.armlinux.org.uk/developer/patches/add.php), or should I send the patch-v2 through E-mail to Linux-Mainline?

Thanks you.

Quoted 7 lines
Quoted 7 lines

Regards,
Victor

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Here is the patch-v3. Please review:

arch/arm/mm/mmu.c +3 -0
index a49f0b9..57ca77f 100644
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
+#include <linux/console.h>
 
 #include <asm/cp15.h>
 #include <asm/cputype.h>
@@ -1727,6 +1728,7 @@
 	unsigned long va = fix_to_virt(__end_of_permanent_fixed_addresses - 1);
 
 	pte_offset_fixmap = pte_offset_late_fixmap;
+	console_lock();
 	pmd_clear(fixmap_pmd(va));
 	local_flush_tlb_kernel_page(va);
 
@@ -1748,6 +1750,7 @@
 
 		create_mapping(&map);
 	}
+	console_unlock();
 }
 

Thanks you.

Regards,
Victor