xen: return a per-mapping error from XENMEM_add_to_physmap_range.
Subsystems (5)
PATCH 1/1 xen: return a per-mapping error from XENMEM_add_to_physmap_range.
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.
We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of MMAPBATCH_V2."
NB I have only implemented the ARM side since the PVH side isn't in tree yet.
--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)
xen/arch/arm/mm.c +4 -0
@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */
xen/include/public/memory.h +7 -1
@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */
@@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Signature · 1 line
1.7.9.1
Quoted 4 lines · Ian Campbell
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
-ENOENTand which failed for some other reason.
And the Linux side:
8<-----------------
Quoted 1 line
From
ccf21a20c014e416f8cf747d284cf33492151da5Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
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
--- 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(-)
arch/arm/xen/enlighten.c +5 -3
@@ -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 ;
arch/x86/xen/mmu.c +5 -3
@@ -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; }
include/xen/interface/memory.h +6 -0
@@ -190,6 +190,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);#define XENMEM_add_to_physmap_range 23struct 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);
Signature · 1 line
1.7.2.5
Any Acks/Nacks?
This touches both ARM and x86 (although x86 only notionally until the PVH stuff is merged).
Quoted 70 lines · Ian Campbell
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
-ENOENTand which failed for some other reason.We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of
MMAPBATCH_V2."NB I have only implemented the ARM side since the PVH side isn't in tree yet.
Signed-off-by Ian Campbell <[email protected]>Cc Mats Petersson <[email protected]>Cc Mukesh Rathor <[email protected]>Cc Jan Beulich <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)xen/arch/arm/mm.c +4
-0@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */ xen/include/public/memory.h +7
-1@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */ @@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Stefano Stabellini
Acked-byQuoted 79 lines · Ian Campbell
Any Acks/Nacks?
This touches both ARM and x86 (although x86 only notionally until the PVH stuff is merged).
Quoted 70 lines · Ian Campbell
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
-ENOENTand which failed for some other reason.We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of
MMAPBATCH_V2."NB I have only implemented the ARM side since the PVH side isn't in tree yet.
Signed-off-by Ian Campbell <[email protected]>Cc Mats Petersson <[email protected]>Cc Mukesh Rathor <[email protected]>Cc Jan Beulich <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)xen/arch/arm/mm.c +4
-0@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */ xen/include/public/memory.h +7
-1@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */ @@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Keir Fraser
Acked-byQuoted 83 lines · Stefano Stabellini
Quoted 80 lines · Ian Campbell
Any Acks/Nacks?
This touches both ARM and x86 (although x86 only notionally until the PVH stuff is merged).
Quoted 71 lines · Ian Campbell
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
-ENOENTand which failed for some other reason.We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of
MMAPBATCH_V2."NB I have only implemented the ARM side since the PVH side isn't in tree yet.
Signed-off-by Ian Campbell <[email protected]>Cc Mats Petersson <[email protected]>Cc Mukesh Rathor <[email protected]>Cc Jan Beulich <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)xen/arch/arm/mm.c +4
-0@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */xen/include/public/memory.h +7
-1@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */ @@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Mats Petersson
Acked-byQuoted 4 lines · Ian Campbell
Any Acks/Nacks?
This touches both ARM and x86 (although x86 only notionally until the PVH stuff is merged).
Quoted 73 lines · Ian Campbell
Quoted 70 lines
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
-ENOENTand which failed for some other reason.We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of
MMAPBATCH_V2."NB I have only implemented the ARM side since the PVH side isn't in tree yet.
Signed-off-by Ian Campbell <[email protected]>Cc Mats Petersson <[email protected]>Cc Mukesh Rathor <[email protected]>Cc Jan Beulich <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)xen/arch/arm/mm.c +4
-0@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */ xen/include/public/memory.h +7
-1@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */ @@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Quoted 1 line · Ian Campbell
Any Acks/Nacks?
I took the Linux patch and applied it to my stable/pvh... something already.
Quoted 77 lines
This touches both ARM and x86 (although x86 only notionally until the PVH stuff is merged).
Quoted 70 lines · Ian Campbell
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
-ENOENTand which failed for some other reason.We have not yet released a version of Xen with this particular hypercall subop so we can change the interface without worrying about compatibility (I think/hope).
This would be used by the privcmd driver, in particular it relates to Mats' patch "improve performance of
MMAPBATCH_V2."NB I have only implemented the ARM side since the PVH side isn't in tree yet.
Signed-off-by Ian Campbell <[email protected]>Cc Mats Petersson <[email protected]>Cc Mukesh Rathor <[email protected]>Cc Jan Beulich <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- xen/arch/arm/mm.c | 4 ++++ xen/include/public/memory.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletions(-)xen/arch/arm/mm.c +4
-0@@ -612,6 +612,10 @@ static int xenmem_add_to_physmap_range(struct domain *d, xatpr->foreign_domid, idx, gpfn); + rc =copy_to_guest_offset (xatpr->errs, xatpr->size-1 , &rc,1 ); +if ( rc <0 ) + goto out; + xatpr->size--;/* Check for continuation if it's not the last interation */ xen/include/public/memory.h +7
-1@@ -236,6 +236,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);/* A batched version of add_to_physmap. */ #define XENMEM_add_to_physmap_range 23struct xen_add_to_physmap_range { +/* IN */ /* Which domain to change the mapping for. */ domid_t domid;uint16_t space;/* => enum phys_map_space */ @@ -247,8 +248,13 @@ struct xen_add_to_physmap_range {/* Indexes into space being mapped. */ XEN_GUEST_HANDLE (xen_ulong_t) idxs; -/* GPFN in domdwhere the source mapping page should appear. */ +/* GPFN in domid where the source mapping page should appear. */ XEN_GUEST_HANDLE (xen_pfn_t) gpfns; + +/* OUT */ + +/* Per index error code. */ +XEN_GUEST_HANDLE (int ) errs; };typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t ;DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_range_t);
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Ian Campbell
Any Acks/Nacks?
I took the Linux patch and applied it to my stable/pvh... something already.
Thanks. I've applied the Xen side with the various acks.