Emulation Technique: Why Do We Talk About Emulation ?
Emulation Technique: Why Do We Talk About Emulation ?
Emulation Technique: Why Do We Talk About Emulation ?
• Goal of emulation :
Provide a method for enabling
a (sub)system to present the
same interface and characteristics
as another.
Emulation Technique
• Three emulation implementations :
Interpretation
• Emulator interprets only one instruction at a time.
Static Binary Translation
• Emulator translates a block of guest binary at a time and further optimizes
for repeated instruction executions.
Dynamic Binary Translation
• This is a hybrid approach of emulator, which mix two approaches above.
Interpreter
Static Binary Translation
• Using the concept of basic block which comes from
compiler optimization technique.
A basic block is a portion of the code within a program with certain
desirable properties that make it highly amenable to analysis.
A basic block has only one entry point, meaning no code within it is
the destination of a jump instruction anywhere in the program.
A basic block has only one exit point, meaning only the last
instruction can cause the program to begin executing code in a
different basic block.
Static Binary Translation
• Static binary translation flow :
1. Fetch one block of guest instructions from guest memory image.
2. Decode and dispatch each instruction to the corresponding
translation unit.
3. Translate guest instruction to host instructions.
4. Write the translated host instructions to code cache.
5. Execute the translated host instruction block in code cache.
Binary Translator
Comparison
• Interpretation implementation
Binary
Translator
return miss
Interpreter
Register mapping problem
Performance improvement
• Solutions :
Translation Chaining
Dynamic Optimization
Translation Chaining
• Non-optimized control flow
between translated blocks and
emulation manager.
Translation Chaining
• Jump from one translation
directly to next, which avoid
switching back to emulation
manager.
Dynamic Optimization
• How to optimize binary codes ?
Static optimization (compiling time optimization)
• Optimization techniques apply to generate binary code base on the
semantic information in source code.
Dynamic optimization (run time optimization)
• Optimization techniques apply to generated binary code base on the
run time information which relate to program input data.