Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.

Slides:



Advertisements
Similar presentations
Linux device-driver issues
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Computer System Laboratory
Intel MP.
Creating a device-file node An introduction to some privileged Linux system-calls (needed for an upcoming programming exercise)
Operating Systems: Segments 1 Segmentation Hardware Support single user program system: – wish somehow to relocate address 0 to after operating system.
IA-32 Processor Architecture
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
Operating System Structure. Announcements Make sure you are registered for CS 415 First CS 415 project is up –Initial design documents due next Friday,
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
November 1, 2004Introduction to Computer Security ©2004 Matt Bishop Slide #29-1 Chapter 33: Virtual Machines Virtual Machine Structure Virtual Machine.
CSE598C Virtual Machines and Their Applications Operating System Support for Virtual Machines Coauthored by Samuel T. King, George W. Dunlap and Peter.
Operating System Program 5 I/O System DMA Device Driver.
System Calls 1.
6.828: PC hardware and x86 Frans Kaashoek
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
A+ Guide to Software Managing, Maintaining and Troubleshooting THIRD EDITION Chapter 9 Managing Memory.
Operating System Support for Virtual Machines Samuel T. King, George W. Dunlap,Peter M.Chen Presented By, Rajesh 1 References [1] Virtual Machines: Supporting.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
IA32 (Pentium) Processor Architecture. Processor modes: 1.Protected (mode we will study) – 32-bit mode – 32-bit (4GB) address space 2.Virtual 8086 modes.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Memory Addressing / Kernel Modules.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
SAPC Hardware Pentium CPU (or 486) 4M usable memory no hard disk; boot from floppy no keyboard or monitor or mouse COM2 serial port: used for console i/o.
 Virtual machine systems: simulators for multiple copies of a machine on itself.  Virtual machine (VM): the simulated machine.  Virtual machine monitor.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
15-410, S’ Hardware Overview Jan. 19, 2004 Dave Eckhardt Bruce Maggs L04_Hardware “Dude, what were you thinking?”
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Full and Para Virtualization
Lecture 26 Virtual Machine Monitors. Virtual Machines Goal: run an guest OS over an host OS Who has done this? Why might it be useful? Examples: Vmware,
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Functions/Methods in Assembly
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
CSE 451: Operating Systems Winter 2015 Module 25 Virtual Machine Monitors Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
1 Hardware Overview Dave Eckhardt
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Lecture 7 Interrupt ,Trap and System Call
Operating System Structure
Operating Systems Engineering
Protection and OS Structure
Protection of System Resources
Anton Burtsev February, 2017
Lecture 24 Virtual Machine Monitors
CS 3305 System Calls Lecture 7.
Want to play a game? – Linux Kernel Modules
Basic Microprocessor Architecture
OS Virtualization.
Operation System Program 4
SAPC Hardware Pentium CPU (or 486) 4M usable memory
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
CS 301 Fall 2002 Computer Organization
Operating Systems Lecture 3.
Computer Security: Art and Science, 2nd Edition
System Calls System calls are the user API to the OS
Presentation transcript:

Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel

Motivation Versions of Linux for the Intel x86 platform previously have provided a system-call to allow execution of ‘real-mode’ ROM-BIOS routines in the CPU’s ‘Virtual-8086’ mode For example, an application (with suitable privileges) could easily invoke a standard SVGA BIOS routine that would modify the graphics display modes for special effects

EM64T But support for ‘Virtual-8086’ emulation is not implemented within the CPU’s IA-32e “compatibility mode”, compelling removal of the Linux ‘vm86()’ system-call from the kernel-versions for x86_64 platforms So we wanted to know if ‘Virtualization Technology’ could offer a way of restoring ‘Virtual-8086’ emulation under 64-bit Linux

How it worked Applications that wanted to execute ‘real- mode’ ROM-BIOS routines could setup a data-structure (‘struct vm86plus_struct’) having entries for the CPU’s registers, then pass that structure to the kernel for execution of the real-mode code, using the supplied register-values as parameters to modify the underlying hardware settings Let’s try to mimic that idea in 64-bit Linux

The sixteen CPU registers EAX ECX EDX EBX ESEBP ESI EDI ESP CS SS DS FS GS EFLAGSEIP General-purpose registers Pointer and Index registers Segment/selector registers Instruction-Pointer register Control and Status ‘Flags’ register We create a ‘struct’ that has fields for all sixteen of these registers (‘myvmx.h’)

The ‘real-mode’ address-space Code that uses ‘real-mode’ addresses is limited to the bottom megabyte of memory IVT RBDA EBDA VRAM ROM Interrupt-Vector Table ROM-BIOS Data Area Extended BIOS Data Area Video display memory Read-Only Memory (BIOS) Read-Only Memory (Video) 0x xFFFFF one-megabyte address-space

Example: INT-0x12 ROM-BIOS includes an interrupt-service routine for ‘Get_Memory_Size’ function (invoked when ‘int $0x12’ executes in real- mode); it returns a value in register AX giving the amount of available real-mode memory (expressed in kilobytes) If the (optional) EBDA is not present, the value returned in AX would be 0x0280 (= = 640 KB)

‘tryoutpc.cpp’ Our demo-program will attempt to execute this ‘INT $0x11’ interrupt service routine because, since it returns a value in AX, we will be able to see whether or not it worked Our Core-2 Duo machines don’t have any display-monitors attached, so couldn’t see if graphics display-modes did get changed by executing the Video BIOS routines

Installable kernel modules The VMX instructions that setup a VM and a VMM must execute with ring0 privileges, so we need to add such code to the Linux kernel – either by modifying the kernel and then recompiling and reinstalling (UGH!!) or, more conveniently, by ‘installing’ the additional code in a ‘module’ at runtime If ‘bugs’ are present, we can remove our module, fix it, and then easily reinstall it

Module-format Two required ‘management’ functions: – for ‘initializations’ at installation-time – for ‘cleanup’ at removal-time Additional ‘payload’ functions: – to provide kernel-services to applications via standard UNIX programming interfaces Module code-license: – to cope with legal issues (e.g., copyrights)

‘linuxvmm.c’ Our demo will be a character-mode Linux device-driver, accessible via a ‘device-file’ (named ‘/dev/vmm’) which an application can ‘open()’ with a call to standard C/C++ library-functions It will provide two service-functions: – memmap() – ioctl()

‘mmap()’ Calling this function will request the kernel to create entries in a task’s page-mapping tables that give it a one-megabyte virtual address-space, initialized in the way that real-mode ROM-BIOS code would expect

‘ioctl()’ Calling this function, with a ‘struct’ that has fields for the sixteen program-registers, asks the kernel to create a Host VMM that will continue to execute the kernel’s code in 64-bit mode, and to launch a Guest VM that will execute the ‘real-mode’ procedure in Virtual-8086 mode, using the sixteen parameter-values in the VM’s registers, returning modifications upon a VM-exit

‘init_module()’ The mandatory ‘init_module()’ function will verify that the CPU supports Intel’s VMX instructions, will allocate kernel-memory for the required VMCS structures and for the guest-task’s various data-structures, and will read various system-registers (such as the VMX-Capability MSRs) And it will ‘register’ the driver’s functions

‘cleanup_module()’ This module-function will ‘unregister’ the driver’s functions, and free the previously allocated kernel-memory, when a user is finished with the device-driver’s services

Compiling the module Special actions are needed for compiling modules for Linux kernel-versions 2.6.x We’ve provided a tool that automates this step for you (named ‘mmake.cpp’); use it like this: $ mmake linuxvmm

‘/dev/vmm’ Special privileges are needed by a user to execute the Linux commands that will set up this device ‘special’ file (it has already been setup by our System Administrator on the classroom and CS lab machines) If you want to do it on your own machine, do this (as ‘root’ user): root# mknod /dev/vmm c 88 0 root# chmod a+rw /dev/vmm

In-class exercise #1 Try downloading and compiling the demo- program (‘tryoutpc.cpp’) and the module (‘linuxvmm.c’), then install the module on your ‘anchor’ machine and run the demo

In-class exercise #2 After you have run the ‘tryoutpc’ program, install the ‘dram.c’ device-driver and use our ‘fileview’ utility to examine the memory-areas where Host and Guest VMCS data-structures were located You can discover the physical address of the Host’s VMCS by using the command: $ cat /proc/linuxvmm The following page-frame is the Guest’s VMCS

Instructor’s Addendum Our initial version of ‘tryoutpc.cpp’ tried to execute the ROM-BIOS interrupt-handler for ‘int-0x12’ (Get_Memory_Size), which worked quite nicely on our Pentium-D development-platform at home -- but not on our Core-2 Duo machines at campus! So we’ve substituted the ‘int-0x11’ handler (Equipment_Check) in place of ‘int-0x12’ in order to have a nice working demo