我正在qemu -enable-kvm上运行一个linux来宾 . 我正在尝试使用已知的物理内存位置在linux和qemu之间创建一个反向通道 . 为了使用内核永远不会分配给任何人的内存地址,我使用1024M物理内存启动了guest虚拟机 . 在访客中,我试图访问2GB字节(2 * 1024 * 1024 * 1024) . 在重新编译内核时,我无法再次在新内核中启动 .

我的代码如下..

/** in context_switch() function of  kernel/sched.c */
#define PID_ADDR ((int *)((unsigned long)2 * (unsigned long)1024 * (unsigned long)1024 * (unsigned long)1024))
int* pid_addr = phys_to_virt(PID_ADDR);

*pid_addr = next->pid //next is the task-struct ptr of the next process that is going to run.

可以解释一下kvm如何使用分配给客户的物理内存?