Commit c83e878b authored by Daniel De Graaf's avatar Daniel De Graaf

xen/arch/*: add struct domain parameter to arch_do_domctl

Since the arch-independent do_domctl function now RCU locks the domain
specified by op->domain, pass the struct domain to the arch-specific
domctl function and remove the duplicate per-subfunction locking.

This also removes two get_domain/put_domain call pairs (in
XEN_DOMCTL_assign_device and XEN_DOMCTL_deassign_device), replacing
them with RCU locking.
Signed-off-by: default avatarDaniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: default avatarTim Deegan <tim@xen.org>
Acked-by: default avatarJan Beulich <jbeulich@suse.com>
Committed-by: default avatarKeir Fraser <keir@xen.org>
parent 8ea0a35a
......@@ -10,7 +10,7 @@
#include <xen/errno.h>
#include <public/domctl.h>
long arch_do_domctl(struct xen_domctl *domctl,
long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
{
return -ENOSYS;
......
This diff is collapsed.
......@@ -882,7 +882,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
break;
default:
ret = arch_do_domctl(op, u_domctl);
ret = arch_do_domctl(op, d, u_domctl);
break;
}
......
......@@ -542,10 +542,9 @@ void iommu_crash_shutdown(void)
}
int iommu_do_domctl(
struct xen_domctl *domctl,
struct xen_domctl *domctl, struct domain *d,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
{
struct domain *d;
u16 seg;
u8 bus, devfn;
int ret = 0;
......@@ -564,10 +563,6 @@ int iommu_do_domctl(
if ( ret )
break;
ret = -EINVAL;
if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
break;
seg = domctl->u.get_device_group.machine_sbdf >> 16;
bus = (domctl->u.get_device_group.machine_sbdf >> 8) & 0xff;
devfn = domctl->u.get_device_group.machine_sbdf & 0xff;
......@@ -588,7 +583,6 @@ int iommu_do_domctl(
}
if ( __copy_field_to_guest(u_domctl, domctl, u.get_device_group) )
ret = -EFAULT;
rcu_unlock_domain(d);
}
break;
......@@ -611,20 +605,15 @@ int iommu_do_domctl(
break;
case XEN_DOMCTL_assign_device:
if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) ||
unlikely(d->is_dying) )
if ( unlikely(d->is_dying) )
{
printk(XENLOG_G_ERR
"XEN_DOMCTL_assign_device: get_domain_by_id() failed\n");
ret = -EINVAL;
if ( d )
goto assign_device_out;
break;
}
ret = xsm_assign_device(d, domctl->u.assign_device.machine_sbdf);
if ( ret )
goto assign_device_out;
break;
seg = domctl->u.get_device_group.machine_sbdf >> 16;
bus = (domctl->u.assign_device.machine_sbdf >> 8) & 0xff;
......@@ -638,22 +627,12 @@ int iommu_do_domctl(
seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
d->domain_id, ret);
assign_device_out:
put_domain(d);
break;
case XEN_DOMCTL_deassign_device:
if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) )
{
printk(XENLOG_G_ERR
"XEN_DOMCTL_deassign_device: get_domain_by_id() failed\n");
ret = -EINVAL;
break;
}
ret = xsm_deassign_device(d, domctl->u.assign_device.machine_sbdf);
if ( ret )
goto deassign_device_out;
break;
seg = domctl->u.get_device_group.machine_sbdf >> 16;
bus = (domctl->u.assign_device.machine_sbdf >> 8) & 0xff;
......@@ -668,8 +647,6 @@ int iommu_do_domctl(
seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
d->domain_id, ret);
deassign_device_out:
put_domain(d);
break;
default:
......
......@@ -37,7 +37,7 @@ do_domctl(
extern long
arch_do_domctl(
struct xen_domctl *domctl,
struct xen_domctl *domctl, struct domain *d,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl);
extern long
......
......@@ -132,7 +132,8 @@ void iommu_crash_shutdown(void);
void iommu_set_dom0_mapping(struct domain *d);
void iommu_share_p2m_table(struct domain *d);
int iommu_do_domctl(struct xen_domctl *, XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
int iommu_do_domctl(struct xen_domctl *, struct domain *d,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count);
void iommu_iotlb_flush_all(struct domain *d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment