From 1581b26995c47666b26530dff55307671215ab41 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Fri, 8 Apr 2022 22:24:56 +0200 Subject: [PATCH] Panic: Print location --- 03_hacky_hello_world/README.md | 30 +++++-- 03_hacky_hello_world/src/main.rs | 2 +- 03_hacky_hello_world/src/panic_wait.rs | 19 +++-- 04_safe_globals/README.md | 5 +- 04_safe_globals/src/panic_wait.rs | 19 +++-- 05_drivers_gpio_uart/README.md | 21 ++--- 05_drivers_gpio_uart/src/panic_wait.rs | 19 +++-- 06_uart_chainloader/demo_payload_rpi3.img | Bin 6696 -> 7112 bytes 06_uart_chainloader/demo_payload_rpi4.img | Bin 6536 -> 7000 bytes 06_uart_chainloader/src/panic_wait.rs | 19 +++-- 07_timestamps/README.md | 36 ++++---- 07_timestamps/src/panic_wait.rs | 31 +++---- 08_hw_debug_JTAG/src/panic_wait.rs | 31 +++---- 09_privilege_level/src/panic_wait.rs | 31 +++---- .../src/panic_wait.rs | 31 +++---- 11_exceptions_part1_groundwork/README.md | 78 +++++++++--------- .../src/_arch/aarch64/exception.rs | 2 +- .../src/panic_wait.rs | 31 +++---- 12_integrated_testing/README.md | 14 ++-- .../src/_arch/aarch64/exception.rs | 2 +- 12_integrated_testing/src/panic_wait.rs | 31 +++---- .../src/_arch/aarch64/exception.rs | 2 +- .../src/panic_wait.rs | 31 +++---- .../src/_arch/aarch64/exception.rs | 2 +- .../src/panic_wait.rs | 31 +++---- .../src/_arch/aarch64/exception.rs | 2 +- .../src/panic_wait.rs | 31 +++---- .../src/_arch/aarch64/exception.rs | 2 +- .../src/panic_wait.rs | 31 +++---- X1_JTAG_boot/jtag_boot_rpi3.img | Bin 7840 -> 8104 bytes X1_JTAG_boot/jtag_boot_rpi4.img | Bin 6864 -> 7032 bytes X1_JTAG_boot/src/panic_wait.rs | 31 +++---- 32 files changed, 339 insertions(+), 276 deletions(-) diff --git a/03_hacky_hello_world/README.md b/03_hacky_hello_world/README.md index dffbbb8a..1e764e65 100644 --- a/03_hacky_hello_world/README.md +++ b/03_hacky_hello_world/README.md @@ -24,9 +24,14 @@ QEMU is no longer running in assembly mode. It will from now on show the output ```console $ make qemu [...] + Hello from Rust! +Kernel panic! + +Panic location: + File 'src/main.rs', line 126, column 5 -Kernel panic: Stopping here. +Stopping here. ``` ## Diff to previous @@ -230,7 +235,7 @@ diff -uNr 02_runtime_init/src/main.rs 03_hacky_hello_world/src/main.rs /// - Only a single core must be active and running this function. unsafe fn kernel_init() -> ! { - panic!() -+ println!("[0] Hello from Rust!"); ++ println!("Hello from Rust!"); + + panic!("Stopping here.") } @@ -238,7 +243,7 @@ diff -uNr 02_runtime_init/src/main.rs 03_hacky_hello_world/src/main.rs diff -uNr 02_runtime_init/src/panic_wait.rs 03_hacky_hello_world/src/panic_wait.rs --- 02_runtime_init/src/panic_wait.rs +++ 03_hacky_hello_world/src/panic_wait.rs -@@ -4,14 +4,52 @@ +@@ -4,14 +4,61 @@ //! A panic handler that infinitely waits. @@ -285,11 +290,20 @@ diff -uNr 02_runtime_init/src/panic_wait.rs 03_hacky_hello_world/src/panic_wait. + // Protect against panic infinite loops if any of the following code panics itself. + panic_prevent_reenter(); + -+ if let Some(args) = info.message() { -+ println!("\nKernel panic: {}", args); -+ } else { -+ println!("\nKernel panic!"); -+ } ++ let (location, line, column) = match info.location() { ++ Some(loc) => (loc.file(), loc.line(), loc.column()), ++ _ => ("???", 0, 0), ++ }; ++ ++ println!( ++ "Kernel panic!\n\n\ ++ Panic location:\n File '{}', line {}, column {}\n\n\ ++ {}", ++ location, ++ line, ++ column, ++ info.message().unwrap_or(&format_args!("")), ++ ); + cpu::wait_forever() } diff --git a/03_hacky_hello_world/src/main.rs b/03_hacky_hello_world/src/main.rs index 7a3957dd..da450139 100644 --- a/03_hacky_hello_world/src/main.rs +++ b/03_hacky_hello_world/src/main.rs @@ -121,7 +121,7 @@ mod print; /// /// - Only a single core must be active and running this function. unsafe fn kernel_init() -> ! { - println!("[0] Hello from Rust!"); + println!("Hello from Rust!"); panic!("Stopping here.") } diff --git a/03_hacky_hello_world/src/panic_wait.rs b/03_hacky_hello_world/src/panic_wait.rs index e37724a4..fb30e8d4 100644 --- a/03_hacky_hello_world/src/panic_wait.rs +++ b/03_hacky_hello_world/src/panic_wait.rs @@ -45,11 +45,20 @@ fn panic(info: &PanicInfo) -> ! { // Protect against panic infinite loops if any of the following code panics itself. panic_prevent_reenter(); - if let Some(args) = info.message() { - println!("\nKernel panic: {}", args); - } else { - println!("\nKernel panic!"); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + println!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/04_safe_globals/README.md b/04_safe_globals/README.md index 83e1a45c..b42be642 100644 --- a/04_safe_globals/README.md +++ b/04_safe_globals/README.md @@ -244,11 +244,12 @@ diff -uNr 03_hacky_hello_world/src/main.rs 04_safe_globals/src/main.rs /// /// - Only a single core must be active and running this function. unsafe fn kernel_init() -> ! { +- println!("Hello from Rust!"); + use console::interface::Statistics; -+ - println!("[0] Hello from Rust!"); - panic!("Stopping here.") ++ println!("[0] Hello from Rust!"); ++ + println!( + "[1] Chars written: {}", + bsp::console::console().chars_written() diff --git a/04_safe_globals/src/panic_wait.rs b/04_safe_globals/src/panic_wait.rs index e37724a4..fb30e8d4 100644 --- a/04_safe_globals/src/panic_wait.rs +++ b/04_safe_globals/src/panic_wait.rs @@ -45,11 +45,20 @@ fn panic(info: &PanicInfo) -> ! { // Protect against panic infinite loops if any of the following code panics itself. panic_prevent_reenter(); - if let Some(args) = info.message() { - println!("\nKernel panic: {}", args); - } else { - println!("\nKernel panic!"); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + println!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/05_drivers_gpio_uart/README.md b/05_drivers_gpio_uart/README.md index 44e5aadf..aa39cbaa 100644 --- a/05_drivers_gpio_uart/README.md +++ b/05_drivers_gpio_uart/README.md @@ -1446,18 +1446,15 @@ diff -uNr 04_safe_globals/src/panic_wait.rs 05_drivers_gpio_uart/src/panic_wait. /// Stop immediately if called a second time. /// /// # Note -@@ -46,9 +62,9 @@ - panic_prevent_reenter(); - - if let Some(args) = info.message() { -- println!("\nKernel panic: {}", args); -+ panic_println!("\nKernel panic: {}", args); - } else { -- println!("\nKernel panic!"); -+ panic_println!("\nKernel panic!"); - } - - cpu::wait_forever() +@@ -50,7 +66,7 @@ + _ => ("???", 0, 0), + }; + +- println!( ++ panic_println!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", diff -uNr 04_safe_globals/tests/boot_test_string.rb 05_drivers_gpio_uart/tests/boot_test_string.rb --- 04_safe_globals/tests/boot_test_string.rb diff --git a/05_drivers_gpio_uart/src/panic_wait.rs b/05_drivers_gpio_uart/src/panic_wait.rs index e879b5b3..e546b06d 100644 --- a/05_drivers_gpio_uart/src/panic_wait.rs +++ b/05_drivers_gpio_uart/src/panic_wait.rs @@ -61,11 +61,20 @@ fn panic(info: &PanicInfo) -> ! { // Protect against panic infinite loops if any of the following code panics itself. panic_prevent_reenter(); - if let Some(args) = info.message() { - panic_println!("\nKernel panic: {}", args); - } else { - panic_println!("\nKernel panic!"); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/06_uart_chainloader/demo_payload_rpi3.img b/06_uart_chainloader/demo_payload_rpi3.img index b95058e4377a7f061a86cb39025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$_E2pOYOc(jK#K)0j;)yp~*> zHxsIhLpT=ft5)|=b_d9+e%t238eBM;~~?} z*Q;xfmW|rH&p~0%uakCLEZu*^d%bI*sZ!HFQxhN=9F1%R6pmmL`_V=f)-m%ME5BX? zgz8b-g;#<6^X3||^e&Jy&wErnG+#8fpIO%0CeUui1fku?qwVL5~Dacxmt>U7C??)>`JgG-Rzb^!e0`C9TeeH}KM^PR-beAaoQkb0ZB- zF`WZ%D8h(olcl53g=1o}NWZd%%8(jZ3)b%@@D?&Ay^`!NNpX^JlCo`Cd&(R)j z6KtUo1}gxgK53xB#ptDPS8R>zI|`ofL)!Beq*vQ|pTk(Ww?ILK@#Nyiq z>5?^xC{1yo#WNo0O+*_`c*b-4fNYrXjML9z0Cj08XdQzW>*FNzE<~n}Q1+KpMBVY&4>ihYl7)J)1TD$IdUxKd?&;RSS>*$X;aQT&w2;jYd%FIXt}Y z(Sv=l!N%dkDxI-QQAb^rr~4a^>K@;v8jU4Z&!?KVRTKwfgZp1ZNvEc#*YqB1Y-+@> z3iMVOuBtXWbT2W3PtZ+V-sX>90Jqy%&n=#lN6Y0PkChoS$2yC1<0HcNNJ)ni;c3zv+-# zU5&1LWkoSf;GyBz;5W1knw`>jTzlAiWm3+yZr4dIPZkXteT(>*w!JVs_`(72p}xV` cKA#E3HNA38?+fxRUejuISLGPuId|i~0W&8^V*mgE diff --git a/06_uart_chainloader/demo_payload_rpi4.img b/06_uart_chainloader/demo_payload_rpi4.img index 33debd906b54faf573ba0976cffd27da54c1c226..9f463d32d7dd4c60080c8b92f3b298fa1d8f9d4c 100755 GIT binary patch delta 3099 zcmb_deN0=|6+ibq+dP|3^JRl0{0s$RzQ)o5ai)d`geH(i=?qgfF$E~g0s%}RSz0ZP z?378NKvcgxw5GIKL(!BztADhLBE^-~Ql(S7EUQLYXjHA5O{K}eJ^~2@H^AGu&yOtY zADt%kN>BHlbI(2JcRugXqqi#kStehpNC4h(OqGgx737O|fBZSg_*e&HDwEF=LtlY7 z$A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#=8A1OK8WAv zA5@k>tt@TTN>6EZgxMS`h@L}H9Q%MCS6ry^XmLGCav`304b#!%cpG&R1}(91ORAF< zC+>I2saX&MK_aKD6P>wk96alUA;_F+u_0L9s--?|X*(c=0iND3@?Ye!d081OZS~R}lod>` zhlEf5I3k+hcWhW@^ZC2Gnzzw3*8MFehiCrzAf4Mpu!lI+k8opneMSyB%C`Cmq^yt( z`7@BRyteP^Ti|TEsj%kIbJfD3!PjtKkNbq@s;>`sl*tYNWj)05 zBDB@fE|kwU@aPaHq7L-@8d=j8@;XK$bovI+T9#NNw5&z;IO5qnBE~wdA^!gYjv!*Q zj(DP0N651=iL;ALLyjZ&2r)*%059Ubka(EKcLL(DRzkT(FJUdspiERRp=Rq!XAWPw z)Z3WyF3dPy*(nQV+@km#MO@T-Ip7G9W;2RDw$Q1zHtYQB&L_`(<(IFOo5&V>d4Z23 zsV$#QV_#|O_{hL_kMxI!nnsRm^zL$Hp`t!?LKnj)L|dnH8V5#OpXu(_U>pe#9XyIB zS9Lj~F85SZOA|gM@V9d1kh8ips~?x>$DcWsQD^-#PWC|HD%07bwwgp)=bLo?^E$l- z9@QT@>q}4QY`hz_h3qY^dTzWzdC65@`BibjIE(byNOJlC_GSOg@i7*L6>{t{29@@R)@87#B!~&-kPu%K#bd! g*~+HIL05sit6Mv!(@uSF@A!eZV|Q1Nvdu027qbFPt^fc4 diff --git a/06_uart_chainloader/src/panic_wait.rs b/06_uart_chainloader/src/panic_wait.rs index e879b5b3..e546b06d 100644 --- a/06_uart_chainloader/src/panic_wait.rs +++ b/06_uart_chainloader/src/panic_wait.rs @@ -61,11 +61,20 @@ fn panic(info: &PanicInfo) -> ! { // Protect against panic infinite loops if any of the following code panics itself. panic_prevent_reenter(); - if let Some(args) = info.message() { - panic_println!("\nKernel panic: {}", args); - } else { - panic_println!("\nKernel panic!"); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/07_timestamps/README.md b/07_timestamps/README.md index bfd2ee14..0af0b046 100644 --- a/07_timestamps/README.md +++ b/07_timestamps/README.md @@ -635,7 +635,7 @@ diff -uNr 06_uart_chainloader/src/main.rs 07_timestamps/src/main.rs diff -uNr 06_uart_chainloader/src/panic_wait.rs 07_timestamps/src/panic_wait.rs --- 06_uart_chainloader/src/panic_wait.rs +++ 07_timestamps/src/panic_wait.rs -@@ -58,13 +58,26 @@ +@@ -58,18 +58,23 @@ #[panic_handler] fn panic(info: &PanicInfo) -> ! { @@ -645,25 +645,21 @@ diff -uNr 06_uart_chainloader/src/panic_wait.rs 07_timestamps/src/panic_wait.rs panic_prevent_reenter(); + let timestamp = crate::time::time_manager().uptime(); -+ - if let Some(args) = info.message() { -- panic_println!("\nKernel panic: {}", args); -+ panic_println!( -+ "[ {:>3}.{:06}] Kernel panic: {}", -+ timestamp.as_secs(), -+ timestamp.subsec_micros(), -+ args, -+ ); - } else { -- panic_println!("\nKernel panic!"); -+ panic_println!( -+ "[ {:>3}.{:06}] Kernel panic!", -+ timestamp.as_secs(), -+ timestamp.subsec_micros(), -+ ); - } - - cpu::wait_forever() + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( +- "Kernel panic!\n\n\ ++ "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", ++ timestamp.as_secs(), ++ timestamp.subsec_micros(), + location, + line, + column, diff -uNr 06_uart_chainloader/src/print.rs 07_timestamps/src/print.rs --- 06_uart_chainloader/src/print.rs diff --git a/07_timestamps/src/panic_wait.rs b/07_timestamps/src/panic_wait.rs index 3c57f562..f851e0d8 100644 --- a/07_timestamps/src/panic_wait.rs +++ b/07_timestamps/src/panic_wait.rs @@ -64,21 +64,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/08_hw_debug_JTAG/src/panic_wait.rs b/08_hw_debug_JTAG/src/panic_wait.rs index 3c57f562..f851e0d8 100644 --- a/08_hw_debug_JTAG/src/panic_wait.rs +++ b/08_hw_debug_JTAG/src/panic_wait.rs @@ -64,21 +64,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/09_privilege_level/src/panic_wait.rs b/09_privilege_level/src/panic_wait.rs index 3c57f562..f851e0d8 100644 --- a/09_privilege_level/src/panic_wait.rs +++ b/09_privilege_level/src/panic_wait.rs @@ -64,21 +64,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/10_virtual_mem_part1_identity_mapping/src/panic_wait.rs b/10_virtual_mem_part1_identity_mapping/src/panic_wait.rs index 3c57f562..f851e0d8 100644 --- a/10_virtual_mem_part1_identity_mapping/src/panic_wait.rs +++ b/10_virtual_mem_part1_identity_mapping/src/panic_wait.rs @@ -64,21 +64,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/11_exceptions_part1_groundwork/README.md b/11_exceptions_part1_groundwork/README.md index 8d18d616..4df5c939 100644 --- a/11_exceptions_part1_groundwork/README.md +++ b/11_exceptions_part1_groundwork/README.md @@ -313,7 +313,7 @@ for each exception yet, a default handler is provided: /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); @@ -413,33 +413,37 @@ Minipush 1.0 [MP] ⏩ Pushing 64 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00 [ML] Loaded! Executing the payload now -[ 0.789853] mingo version 0.11.0 -[ 0.790060] Booting on: Raspberry Pi 3 -[ 0.790515] MMU online. Special regions: -[ 0.790992] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data -[ 0.792010] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO -[ 0.792899] Current privilege level: EL1 -[ 0.793375] Exception handling state: -[ 0.793819] Debug: Masked -[ 0.794209] SError: Masked -[ 0.794599] IRQ: Masked -[ 0.794989] FIQ: Masked -[ 0.795379] Architectural timer resolution: 52 ns -[ 0.795954] Drivers loaded: -[ 0.796289] 1. BCM GPIO -[ 0.796647] 2. BCM PL011 UART -[ 0.797070] Timer test, spinning for 1 second -[ 1.797600] -[ 1.797604] Trying to read from address 8 GiB... -[ 1.798154] ************************************************ -[ 1.798846] Whoa! We recovered from a synchronous exception! -[ 1.799539] ************************************************ -[ 1.800233] -[ 1.800406] Let's try again -[ 1.800742] Trying to read from address 9 GiB... -[ 1.801306] Kernel panic: +[ 0.787414] mingo version 0.11.0 +[ 0.787621] Booting on: Raspberry Pi 3 +[ 0.788076] MMU online. Special regions: +[ 0.788553] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data +[ 0.789571] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO +[ 0.790460] Current privilege level: EL1 +[ 0.790936] Exception handling state: +[ 0.791380] Debug: Masked +[ 0.791770] SError: Masked +[ 0.792160] IRQ: Masked +[ 0.792550] FIQ: Masked +[ 0.792940] Architectural timer resolution: 52 ns +[ 0.793514] Drivers loaded: +[ 0.793850] 1. BCM GPIO +[ 0.794208] 2. BCM PL011 UART +[ 0.794630] Timer test, spinning for 1 second +[ 1.795161] +[ 1.795165] Trying to read from address 8 GiB... +[ 1.795715] ************************************************ +[ 1.796407] Whoa! We recovered from a synchronous exception! +[ 1.797100] ************************************************ +[ 1.797794] +[ 1.797967] Let's try again +[ 1.798303] Trying to read from address 9 GiB... +[ 1.798867] Kernel panic! + +Panic location: + File 'src/_arch/aarch64/exception.rs', line 58, column 5 CPU Exception! + ESR_EL1: 0x96000004 Exception Class (EC) : 0x25 - Data Abort, current EL Instr Specific Syndrome (ISS): 0x4 @@ -459,21 +463,21 @@ SPSR_EL1: 0x600003c5 ELR_EL1: 0x0000000000082194 General purpose register: - x0 : 0x0000000000000000 x1 : 0x000000000008555f - x2 : 0x0000000000000027 x3 : 0x000000000008435c - x4 : 0x0000000000000006 x5 : 0x3f27329c00000000 - x6 : 0x0000000000000000 x7 : 0xd3d1b900228f0241 - x8 : 0x0000000240000000 x9 : 0x000000000008555f + x0 : 0x0000000000000000 x1 : 0x0000000000085517 + x2 : 0x0000000000000027 x3 : 0x0000000000084380 + x4 : 0x0000000000000006 x5 : 0xfb5f341800000000 + x6 : 0x0000000000000000 x7 : 0x7f91bc012b2b0209 + x8 : 0x0000000240000000 x9 : 0x0000000000085517 x10: 0x0000000000000443 x11: 0x000000003f201000 x12: 0x0000000000000019 x13: 0x00000000ffffd8f0 x14: 0x000000000000147b x15: 0x00000000ffffff9c x16: 0x000000000007fd38 x17: 0x0000000005f5e0ff - x18: 0x0000000000000034 x19: 0x0000000000090008 - x20: 0x0000000000085398 x21: 0x000000003b9aca00 - x22: 0x0000000000082e30 x23: 0x0000000000082308 + x18: 0x0000000000000030 x19: 0x0000000000090008 + x20: 0x0000000000085350 x21: 0x000000003b9aca00 + x22: 0x0000000000082e4c x23: 0x0000000000082308 x24: 0x0000000010624dd3 x25: 0xffffffffc4653600 - x26: 0x00000000000866b8 x27: 0x0000000000085458 - x28: 0x0000000000084fe0 x29: 0x0000000000086770 + x26: 0x0000000000086638 x27: 0x0000000000085410 + x28: 0x0000000000084f90 x29: 0x0000000000086538 lr : 0x0000000000082188 ``` @@ -546,7 +550,7 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +/// Prints verbose information about the exception and then panics. +fn default_exception_handler(exc: &ExceptionContext) { + panic!( -+ "\n\nCPU Exception!\n\ ++ "CPU Exception!\n\n\ + {}", + exc + ); diff --git a/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs b/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs index f8178210..e8484938 100644 --- a/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs +++ b/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs @@ -56,7 +56,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/11_exceptions_part1_groundwork/src/panic_wait.rs b/11_exceptions_part1_groundwork/src/panic_wait.rs index 3c57f562..f851e0d8 100644 --- a/11_exceptions_part1_groundwork/src/panic_wait.rs +++ b/11_exceptions_part1_groundwork/src/panic_wait.rs @@ -64,21 +64,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() } diff --git a/12_integrated_testing/README.md b/12_integrated_testing/README.md index 5de7c0ef..8a20a0d5 100644 --- a/12_integrated_testing/README.md +++ b/12_integrated_testing/README.md @@ -856,10 +856,14 @@ Compiling integration test(s) - rpi3 🦀 Testing synchronous exception handling by causing a page fault ------------------------------------------------------------------- - [ 0.163030] Writing beyond mapped area to address 9 GiB... - [ 0.164791] Kernel panic: + [ 0.132792] Writing beyond mapped area to address 9 GiB... + [ 0.134563] Kernel panic! + + Panic location: + File 'src/_arch/aarch64/exception.rs', line 58, column 5 CPU Exception! + ESR_EL1: 0x96000004 Exception Class (EC) : 0x25 - Data Abort, current EL [...] @@ -1753,9 +1757,9 @@ diff -uNr 11_exceptions_part1_groundwork/src/panic_wait.rs 12_integrated_testing } #[panic_handler] -@@ -80,5 +97,5 @@ - ); - } +@@ -81,5 +98,5 @@ + info.message().unwrap_or(&format_args!("")), + ); - cpu::wait_forever() + _panic_exit() diff --git a/12_integrated_testing/src/_arch/aarch64/exception.rs b/12_integrated_testing/src/_arch/aarch64/exception.rs index e15dc7a0..e84699e1 100644 --- a/12_integrated_testing/src/_arch/aarch64/exception.rs +++ b/12_integrated_testing/src/_arch/aarch64/exception.rs @@ -56,7 +56,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/12_integrated_testing/src/panic_wait.rs b/12_integrated_testing/src/panic_wait.rs index a1b090d7..6f09f11c 100644 --- a/12_integrated_testing/src/panic_wait.rs +++ b/12_integrated_testing/src/panic_wait.rs @@ -81,21 +81,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); _panic_exit() } diff --git a/13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/exception.rs b/13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/exception.rs index 18441018..495dba34 100644 --- a/13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/exception.rs +++ b/13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/exception.rs @@ -57,7 +57,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/13_exceptions_part2_peripheral_IRQs/src/panic_wait.rs b/13_exceptions_part2_peripheral_IRQs/src/panic_wait.rs index 787bc7dc..08d7d453 100644 --- a/13_exceptions_part2_peripheral_IRQs/src/panic_wait.rs +++ b/13_exceptions_part2_peripheral_IRQs/src/panic_wait.rs @@ -83,21 +83,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); _panic_exit() } diff --git a/14_virtual_mem_part2_mmio_remap/src/_arch/aarch64/exception.rs b/14_virtual_mem_part2_mmio_remap/src/_arch/aarch64/exception.rs index 18441018..495dba34 100644 --- a/14_virtual_mem_part2_mmio_remap/src/_arch/aarch64/exception.rs +++ b/14_virtual_mem_part2_mmio_remap/src/_arch/aarch64/exception.rs @@ -57,7 +57,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/14_virtual_mem_part2_mmio_remap/src/panic_wait.rs b/14_virtual_mem_part2_mmio_remap/src/panic_wait.rs index 787bc7dc..08d7d453 100644 --- a/14_virtual_mem_part2_mmio_remap/src/panic_wait.rs +++ b/14_virtual_mem_part2_mmio_remap/src/panic_wait.rs @@ -83,21 +83,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); _panic_exit() } diff --git a/15_virtual_mem_part3_precomputed_tables/src/_arch/aarch64/exception.rs b/15_virtual_mem_part3_precomputed_tables/src/_arch/aarch64/exception.rs index 18441018..495dba34 100644 --- a/15_virtual_mem_part3_precomputed_tables/src/_arch/aarch64/exception.rs +++ b/15_virtual_mem_part3_precomputed_tables/src/_arch/aarch64/exception.rs @@ -57,7 +57,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/15_virtual_mem_part3_precomputed_tables/src/panic_wait.rs b/15_virtual_mem_part3_precomputed_tables/src/panic_wait.rs index 787bc7dc..08d7d453 100644 --- a/15_virtual_mem_part3_precomputed_tables/src/panic_wait.rs +++ b/15_virtual_mem_part3_precomputed_tables/src/panic_wait.rs @@ -83,21 +83,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); _panic_exit() } diff --git a/16_virtual_mem_part4_higher_half_kernel/src/_arch/aarch64/exception.rs b/16_virtual_mem_part4_higher_half_kernel/src/_arch/aarch64/exception.rs index 18441018..495dba34 100644 --- a/16_virtual_mem_part4_higher_half_kernel/src/_arch/aarch64/exception.rs +++ b/16_virtual_mem_part4_higher_half_kernel/src/_arch/aarch64/exception.rs @@ -57,7 +57,7 @@ struct ExceptionContext { /// Prints verbose information about the exception and then panics. fn default_exception_handler(exc: &ExceptionContext) { panic!( - "\n\nCPU Exception!\n\ + "CPU Exception!\n\n\ {}", exc ); diff --git a/16_virtual_mem_part4_higher_half_kernel/src/panic_wait.rs b/16_virtual_mem_part4_higher_half_kernel/src/panic_wait.rs index 787bc7dc..08d7d453 100644 --- a/16_virtual_mem_part4_higher_half_kernel/src/panic_wait.rs +++ b/16_virtual_mem_part4_higher_half_kernel/src/panic_wait.rs @@ -83,21 +83,22 @@ fn panic(info: &PanicInfo) -> ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); _panic_exit() } diff --git a/X1_JTAG_boot/jtag_boot_rpi3.img b/X1_JTAG_boot/jtag_boot_rpi3.img index 9fcd693ec7b0fc4bda4a744f682aa366843ed900..14b22a47c71443e49155f7e5c782e9f24bb121bc 100755 GIT binary patch delta 2334 zcmah~eN0nV6u+;JVq2hm6alHU54%|&D4?K-A5bJ4SZ8!~#w9wzRJIZkN!870v~^_B zWhVCSGTC%la3<4Rbi*+dx+R;0EYs`{XB>-vm{`z1S~@?cj&8!+x$nI?H8VTO>v`wi zbI<*qbAIQwXUWOhz%;|T8q6WoSBPq{ZQcgE7Ig_o_*LrEUYgjQN&k8)i;g#$=)<+y z^#01JR0pp5!M)Y32vs%-{IDcRxgzqr^n*3k*J}CUqVS?&Jv_;Id#IhoEH(Ia345G;SkLWlN8xRUO z?^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OIxt^<;v4*_C zzBXEp>UTto!_g|pFb8b(0+zz>_h$#den&<&X`_Thf>M?wZ(m5^C+(%Ey4Ts!V$aL# zqG$o|XK!LCafQ3J(+$}_dkj+Is6H@ucm&|Z6Ape&L_0Tz*9W|Ze>=vn)hCav>G8`H z!6J>-ha0!MZ|f6hg2K#FXtGLQz95RTel0AX{B}CnQE(wN{qdzaUH&IQ-S^i*TQ11D zx8J#)IR?uaQGDp7M!JC=NqRxZYysWCv*6$%x>-jAi4cjHu0f!G)N#T_Ib^4$Ixvps z_hV?Q5kwz^vmWAK{z4N8j+#mvJp`5wun_d5U|B!)*3vYTHQNz{w7((R583hFZi3|z z8IXO+z#;onD2*tu+m}28DA6YEA~f9tS&0nYpo4yn_WN)@Ht3{jZ@#d31hS0)rMmpE zf@}oQcFJglIT<032oafts0&eME+axjB6xu_K~?U2Q(iaMpoGsMyL(}W)15ohNCnsVddL|uArIBC&$0jep7 zo7Thu%A*{bucRq-^5PswMk0^1g$X2MNO)*Bo&$j^vYzzNnn&Vn65vXQY_Ggynf6q< z6t7g?J1f|C#kDO?z}huJIyV}DTGaD|4#cqGB1j;IBomr(@zTqPI-!mx+kn2$tR)@I z*oFJ2fj)=>z3&5I6FW18op|6QLgz;}<_tK)3pm4an^PY7A$0kXO{b;!vmSVQ|cJ`qDf93p8 zsJPu#WzMclj}pI7X9RT;A>`X#d>msEXK)h9wjKGtWgFqK&p1FIVF6_l0iOKXKw zJ;-HL)yF_%g{;d|$we(})KndQ$?>M6dpI;c{GQ{~;P}Xp({NV>jMF2pUsOFu)T)}e zNWI5@8F@X)FYzD0qA~=aL07_3whvg$+` ! { panic_prevent_reenter(); let timestamp = crate::time::time_manager().uptime(); - - if let Some(args) = info.message() { - panic_println!( - "[ {:>3}.{:06}] Kernel panic: {}", - timestamp.as_secs(), - timestamp.subsec_micros(), - args, - ); - } else { - panic_println!( - "[ {:>3}.{:06}] Kernel panic!", - timestamp.as_secs(), - timestamp.subsec_micros(), - ); - } + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + + panic_println!( + "[ {:>3}.{:06}] Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + {}", + timestamp.as_secs(), + timestamp.subsec_micros(), + location, + line, + column, + info.message().unwrap_or(&format_args!("")), + ); cpu::wait_forever() }