From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Wroblewski Subject: Re: Why does xc_map_foreign_range() refuse to map pfns below 1M from a domU Date: Tue, 3 Dec 2013 18:36:48 +0100 Message-ID: <529E16B0.5010104@citrix.com> References: <1386085913.13256.52.camel@kazak.uk.xensource.com> <1386086974.13256.60.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1386086974.13256.60.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Razvan Cojocaru , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 12/03/2013 05:09 PM, Ian Campbell wrote: > On Tue, 2013-12-03 at 17:59 +0200, Razvan Cojocaru wrote: >>>> The Linux domU is perfectly able to map (using xc_map_foreign_range()) >>>> pages from the Windows domU, except for pages below 1M. >>> >>> With no XSM how does it have the privilege to do this? >> >> What I meant to say is that the domU is being allowed to do this sort >> of thing, i.e. the problem is definitely not caused by XSM. > > OK, so XSM is involved but you are 101% certain that it is not > preventing the mappings? > We've ran into this issue in xenclient recently too, when we finally upgraded stubdomain's kernel to pvops version. It seems pvops kernel contains safeguard to only allow <1M mappings if it's dom0 (xen_initial_domain()). This check is placed in arch/x86/xen/mmu.c: static pte_t xen_make_pte(pteval_t pte) { phys_addr_t addr = (pte & PTE_PFN_MASK); ... /* * Unprivileged domains are allowed to do IOMAPpings for * PCI passthrough, but not map ISA space. The ISA * mappings are just dummy local mappings to keep other * parts of the kernel happy. */ if (unlikely(pte & _PAGE_IOMAP) && (xen_initial_domain() || addr >= ISA_END_ADDRESS)) { pte = iomap_pte(pte); } else { pte &= ~_PAGE_IOMAP; pte = pte_pfn_to_mfn(pte); } return native_make_pte(pte); } We patched this out (in a fugly and probably not very correct way), for our stubdomain kernel, since we needed our stubdomain qemu vms to be able to map windows guest <1M range (since qemu needs to be able to write data and read data there in order to chat with seabios etc). Maybe Konrad (CC'ed) knows why the check is there in guest kernel, and a good way to solve this. I think the goal of check was to only stop <1M mapping of its own memory in order to stop pvops kernel boot messing it, but by ricochet it also prevents mapping of foreign domain <1M ranges...