Received: from eggs.gnu.org ([140.186.70.92]:37408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0mYA-00016E-VQ for qemu-devel@nongnu.org; Mon, 05 Sep 2011 23:42:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0mY9-0008Fw-La for qemu-devel@nongnu.org; Mon, 05 Sep 2011 23:42:14 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:63156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0mY8-0008Ec-Rf for qemu-devel@nongnu.org; Mon, 05 Sep 2011 23:42:13 -0400 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 7EF8FAD4 for ; Tue, 6 Sep 2011 11:41:13 +0800 (CST) Received: from alumni.cs.nctu.edu.tw (alumni.cs.nctu.edu.tw [140.113.235.116]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 76911AD3 for ; Tue, 6 Sep 2011 11:41:13 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.4/8.14.4/Submit) id p863g2fb060276 for qemu-devel@nongnu.org; Tue, 6 Sep 2011 11:42:02 +0800 (CST) (envelope-from chenwj) Date: Tue, 6 Sep 2011 11:42:02 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7?= Message-ID: <20110906034202.GA51207@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] How QEMU manages guest machine's memory? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, all I am trying to figure out how QEMU manages the guest machine's memory. = If I understand correctly, QEMU uses RAMBlock as a unit when it allocates gues= t machine's memory. All RAMBlocks are maintained in RAMList. Guest machine = needs to call qemu_ram_alloc first to get a RAMBlock, then call cpu_register_ph= ysical_memory to register that RAMBlock to QEMU. Take PC machine as an example, void pc_memory_init(ram_addr_t ram_size, ...) { // ram_addr is the offset of the allocated RAMBlock in the RAMList, // right? ram_addr =3D qemu_ram_alloc(NULL, "pc.ram", below_4g_mem_size + above_4g_mem_size); // RAMBlock is paged by QEMU, and this information is stored in // PhysPageDesc, right? cpu_register_physical_memory(0, 0xa0000, ram_addr); } Is PhysPageDesc used to maintain GPA -> HVA mapping? If someone can give me a high level overview on how QEMU manages the guest machine's memory, I'll be very appreciate that. Thanks! Regards, chenwj --=20 Wei-Ren Chen (=E9=99=B3=E9=9F=8B=E4=BB=BB) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667