[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 6/7] x86: add iommu_op to query reserved ranges
>>> On 19.03.18 at 16:36, <Paul.Durrant@xxxxxxxxxx> wrote: >> From: Jan Beulich [mailto:JBeulich@xxxxxxxx] >> Sent: 19 March 2018 15:14 >> >> >>> On 12.02.18 at 11:47, <paul.durrant@xxxxxxxxxx> wrote: >> > --- a/xen/arch/x86/iommu_op.c >> > +++ b/xen/arch/x86/iommu_op.c >> > @@ -22,6 +22,58 @@ >> > #include <xen/event.h> >> > #include <xen/guest_access.h> >> > #include <xen/hypercall.h> >> > +#include <xen/iommu.h> >> > + >> > +struct get_rdm_ctxt { >> > + unsigned int max_entries; >> > + unsigned int nr_entries; >> > + XEN_GUEST_HANDLE(xen_iommu_reserved_region_t) regions; >> > +}; >> > + >> > +static int get_rdm(xen_pfn_t start, xen_ulong_t nr, u32 id, void *arg) >> > +{ >> > + struct get_rdm_ctxt *ctxt = arg; >> > + >> > + if ( ctxt->nr_entries < ctxt->max_entries ) >> > + { >> > + xen_iommu_reserved_region_t region = { >> > + .start_bfn = start, >> > + .nr_frames = nr, >> > + }; >> > + >> > + if ( copy_to_guest_offset(ctxt->regions, ctxt->nr_entries, >> > ®ion, >> > + 1) ) >> > + return -EFAULT; >> > + } >> > + >> > + ctxt->nr_entries++; >> > + >> > + return 1; >> > +} >> > + >> > +static int iommuop_query_reserved(struct >> xen_iommu_op_query_reserved *op) >> > +{ >> > + struct get_rdm_ctxt ctxt = { >> > + .max_entries = op->nr_entries, >> > + .regions = op->regions, >> > + }; >> > + int rc; >> > + >> > + if (op->pad != 0) >> > + return -EINVAL; >> > + >> > + rc = iommu_get_reserved_device_memory(get_rdm, &ctxt); >> > + if ( rc ) >> > + return rc; >> > + >> > + /* Pass back the actual number of reserved regions */ >> > + op->nr_entries = ctxt.nr_entries; >> > + >> > + if ( ctxt.nr_entries > ctxt.max_entries ) >> > + return -ENOBUFS; >> > + >> > + return 0; >> > +} >> >> One more note here: As it looks we can only hope there won't be >> too many RMRRs, as the number of entries that can be requested >> here is basically unbounded. >> > > The caller has to be able to allocate a buffer large enough but, yes there > is no explicit limit. I'll add pre-empt checks. Thing is - preempt check probably won't be easy with the way iommu_get_reserved_device_memory() works. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |