v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086 v8086, Execute 16bit Code in Protected How to? Mode Conclusion
Corentin Derbois
[email protected] http://www.lse.epita.fr
July 17, 2013 Plan
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086 CPU execution workflow Why?
1 v8086 How to? CPU execution workflow Conclusion Why? Workflow
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086 CPU execution workflow Why?
How to?
Conclusion v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086 CPU execution workflow Why?
Rationale How to?
Conclusion Easy video management • 16 bit code execution • BIOS data information access • Plan
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086 2 How to? How to? Enable Virtual-8086 Mode Enable Virtual-8086 Mode Interruption management Execution Interruption management Exit from v8086 Execution Issues & Solutions Conclusion Exit from v8086 Issues & Solutions Enable Virtual-8086 Mode
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Needed value Enable Virtual-8086 Mode Interruption management Execution CS/SS/SP/IP Exit from v8086 • Issues & Solutions Eflags • Conclusion VM • IOCTLX • NT if iret is used • VM & NT
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Man page: 20.2 Enable Virtual-8086 Mode Interruption management Execution The processor runs in virtual-8086 mode when the VM Exit from v8086 (virtual machine) flag in the EFLAGS register is set. Issues & Solutions Conclusion A CALL or JMP instruction. • An IRET instruction, where the NT flag in the • EFLAGS image is set to 1. Tss
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Interruption management Execution Exit from v8086 Issues & Solutions
Conclusion Interruption managment
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Interruption mode Interruption management Execution In v8086 all interruptions can be managed in two different Exit from v8086 Issues & Solutions
way: Conclusion Redirected in protected mode • Managed by the 8086 virtual processor • IOPL table
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Interruption management Execution Exit from v8086 Issues & Solutions
Conclusion Execution
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Real mode Interruption management Execution Exit from v8086 Real mode address Issues & Solutions • Conclusion Pagination is enabled • Virtualized interruptions • RealMode address
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Interruption management Execution Exit from v8086 Issues & Solutions
Conclusion Exit
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Enable Virtual-8086 Mode Interruption management Exit Execution Exit from v8086 Issues & Solutions Don’t exit, use task • Conclusion Use interruptions to comunicate • Issues
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Issues Enable Virtual-8086 Mode Interruption management Execution Switch time Exit from v8086 • Issues & Solutions Lower addresses in vitual address space Conclusion • BIOS at specific address • Long mode • Solution
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
Emulation 8086 v8086 How to? Enable Virtual-8086 Mode Emulation of 8086 gave the possibility to bypass most of Interruption management Execution the problems of v8086, like switching context. Exit from v8086 Issues & Solutions
Conclusion Special case: Emulation of interruption
IVT at 0x0 • transform interrupt to jump • Plan
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to?
Conclusion 3 Conclusion Conclusion
v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to? Used by current system Conclusion
Windows • Linux • Bsd • v8086, Execute 16bit Code in Protected Mode Corentin Derbois
v8086
How to?
Conclusion
Questions?