: PVH xen: add XENMEM_add_to_physmap_range
PATCH v2 2/18 : PVH xen: add XENMEM_add_to_physmap_range
In this patch we add a new function xenmem_add_to_physmap_range(), and change xenmem_add_to_physmap_once parameters so it can be called from xenmem_add_to_physmap_range. There is no PVH specific change here.
Changes in V2:
- Do not break parameter so xenmem_add_to_physmap_once() but pass in struct xen_add_to_physmap.
--- xen/arch/x86/mm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 3 deletions(-)
xen/arch/x86/mm.c +79 -3
@@ -4268,7 +4268,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)static int xenmem_add_to_physmap_once (struct domain *d, -const struct xen_add_to_physmap *xatp) +const struct xen_add_to_physmap *xatp, +domid_t foreign_domid) {struct page_info *page =NULL ;unsigned long gfn =0 ;/* gcc ... */
@@ -4395,7 +4396,7 @@ static int xenmem_add_to_physmap(struct domain *d, start_xatp = *xatp;while ( xatp->size >0 ) { - rc =xenmem_add_to_physmap_once (d, xatp); + rc =xenmem_add_to_physmap_once (d, xatp,-1 );if ( rc <0 )return rc;
@@ -4421,7 +4422,52 @@ static int xenmem_add_to_physmap(struct domain *d,return rc; } -return xenmem_add_to_physmap_once (d, xatp); +return xenmem_add_to_physmap_once (d, xatp,-1 ); +} + +static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr) +{ +int rc; + +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc) + goto out; + + xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out: +return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)
@@ -4438,6 +4484,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&xatp, arg,1 ) )return -EFAULT ; +/* This one is only supported for add_to_physmap_range */ +if ( xatp.space == XENMAPSPACE_gmfn_foreign ) +return -EINVAL ; + d =rcu_lock_domain_by_any_id (xatp.domid);if ( d ==NULL )return -ESRCH ;
@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range: + { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ; + + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) ) + rc = -EFAULT ; + +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;
Signature · 1 line
1.7.2.3
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.
Quoted 8 lines
Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 3 deletions(-)
This continued to lack compat mode support (i.e. modification to xen/arch/x86/x86_64/compat/mm.c:compat_arch_memory_op()).
xen/arch/x86/mm.c static int handle_iomem_range(unsigned long s, unsigned long e, void *p) · line 4272
Quoted 9 lines
xen/arch/x86/mm.c +2
-1@@ -4268,7 +4268,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)static int xenmem_add_to_physmap_once (struct domain *d, -const struct xen_add_to_physmap *xatp) +const struct xen_add_to_physmap *xatp, +domid_t foreign_domid)
So you add this new parameter but don't use it?
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4399
Quoted 9 lines
xen/arch/x86/mm.c +1
-1{struct page_info *page =NULL ;unsigned long gfn =0 ;/* gcc ... */ @@ -4395,7 +4396,7 @@ static int xenmem_add_to_physmap(struct domain *d, start_xatp = *xatp;while ( xatp->size >0 ) { - rc =xenmem_add_to_physmap_once (d, xatp); + rc =xenmem_add_to_physmap_once (d, xatp,-1 );
And if it indeed is being used, please use a proper DOMID_* value here.
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4425
Quoted 9 lines
xen/arch/x86/mm.c +1
-1if ( rc <0 )return rc;@@ -4421,7 +4422,52 @@ static int xenmem_add_to_physmap(struct domain *d,return rc; } -return xenmem_add_to_physmap_once (d, xatp); +return xenmem_add_to_physmap_once (d, xatp,-1 );
And here.
Quoted 19 lines
xen/arch/x86/mm.c +19
-0+} + +static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr) +{ +int rc; + +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 );
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4454
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+if ( rc <0 ) + goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc) + goto out;
That doesn't seem right, together with you apparently not using the "errs" array altogether.
Quoted 41 lines
xen/arch/x86/mm.c +27
-0+ + xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out: +return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)@@ -4438,6 +4484,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&xatp, arg,1 ) )return -EFAULT ; +/* This one is only supported for add_to_physmap_range */ +if ( xatp.space == XENMAPSPACE_gmfn_foreign ) +return -EINVAL ; + d =rcu_lock_domain_by_any_id (xatp.domid);if ( d ==NULL )return -ESRCH ;@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range: + { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ;
xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4534
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) )
For one, shouldn't this be "!rc"?
And then you update ->size, but that one is specified to be only and IN field. And considering that "errs" is the only OUT one, yet that isn't even formally correct (because the field itself is an IN, its what it points to where the output goes), I don't see why you would need to copy back any part of the structure.
Jan
Quoted 20 lines
xen/arch/x86/mm.c +9
-0+ rc = -EFAULT ; + +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;Signature · 7 lines
1.7.2.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 3 deletions(-)This continued to lack compat mode support (i.e. modification to xen/arch/x86/x86_64/compat/mm.c:compat_arch_memory_op()).
Do we need it? Only 64-bit kernels can use PVH - and that was from the start the idea.
Quoted 125 lines
xen/arch/x86/mm.c static int handle_iomem_range(unsigned long s, unsigned long e, void *p) · line 4272
Quoted 10 lines
xen/arch/x86/mm.c +2
-1@@ -4268,7 +4268,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)static int xenmem_add_to_physmap_once (struct domain *d, -const struct xen_add_to_physmap *xatp) +const struct xen_add_to_physmap *xatp, +domid_t foreign_domid)So you add this new parameter but don't use it?
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4399
Quoted 9 lines
xen/arch/x86/mm.c +1
-1{struct page_info *page =NULL ;unsigned long gfn =0 ;/* gcc ... */ @@ -4395,7 +4396,7 @@ static int xenmem_add_to_physmap(struct domain *d, start_xatp = *xatp;while ( xatp->size >0 ) { - rc =xenmem_add_to_physmap_once (d, xatp); + rc =xenmem_add_to_physmap_once (d, xatp,-1 );And if it indeed is being used, please use a proper DOMID_* value here.
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4425
Quoted 9 lines
xen/arch/x86/mm.c +1
-1if ( rc <0 )return rc;@@ -4421,7 +4422,52 @@ static int xenmem_add_to_physmap(struct domain *d,return rc; } -return xenmem_add_to_physmap_once (d, xatp); +return xenmem_add_to_physmap_once (d, xatp,-1 );And here.
Quoted 19 lines
xen/arch/x86/mm.c +19
-0+} + +static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr) +{ +int rc; + +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 );xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4454
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+if ( rc <0 ) + goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc) + goto out;That doesn't seem right, together with you apparently not using the "errs" array altogether.
Quoted 41 lines
xen/arch/x86/mm.c +27
-0+ + xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out: +return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)@@ -4438,6 +4484,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&xatp, arg,1 ) )return -EFAULT ; +/* This one is only supported for add_to_physmap_range */ +if ( xatp.space == XENMAPSPACE_gmfn_foreign ) +return -EINVAL ; + d =rcu_lock_domain_by_any_id (xatp.domid);if ( d ==NULL )return -ESRCH ;@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range: + { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ;xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4534
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) )For one, shouldn't this be "!rc"?
Quoted 4 lines
And then you update ->size, but that one is specified to be only and IN field. And considering that "errs" is the only OUT one, yet that isn't even formally correct (because the field itself is an IN, its what it points to where the output goes), I don't see why you
The 'err' is not formally correct? The memory.h says:
258 /* OUT */
259
260 /* Per index error code. */
261 XEN_GUEST_HANDLE(int) errs;
262 };
or are you referring to 'size' which I agree with - it is part of 'IN'.
Quoted 32 lines
would need to copy back any part of the structure.
Jan
Quoted 20 lines
xen/arch/x86/mm.c +9
-0+ rc = -EFAULT ; + +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;Signature · 7 lines
1.7.2.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Quoted 7 lines
Quoted 7 lines
Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82
Quoted 8 lines
+++++++++++++++++++++++++++++++++++++++++++++++++++--
Quoted 4 lines
Quoted 1 line
1 files changed, 79 insertions(+), 3 deletions(-)This continued to lack compat mode support (i.e. modification to xen/arch/x86/x86_64/compat/mm.c:compat_arch_memory_op()).
Do we need it? Only 64-bit kernels can use PVH - and that was from the start the idea.
I wasn't really aware of that, but I certainly do mind implementing a hypercall usable by a PV or HVM guest only half way. Or did I overlook code refusing the particular sub-op for plain PV and plain HVM guests?
Jan
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Quoted 7 lines
Quoted 7 lines
Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82+++++++++++++++++++++++++++++++++++++++++++++++++++--
Quoted 4 lines
Quoted 1 line
1 files changed, 79 insertions(+), 3 deletions(-)This continued to lack compat mode support (i.e. modification to xen/arch/x86/x86_64/compat/mm.c:compat_arch_memory_op()).
Quoted 7 lines
Quoted 2 lines
Do we need it? Only 64-bit kernels can use PVH - and that was from the start the idea.
I wasn't really aware of that, but I certainly do mind implementing a hypercall usable by a PV or HVM guest only half way. Or did I overlook code refusing the particular sub-op for plain PV and plain HVM guests?
There were some patches in the series (I can't recall the names of them thought) that had some of the PV hypercalls return -EINVAL (or -ENOSYS as I suggested).
I think it might be better to introduce one patch that would neuter the PV/HVM hypercalls that we don't want to support or can't yet (for example b/c we haven't fixed the bugs).
Are you OK if those paths are done in the common code? Meaning say for the PHYSDEV_op hypercalls some return -ENOSYS?
Or would doing it via the grand hypercall[0->X] table that was in one of the patches and filtering the unsafe hypercalls? That seems a much easier way and won't mess with the generic code paths?
Quoted 3 lines
Jan
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
There were some patches in the series (I can't recall the names of them thought) that had some of the PV hypercalls return
-EINVAL(or-ENOSYSas I suggested).I think it might be better to introduce one patch that would neuter the PV/HVM hypercalls that we don't want to support or can't yet (for example b/c we haven't fixed the bugs).
Are you OK if those paths are done in the common code? Meaning say for the
PHYSDEV_ophypercalls some return-ENOSYS?
If intended to be permanent, then of course.
If intended to be temporary (until fixed), then yes as long as an accompanying comment makes this clear (and greppable for).
Jan
Quoted 20 lines · On Mon, 18 Mar 2013 11:38:35 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
On 16.03.13 at 01:20, Mukesh Rathor <[email protected]> wrote:
xen/arch/x86/mm.c +5
-0+struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ;xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4534
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) )For one, shouldn't this be "!rc"?
Quoted 5 lines
And then you update ->size, but that one is specified to be only and IN field. And considering that "errs" is the only OUT one, yet that isn't even formally correct (because the field itself is an IN, its what it points to where the output goes), I don't see why you would need to copy back any part of the structure.
Ah, I see the struct got updated. Konrad, do you have updated version of the struct with following added to the end:
struct xen_add_to_physmap_range {
....
/* OUT */
/* Per index error code. */
XEN_GUEST_HANDLE(int) errs;in the latest linux tree?
thanks,
Mukesh
Quoted 32 lines · Mukesh Rathor
Quoted 20 lines · On Mon, 18 Mar 2013 11:38:35 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
On 16.03.13 at 01:20, Mukesh Rathor <[email protected]> wrote:
xen/arch/x86/mm.c +5
-0+struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ;xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4534
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) )For one, shouldn't this be "!rc"?
Quoted 5 lines
And then you update ->size, but that one is specified to be only and IN field. And considering that "errs" is the only OUT one, yet that isn't even formally correct (because the field itself is an IN, its what it points to where the output goes), I don't see why you would need to copy back any part of the structure.
Ah, I see the struct got updated. Konrad, do you have updated version of the struct with following added to the end:
Quoted 8 lines
struct
xen_add_to_physmap_range{
..../* OUT */ /* Per index error code. */ XEN_GUEST_HANDLE(int) errs;in the latest linux tree?
Yes. 5caed269ea867f36225376a6546411ed7c106226
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
Quoted 10 lines
thanks,
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 37 lines · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 3 deletions(-)xen/arch/x86/mm.c +3
-2@@ -4268,7 +4268,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)static int xenmem_add_to_physmap_once (struct domain *d, -const struct xen_add_to_physmap *xatp) +const struct xen_add_to_physmap *xatp, +domid_t foreign_domid) {struct page_info *page =NULL ;unsigned long gfn =0 ;/* gcc ... */ @@ -4395,7 +4396,7 @@ static int xenmem_add_to_physmap(struct domain *d, start_xatp = *xatp;while ( xatp->size >0 ) { - rc =xenmem_add_to_physmap_once (d, xatp); + rc =xenmem_add_to_physmap_once (d, xatp,-1 );if ( rc <0 )return rc;
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4429
Quoted 9 lines
xen/arch/x86/mm.c +5
-1@@ -4421,7 +4422,52 @@ static int xenmem_add_to_physmap(struct domain *d,return rc; } -return xenmem_add_to_physmap_once (d, xatp); +return xenmem_add_to_physmap_once (d, xatp,-1 ); +} + +static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr)
noinline?
Quoted 16 lines
xen/arch/x86/mm.c +16
-0+{ +int rc; + +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 ); +if ( rc <0 )
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4455
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc) + goto out; +
Should you also set?
xatp.err = 0;
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4468
Quoted 13 lines
xen/arch/x86/mm.c +13
-0+ xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out:
And in case of error, like this, se xatp.err to rc?
Quoted 28 lines
xen/arch/x86/mm.c +14
-0+return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)@@ -4438,6 +4484,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&xatp, arg,1 ) )return -EFAULT ; +/* This one is only supported for add_to_physmap_range */ +if ( xatp.space == XENMAPSPACE_gmfn_foreign ) +return -EINVAL ; + d =rcu_lock_domain_by_any_id (xatp.domid);if ( d ==NULL )return -ESRCH ;@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range: + { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ; +
xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4535
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) ) + rc = -EFAULT ;
That is a bit odd. You are only copying in the values in case of error? But what if the kernel gave you an 'xatpr' that has garbage for the xatp.err field (which is marked as OUT). Should we do the copy_to_guest irrespective of the rc?
Quoted 20 lines
xen/arch/x86/mm.c +8
-0+ +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;Signature · 7 lines
1.7.2.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 7 lines · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.
You could also add in the comment section here:
XENMAPSPACE_gmfn_foreign should never be used in XENMEM_add_to_physmap hypercall. Before this patch we would wound down to xenmem_add_to_physmap_once which would return -EINVAL (as mfn=0).
Now we do it straight away by returning -EINVAL.
Quoted 136 lines
Signed-off-by Mukesh Rathor <[email protected]>--- xen/arch/x86/mm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 3 deletions(-)xen/arch/x86/mm.c +79
-3@@ -4268,7 +4268,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)static int xenmem_add_to_physmap_once (struct domain *d, -const struct xen_add_to_physmap *xatp) +const struct xen_add_to_physmap *xatp, +domid_t foreign_domid) {struct page_info *page =NULL ;unsigned long gfn =0 ;/* gcc ... */ @@ -4395,7 +4396,7 @@ static int xenmem_add_to_physmap(struct domain *d, start_xatp = *xatp;while ( xatp->size >0 ) { - rc =xenmem_add_to_physmap_once (d, xatp); + rc =xenmem_add_to_physmap_once (d, xatp,-1 );if ( rc <0 )return rc;@@ -4421,7 +4422,52 @@ static int xenmem_add_to_physmap(struct domain *d,return rc; } -return xenmem_add_to_physmap_once (d, xatp); +return xenmem_add_to_physmap_once (d, xatp,-1 ); +} + +static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr) +{ +int rc; + +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 ); +if ( rc <0 ) + goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc) + goto out; + + xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out: +return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)@@ -4438,6 +4484,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&xatp, arg,1 ) )return -EFAULT ; +/* This one is only supported for add_to_physmap_range */ +if ( xatp.space == XENMAPSPACE_gmfn_foreign ) +return -EINVAL ; + d =rcu_lock_domain_by_any_id (xatp.domid);if ( d ==NULL )return -ESRCH ;@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range: + { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ; + + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc; + + rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) ) + rc = -EFAULT ; + +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;Signature · 7 lines
1.7.2.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 7 lines · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Reviewed-by Konrad Rzeszutek Wilk <[email protected]>
I'm confused: A little earlier you sent a response raising several issues, and now you send a Reviewed-by?
Jan
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 4 lines · Mukesh Rathor
In this patch we add a new function
xenmem_add_to_physmap_range(), and changexenmem_add_to_physmap_onceparameters so it can be called fromxenmem_add_to_physmap_range. There is no PVH specific change here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Changes in V2:
- Do not break parameter soxenmem_add_to_physmap_once()but pass in structxen_add_to_physmap.Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I'm confused: A little earlier you sent a response raising several issues, and now you send a Reviewed-by?
Sorry, I looked at it a first and it looked OK, so I did the Reviewed-by.
Then looked at some other patches, some cog in my brain did a late page-fault on this patch and I went back in here. Then realized that there certain things I was not sure off and asked Mukesh.
So, Reviewed-by rescinded for this patch right now. Thanks for catching that process error.
Quoted 3 lines
Jan
Quoted 4 lines · Mukesh Rathor
xen/arch/x86/mm.c +4
-0+static noinline int xenmem_add_to_physmap_range(struct domain *d, +struct xen_add_to_physmap_range *xatpr) +{ +int rc;
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4441
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ +/* Process entries in reverse order to allow continuations */ +while ( xatpr->size >0 ) + { +xen_ulong_t idx; +xen_pfn_t gpfn; +struct xen_add_to_physmap xatp; + + rc =copy_from_guest_offset (&idx, xatpr->idxs, xatpr->size-1 ,1 ); +if ( rc <0 )
copy_from_guest_offset() returns the number of bytes that could not be copied, which would never be < 0.
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4445
Quoted 4 lines
xen/arch/x86/mm.c +4
-0+ goto out; + + rc =copy_from_guest_offset (&gpfn, xatpr->gpfns, xatpr->size-1 ,1 ); +if ( rc <0 )
Ditto.
xen/arch/x86/mm.c static int xenmem_add_to_physmap(struct domain *d, · line 4453
Quoted 8 lines
xen/arch/x86/mm.c +8
-0+ goto out; + + xatp.space = xatpr->space; + xatp.idx = idx; + xatp.gpfn = gpfn; + rc =xenmem_add_to_physmap_once (d, &xatp, xatpr->foreign_domid); + +if (rc)
Whitespace missing.
Quoted 25 lines
xen/arch/x86/mm.c +18
-0+ goto out; + + xatpr->size--; + +/* Check for continuation if it's not the last interation */ +if ( xatpr->size >0 &&hypercall_preempt_check () ) + { + rc = -EAGAIN ; + goto out; + } + } + + rc =0 ; + +out: +return rc; + }long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg)@@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +case XENMEM_add_to_physmap_range:
xen/arch/x86/mm.c long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4528
Quoted 10 lines
xen/arch/x86/mm.c +10
-0+ { +struct xen_add_to_physmap_range xatpr; +struct domain *d; + +if (copy_from_guest (&xatpr, arg,1 ) ) +return -EFAULT ; + + rc =rcu_lock_target_domain_by_id (xatpr.domid, &d); +if ( rc !=0 ) +return rc;
There should be an XSM hook here somewhere.
Quoted 25 lines
xen/arch/x86/mm.c +14
-0+ rc =xenmem_add_to_physmap_range (d, &xatpr); + +rcu_unlock_domain (d); + +if ( rc &©_to_guest (arg, &xatpr,1 ) ) + rc = -EFAULT ; + +if ( rc == -EAGAIN ) + rc =hypercall_create_continuation ( + __HYPERVISOR_memory_op,"ih" , op, arg); + +return rc; + } +case XENMEM_set_memory_map: {struct xen_foreign_memory_map fmap;Signature · 7 lines
1.7.2.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel