[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC XEN PATCH v4 25/41] xen/pmem: support PMEM_REGION_TYPE_DATA for XEN_SYSCTL_nvdimm_pmem_get_regions
Allow XEN_SYSCTL_nvdimm_pmem_get_regions to return a list of data PMEM regions. Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx> --- Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> --- tools/libxc/xc_misc.c | 8 ++++++++ xen/common/pmem.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 12 ++++++++++++ 3 files changed, 66 insertions(+) diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index b535f83df6..f425fb01e0 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -943,6 +943,10 @@ int xc_nvdimm_pmem_get_regions(xc_interface *xch, uint8_t type, size = sizeof(xen_sysctl_nvdimm_pmem_mgmt_region_t) * max; break; + case PMEM_REGION_TYPE_DATA: + size = sizeof(xen_sysctl_nvdimm_pmem_data_region_t) * max; + break; + default: return -EINVAL; } @@ -967,6 +971,10 @@ int xc_nvdimm_pmem_get_regions(xc_interface *xch, uint8_t type, set_xen_guest_handle(regions->u_buffer.mgmt_regions, buffer); break; + case PMEM_REGION_TYPE_DATA: + set_xen_guest_handle(regions->u_buffer.data_regions, buffer); + break; + default: rc = -EINVAL; goto out; diff --git a/xen/common/pmem.c b/xen/common/pmem.c index b1cefc3d70..cd557c7851 100644 --- a/xen/common/pmem.c +++ b/xen/common/pmem.c @@ -243,6 +243,48 @@ static int pmem_get_mgmt_regions( return rc; } +static int pmem_get_data_regions( + XEN_GUEST_HANDLE_64(xen_sysctl_nvdimm_pmem_data_region_t) regions, + unsigned int *num_regions) +{ + struct list_head *cur; + unsigned int nr = 0, max = *num_regions; + xen_sysctl_nvdimm_pmem_data_region_t region; + int rc = 0; + + if ( !guest_handle_okay(regions, max * sizeof(region)) ) + return -EINVAL; + + spin_lock(&pmem_data_lock); + + list_for_each(cur, &pmem_data_regions) + { + struct pmem *pmem = list_entry(cur, struct pmem, link); + + if ( nr >= max ) + break; + + region.smfn = pmem->smfn; + region.emfn = pmem->emfn; + region.mgmt_smfn = pmem->u.data.mgmt_smfn; + region.mgmt_emfn = pmem->u.data.mgmt_emfn; + + if ( copy_to_guest_offset(regions, nr, ®ion, 1) ) + { + rc = -EFAULT; + break; + } + + nr++; + } + + spin_unlock(&pmem_data_lock); + + *num_regions = nr; + + return rc; +} + static int pmem_get_regions(xen_sysctl_nvdimm_pmem_regions_t *regions) { unsigned int type = regions->type, max = regions->num_regions; @@ -261,6 +303,10 @@ static int pmem_get_regions(xen_sysctl_nvdimm_pmem_regions_t *regions) rc = pmem_get_mgmt_regions(regions->u_buffer.mgmt_regions, &max); break; + case PMEM_REGION_TYPE_DATA: + rc = pmem_get_data_regions(regions->u_buffer.data_regions, &max); + break; + default: rc = -EINVAL; } diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index d1fbb30247..c3555ced5c 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1072,6 +1072,16 @@ struct xen_sysctl_nvdimm_pmem_mgmt_region { typedef struct xen_sysctl_nvdimm_pmem_mgmt_region xen_sysctl_nvdimm_pmem_mgmt_region_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_nvdimm_pmem_mgmt_region_t); +/* PMEM_REGION_TYPE_DATA */ +struct xen_sysctl_nvdimm_pmem_data_region { + uint64_t smfn; + uint64_t emfn; + uint64_t mgmt_smfn; + uint64_t mgmt_emfn; +}; +typedef struct xen_sysctl_nvdimm_pmem_data_region xen_sysctl_nvdimm_pmem_data_region_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_nvdimm_pmem_data_region_t); + /* XEN_SYSCTL_nvdimm_pmem_get_regions_nr */ struct xen_sysctl_nvdimm_pmem_regions_nr { uint8_t type; /* IN: one of PMEM_REGION_TYPE_* */ @@ -1092,6 +1102,8 @@ struct xen_sysctl_nvdimm_pmem_regions { XEN_GUEST_HANDLE_64(xen_sysctl_nvdimm_pmem_raw_region_t) raw_regions; /* if type == PMEM_REGION_TYPE_MGMT */ XEN_GUEST_HANDLE_64(xen_sysctl_nvdimm_pmem_mgmt_region_t) mgmt_regions; + /* if type == PMEM_REGION_TYPE_DATA */ + XEN_GUEST_HANDLE_64(xen_sysctl_nvdimm_pmem_data_region_t) data_regions; } u_buffer; /* IN: the guest handler where the entries of PMEM regions of the type @type are returned */ }; -- 2.15.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |