From: "Chen, Tiejun" <tiejun.chen@intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
"jbeulich@suse.com" <jbeulich@suse.com>,
"tim@xen.org" <tim@xen.org>,
"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
"Zhang, Yang Z" <yang.z.zhang@intel.com>,
"wei.liu2@citrix.com" <wei.liu2@citrix.com>,
"ian.campbell@citrix.com" <ian.campbell@citrix.com>,
"Ian.Jackson@eu.citrix.com" <Ian.Jackson@eu.citrix.com>,
"stefano.stabellini@citrix.com" <stefano.stabellini@citrix.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [v3][PATCH 10/16] tools: extend xc_assign_device() to support rdm reservation policy
Date: Fri, 12 Jun 2015 16:25:24 +0800 [thread overview]
Message-ID: <557A9774.8070003@intel.com> (raw)
In-Reply-To: <AADFC41AFE54684AB9EE6CBC0274A5D12628A21A@SHSMSX101.ccr.corp.intel.com>
On 2015/6/11 18:02, Tian, Kevin wrote:
>> From: Chen, Tiejun
>> Sent: Thursday, June 11, 2015 9:15 AM
>>
>> This patch passes rdm reservation policy to xc_assign_device() so the policy
>> is checked when assigning devices to a VM.
>>
>> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
>> ---
>> tools/libxc/include/xenctrl.h | 3 ++-
>> tools/libxc/xc_domain.c | 6 +++++-
>> tools/libxl/libxl_pci.c | 3 ++-
>> tools/ocaml/libs/xc/xenctrl_stubs.c | 18 ++++++++++++++----
>> tools/python/xen/lowlevel/xc/xc.c | 29 +++++++++++++++++++----------
>> 5 files changed, 42 insertions(+), 17 deletions(-)
>>
>> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
>> index 6c01362..7fd60d5 100644
>> --- a/tools/libxc/include/xenctrl.h
>> +++ b/tools/libxc/include/xenctrl.h
>> @@ -2078,7 +2078,8 @@ int xc_hvm_destroy_ioreq_server(xc_interface *xch,
>> /* HVM guest pass-through */
>> int xc_assign_device(xc_interface *xch,
>> uint32_t domid,
>> - uint32_t machine_sbdf);
>> + uint32_t machine_sbdf,
>> + uint32_t flag);
>>
>> int xc_get_device_group(xc_interface *xch,
>> uint32_t domid,
>> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
>> index 4f96e1b..19127ec 100644
>> --- a/tools/libxc/xc_domain.c
>> +++ b/tools/libxc/xc_domain.c
>> @@ -1697,7 +1697,8 @@ int xc_domain_setdebugging(xc_interface *xch,
>> int xc_assign_device(
>> xc_interface *xch,
>> uint32_t domid,
>> - uint32_t machine_sbdf)
>> + uint32_t machine_sbdf,
>> + uint32_t flag)
>> {
>> DECLARE_DOMCTL;
>>
>> @@ -1705,6 +1706,7 @@ int xc_assign_device(
>> domctl.domain = domid;
>> domctl.u.assign_device.dev = XEN_DOMCTL_DEV_PCI;
>> domctl.u.assign_device.u.pci.machine_sbdf = machine_sbdf;
>> + domctl.u.assign_device.flag = flag;
>>
>> return do_domctl(xch, &domctl);
>> }
>> @@ -1792,6 +1794,8 @@ int xc_assign_dt_device(
>>
>> domctl.u.assign_device.dev = XEN_DOMCTL_DEV_DT;
>> domctl.u.assign_device.u.dt.size = size;
>> + /* DT doesn't own any RDM. */
>> + domctl.u.assign_device.flag = XEN_DOMCTL_DEV_NO_RDM;
>
> still not clear about this NO_RDM flag. If a device-tree device doesn't
> own RDM, the hypervisor will know it. Why do we require toolstack
> to tell hypervisor not use it?
I think an explicit flag can make this sort of case identified, right?
And other flags brings easily some confusions, or even a potential risk
in the future.
Thanks
Tiejun
>
>> set_xen_guest_handle(domctl.u.assign_device.u.dt.path, path);
>>
>> rc = do_domctl(xch, &domctl);
>> diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
>> index e0743f8..632c15e 100644
>> --- a/tools/libxl/libxl_pci.c
>> +++ b/tools/libxl/libxl_pci.c
>> @@ -894,6 +894,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid,
>> libxl_device_pci *pcidev, i
>> FILE *f;
>> unsigned long long start, end, flags, size;
>> int irq, i, rc, hvm = 0;
>> + uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
>>
>> if (type == LIBXL_DOMAIN_TYPE_INVALID)
>> return ERROR_FAIL;
>> @@ -987,7 +988,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid,
>> libxl_device_pci *pcidev, i
>>
>> out:
>> if (!libxl_is_stubdom(ctx, domid, NULL)) {
>> - rc = xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
>> + rc = xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev), flag);
>> if (rc < 0 && (hvm || errno != ENOSYS)) {
>> LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_assign_device failed");
>> return ERROR_FAIL;
>> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
>> index 64f1137..317bf75 100644
>> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
>> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
>> @@ -1172,12 +1172,19 @@ CAMLprim value stub_xc_domain_test_assign_device(value
>> xch, value domid, value d
>> CAMLreturn(Val_bool(ret == 0));
>> }
>>
>> -CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc)
>> +static int domain_assign_device_rdm_flag_table[] = {
>> + XEN_DOMCTL_DEV_NO_RDM,
>> + XEN_DOMCTL_DEV_RDM_RELAXED,
>> + XEN_DOMCTL_DEV_RDM_STRICT,
>> +};
>> +
>> +CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc,
>> + value rflag)
>> {
>> - CAMLparam3(xch, domid, desc);
>> + CAMLparam4(xch, domid, desc, rflag);
>> int ret;
>> int domain, bus, dev, func;
>> - uint32_t sbdf;
>> + uint32_t sbdf, flag;
>>
>> domain = Int_val(Field(desc, 0));
>> bus = Int_val(Field(desc, 1));
>> @@ -1185,7 +1192,10 @@ CAMLprim value stub_xc_domain_assign_device(value xch,
>> value domid, value desc)
>> func = Int_val(Field(desc, 3));
>> sbdf = encode_sbdf(domain, bus, dev, func);
>>
>> - ret = xc_assign_device(_H(xch), _D(domid), sbdf);
>> + ret = Int_val(Field(rflag, 0));
>> + flag = domain_assign_device_rdm_flag_table[ret];
>> +
>> + ret = xc_assign_device(_H(xch), _D(domid), sbdf, flag);
>>
>> if (ret < 0)
>> failwith_xc(_H(xch));
>> diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
>> index c77e15b..172bdf0 100644
>> --- a/tools/python/xen/lowlevel/xc/xc.c
>> +++ b/tools/python/xen/lowlevel/xc/xc.c
>> @@ -592,7 +592,8 @@ static int token_value(char *token)
>> return strtol(token, NULL, 16);
>> }
>>
>> -static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
>> +static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func,
>> + int *flag)
>> {
>> char *token;
>>
>> @@ -607,8 +608,16 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int
>> *func)
>> *dev = token_value(token);
>> token = strchr(token, ',') + 1;
>> *func = token_value(token);
>> - token = strchr(token, ',');
>> - *str = token ? token + 1 : NULL;
>> + token = strchr(token, ',') + 1;
>> + if ( token ) {
>> + *flag = token_value(token);
>> + *str = token + 1;
>> + }
>> + else
>> + {
>> + *flag = XEN_DOMCTL_DEV_RDM_STRICT;
>> + *str = NULL;
>> + }
>>
>> return 1;
>> }
>> @@ -620,14 +629,14 @@ static PyObject *pyxc_test_assign_device(XcObject *self,
>> uint32_t dom;
>> char *pci_str;
>> int32_t sbdf = 0;
>> - int seg, bus, dev, func;
>> + int seg, bus, dev, func, flag;
>>
>> static char *kwd_list[] = { "domid", "pci", NULL };
>> if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
>> &dom, &pci_str) )
>> return NULL;
>>
>> - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
>> + while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
>> {
>> sbdf = seg << 16;
>> sbdf |= (bus & 0xff) << 8;
>> @@ -653,21 +662,21 @@ static PyObject *pyxc_assign_device(XcObject *self,
>> uint32_t dom;
>> char *pci_str;
>> int32_t sbdf = 0;
>> - int seg, bus, dev, func;
>> + int seg, bus, dev, func, flag;
>>
>> static char *kwd_list[] = { "domid", "pci", NULL };
>> if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
>> &dom, &pci_str) )
>> return NULL;
>>
>> - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
>> + while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
>> {
>> sbdf = seg << 16;
>> sbdf |= (bus & 0xff) << 8;
>> sbdf |= (dev & 0x1f) << 3;
>> sbdf |= (func & 0x7);
>>
>> - if ( xc_assign_device(self->xc_handle, dom, sbdf) != 0 )
>> + if ( xc_assign_device(self->xc_handle, dom, sbdf, flag) != 0 )
>> {
>> if (errno == ENOSYS)
>> sbdf = -1;
>> @@ -686,14 +695,14 @@ static PyObject *pyxc_deassign_device(XcObject *self,
>> uint32_t dom;
>> char *pci_str;
>> int32_t sbdf = 0;
>> - int seg, bus, dev, func;
>> + int seg, bus, dev, func, flag;
>>
>> static char *kwd_list[] = { "domid", "pci", NULL };
>> if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
>> &dom, &pci_str) )
>> return NULL;
>>
>> - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
>> + while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
>> {
>> sbdf = seg << 16;
>> sbdf |= (bus & 0xff) << 8;
>> --
>> 1.9.1
>
>
>
next prev parent reply other threads:[~2015-06-12 8:25 UTC|newest]
Thread overview: 114+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 1:15 [v3][PATCH 00/16] Fix RMRR Tiejun Chen
2015-06-11 1:15 ` [v3][PATCH 01/16] xen: introduce XENMEM_reserved_device_memory_map Tiejun Chen
2015-06-11 8:56 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 02/16] xen/x86/p2m: introduce set_identity_p2m_entry Tiejun Chen
2015-06-11 7:33 ` Jan Beulich
2015-06-11 8:23 ` Chen, Tiejun
2015-06-11 9:23 ` Jan Beulich
2015-06-11 9:25 ` Chen, Tiejun
2015-06-11 9:00 ` Tian, Kevin
2015-06-11 9:18 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 03/16] xen/vtd: create RMRR mapping Tiejun Chen
2015-06-11 9:14 ` Tian, Kevin
2015-06-11 9:31 ` Chen, Tiejun
2015-06-11 14:07 ` Tim Deegan
2015-06-12 2:43 ` Chen, Tiejun
2015-06-12 5:58 ` Chen, Tiejun
2015-06-12 5:59 ` Tian, Kevin
2015-06-12 6:13 ` Chen, Tiejun
2015-06-18 10:07 ` Tim Deegan
2015-06-19 0:37 ` Chen, Tiejun
2015-06-17 10:03 ` Jan Beulich
2015-06-18 6:23 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 04/16] xen/passthrough: extend hypercall to support rdm reservation policy Tiejun Chen
2015-06-11 9:28 ` Tian, Kevin
2015-06-12 6:31 ` Chen, Tiejun
2015-06-12 8:45 ` Jan Beulich
2015-06-12 9:20 ` Chen, Tiejun
2015-06-12 9:26 ` Jan Beulich
2015-06-15 7:39 ` Chen, Tiejun
2015-06-16 2:30 ` Tian, Kevin
2015-06-17 10:11 ` Jan Beulich
2015-06-18 7:14 ` Chen, Tiejun
2015-06-18 7:53 ` Jan Beulich
2015-06-18 8:48 ` Chen, Tiejun
2015-06-18 9:13 ` Jan Beulich
2015-06-18 9:31 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 05/16] xen: enable XENMEM_memory_map in hvm Tiejun Chen
2015-06-11 9:29 ` Tian, Kevin
2015-06-17 10:14 ` Jan Beulich
2015-06-18 8:53 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 06/16] hvmloader: get guest memory map into memory_map[] Tiejun Chen
2015-06-11 9:38 ` Tian, Kevin
2015-06-12 7:33 ` Chen, Tiejun
2015-06-17 10:22 ` Jan Beulich
2015-06-18 9:13 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 07/16] hvmloader/pci: skip reserved ranges Tiejun Chen
2015-06-11 9:51 ` Tian, Kevin
2015-06-12 7:53 ` Chen, Tiejun
2015-06-16 5:47 ` Tian, Kevin
2015-06-16 9:29 ` Chen, Tiejun
2015-06-16 9:40 ` Jan Beulich
2015-06-17 7:10 ` Chen, Tiejun
2015-06-17 7:19 ` Jan Beulich
2015-06-17 7:54 ` Chen, Tiejun
2015-06-17 8:05 ` Jan Beulich
2015-06-17 8:26 ` Chen, Tiejun
2015-06-17 8:47 ` Chen, Tiejun
2015-06-17 9:02 ` Jan Beulich
2015-06-17 9:18 ` Chen, Tiejun
2015-06-17 9:24 ` Jan Beulich
2015-06-18 6:17 ` Chen, Tiejun
2015-06-18 6:29 ` Jan Beulich
2015-06-18 7:01 ` Chen, Tiejun
2015-06-18 8:05 ` Jan Beulich
2015-06-19 2:02 ` Chen, Tiejun
2015-06-23 9:46 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 08/16] hvmloader/e820: construct guest e820 table Tiejun Chen
2015-06-11 9:59 ` Tian, Kevin
2015-06-12 8:19 ` Chen, Tiejun
2015-06-16 5:54 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 09/16] tools/libxc: Expose new hypercall xc_reserved_device_memory_map Tiejun Chen
2015-06-11 10:00 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 10/16] tools: extend xc_assign_device() to support rdm reservation policy Tiejun Chen
2015-06-11 10:02 ` Tian, Kevin
2015-06-12 8:25 ` Chen, Tiejun [this message]
2015-06-16 2:28 ` Tian, Kevin
2015-06-12 15:43 ` Wei Liu
2015-06-15 1:12 ` Chen, Tiejun
2015-06-15 14:58 ` Wei Liu
2015-06-16 2:31 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 11/16] tools: introduce some new parameters to set rdm policy Tiejun Chen
2015-06-12 16:02 ` Wei Liu
2015-06-15 1:19 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 12/16] tools/libxl: passes rdm reservation policy Tiejun Chen
2015-06-12 16:17 ` Wei Liu
2015-06-15 1:26 ` Chen, Tiejun
2015-06-15 15:00 ` Wei Liu
2015-06-11 1:15 ` [v3][PATCH 13/16] tools/libxl: detect and avoid conflicts with RDM Tiejun Chen
2015-06-11 10:19 ` Tian, Kevin
2015-06-12 8:30 ` Chen, Tiejun
2015-06-12 16:39 ` Wei Liu
2015-06-15 1:50 ` Chen, Tiejun
2015-06-15 15:01 ` Wei Liu
2015-06-16 1:44 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 14/16] tools/libxl: extend XENMEM_set_memory_map Tiejun Chen
2015-06-12 16:43 ` Wei Liu
2015-06-15 2:15 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 15/16] xen/vtd: enable USB device assignment Tiejun Chen
2015-06-11 10:22 ` Tian, Kevin
2015-06-12 8:59 ` Chen, Tiejun
2015-06-16 5:58 ` Tian, Kevin
2015-06-16 6:09 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 16/16] xen/vtd: prevent from assign the device with shared rmrr Tiejun Chen
2015-06-11 10:25 ` Tian, Kevin
2015-06-12 8:44 ` Chen, Tiejun
2015-06-17 10:28 ` Jan Beulich
2015-06-18 9:23 ` Chen, Tiejun
2015-06-11 7:27 ` [v3][PATCH 00/16] Fix RMRR Jan Beulich
2015-06-11 8:42 ` Tian, Kevin
2015-06-11 9:06 ` Chen, Tiejun
2015-06-11 12:52 ` Tim Deegan
2015-06-12 2:10 ` Chen, Tiejun
2015-06-12 8:04 ` Jan Beulich
2015-06-12 8:20 ` Chen, Tiejun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=557A9774.8070003@intel.com \
--to=tiejun.chen@intel.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.