© 2009 Wind River Merging KGDB KDB and Kernel Mode Setting Jason Wessel – Wind River Jesse Barnes - Intel.

Slides:



Advertisements
Similar presentations
GDB Improvements for Telecom System. GDBs Strengths, Today Primary debugger for Linux Used by Eclipse for C, C++ debugging –Eclipse communicates with.
Advertisements

User-Mode Linux Ken C.K. Lee
Chapter 6 Limited Direct Execution
3: OS Structures 1 OPERATING SYSTEM STRUCTURES PROCESS MANAGEMENT A process is a program in execution: (A program is passive, a process active.) A process.
Presenter : Chien-Hung Chen Tsung-Cheng Lin Kuan-Fu Kuo EICE team Open On-Chip Debugger Ch6. Design and Architecture.
Operating Systems High Level View Chapter 1,2. Who is the User? End Users Application Programmers System Programmers Administrators.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Dependable computing needs pervasive debugging Tim Harris
2: OS Structures 1 Jerry Breecher OPERATING SYSTEMS STRUCTURES.
OS Spring’03 Introduction Operating Systems Spring 2003.
Figure 1.1 Interaction between applications and the operating system.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Copyright © 2006 Intel Corporation, released under EPL version /20061 Eclipse DSDP-TM Target Connection Adapters Peter Lachner WW08’06 rev 1.0.
Kernel module programming and debugging Advanced Operating Systems.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CHAPTER 9: Input / Output
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Scheduler Activations Jeff Chase. Threads in a Process Threads are useful at user-level – Parallelism, hide I/O latency, interactivity Option A (early.
Cortex-M3 Debugging System
Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://
Debugging techniques in Linux Debugging Techniques in Linux Chetan Kumar S Wipro Technologies.
Host and Application Security Lesson 4: The Win32 Boot Process.
CHAPTER 9: Input / Output
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
Eric Keller, Evan Green Princeton University PRESTO /22/08 Virtualizing the Data Plane Through Source Code Merging.
1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Thread Scheduling.
Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption.
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
Debugging Computer Networks Sep. 26, 2007 Seunghwan Hong.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Intel Open Source Technology Center Lu Baolu 2015/09
Lecture on Central Process Unit (CPU)
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
ChibiOS/RT Demo A free embedded RTOS
ICOM Noack Linux I/O structure Device special files Device switch tables and fops How the kernel finds a device Parts of a device driver or module.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
An operating system (OS) is a collection of system programs that together control the operation of a computer system.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
 Wind River Systems, Inc Chapter - 4 CrossWind.
OPERATING SYSTEMS STRUCTURES Jerry Breecher 2: Operating System Structures 1.
Introduction to Operating Systems Concepts
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardware Application I/O Interface
Processes and threads.
Radare >1.0 &&
Chapter 1: A Tour of Computer Systems
Mechanism: Limited Direct Execution
Chapter 2: System Structures
Kernel Tracing David Ferry, Chris Gill
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
Lecture Topics: 11/1 General Operating System Concepts Processes
Chapter 2: Operating-System Structures
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Why Threads Are A Bad Idea (for most purposes)
OPERATING SYSTEMS STRUCTURES
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Why Threads Are A Bad Idea (for most purposes)
Chapter 2: Operating-System Structures
Interrupts and Interrupt Handling
Why Threads Are A Bad Idea (for most purposes)
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

© 2009 Wind River Merging KGDB KDB and Kernel Mode Setting Jason Wessel – Wind River Jesse Barnes - Intel

© 2009 Wind River 2 The Glossary KGDB – Kernel GDB remote interface – KGDB core merged to mainline kernel in – Generic gdb serial interface for single or multi processor systems, where gdb provides a source view of the system – Works only with a uart based console driver KDB – Kernel debugger – Never merged to mainline kernel and not likely to merge as is – Supports only i386 and x86_64 – Provides a simple debugger via the system console or a serial port, with no high level source KMS – Kernel Mode Settting – Merged to mainline kernel in – Core graphics driver in the kernel provides seamless switch from console to graphics modes (vs reinitializing the HW each time)

© 2009 Wind River 3 The Goal – Let the MERGE BEGIN! A simple, reliable multi-architecture debug shell Works with graphics or serial Ability to use kgdb or kdb Join the KDB and KGDB communities together Provide an API for future command expansion – Trace dumping – Disassembly – Subsystem inspection commands (vfs, network, etc)

© 2009 Wind River 4 An example problem Awe MAN! If only I had a few more lines in the trace...

© 2009 Wind River 5 The debug shell

© 2009 Wind River 6 Basic KGDB design KGDB has 4 main pieces Debug Core – Generic debug API – Handles exceptions – Syncs/saves/restores CPUs – API for SW/HW breakpoints Arch specific KGDB – Interface to read/write registers – Arch specific exceptions and watch dogs – Single stepping interface GDB Stub – Speaks the gdb serial protocol Polled I/O Driver (kgdboc / kgdboe / kgdbou / kgdb_8250) – Uses the console UART driver to multiplex a single serial line – Another host's gdb connects to this port Debug Core GDB Stub Polled I/O Driver Arch Specific KGDB

© 2009 Wind River 7 Basic KDB design KDB has lots of parts 129 files changed, insertions(+), 10 deletions(-) Low Level Arch Specific exceptions kdb_main kdb_io Polled Keyboard driver Polled serial driver Assembly set_jmp() long_jmp() Back tracer Other modules kdump etc... disassembler Single Step BOOM! Crash! Thunk! Splat!

© 2009 Wind River 8 Merging KDB & KGDB The polled keyboard driver hooks into kgdboc The kdb_main, kdb_io and cmd handlers hook straight to the debug core gdb can use “monitor...cmd...” to issue kdb cmds KDB got all the architecture specific pieces removed – KDB core = 27 files changed, 6521 insertions(+), 10 deletions(-) – KGDB changes = 9 files changed, 154 insertions(+), 31 deletions(-) Debug Core kdb_main and kdb_io Polled I/O Driver KGDBOC Arch Specific KGDB GDB Stub KDB Polled Keyboard driver

© 2009 Wind River 9 KMS (kernel mode setting) basics Mode setting refers to changing the graphics console display characteristics, such as the display type/size, screen blanking and graphics hw management Mode setting in userspace causes issues: – suspend/resume – interaction with kernel drivers – Ability to change from X to console on crash (BOSD) KMS paves the way for flicker free console switching Adding in console debugger support becomes desirable to analyse a crash or inspect the system The hard part lies in making KMS work without locks – Take an exception – Transition to console atomically – Run kdb – Restore graphics – Resume system

© 2009 Wind River 10 kgdb + kdb + kms KMS bolts into the debugger via kgdboc entry/exit call backs Configuration of using KMS is dynamic through kgdboc Debug Core kdb kgdboc Arch Specific KGDB GDB Stub KMS Hooks

© 2009 Wind River 11 Demonstration time KGDB, KDB and KMS in < 60 seconds –

© 2009 Wind River 12 But wait there's MORE! How about kgdb + kdb + kms + usb serial

© 2009 Wind River 13 Moving beyond the prototype The first priority is to finish cleaning kdb core and post to LKML – kernel/kgdb.c → kernel/debug/debug_core.c and gdbstub.c – kernel/debug/kdb/* – Rename arch/*/kernel/kgdb.c → arch/*/kernel/debug_arch.c For KMS, there are certainly problems with the locks +++ b/drivers/gpu/drm/drm_crtc.c +#ifdef CONFIG_KGDB + if (atomic_read(&kgdb_active) == -1) +#endif + mutex_lock(&dev->mode_config.idr_mutex); KMS needs some generic debugger API work – Only the Intel 915 works today with kdb – Jesse suggested the possibility for a dedicated debug console

© 2009 Wind River 14 Moving beyond the prototype The USB keyboard driver is UGLY!!! – The low level uchi/ohci/ehci are modified to allow for polloing and pulling off packets of the keyboard type only Anyone want to help with an “alternatives” implementation? – The debugger needs to change some code paths after entry – The debugger should stay out of the way otherwise Low Level exception support – The debug core needs the first right of breakpoint handling – Perhaps code “alternatives”? panic() should allow a debug hook before calling smp_send_stop()

© 2009 Wind River 15 Nested Exception Support Prototype hack for debugging part of the code used by the debugger proves useful – It was possible to debug the KMS code with kgdb so long as on the second exception kgdb jumps directly into the debug core – Without the “hack” the debug core prints a stack dump an panics The kgdb_ll_trap() was introduced by kdb to allow the debug core to step through an atomic_notifier_call_chain It is now a TODO item to consider nested exception debugging because you can also debug parts of the debugger itself

© 2009 Wind River 16 Displaced Stepping? Problems without displaced stepping – Missed breakpoint free all cpus and wait for a thread to get scheduled which uses HW single stepping – Deadlock on lock single stepping by freeing only one CPU, dead locks on any lock held by a frozen CPU Displaced stepping is leaving a break point planted and executing the original instruction out of line – An experimental patch modifies kprobes to plant a probe to single step a kernel thread – The down side is you cannot debug some further small pieces of the kernel

© 2009 Wind River 17 Mainline for kgdboe someday? Today's kgdboe has a major short coming, in that it is not robust Network drivers can be in a state where it is impossible to use them safely from the exception context (preempted with locks held) Possible solutions: – Perhaps a dedicated queue in the HW is the answer (e1000e) – While it would require a dedicated ethernet interface, you could use a self contained, exception safe network stack – A redesigned poll interface

© 2009 Wind River 18 kgdbou (kgdb over usb) It is on the mile long todo list :-) First up is work around improved USB console support – merged USB sysrq support – USB EHCI debug port console (supports early_printk) – Stable USB console support is a work in progress – kgdbou present state is considered “too much of a hack” Kgdb integration can proceed after the console support – On the demo machine there are if (kgdb_activate...) checks in the hot path which would need to resolved by design

© 2009 Wind River 19 The kernel debugger and the future We want to unite the all the of the kernel debugger folks Send patches to The kgdb wiki is slated to launch in late September Special Thanks – Jesse Barnes - for his KMS code – Martin Hicks - (KDB maintainer) for kdb cleanup patches