Dynamic Binary Translation - Operating Systems Design | CS 423, Study notes of Operating Systems

Material Type: Notes; Class: Operating Systems Design; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-hcu
koofers-user-hcu 🇺🇸

5

(1)

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Dynamic binary translation
Sam King / Klara Nahrstedt
VMM environment
Duplicate
Virtual machine == physical machine
Efficient
Runs almost as fast s real machine
Isolated
VMM has control over resources
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Dynamic Binary Translation - Operating Systems Design | CS 423 and more Study notes Operating Systems in PDF only on Docsity!

Dynamic binary translation

Sam King / Klara Nahrstedt

VMM environment

• Duplicate

– Virtual machine == physical machine

• Efficient

– Runs almost as fast s real machine

• Isolated

– VMM has control over resources

VMM is a simulator

• Simulator is software that simulates the

execution of a computer

while(1){ inst = mem[PC]; // fetch if(inst == add) { // decode // execute reg[inst.reg1] = reg[inst.reg2] + reg[inst.reg3]; PC++; } } // repeat

Simulator

  • CPU state --- data structure within your sim.
    • Includes registers, IDT, etc.
  • Memory --- malloc
    • Guest physical address 0 == beginning of malloc
  • Disk --- file
    • Disk block 1 = file offset 1*(size of disk block)
  • Display --- window
  • Within the simulator, software does not “know” it is

being simulated

Main issues

• Privileged instructions

• Instructions operate on physical state,

not virtual state

Privileged instructions

  • CPU divided into supervisor and user modes
  • Part of the CPU ISA only accessible by “supervisor”

code

  • Allowing guest OS execute these would violate

isolation

  • E.g., I/O instructions to write disk blocks
  • Solution: run guest OS in user mode
  • CPU user mode: only non-privileged inst
  • CPU supervisor mode: all inst

Example: interrupt descriptor table (IDT)

• x86 processor have an IDT register

  • CPU uses to find interrupt service routines

• Set the IDT register using the lidt instruction

• VMM must handle all interrupts to maintain

control

• Goal: allow the guest OS to set the virtual IDT

register without affecting the physical CPU

Guest OS priv. inst.

Hardware

VMM

Guest OS

Guest

app

Sensitive non-privileged instructions

• x86 has a number of instructions that

are sensitive, non-privileged instructions

– Causes physical state of CPU to leak

– Why is this a problem?

• What property does this violate?

Guest OS sensitive non-priv.

Hardware

VMM

Guest OS

Guest

app

Key insight

• Solution: simulate the OS, let user-mode

code run natively

  • Simulation is flexible
    • Can interpose on all instructions
    • Problem: simulation is too slow

• Will work if guest OS calls SIDT, what about

guest user mode?

  • Try it out for yourself! This is the basis for the “red

pill” VMM detection technique

Simulation flexibility

• Normal simulations flexible, slow

• Can we simulate fast, still flexible?

while(1){ inst = mem[PC]; // fetch if(inst == add) { // decode // execute reg[inst.reg1] = reg[inst.reg2] + reg[inst.reg3]; PC++; } } // repeat