From: Wei Liu Subject: [PATCH v3 10/19] xen: handle XENMEM_get_vnumainfo in compat_memory_op Date: Tue, 13 Jan 2015 12:11:38 +0000 Message-ID: <1421151107-20842-11-git-send-email-wei.liu2@citrix.com> References: <1421151107-20842-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421151107-20842-1-git-send-email-wei.liu2@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: xen-devel@lists.xen.org Cc: dario.faggioli@citrix.com, Wei Liu , jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org Signed-off-by: Wei Liu Cc: Jan Beulich --- Changes in v3: 1. Fix hard tabs. 2. Fix subject line. 3. Add extra hunk to handle -ENOBUFS (hence drop Reviewed-by:) --- xen/common/compat/memory.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/xlat.lst | 2 ++ 2 files changed, 48 insertions(+) diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index 06c90be..5e69282 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -15,6 +15,7 @@ CHECK_TYPE(domid); #undef xen_domid_t CHECK_mem_access_op; +CHECK_vmemrange; int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) { @@ -32,12 +33,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) struct xen_add_to_physmap *atp; struct xen_add_to_physmap_batch *atpb; struct xen_remove_from_physmap *xrfp; + struct xen_vnuma_topology_info *vnuma; } nat; union { struct compat_memory_reservation rsrv; struct compat_memory_exchange xchg; struct compat_add_to_physmap atp; struct compat_add_to_physmap_batch atpb; + struct compat_vnuma_topology_info vnuma; } cmp; set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE); @@ -273,11 +276,46 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) break; } + case XENMEM_get_vnumainfo: + { + enum XLAT_vnuma_topology_info_vdistance vdistance = + XLAT_vnuma_topology_info_vdistance_h; + enum XLAT_vnuma_topology_info_vcpu_to_vnode vcpu_to_vnode = + XLAT_vnuma_topology_info_vcpu_to_vnode_h; + enum XLAT_vnuma_topology_info_vmemrange vmemrange = + XLAT_vnuma_topology_info_vmemrange_h; + + if ( copy_from_guest(&cmp.vnuma, compat, 1) ) + return -EFAULT; + +#define XLAT_vnuma_topology_info_HNDL_vdistance_h(_d_, _s_) \ + guest_from_compat_handle((_d_)->vdistance.h, (_s_)->vdistance.h) +#define XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h(_d_, _s_) \ + guest_from_compat_handle((_d_)->vcpu_to_vnode.h, (_s_)->vcpu_to_vnode.h) +#define XLAT_vnuma_topology_info_HNDL_vmemrange_h(_d_, _s_) \ + guest_from_compat_handle((_d_)->vmemrange.h, (_s_)->vmemrange.h) + + XLAT_vnuma_topology_info(nat.vnuma, &cmp.vnuma); + +#undef XLAT_vnuma_topology_info_HNDL_vdistance_h +#undef XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h +#undef XLAT_vnuma_topology_info_HNDL_vmemrange_h + break; + } + default: return compat_arch_memory_op(cmd, compat); } rc = do_memory_op(cmd, nat.hnd); + if ( rc == -ENOBUFS && op == XENMEM_get_vnumainfo ) + { + cmp.vnuma.nr_vnodes = nat.vnuma->nr_vnodes; + cmp.vnuma.nr_vcpus = nat.vnuma->nr_vcpus; + cmp.vnuma.nr_vmemranges = nat.vnuma->nr_vmemranges; + if ( __copy_to_guest(compat, &cmp.vnuma, 1) ) + rc = -EFAULT; + } if ( rc < 0 ) break; @@ -398,6 +436,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) case XENMEM_remove_from_physmap: break; + case XENMEM_get_vnumainfo: + cmp.vnuma.nr_vnodes = nat.vnuma->nr_vnodes; + cmp.vnuma.nr_vcpus = nat.vnuma->nr_vcpus; + cmp.vnuma.nr_vmemranges = nat.vnuma->nr_vmemranges; + if ( __copy_to_guest(compat, &cmp.vnuma, 1) ) + rc = -EFAULT; + break; + default: domain_crash(current->domain); split = 0; diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst index 41b3e35..9c9fd9a 100644 --- a/xen/include/xlat.lst +++ b/xen/include/xlat.lst @@ -64,6 +64,8 @@ ? mem_access_op memory.h ! pod_target memory.h ! remove_from_physmap memory.h +? vmemrange memory.h +! vnuma_topology_info memory.h ? physdev_eoi physdev.h ? physdev_get_free_pirq physdev.h ? physdev_irq physdev.h -- 1.7.10.4