Miouyouyou / RockMyy

Build scripts and patches used to cross-compile 5.6-rcX kernels for RK3288 boards
MIT License
32 stars 8 forks source link

5.0-rc2 cannot boot #12

Closed Miouyouyou closed 5 years ago

Miouyouyou commented 5 years ago

The following issue arises when trying to boot a 5.0-rc2 with no patches on a Tinkerboard :

[    1.682129] Unable to handle kernel NULL pointer dereference at virtual address 000001bc
[    1.691257] pgd = (ptrval)
[    1.694309] [000001bc] *pgd=00000000
[    1.698349] Internal error: Oops: 805 [#1] PREEMPT SMP ARM
[    1.704497] Modules linked in:
[    1.707928] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2-Myy-HiveFive #1
[    1.716120] Hardware name: Rockchip (Device Tree)
[    1.721404] PC is at serial8250_register_8250_port+0x2e0/0x3b8
[    1.727945] LR is at serial8250_register_8250_port+0x9c/0x3b8
[    1.734383] pc : [<c072ee2c>]    lr : [<c072ebe8>]    psr: 60000013
[    1.741405] sp : ef0f5c28  ip : c0f186f4  fp : 00000000
[    1.747258] r10: 00000000  r9 : 000001c0  r8 : c13a1ba0
[    1.753112] r7 : 00000004  r6 : ef0f5c68  r5 : ffffffe4  r4 : 00000000
[    1.760425] r3 : 00000000  r2 : 00000004  r1 : 000001c0  r0 : 00000004
[    1.767741] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[    1.775735] Control: 10c5387d  Table: 0000406a  DAC: 00000051
[    1.782174] Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
[    1.788905] Stack: (0xef0f5c28 to 0xef0f6000)
[    1.793792] 5c20:                   60000013 00000000 00000000 c0d29350 ee9eb740 ee9eb740
[    1.802964] 5c40: 00000000 ef2a2410 ef2a2400 00000000 c13a2884 c0736d8c 00000001 006012c0
[    1.812136] 5c60: c106459e 00000004 00000000 dead4ead ffffffff ffffffff 00000000 f0d89000
[    1.821308] 5c80: c07360d8 c073640c c07365bc c073668c 00000000 00000000 00000000 00000000
[    1.830478] 5ca0: 00000000 00000000 00000000 00000000 c07366e0 c0736e84 00000000 00000000
[    1.839650] 5cc0: 00000000 00000025 00000000 016e3600 00000040 00030200 00000000 00000000
[    1.848820] 5ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.857990] 5d00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 29000000
[    1.867151] 5d20: 00000000 00000000 00000000 00000000 00000004 00000000 00000000 00000004
[    1.876322] 5d40: 00000000 ff1c0000 00000000 ef2a2410 00000000 00000000 00000000 00000000
[    1.885492] 5d60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.894662] 5d80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.903824] 5da0: 00000000 00000000 ee9eb740 00000000 00000000 00000000 00000000 00000000
[    1.912994] 5dc0: 00000000 00000000 00010900 00000000 00000000 00000000 00000000 00000000
[    1.922154] 5de0: 00000000 ee9eb75c 00000000 00000000 00000000 00000000 00000000 00000000
[    1.931325] 5e00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.940496] 5e20: 00000000 00000000 ef2a2410 00000000 c13a2884 c18a29a0 00000000 c079b908
[    1.949667] 5e40: ef2a2410 00000000 c18a29a4 c0799d08 00000000 ef2a2410 c13a2884 c13a2884
[    1.958839] 5e60: c13a54d0 00000000 c12a7230 efffcc40 00000018 c079a03c c13a2884 ef2a2410
[    1.968011] 5e80: 00000000 ef2a2410 ef2a2444 c13a2884 c13a54d0 00000000 c12a7230 c079a0e4
[    1.977183] 5ea0: ef2a2410 c13a2884 c079a058 c0798464 ef135070 ef2230c0 c13a2884 eeaf7e00
[    1.986354] 5ec0: 00000000 c07992ec c1076ca5 00000001 00000000 c13a2884 c1400de0 c130e488
[    1.995526] 5ee0: c123d98c c079acdc ffffe000 c1400de0 c130e488 c0102ddc 00000000 00000000
[    2.004697] 5f00: c1098098 efffcc00 c115a300 00000000 00000000 c013badc 00000000 c11580c8
[    2.013869] 5f20: 000001b7 00000006 00000006 c115a314 000001b6 c115a314 efffcc83 efffcc8c
[    2.023040] 5f40: 00000000 e02164a4 c1413500 00000007 c1413500 ef0f4000 c1400de0 c1275840
[    2.032211] 5f60: c12a7230 c12011e0 00000006 00000006 00000000 c12004a8 c0d24430 000001b7
[    2.041382] 5f80: 00000000 00000000 c0d24430 00000000 00000000 00000000 00000000 00000000
[    2.050553] 5fa0: 00000000 c0d24438 00000000 c01010e8 00000000 00000000 00000000 00000000
[    2.059714] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.068884] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[    2.078063] [<c072ee2c>] (serial8250_register_8250_port) from [<c0736d8c>] (dw8250_probe+0x5a4/0x69c)
[    2.088399] [<c0736d8c>] (dw8250_probe) from [<c079b908>] (platform_drv_probe+0x48/0x94)
[    2.097479] [<c079b908>] (platform_drv_probe) from [<c0799d08>] (really_probe+0x1f0/0x2c0)
[    2.106754] [<c0799d08>] (really_probe) from [<c079a03c>] (driver_probe_device+0x140/0x15c)
[    2.116126] [<c079a03c>] (driver_probe_device) from [<c079a0e4>] (__driver_attach+0x8c/0xc8)
[    2.125593] [<c079a0e4>] (__driver_attach) from [<c0798464>] (bus_for_each_dev+0x54/0x78)
[    2.134768] [<c0798464>] (bus_for_each_dev) from [<c07992ec>] (bus_add_driver+0x170/0x1d8)
[    2.144039] [<c07992ec>] (bus_add_driver) from [<c079acdc>] (driver_register+0xb4/0xf8)
[    2.153019] [<c079acdc>] (driver_register) from [<c0102ddc>] (do_one_initcall+0xbc/0x264)
[    2.162197] [<c0102ddc>] (do_one_initcall) from [<c12011e0>] (kernel_init_freeable+0x368/0x3c4)
[    2.171957] [<c12011e0>] (kernel_init_freeable) from [<c0d24438>] (kernel_init+0x8/0x10c)
[    2.181132] [<c0d24438>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[    2.189614] Exception stack(0xef0f5fb0 to 0xef0f5ff8)
[    2.195277] 5fa0:                                     00000000 00000000 00000000 00000000
[    2.204447] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.213616] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    2.221034] Code: e2505000 059450d4 e59631bc e3530000 (e58431bc) 
[    2.228015] ---[ end trace 60950f0031400bd8 ]---
[    2.233262] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    2.241862] CPU2: stopping
[    2.244911] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G      D           5.0.0-rc2-Myy-HiveFive #1
[    2.254659] Hardware name: Rockchip (Device Tree)
[    2.259950] [<c010f930>] (unwind_backtrace) from [<c010b998>] (show_stack+0x10/0x14)
[    2.268642] [<c010b998>] (show_stack) from [<c0d0f7e0>] (dump_stack+0x70/0x8c)
[    2.276748] [<c0d0f7e0>] (dump_stack) from [<c010e740>] (handle_IPI+0x2f0/0x3e4)
[    2.285049] [<c010e740>] (handle_IPI) from [<c06ad77c>] (gic_handle_irq+0x84/0x90)
[    2.293541] [<c06ad77c>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0xa8)
[    2.301927] Exception stack(0xef125f68 to 0xef125fb0)
[    2.307591] 5f60:                   00000000 00000da8 ef7c11e0 c0119d80 00000000 00000000
[    2.316763] 5f80: ef124000 c130e4b0 00000004 ef125fc0 c130e4f0 00000000 00000000 ef125fb8
[    2.325929] 5fa0: c0108494 c0108484 60000013 ffffffff
[    2.331600] [<c0101a0c>] (__irq_svc) from [<c0108484>] (arch_cpu_idle+0x1c/0x38)
[    2.339901] [<c0108484>] (arch_cpu_idle) from [<c014a90c>] (do_idle+0x10c/0x230)
[    2.348200] [<c014a90c>] (do_idle) from [<c014aca0>] (cpu_startup_entry+0x18/0x20)
[    2.356689] [<c014aca0>] (cpu_startup_entry) from [<0010256c>] (0x10256c)
[    2.364297] CPU3: stopping
[    2.367346] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G      D           5.0.0-rc2-Myy-HiveFive #1
[    2.377096] Hardware name: Rockchip (Device Tree)
[    2.382383] [<c010f930>] (unwind_backtrace) from [<c010b998>] (show_stack+0x10/0x14)
[    2.391073] [<c010b998>] (show_stack) from [<c0d0f7e0>] (dump_stack+0x70/0x8c)
[    2.399178] [<c0d0f7e0>] (dump_stack) from [<c010e740>] (handle_IPI+0x2f0/0x3e4)
[    2.407478] [<c010e740>] (handle_IPI) from [<c06ad77c>] (gic_handle_irq+0x84/0x90)
[    2.415970] [<c06ad77c>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0xa8)
[    2.424356] Exception stack(0xef127f68 to 0xef127fb0)
[    2.430022] 7f60:                   00000000 0000102c ef7d31e0 c0119d80 00000000 00000000
[    2.439194] 7f80: ef126000 c130e4b0 00000008 ef127fc0 c130e4f0 00000000 00000000 ef127fb8
[    2.448361] 7fa0: c0108494 c0108484 60000013 ffffffff
[    2.454032] [<c0101a0c>] (__irq_svc) from [<c0108484>] (arch_cpu_idle+0x1c/0x38)
[    2.462332] [<c0108484>] (arch_cpu_idle) from [<c014a90c>] (do_idle+0x10c/0x230)
[    2.470632] [<c014a90c>] (do_idle) from [<c014aca0>] (cpu_startup_entry+0x18/0x20)
[    2.479122] [<c014aca0>] (cpu_startup_entry) from [<0010256c>] (0x10256c)
[    2.486722] CPU1: stopping
[    2.489770] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D           5.0.0-rc2-Myy-HiveFive #1
[    2.499519] Hardware name: Rockchip (Device Tree)
[    2.504806] [<c010f930>] (unwind_backtrace) from [<c010b998>] (show_stack+0x10/0x14)
[    2.513494] [<c010b998>] (show_stack) from [<c0d0f7e0>] (dump_stack+0x70/0x8c)
[    2.521600] [<c0d0f7e0>] (dump_stack) from [<c010e740>] (handle_IPI+0x2f0/0x3e4)
[    2.529898] [<c010e740>] (handle_IPI) from [<c06ad77c>] (gic_handle_irq+0x84/0x90)
[    2.538389] [<c06ad77c>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0xa8)
[    2.546775] Exception stack(0xef123f68 to 0xef123fb0)
[    2.552440] 3f60:                   00000000 00002260 ef7af1e0 c0119d80 00000000 00000000
[    2.561603] 3f80: ef122000 c130e4b0 00000002 ef123fc0 c130e4f0 00000000 00000000 ef123fb8
[    2.570769] 3fa0: c0108494 c0108484 60000013 ffffffff
[    2.576439] [<c0101a0c>] (__irq_svc) from [<c0108484>] (arch_cpu_idle+0x1c/0x38)
[    2.584739] [<c0108484>] (arch_cpu_idle) from [<c014a90c>] (do_idle+0x10c/0x230)
[    2.593037] [<c014a90c>] (do_idle) from [<c014aca0>] (cpu_startup_entry+0x18/0x20)
[    2.601526] [<c014aca0>] (cpu_startup_entry) from [<0010256c>] (0x10256c)
[    2.609146] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

Given than I tried with and without any patches, I can conclude that it's the current state of the 5.0 kernel.

I'll try to investigate this.

Miouyouyou commented 5 years ago

Barely nothing changed beside this :

https://elixir.bootlin.com/linux/v5.0-rc2/source/drivers/tty/serial/8250/8250_core.c#L1076 ( Previous code : https://elixir.bootlin.com/linux/v4.20.2/source/drivers/tty/serial/8250/8250_core.c#L1059 )

So this might be the issue. I'll check tomorrow.

Miouyouyou commented 5 years ago

This resolves the issue :

From 7e43ae8446b420907f00b43308ad0b99b6fe4e51 Mon Sep 17 00:00:00 2001
From: "Miouyouyou (Myy)" <myy@miouyouyou.fr>
Date: Wed, 16 Jan 2019 23:58:52 +0100
Subject: [PATCH] drivers: tty: serial: Bail out if no UART is detected

Before the 5.0, serial8250_register_8250_port consisted of one BIG
if(uart && uart->port.type != PORT_8250_CIR) block, which prevented
NULL dereference if uart, a pointer to an "uart_8250_port" detected
through "serial8250_find_match_or_unused", were to be NULL.

However, a recent patch added a few bits of code just after that,
and that code manipulates the "uart" pointer without checking if
it's NULL or not.

This patch changes the mechanism and bail out early if no UART
structure pointer is provided serial8250_find_match_or_unused.

A goto is used instead of returning directly, since we're inside
a mutex and must release it correctly.

Signed-off-by: Miouyouyou (Myy) <myy@miouyouyou.fr>
---
 drivers/tty/serial/8250/8250_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 189ab1212..11120c2d9 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -981,7 +981,12 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
        mutex_lock(&serial_mutex);

        uart = serial8250_find_match_or_unused(&up->port);
-       if (uart && uart->port.type != PORT_8250_CIR) {
+       if (!uart) {
+               printk(KERN_INFO "One UART port failed to register correctly\n");
+               goto no_uart;
+       }
+
+       if (uart->port.type != PORT_8250_CIR) {
                if (uart->port.dev)
                        uart_remove_one_port(&serial8250_reg, &uart->port);

@@ -1081,6 +1086,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
                uart->overrun_backoff_time_ms = 0;
        }

+no_uart:
        mutex_unlock(&serial_mutex);

        return ret;
-- 
2.16.4