From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH v4 17/21] xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled Date: Tue, 22 Apr 2014 14:14:31 +0100 Message-ID: <1398172475-27873-18-git-send-email-julien.grall@linaro.org> References: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WcaXk-0006Ex-1m for xen-devel@lists.xenproject.org; Tue, 22 Apr 2014 13:15:24 +0000 Received: by mail-ee0-f51.google.com with SMTP id c13so4672899eek.10 for ; Tue, 22 Apr 2014 06:15:17 -0700 (PDT) In-Reply-To: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org When iommu={disable,off,no,false} is given to Xen command line, the IOMMU framework won't specify that the device shouldn't be passthrough to DOM0. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v2: - Patch added --- xen/arch/arm/device.c | 15 +++++++++++++++ xen/arch/arm/domain_build.c | 10 ++++++++++ xen/include/asm-arm/device.h | 10 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index f86b2e3..59e94c0 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -67,6 +67,21 @@ int __init device_init(struct dt_device_node *dev, enum device_type type, return -EBADF; } +enum device_type device_get_type(const struct dt_device_node *dev) +{ + const struct device_desc *desc; + + ASSERT(dev != NULL); + + for ( desc = _sdevice; desc != _edevice; desc++ ) + { + if ( device_is_compatible(desc, dev) ) + return desc->type; + } + + return DEVICE_UNKNOWN; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 12e8238..b9b2fa0 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -833,6 +834,15 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, return 0; } + /* Even if the IOMMU device is not used by Xen, it should not be + * passthrough to DOM0 + */ + if ( device_get_type(node) == DEVICE_IOMMU ) + { + DPRINT(" IOMMU, skip it\n"); + return 0; + } + /* * Some device doesn't need to be mapped in Xen: * - Memory: the guest will see a different view of memory. It will diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index ed04344..60109cc 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -8,6 +8,8 @@ enum device_type { DEVICE_SERIAL, DEVICE_IOMMU, + /* Use for error */ + DEVICE_UNKNOWN, }; struct device_desc { @@ -32,6 +34,14 @@ struct device_desc { int __init device_init(struct dt_device_node *dev, enum device_type type, const void *data); +/** + * device_get_type - Get the type of the device + * @dev: device to match + * + * Return the device type on success or DEVICE_ANY on failure + */ +enum device_type device_get_type(const struct dt_device_node *dev); + #define DT_DEVICE_START(_name, _namestr, _type) \ static const struct device_desc __dev_desc_##_name __used \ __attribute__((__section__(".dev.info"))) = { \ -- 1.7.10.4