190 likes | 373 Views
VirtualKd on Linux. Tudor Cornea tudor.cornea@gmail.com. As. Dr. Ing. Răzvan Deaconescu Ing. Cosmin Rohat. Bachelor Presentation Session - July 201 2. Content s. Introduction to Kernel Debugging About the VirtualKd Project Implementation Conclusion & Further work. Project idea :
E N D
VirtualKd on Linux Tudor Corneatudor.cornea@gmail.com As. Dr. Ing. Răzvan Deaconescu Ing. Cosmin Rohat • Bachelor Presentation Session - July 2012
Contents • Introduction to Kernel Debugging • About the VirtualKd Project • Implementation • Conclusion & Further work Bachelor Presentation Session - July2012
Project idea : To speed-up kernel module debugging on Linux, using native VMware communication mechanisms. Bachelor Presentation Session - July 2012
Kernel Debugging: Overview • Traditional approach: “printk debugging” • Easy to use • Low/No overhead • Some errors are difficult to find • Serial port debugging • Better error catching • Requires kernel recompilation • Slow Bachelor Presentation Session - July 2012
Motivation for the VirtualKd Project • Virtual machines emulate the serial port • Problem: Serial port is slow (~20 KB/s) • Why not let the VM hypervisor handle the data transfer? • VirtualKd • GuestRPC • Available for the Windows kernel Bachelor Presentation Session - July 2012
Installing VirtualKd First task: Installing VirtualKd and creating a debugging session on Windows Bachelor Presentation Session - July 2012
Project Overview • Keywords: VMware; virtual console; debugger Bachelor Presentation Session - July 2012
Project Steps • Console driver that captures debugging output on the guest • Sending the debugging output to a process on the host • Attaching a debugger Bachelor Presentation Session - July 2012
Registering a Console • Capturing kernel printk() messages • Registering a virtual console driver • Problem : can not use printk() inside write method (recursive printk’s) • => • Write data in memory • Display it after console is unregistered Bachelor Presentation Session - July 2012
VMware Communication • Used Open-Vm-Tools • VMCI Sockets for VM-Host communication • API similar to BSD sockets • Works on a single physical machine Bachelor Presentation Session - July 2012
VMCI-based Kernel Sender • Two components: • Client • On the guest • Inside a kernel module • Registers a console • Sends debug output through a socket • Server • On the host • User space program • Receives the debug output Bachelor Presentation Session - July 2012
Integrating VMCI into the Console Driver • Issues Encountered • Lack of documentation for Open-Vm-Tools • Kernel panic when sending the data through a socket in write() => Need to disable interrupts • Write() will be called each time a printk() call is made => The protocol between the client and server should be as simple as possible Bachelor Presentation Session - July 2012
Adding debugger support • Debugging solution used: kgdb • Kernel patched with kgdb support • Uses gdb on the Linux kernel • Kernel debugging packets : put_packet(), get_packet() Bachelor Presentation Session - July 2012
Kgdb support • Idea: • Using kprobes API, • register hooks to put_packet/get_packet Bachelor Presentation Session - July 2012
Performance analysis Similar functionality with Netconsole No networking required! Bachelor Presentation Session - July 2012
Results • Installed and configured VirtualKd for Windows • Managed to capture printk() messages • Finished host-guest VMCI communication • Relies on VMCI kernel module => Early boot messages can not be captured Bachelor Presentation Session - July 2012
Conclusion • Not as fast as Netconsole .... but • Still better than using serial port • Can be used in networkless environments • Can potentially be improved, using other VMware communication APIs Bachelor Presentation Session - July 2012
Future Work • Possibly test other VMware transport mechanisms • GuestRPC • VMware Shared Memory API • Capturing “early printk” output • Adding support for a kgdb I/O driver Bachelor Presentation Session - July 2012
Questions Bachelor Presentation Session - July 2012