From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCH 06/12] xen: mark grant mapped pages as foreign Date: Fri, 9 Jan 2015 16:39:22 +0000 Message-ID: <54B0043A.1030805@citrix.com> References: <1420570657-8203-1-git-send-email-david.vrabel@citrix.com> <1420570657-8203-7-git-send-email-david.vrabel@citrix.com> <1420820376.21186.39.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y9cau-0001sz-MW for xen-devel@lists.xenproject.org; Fri, 09 Jan 2015 16:39:28 +0000 In-Reply-To: <1420820376.21186.39.camel@citrix.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 , Stefano Stabellini Cc: xen-devel@lists.xenproject.org, Jenny Herbert , Jenny Herbert , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 09/01/15 16:19, Ian Campbell wrote: > On Fri, 2015-01-09 at 16:03 +0000, Stefano Stabellini wrote: >> On Tue, 6 Jan 2015, David Vrabel wrote: >>> From: Jenny Herbert >>> >>> Use the "foreign" page flag to mark pages that have a grant map. Use >>> page->private to store information of the grant (the granting domain >>> and the grant reference). >>> >>> Signed-off-by: Jenny Herbert >>> Signed-off-by: David Vrabel >>> --- >>> arch/x86/xen/p2m.c | 50 ++++++++++++++++++++++++++++++++++++++------- >>> include/xen/grant_table.h | 13 ++++++++++++ >>> 2 files changed, 56 insertions(+), 7 deletions(-) >>> >>> diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c >>> index 0d70814..22624a3 100644 >>> --- a/arch/x86/xen/p2m.c >>> +++ b/arch/x86/xen/p2m.c >>> @@ -648,6 +648,43 @@ bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) >>> return true; >>> } >>> >>> +static int >>> +init_page_grant_ref(struct page *p, domid_t domid, grant_ref_t grantref) >>> +{ >>> +#ifdef CONFIG_X86_64 >>> + uint64_t gref; >>> + uint64_t* gref_p = &gref; >>> +#else >>> + uint64_t* gref_p = kmalloc(sizeof(uint64_t), GFP_KERNEL); >>> + if (!gref) >>> + return -ENOMEM; >>> + uint64_t* gref = gref_p; >>> +#endif >>> + >>> + *gref_p = ((uint64_t) grantref << 32) | domid; >>> + p->private = gref; >>> + >>> + WARN_ON(PagePrivate(p)); >>> + WARN_ON(PageForeign(p)); >>> + SetPagePrivate(p); >>> + SetPageForeign(p); >>> + return 0; >>> +} >>> + >>> +static void >>> +clear_page_grant_ref(struct page *p) >>> +{ >>> + WARN_ON(!PagePrivate(p)); >>> + WARN_ON(!PageForeign(p)); >>> + >>> +#ifndef CONFIG_X86_64 >>> + kfree(p->private); >>> +#endif >>> + p->private = 0; >>> + ClearPagePrivate(p); >>> + ClearPageForeign(p); >>> +} >> >> Given that get_page_grant_ref is used by netback, these functions need >> to be made arch-independent, moved to an arch-independent code location >> and called appropriately. I've fixed this already. > ... or stubbed out for arches which don't need this (which might include > arm*?). I'm reasonably certain that this is required for HVM and ARM guests as well. The grant copy will still fail to get the page by gfn since the mfn is owned by a different domain. David