SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Kernel debug log and
console on openSUSE
August, 2019, Taipei, COSCUP
Joey Lee
SUSE Labs Taipei
2
Agenda
• Kernel log
• Consoles
• Q&A
3
Kernel log buffer and consoles
Kernel log
5
Kernel log
6
Kernel log buffer
• SLE15 / openSUSE Leap 15.1
‒ CONFIG_LOG_BUF_SHIFT=18
‒ CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13
‒ 2^18 = 256KB
• log_buf_len=n[KMG]
‒ Sets the size of the printk ring buffer,
‒ in bytes. n must be a power of two and greater than the
minimal size. The minimal size is defined by
LOG_BUF_SHIFT kernel config parameter. There is also
CONFIG_LOG_CPU_MAX_BUF_SHIFT config parameter
that allows to increase the default size depending on the
number of CPUs. See init/Kconfig for more details. [1]
7
Kernel log buffer (cont.)
• The kmsg is an ring buffer
static char __log_buf[__LOG_BUF_LEN]
__aligned(LOG_ALIGN);
• Protected by spinlock
DEFINE_RAW_SPINLOCK(logbuf_lock);
• /dev/kmsg
[11] = { "kmsg", 0644, &kmsg_fops, 0 },
• dmesg utility accesses /dev/kmsg
8
dmesg
• Print or control the kernel ring buffer
• Default print all /dev/kmsg messages
• Restrict message level
‒ dmesg -l err,warn
‒ dmesg -l info,debug
• Set console level
‒ dmesg -n 8
• Wait for new messages
‒ dmesg -w
• Clear ring buffer
‒ sudo dmesg -C
9
loglevel
• loglevel=0..7
• Console loglevel
• All Kernel Messages with a loglevel smaller than the
console loglevel will be printed to the console.
suppress_message_printing(msg→level)
static bool suppress_message_printing(int level)
{
return (level >= console_loglevel && !ignore_loglevel);
}
10
loglevel defined
• The loglevels are defined as follows:
0 (KERN_EMERG) system is unusable
1 (KERN_ALERT) action must be taken immediately
2 (KERN_CRIT) critical conditions
3 (KERN_ERR) error conditions
4 (KERN_WARNING) warning conditions [quiet]
5 (KERN_NOTICE) normal but significant conditions
6 (KERN_INFO) informational
7 (KERN_DEBUG) debug-level messages [default]
10 (CONSOLE_LOGLEVEL_DEBUG)
11
Kernel parameters for loglevel
• ignore_loglevel
‒ Ignore loglevel setting - this will print /all/ kernel messages to
the console. Useful for debugging. We also add it as printk
module parameter, so users could change it dynamically,
usually by
/sys/module/printk/parameters/ignore_loglevel. [1]
• debug
‒ [KNL] Enable kernel debugging (events log level).
‒ console_loglevel = CONSOLE_LOGLEVEL_DEBUG; // 10
• quiet
‒ [KNL] Disable most log messages
‒ console_loglevel = CONSOLE_LOGLEVEL_QUIET; // 4
12
rsyslog
• The rsyslog overwrites loglevel when booting
• systemctl status rsyslog
• /etc/rsyslog.conf
# set log level 1 (same as in /etc/sysconfig/syslog).
$klogConsoleLogLevel 1
• # cat /proc/sys/kernel/printk
1 4 1 7
13
printk sysfs
• cat /proc/sys/kernel/printk
1 4 1 7
• console_loglevel: messages with a higher priority
than this will be printed to the console
• default_message_loglevel: messages without an
explicit priority will be printed with this priority
• minimum_console_loglevel: minimum (highest)
value to which console_loglevel can be set
• default_console_loglevel: default value for
console_loglevel
14
Default loglevel of SLE/openSUSE
• Kernel config: loglevel=7
‒ CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7
• Grub2 config (grub.cfg): loglevel=4
‒ Kernel parameter: quiet
‒ GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda1
splash=silent quiet showopts"
• rsyslog config (/etc/rsyslog.conf): loglevel=1
‒ $klogConsoleLogLevel 1
• Conclusion
‒ Before rsyslog start: console_loglevel = 4
‒ After rsyslog start: console_loglevel = 1
‒ Please add loglevel=9 or debug, and also “dmesg -n 8” for debugging
15
Dynamic debug
• ddebug_query
‒ [KNL,DYNAMIC_DEBUG] Enable debug messages at
early boot time. See Documentation/dynamic-debug-
howto.txt for details. [1]
‒ Dynamic debug is designed to allow you to dynamically
enable/disable kernel code to obtain additional kernel
information. Currently, if ``CONFIG_DYNAMIC_DEBUG``
is set, then all ``pr_debug()``/``dev_dbg()`` and
``print_hex_dump_debug()``/``print_hex_dump_bytes()``
calls can be dynamically enabled per-callsite. [2]
16
Dynamic debug (cont.)
• Kernel parameter:
'ddebug_query=file drivers/firmware/efi/efi-secret-key.c +p'
'ddebug_query=file kernel/module_signing.c +p; file
crypto/asymmetric_keys/pkcs7_trust.c +p'
• Userland command:
# echo -n 'file drivers/base/firmware_class.c +p' >
/sys/kernel/debug/dynamic_debug/control
# cat /sys/kernel/debug/dynamic_debug/control
17
pr_debug() / dev_dbg()
#if defined(CONFIG_DYNAMIC_DEBUG)
#include <linux/dynamic_debug.h>
#define pr_debug(fmt, ...) 
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#elif defined(DEBUG)
#define pr_debug(fmt, ...) 
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_debug(fmt, ...) 
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
Consoles
19
Consoles
20
earlyprintk
• Serial port: earlyprintk=ttyS0,115200
‒ EFI framebuffer: earlyprintk=efi
‒ VGA: earlyprintk=vga
‒ USB2 debug port: earlyprintk=dbgp
‒ USB3 debug port: earlyprintk=xdbc
• earlyprintk is useful when the kernel crashes before the
normal console is initialized. It is not enabled by default
because it has some cosmetic problems.
‒ It’s a OLD parameter in kernel
• Only one of vga, efi, serial, or usb debug port can be used
at a time.
• early_printk() callers: e820, kaslr, mm(idt), perf
21
earlycon
• Output early console device and options.
• CONFIG_SERIAL_EARLYCON
‒ v3.16 kernel
‒ Support for early consoles with the earlycon parameter. This enables the console
before standard serial driver is probed. The console is enabled when early_param is
processed.
• earlycon
‒ [X86] ACPI SPCR (Serial Port Console Redirection Table)
‒ [ARM64] Device Tree
• earlycon=uart[8250],io,<addr>[,options]
=uart[8250],mmio,<addr>[,options]
...
‒ earlycon=uart,io,0x3f8,115200
• EARLYCON_DECLARE() or OF_EARLYCON_DECLARE() in kernel
‒ Set initial function to __earlycon_table section
22
console
• Output console device and options.
• tty<n>
ttyS<n>[,options]
ttyUSB0[,options]
‒ Serial: console=ttyS0,115200n8
‒ USB: console=ttyUSB0,115200n8
‒ ARM: console=ttyAMA0,115200n8
• Maximum 8 consoles
‒ console_cmdline[MAX_CMDLINECONSOLES]
‒ #define MAX_CMDLINECONSOLES 8
23
Reading messages from consoles
• screen command
‒ # screen /dev/ttyS0 115200
‒ # screen -h 10000 /dev/ttyUSB1 115200
• minicom
‒ # minicom -b 115200 -D /dev/ttyUSB0
24
When can earlcon be enabled?
No console before here
25
The debug log in early booting stage
• For booting
‒ In EFI stub, the efi_printk() log is only for expected error.
‒ In kernel, earlyprintk= or earlycon= only be enabled after
parse_early_param().
‒ “KASLR using” message should be exposed with
earlyprintk= or earlycon=
‒ KASLR (Kernel Address Space Layout Randomization)
• For problems that occur before the serial console
and EFI framebuffer are initialized [4]
‒ Debugging a mysterious reset with an infinite loop
‒ Debugging a hang by triggering a reset
26
DEBUG_LL and ARM
• Kernel low-level debugging functions
• CONFIG_DEBUG_LL
‒ ARM, Unicore32
‒ Say Y here to include definitions of printascii, printch, printhex in the kernel.
This is helpful if you are debugging code that executes before the console is
initialized.
‒ Note that selecting this option will limit the kernel to a single UART definition,
… this option should not be enabled for kernels that are intended to be
portable.
‒ CONFIG_DEBUG_BCM2835 for Raspberry Pi 1
‒ DEBUG_UART_PHYS = 0x20201000, DEBUG_UART_VIRT = 0xf0201000
‒ CONFIG_DEBUG_BCM2836 for Raspberry Pi 2
‒ DEBUG_UART_PHYS = 0x3f201000, DEBUG_UART_VIRT = 0xf0201000
• Should works with CONFIG_EARLY_PRINTK
‒ Enable by earlyprintk kernel parameter
27
netconsole
• This module logs kernel printk messages over UDP
allowing debugging of problem where disk logging fails
and serial consoles are impractical. [3]
• As a built-in, netconsole initializes immediately after NIC
cards and will bring up the specified interface as soon as
possible. While this doesn't allow capture of early kernel
panics, it does capture most of the boot process. [3]
• CONFIG_NETCONSOLE=y
‒ NIC driver must also be build-in
• CONFIG_NETCONSOLE=m
‒ /etc/modules-load.d/netconsole.conf
‒ /etc/modprobe.d/netconsole.conf
28
netconsole (cont.)
• Sender: netconsole=[+][src-port]@[src-ip]/[<dev>],
[tgt-port]@<tgt-ip>/[tgt-macaddr]
netconsole=6665@192.168.1.83/eth0,6666@192.168.1.11
/ab:cd:23:b0:14:b6
netconsole=@192.168.1.83/,@192.168.1.11/
• Receiver: netcat
netcat -k -l -u 192.168.1.11 6666
Q&A
30
Reference
• [1] Documentation/admin-guide/kernel-
parameters.txt, Linux Kernel
• [2] Documentation/admin-guide/dynamic-debug-
howto.rst, Linux Kernel
• [3] Documentation/networking/netconsole.txt, Linux
Kernel
• [4] Early x86 Linux boot debug tricks, Matt Fleming
‒ http://www.codeblueprint.co.uk/2015/04/15/early-x86-linux-
boot-debug-tricks.html
Thank you.
31
Feedback to
jlee@suse.com
Corporate Headquarters
Maxfeldstrasse 5
90409 Nuremberg
Germany
+49 911 740 53 0 (Worldwide)
www.suse.com
Join us on:
www.opensuse.org
33
Unpublished Work of SUSE. All Rights Reserved.
This work is an unpublished work and contains confidential, proprietary and trade secret information of SUSE.
Access to this work is restricted to SUSE employees who have a need to know to perform tasks within the scope of
their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated,
abridged, condensed, expanded, collected, or adapted without the prior written consent of SUSE.
Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability.
General Disclaimer
This document is not to be construed as a promise by any participating company to develop, deliver, or market a
product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making
purchasing decisions. SUSE makes no representations or warranties with respect to the contents of this document,
and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose.
The development, release, and timing of features or functionality described for SUSE products remains at the sole
discretion of SUSE. Further, SUSE reserves the right to revise this document and to make changes to its content, at
any time, without obligation to notify any person or entity of such revisions or changes. All SUSE marks referenced in
this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All
third-party trademarks are the property of their respective owners.

Mais conteúdo relacionado

Mais procurados

Note - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and InstallNote - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and Installboyw165
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisPaul V. Novarese
 
Multi-signed Kernel Module
Multi-signed Kernel ModuleMulti-signed Kernel Module
Multi-signed Kernel ModuleSUSE Labs Taipei
 
/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinityTakuya ASADA
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New HardwareRuggedBoardGroup
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)Linaro
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Adrian Huang
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIAnne Nicolas
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 
kexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorkexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorThe Linux Foundation
 
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3Linaro
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 
Page cache in Linux kernel
Page cache in Linux kernelPage cache in Linux kernel
Page cache in Linux kernelAdrian Huang
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Macpaul Lin
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...Adrian Huang
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...Adrian Huang
 

Mais procurados (20)

Note - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and InstallNote - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and Install
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and Analysis
 
Multi-signed Kernel Module
Multi-signed Kernel ModuleMulti-signed Kernel Module
Multi-signed Kernel Module
 
/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
 
Device tree
Device treeDevice tree
Device tree
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
kexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorkexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisor
 
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
Page cache in Linux kernel
Page cache in Linux kernelPage cache in Linux kernel
Page cache in Linux kernel
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
 

Semelhante a Kernel debug log and console on openSUSE

Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time OptimizationKan-Ru Chen
 
Fast boot
Fast bootFast boot
Fast bootSZ Lin
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugginglibfetion
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyLinaro
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and InsightsGlobalLogic Ukraine
 
QEMU Sandboxing for dummies
QEMU Sandboxing for dummiesQEMU Sandboxing for dummies
QEMU Sandboxing for dummiesEduardo Otubo
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightLinaro
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Jian-Hong Pan
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux AwarenessPeter Griffin
 
Armboot process zeelogic
Armboot process zeelogicArmboot process zeelogic
Armboot process zeelogicAleem Shariff
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingMarian Marinov
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modulesHao-Ran Liu
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopLorin Hochstein
 
Advanced Root Cause Analysis
Advanced Root Cause AnalysisAdvanced Root Cause Analysis
Advanced Root Cause AnalysisEric Sloof
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactAlessandro Selli
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentMohammed Farrag
 

Semelhante a Kernel debug log and console on openSUSE (20)

Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Fast boot
Fast bootFast boot
Fast boot
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
QEMU Sandboxing for dummies
QEMU Sandboxing for dummiesQEMU Sandboxing for dummies
QEMU Sandboxing for dummies
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
 
Armboot process zeelogic
Armboot process zeelogicArmboot process zeelogic
Armboot process zeelogic
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptop
 
101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
 
Advanced Root Cause Analysis
Advanced Root Cause AnalysisAdvanced Root Cause Analysis
Advanced Root Cause Analysis
 
Analisis_avanzado_vmware
Analisis_avanzado_vmwareAnalisis_avanzado_vmware
Analisis_avanzado_vmware
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development
 

Mais de SUSE Labs Taipei

Locked down openSUSE Tumbleweed kernel
Locked down openSUSE Tumbleweed kernelLocked down openSUSE Tumbleweed kernel
Locked down openSUSE Tumbleweed kernelSUSE Labs Taipei
 
SUSE shim and things related to it
SUSE shim and things related to itSUSE shim and things related to it
SUSE shim and things related to itSUSE Labs Taipei
 
The bright future of SUSE and openSUSE
The bright future of SUSE and openSUSEThe bright future of SUSE and openSUSE
The bright future of SUSE and openSUSESUSE Labs Taipei
 
Convert your package to multibuild on Open Build Service
Convert your package to multibuild on Open Build ServiceConvert your package to multibuild on Open Build Service
Convert your package to multibuild on Open Build ServiceSUSE Labs Taipei
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic ControlSUSE Labs Taipei
 
Looking into trusted and encrypted keys
Looking into trusted and encrypted keysLooking into trusted and encrypted keys
Looking into trusted and encrypted keysSUSE Labs Taipei
 
Use bonding driver with ethernet
Use bonding driver with ethernetUse bonding driver with ethernet
Use bonding driver with ethernetSUSE Labs Taipei
 
Use build service API in your program
Use build service API in your programUse build service API in your program
Use build service API in your programSUSE Labs Taipei
 
eBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to UserspaceeBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to UserspaceSUSE Labs Taipei
 
Develop and Maintain a Distro with Open Build Service
Develop and Maintain a Distro with Open Build ServiceDevelop and Maintain a Distro with Open Build Service
Develop and Maintain a Distro with Open Build ServiceSUSE Labs Taipei
 

Mais de SUSE Labs Taipei (18)

Locked down openSUSE Tumbleweed kernel
Locked down openSUSE Tumbleweed kernelLocked down openSUSE Tumbleweed kernel
Locked down openSUSE Tumbleweed kernel
 
SUSE shim and things related to it
SUSE shim and things related to itSUSE shim and things related to it
SUSE shim and things related to it
 
The bright future of SUSE and openSUSE
The bright future of SUSE and openSUSEThe bright future of SUSE and openSUSE
The bright future of SUSE and openSUSE
 
EFI Secure Key
EFI Secure KeyEFI Secure Key
EFI Secure Key
 
eBPF maps 101
eBPF maps 101eBPF maps 101
eBPF maps 101
 
Convert your package to multibuild on Open Build Service
Convert your package to multibuild on Open Build ServiceConvert your package to multibuild on Open Build Service
Convert your package to multibuild on Open Build Service
 
Ixgbe internals
Ixgbe internalsIxgbe internals
Ixgbe internals
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 
Looking into trusted and encrypted keys
Looking into trusted and encrypted keysLooking into trusted and encrypted keys
Looking into trusted and encrypted keys
 
Use bonding driver with ethernet
Use bonding driver with ethernetUse bonding driver with ethernet
Use bonding driver with ethernet
 
Use build service API in your program
Use build service API in your programUse build service API in your program
Use build service API in your program
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
eBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to UserspaceeBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to Userspace
 
S4 sig-check-lpc-20130918
S4 sig-check-lpc-20130918S4 sig-check-lpc-20130918
S4 sig-check-lpc-20130918
 
openSUSE12.2 Review
openSUSE12.2 ReviewopenSUSE12.2 Review
openSUSE12.2 Review
 
oS KDE Repos & MM
oS KDE Repos & MMoS KDE Repos & MM
oS KDE Repos & MM
 
Develop and Maintain a Distro with Open Build Service
Develop and Maintain a Distro with Open Build ServiceDevelop and Maintain a Distro with Open Build Service
Develop and Maintain a Distro with Open Build Service
 
Coscup 2012-urfkill
Coscup 2012-urfkillCoscup 2012-urfkill
Coscup 2012-urfkill
 

Último

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 

Último (20)

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 

Kernel debug log and console on openSUSE

  • 1. Kernel debug log and console on openSUSE August, 2019, Taipei, COSCUP Joey Lee SUSE Labs Taipei
  • 2. 2 Agenda • Kernel log • Consoles • Q&A
  • 3. 3 Kernel log buffer and consoles
  • 6. 6 Kernel log buffer • SLE15 / openSUSE Leap 15.1 ‒ CONFIG_LOG_BUF_SHIFT=18 ‒ CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 ‒ 2^18 = 256KB • log_buf_len=n[KMG] ‒ Sets the size of the printk ring buffer, ‒ in bytes. n must be a power of two and greater than the minimal size. The minimal size is defined by LOG_BUF_SHIFT kernel config parameter. There is also CONFIG_LOG_CPU_MAX_BUF_SHIFT config parameter that allows to increase the default size depending on the number of CPUs. See init/Kconfig for more details. [1]
  • 7. 7 Kernel log buffer (cont.) • The kmsg is an ring buffer static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN); • Protected by spinlock DEFINE_RAW_SPINLOCK(logbuf_lock); • /dev/kmsg [11] = { "kmsg", 0644, &kmsg_fops, 0 }, • dmesg utility accesses /dev/kmsg
  • 8. 8 dmesg • Print or control the kernel ring buffer • Default print all /dev/kmsg messages • Restrict message level ‒ dmesg -l err,warn ‒ dmesg -l info,debug • Set console level ‒ dmesg -n 8 • Wait for new messages ‒ dmesg -w • Clear ring buffer ‒ sudo dmesg -C
  • 9. 9 loglevel • loglevel=0..7 • Console loglevel • All Kernel Messages with a loglevel smaller than the console loglevel will be printed to the console. suppress_message_printing(msg→level) static bool suppress_message_printing(int level) { return (level >= console_loglevel && !ignore_loglevel); }
  • 10. 10 loglevel defined • The loglevels are defined as follows: 0 (KERN_EMERG) system is unusable 1 (KERN_ALERT) action must be taken immediately 2 (KERN_CRIT) critical conditions 3 (KERN_ERR) error conditions 4 (KERN_WARNING) warning conditions [quiet] 5 (KERN_NOTICE) normal but significant conditions 6 (KERN_INFO) informational 7 (KERN_DEBUG) debug-level messages [default] 10 (CONSOLE_LOGLEVEL_DEBUG)
  • 11. 11 Kernel parameters for loglevel • ignore_loglevel ‒ Ignore loglevel setting - this will print /all/ kernel messages to the console. Useful for debugging. We also add it as printk module parameter, so users could change it dynamically, usually by /sys/module/printk/parameters/ignore_loglevel. [1] • debug ‒ [KNL] Enable kernel debugging (events log level). ‒ console_loglevel = CONSOLE_LOGLEVEL_DEBUG; // 10 • quiet ‒ [KNL] Disable most log messages ‒ console_loglevel = CONSOLE_LOGLEVEL_QUIET; // 4
  • 12. 12 rsyslog • The rsyslog overwrites loglevel when booting • systemctl status rsyslog • /etc/rsyslog.conf # set log level 1 (same as in /etc/sysconfig/syslog). $klogConsoleLogLevel 1 • # cat /proc/sys/kernel/printk 1 4 1 7
  • 13. 13 printk sysfs • cat /proc/sys/kernel/printk 1 4 1 7 • console_loglevel: messages with a higher priority than this will be printed to the console • default_message_loglevel: messages without an explicit priority will be printed with this priority • minimum_console_loglevel: minimum (highest) value to which console_loglevel can be set • default_console_loglevel: default value for console_loglevel
  • 14. 14 Default loglevel of SLE/openSUSE • Kernel config: loglevel=7 ‒ CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 • Grub2 config (grub.cfg): loglevel=4 ‒ Kernel parameter: quiet ‒ GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda1 splash=silent quiet showopts" • rsyslog config (/etc/rsyslog.conf): loglevel=1 ‒ $klogConsoleLogLevel 1 • Conclusion ‒ Before rsyslog start: console_loglevel = 4 ‒ After rsyslog start: console_loglevel = 1 ‒ Please add loglevel=9 or debug, and also “dmesg -n 8” for debugging
  • 15. 15 Dynamic debug • ddebug_query ‒ [KNL,DYNAMIC_DEBUG] Enable debug messages at early boot time. See Documentation/dynamic-debug- howto.txt for details. [1] ‒ Dynamic debug is designed to allow you to dynamically enable/disable kernel code to obtain additional kernel information. Currently, if ``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and ``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically enabled per-callsite. [2]
  • 16. 16 Dynamic debug (cont.) • Kernel parameter: 'ddebug_query=file drivers/firmware/efi/efi-secret-key.c +p' 'ddebug_query=file kernel/module_signing.c +p; file crypto/asymmetric_keys/pkcs7_trust.c +p' • Userland command: # echo -n 'file drivers/base/firmware_class.c +p' > /sys/kernel/debug/dynamic_debug/control # cat /sys/kernel/debug/dynamic_debug/control
  • 17. 17 pr_debug() / dev_dbg() #if defined(CONFIG_DYNAMIC_DEBUG) #include <linux/dynamic_debug.h> #define pr_debug(fmt, ...) dynamic_pr_debug(fmt, ##__VA_ARGS__) #elif defined(DEBUG) #define pr_debug(fmt, ...) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug(fmt, ...) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif
  • 20. 20 earlyprintk • Serial port: earlyprintk=ttyS0,115200 ‒ EFI framebuffer: earlyprintk=efi ‒ VGA: earlyprintk=vga ‒ USB2 debug port: earlyprintk=dbgp ‒ USB3 debug port: earlyprintk=xdbc • earlyprintk is useful when the kernel crashes before the normal console is initialized. It is not enabled by default because it has some cosmetic problems. ‒ It’s a OLD parameter in kernel • Only one of vga, efi, serial, or usb debug port can be used at a time. • early_printk() callers: e820, kaslr, mm(idt), perf
  • 21. 21 earlycon • Output early console device and options. • CONFIG_SERIAL_EARLYCON ‒ v3.16 kernel ‒ Support for early consoles with the earlycon parameter. This enables the console before standard serial driver is probed. The console is enabled when early_param is processed. • earlycon ‒ [X86] ACPI SPCR (Serial Port Console Redirection Table) ‒ [ARM64] Device Tree • earlycon=uart[8250],io,<addr>[,options] =uart[8250],mmio,<addr>[,options] ... ‒ earlycon=uart,io,0x3f8,115200 • EARLYCON_DECLARE() or OF_EARLYCON_DECLARE() in kernel ‒ Set initial function to __earlycon_table section
  • 22. 22 console • Output console device and options. • tty<n> ttyS<n>[,options] ttyUSB0[,options] ‒ Serial: console=ttyS0,115200n8 ‒ USB: console=ttyUSB0,115200n8 ‒ ARM: console=ttyAMA0,115200n8 • Maximum 8 consoles ‒ console_cmdline[MAX_CMDLINECONSOLES] ‒ #define MAX_CMDLINECONSOLES 8
  • 23. 23 Reading messages from consoles • screen command ‒ # screen /dev/ttyS0 115200 ‒ # screen -h 10000 /dev/ttyUSB1 115200 • minicom ‒ # minicom -b 115200 -D /dev/ttyUSB0
  • 24. 24 When can earlcon be enabled? No console before here
  • 25. 25 The debug log in early booting stage • For booting ‒ In EFI stub, the efi_printk() log is only for expected error. ‒ In kernel, earlyprintk= or earlycon= only be enabled after parse_early_param(). ‒ “KASLR using” message should be exposed with earlyprintk= or earlycon= ‒ KASLR (Kernel Address Space Layout Randomization) • For problems that occur before the serial console and EFI framebuffer are initialized [4] ‒ Debugging a mysterious reset with an infinite loop ‒ Debugging a hang by triggering a reset
  • 26. 26 DEBUG_LL and ARM • Kernel low-level debugging functions • CONFIG_DEBUG_LL ‒ ARM, Unicore32 ‒ Say Y here to include definitions of printascii, printch, printhex in the kernel. This is helpful if you are debugging code that executes before the console is initialized. ‒ Note that selecting this option will limit the kernel to a single UART definition, … this option should not be enabled for kernels that are intended to be portable. ‒ CONFIG_DEBUG_BCM2835 for Raspberry Pi 1 ‒ DEBUG_UART_PHYS = 0x20201000, DEBUG_UART_VIRT = 0xf0201000 ‒ CONFIG_DEBUG_BCM2836 for Raspberry Pi 2 ‒ DEBUG_UART_PHYS = 0x3f201000, DEBUG_UART_VIRT = 0xf0201000 • Should works with CONFIG_EARLY_PRINTK ‒ Enable by earlyprintk kernel parameter
  • 27. 27 netconsole • This module logs kernel printk messages over UDP allowing debugging of problem where disk logging fails and serial consoles are impractical. [3] • As a built-in, netconsole initializes immediately after NIC cards and will bring up the specified interface as soon as possible. While this doesn't allow capture of early kernel panics, it does capture most of the boot process. [3] • CONFIG_NETCONSOLE=y ‒ NIC driver must also be build-in • CONFIG_NETCONSOLE=m ‒ /etc/modules-load.d/netconsole.conf ‒ /etc/modprobe.d/netconsole.conf
  • 28. 28 netconsole (cont.) • Sender: netconsole=[+][src-port]@[src-ip]/[<dev>], [tgt-port]@<tgt-ip>/[tgt-macaddr] netconsole=6665@192.168.1.83/eth0,6666@192.168.1.11 /ab:cd:23:b0:14:b6 netconsole=@192.168.1.83/,@192.168.1.11/ • Receiver: netcat netcat -k -l -u 192.168.1.11 6666
  • 29. Q&A
  • 30. 30 Reference • [1] Documentation/admin-guide/kernel- parameters.txt, Linux Kernel • [2] Documentation/admin-guide/dynamic-debug- howto.rst, Linux Kernel • [3] Documentation/networking/netconsole.txt, Linux Kernel • [4] Early x86 Linux boot debug tricks, Matt Fleming ‒ http://www.codeblueprint.co.uk/2015/04/15/early-x86-linux- boot-debug-tricks.html
  • 32.
  • 33. Corporate Headquarters Maxfeldstrasse 5 90409 Nuremberg Germany +49 911 740 53 0 (Worldwide) www.suse.com Join us on: www.opensuse.org 33
  • 34. Unpublished Work of SUSE. All Rights Reserved. This work is an unpublished work and contains confidential, proprietary and trade secret information of SUSE. Access to this work is restricted to SUSE employees who have a need to know to perform tasks within the scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of SUSE. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability. General Disclaimer This document is not to be construed as a promise by any participating company to develop, deliver, or market a product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. SUSE makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. The development, release, and timing of features or functionality described for SUSE products remains at the sole discretion of SUSE. Further, SUSE reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All SUSE marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.