From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH 2 of 3] x86/mm: Teach paging to page table-based p2m Date: Thu, 15 Mar 2012 17:21:45 +0000 Message-ID: <20120315172145.GE12366@ocelot.phlegethon.org> References: <20120308141531.GJ64337@ocelot.phlegethon.org> <20120315105254.GA18381@whitby.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline 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: Andres Lagar-Cavilla Cc: olaf@aepfle.de, xen-devel@lists.xensource.com, keir@xen.org, Tim Deegan , andres@gridcentric.ca, wei.wang2@amd.com, hongkaixing@huawei.com, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org At 08:46 -0700 on 15 Mar (1331801170), Andres Lagar-Cavilla wrote: > > Righto. In that case, I'd be happy with just clipping MFNs and not > > trying to unpack them. But I think it should happen in the main > > pte-building macros, not scattered around the p2m code. It should just > > be a matter of using PADDR_MASK in the right place. > > Something along these lines? (RFC, not tested yet) > Andres > > /* Construct a pte from a pfn and access flags. */ > #define l1e_from_pfn(pfn, flags) \ > - ((l1_pgentry_t) { ((intpte_t)(pfn) << PAGE_SHIFT) | put_pte_flags(flags) }) > + ((l1_pgentry_t) { ((intpte_t)((pfn) & (PADDR_MASK >> PAGE_SHIFT)) << \ > + PAGE_SHIFT) | put_pte_flags(flags) }) Yes, that's the idea. I think > + ((l1_pgentry_t) { (((intpte_t)(pfn) << PAGE_SHIFT) & PADDR_MASK) \ > + | put_pte_flags(flags) }) is a little neater, maybe? In any case, I'd like Keir's ack on this, since it will affect all the PV pagetable code too (hopefully in a trivial and correct way). Tim.