From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [v7][PATCH 03/16] xen/passthrough: extend hypercall to support rdm reservation policy Date: Tue, 14 Jul 2015 11:46:38 +0100 Message-ID: <55A4E88E.9060502@eu.citrix.com> References: <1436420047-25356-1-git-send-email-tiejun.chen@intel.com> <1436420047-25356-4-git-send-email-tiejun.chen@intel.com> <55A35EFA.9030304@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <55A35EFA.9030304@intel.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: "Chen, Tiejun" Cc: Kevin Tian , Keir Fraser , Suravee Suthikulpanit , Andrew Cooper , Tim Deegan , "xen-devel@lists.xen.org" , Aravind Gopalakrishnan , Jan Beulich , Yang Zhang , Stefano Stabellini , Ian Campbell List-Id: xen-devel@lists.xenproject.org On 07/13/2015 07:47 AM, Chen, Tiejun wrote: >> Thanks for this; a few more comments... >> > > Thanks for your time. > >>> @@ -1577,9 +1578,15 @@ int iommu_do_pci_domctl( >>> seg = machine_sbdf >> 16; >>> bus = PCI_BUS(machine_sbdf); >>> devfn = PCI_DEVFN2(machine_sbdf); >>> + flag = domctl->u.assign_device.flag; >>> + if ( flag > XEN_DOMCTL_DEV_RDM_RELAXED ) >> >> This is not a blocker, but a stylistic comment: I would have inverted >> the bitmask here, as that's conceptually what you're checking. I >> won't make this a blocker for going in. > > What about this? > > diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c > index 6e23fc6..17a4206 100644 > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -1579,7 +1579,7 @@ int iommu_do_pci_domctl( > bus = PCI_BUS(machine_sbdf); > devfn = PCI_DEVFN2(machine_sbdf); > flag = domctl->u.assign_device.flag; > - if ( flag > XEN_DOMCTL_DEV_RDM_RELAXED ) > + if ( flag & ~XEN_DOMCTL_DEV_RDM_MASK ) > { > ret = -EINVAL; > break; > diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h > index bca25c9..07549a4 100644 > --- a/xen/include/public/domctl.h > +++ b/xen/include/public/domctl.h > @@ -480,6 +480,7 @@ struct xen_domctl_assign_device { > } u; > /* IN */ > #define XEN_DOMCTL_DEV_RDM_RELAXED 1 > +#define XEN_DOMCTL_DEV_RDM_MASK 0x1 The way this sort of thing is defined in the rest of domctl.h is like this: #define _XEN_DOMCTL_CDF_hvm_guest 0 #define XEN_DOMCTL_CDF_hvm_guest (1U<<_XEN_DOMCTL_CDF_hvm_guest) So the above should be #define _XEN_DOMCTL_DEV_RDM_RELAXED 0 #define XEN_DOMCTL_DEV_RDM_RELAXED (1U<<_XEN_DOMCTL_DEV_RDM_RELAXED) And then your check in iommu_do_pci_domctl() would look like if (flag & ~XEN_DOMCTL_DEV_RDM_RELAXED) And if we end up adding any extra flags, we just | them into the above conditional, as is done in, for example, the XEN_DOMCTL_createdomain case in xen/common/domctl.c:do_domctl(). Thanks, -George