From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: question regarding foreign memory mapping in xen Date: Mon, 27 May 2013 14:17:27 +0100 Message-ID: <51A35CE7.6060801@citrix.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Sengul Thomas Cc: Xen Devel List-Id: xen-devel@lists.xenproject.org On 27/05/13 14:06, Sengul Thomas wrote: > Hello xen developers :) > > I'm reading source codes of xen and got a question in tool-stack part > and got series of questions: > > In file tools/libxc/xc_linux_osdep.c, function linux_privcmd_map_foreign_bulk, > I notice that mmap and ioctl IOCTL_PRIVCMD_MMAPBATCH_V2, are used > for mapping a foreign memory into dom0. > > Is it because mmap is for mapping from /proc/xen/privcmd to dom0 memory and > ioctl is for mapping from foreign memory (probably domU) into /proc/xen/privcmd? > > Also, I am trying to understand how ioctl IOCTL_PRIVCMD_MMAPBATCH_V2 works, > and it is quite hard. > In function privcmd_ioctl_mmap_batch, it allocates pages in dom0 side, > and I don't understand why do we need this allocation. > If we map a page from foreign domain, just changing grant table is not enough? > Please enlighten me. A foreign mapping is unrelated to grant tables. Grant tables are used for a domain to negotiate to allow other domains access to parts of its memory. Foreign mappings are for the toolstack needing to play with a domains memory without its knowledge. It is the basis of domain create/migrate etc. ~Andrew > > Also, I see that in function mmap_batch_fn (i.e., called with the > newly allocated pages), > xen_remap_domain_mfn_range function is called. > Could you tell me what does this function (xen_remap_domain_mfn_range) > do briefly. > It would help me understand xen more! > > Best regards, > Thomas > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel