QEMU CPU仿真原理

dae*_*hee 10 linux qemu emulation

在QEMU中,操作系统可以在软件模拟CPU之上运行.如何通过软件模拟CPU?我想知道细节.

如果CPU是由软件模拟的,寄存器是用主机系统内存模拟的吗?说有ARM汇编代码

LDRB r0,[r1],#1

如何在x86环境中模拟?我的猜测是仿真软件为r0(4byte),r1(4byte)保留内存映射空间,然后更新相应内存位置的寄存器值...我错了吗?我想详细说明......

先感谢您

unw*_*ind 13

请参阅此文件,了解由QEMU完成的ARM CPU状态的C级建模.

这是非常直接的,并且(当然)因为您怀疑寄存器(以及所有其他状态)被建模为C变量.

核心结构开始:

typedef struct CPUARMState {
    /* Regs for current mode.  */
    uint32_t regs[16];
   /* Frequently accessed CPSR bits are stored separately for efficiency.
      This contains all the other bits.  Use cpsr_{read,write} to access
      the whole CPSR.  */
   uint32_t uncached_cpsr;
   uint32_t spsr;
Run Code Online (Sandbox Code Playgroud)