[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: return a per-mapping error from XENMEM_add_to_physmap_range.



On Fri, 2013-01-04 at 14:03 +0000, Ian Campbell wrote:
> Since ARM and PVH dom0 kernel use this to map foreign domain pages
> they could in the future hit paged out or shared pages etc and
> therefore need to propagate which frames are -ENOENT and which failed
> for some other reason.

And the Linux side:

8<-----------------

>From ccf21a20c014e416f8cf747d284cf33492151da5 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 4 Jan 2013 13:58:29 +0000
Subject: [PATCH] xen: implement updated XENMEM_add_to_physmap_range ABI

Allows for more fine grained error reporting. Only used by PVH and
ARM both of which are marked EXPERIMENTAL precisely because the ABI
is not yet stable

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 arch/arm/xen/enlighten.c       |    8 +++++---
 arch/x86/xen/mmu.c             |    8 +++++---
 include/xen/interface/memory.h |    6 ++++++
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index f28fc1a..31e4ae3 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -59,14 +59,16 @@ static int map_foreign_page(unsigned long lpfn, unsigned 
long fgmfn,
        };
        xen_ulong_t idx = fgmfn;
        xen_pfn_t gpfn = lpfn;
+       int err = 0;
 
        set_xen_guest_handle(xatp.idxs, &idx);
        set_xen_guest_handle(xatp.gpfns, &gpfn);
+       set_xen_guest_handle(xatp.errs, &err);
 
        rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
-       if (rc) {
-               pr_warn("Failed to map pfn to mfn rc:%d pfn:%lx mfn:%lx\n",
-                       rc, lpfn, fgmfn);
+       if (rc || err) {
+               pr_warn("Failed to map pfn to mfn rc:%d:%d pfn:%lx mfn:%lx\n",
+                       rc, err, lpfn, fgmfn);
                return 1;
        }
        return 0;
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index fee34fe..41f6de4 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2508,14 +2508,16 @@ static int pvh_add_to_xen_p2m(unsigned long lpfn, 
unsigned long fgmfn,
        };
        xen_ulong_t idx = fgmfn;
        xen_pfn_t gpfn = lpfn;
+       int err = 0;
 
        set_xen_guest_handle(xatp.idxs, &idx);
        set_xen_guest_handle(xatp.gpfns, &gpfn);
+       set_xen_guest_handle(xatp.errs, &err);
 
        rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
-       if (rc)
-               pr_warn("d0: Failed to map pfn (0x%lx) to mfn (0x%lx) rc:%d\n",
-                       lpfn, fgmfn, rc);
+       if (rc || err)
+               pr_warn("d0: Failed to map pfn (0x%lx) to mfn (0x%lx) 
rc:%d:%d\n",
+                       lpfn, fgmfn, rc, err);
        return rc;
 }
 
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index b40a431..2ecfe4f 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -190,6 +190,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
 
 #define XENMEM_add_to_physmap_range 23
 struct xen_add_to_physmap_range {
+    /* IN */
     /* Which domain to change the mapping for. */
     domid_t domid;
     uint16_t space; /* => enum phys_map_space */
@@ -203,6 +204,11 @@ struct xen_add_to_physmap_range {
 
     /* GPFN in domid where the source mapping page should appear. */
     GUEST_HANDLE(xen_pfn_t) gpfns;
+
+    /* OUT */
+
+    /* Per index error code. */
+    GUEST_HANDLE(int) errs;
 };
 DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range);
 
-- 
1.7.2.5




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.