From mboxrd@z Thu Jan 1 00:00:00 1970 From: tgh Subject: Re: question about machine-to-physic table and phy-to-machine table Date: Tue, 27 Mar 2007 14:14:07 +0800 Message-ID: <4608B62F.5000805@ncic.ac.cn> References: <45F93B96.76E4.0078.0@novell.com> <460333B8.70307@ncic.ac.cn> <200703270514.53524.mark.williamson@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <200703270514.53524.mark.williamson@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Mark Williamson Cc: xen-devel@lists.xensource.com, Daniel Stodden List-Id: xen-devel@lists.xenproject.org Thank you for your detail reply your explanation is really helpful and p2m and m2p are all lazily allocated ,that is when the guestos deal with=20 page fault for using ,say writing, a page which is virtual-mapped but=20 not allocated machine page ,is it right? Mark Williamson =E5=86=99=E9=81=93: >> I read the code ,there are machine-to-physic table and >> physic-to-machine table >> there are machine address for hardward address ,physic address for >> guestos's view hardware and virtual address ,is it right? >> >> phy-to-machine table is a mapping for guestos's view hardware to real >> hardward ,is it right? >> I am confused about the meaning and function of machine-to-physic add= ress >> =20 > > * Machine addresses represent real RAM in the host. The memory a guest= owns=20 > will certainly not start at 0 and will not necessarily be contiguous - = it=20 > might be in a number of chunks with big gaps between. > > * (pseudo)physical addresses represent the memory the guest owns. This= =20 > address space starts at 0 and is contiguous. > > * Virtual addresses are used by software running in the guest, and by t= he=20 > guest kernel. They're translated by the host CPU into machine addresse= s so=20 > that it can access the correct RAM. > > Guests use physical addresses as an abstraction: most operating system = memory=20 > management code assumes that the RAM owned by the OS starts at 0 and is= =20 > contiguous. Because this is not the case for Machine addresses under X= en,=20 > most of the guest's code is "tricked" by giving it pseudophysical addre= sses=20 > that look like it expects memory to look. > > The P2M and M2P tables record the relationship between pseudophysical p= age=20 > frames (which the core OS code uses) and machine page frames (which the= host=20 > really uses). The Xen "architecture" code within the guest OS uses the= se=20 > tables to manage the translation between pseudophysical and machine pag= e=20 > frames so that the guest's page tables can be handled correctly. For=20 > paravirtualised guests, page tables must contain machine addresses - th= ese=20 > must be translated from the pseudophysical addresses used by core OS co= de. > > Hope that helps clarify how this all fits together, tgh. > > Cheers, > Mark > > =20