virtualkd on linux

19
Author “POLITEHNIC A” University of Bucharest Automatic Control and Computers Faculty Computer Science Departmen t Scientific Advisors VirtualKd on Linux Tudor Cornea [email protected] As. Dr. Ing. Răzvan Deaconescu Ing. Cosmin Rohat Bachelor Presentation Session - July 2012

Upload: gay-calhoun

Post on 30-Dec-2015

51 views

Category:

Documents


1 download

DESCRIPTION

VirtualKd on Linux. Tudor Cornea [email protected]. 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 : - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: VirtualKd on Linux

Author

“POLITEHNICA” University of

Bucharest

Automatic Control and Computers

Faculty

Computer Science

Department

Scientific Advisors

VirtualKd on Linux

Tudor [email protected]

As. Dr. Ing. Răzvan DeaconescuIng. Cosmin Rohat

Bachelor Presentation Session - July 2012

Page 2: VirtualKd on Linux

Contents

• Introduction to Kernel Debugging• About the VirtualKd Project• Implementation• Conclusion & Further work

19.04.23 Bachelor Presentation Session - July 2012 2

Page 3: VirtualKd on Linux

• Project idea : To speed-up kernel module debugging on

Linux, using native VMware communication mechanisms.

19.04.23 Bachelor Presentation Session - July 2012 3

Page 4: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 4

Page 5: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 5

Page 6: VirtualKd on Linux

Installing VirtualKd

19.04.23 Bachelor Presentation Session - July 2012 6

First task: Installing VirtualKd and creating a debugging session on Windows

Page 7: VirtualKd on Linux

Project Overview

19.04.23 Bachelor Presentation Session - July 2012 7

• Keywords: VMware; virtual console; debugger

Page 8: VirtualKd on Linux

Project Steps

1. Console driver that captures debugging output on the guest

2. Sending the debugging output to a process on the host

3. Attaching a debugger

19.04.23 Bachelor Presentation Session - July 2012 8

Page 9: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 9

Page 10: VirtualKd on Linux

VMware Communication

• Used Open-Vm-Tools

• VMCI Sockets for VM-Host communication

• API similar to BSD sockets• Works on a single physical machine

19.04.23 Bachelor Presentation Session - July 2012 10

Page 11: VirtualKd on Linux

VMCI-based Kernel Sender

19.04.23 Bachelor Presentation Session - July 2012 11

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

Page 12: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 12

Page 13: VirtualKd on Linux

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()

19.04.23 Bachelor Presentation Session - July 2012 13

Page 14: VirtualKd on Linux

Kgdb support

19.04.23 Bachelor Presentation Session - July 2012 14

Idea:Using kprobes API, register hooks to put_packet/get_packet

Page 15: VirtualKd on Linux

Performance analysis

19.04.23 Bachelor Presentation Session - July 2012 15

Solution Average Transfer Rate (KB/s)

Netconsole 600

VirtualKd on Linux 350-400

Serial Port 30

Similar functionality with Netconsole

No networking required!

Page 16: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 16

Page 17: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 17

Page 18: VirtualKd on Linux

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

19.04.23 Bachelor Presentation Session - July 2012 18

Page 19: VirtualKd on Linux

Questions

19.04.23 Bachelor Presentation Session - July 2012 19