From patchwork Tue May 13 15:50:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 30084 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B5F220446 for ; Tue, 13 May 2014 15:52:05 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id 29sf1657462yhl.10 for ; Tue, 13 May 2014 08:52:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=b9tShGpFjf5svb1awAVO/neoa8moGP9sbXDRXyDiDvo=; b=PZ1TfIPINc1Oi89om79q0zEK7jdkwslrsJ3ZjQMQ9bWGBBlaqn4cVl3ULnPCyezsE+ QER+KGwO7Xo0ZO/5RWOZ9zQPHonMl8vMvagbE6tJonE+Tua+bVs3ME3MExKwEy1pZ41a ZnXXwn9ul5OPy79JMJZ4pIarADqCrr2MzKieTO1SR7zAgy8worHpY4Q/WYMASH+gsRiJ /0A62dE+EVzpOD2KmSiO6a/e8FnNkA9H3gkdaH3O24tFAUoCjXcD/FtN84v0+YuRdmfi tEOjGlKaw0QRifCqKQAaRTHewGNUmj0JCmXjvg0K6aJGNEm5B9aS36k/lv37WfNvrWU8 pXdA== X-Gm-Message-State: ALoCoQlNBnRn7g9XLk8Ycd2xVWH2OpJvH5M6fpShSeci2LqN97I0kIWSDvuuji0ncLnxl1qK0lu8 X-Received: by 10.224.29.129 with SMTP id q1mr17533758qac.3.1399996325293; Tue, 13 May 2014 08:52:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.201 with SMTP id z67ls1896690qgd.59.gmail; Tue, 13 May 2014 08:52:05 -0700 (PDT) X-Received: by 10.52.255.98 with SMTP id ap2mr9322118vdd.3.1399996325203; Tue, 13 May 2014 08:52:05 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id tj4si2715295vdc.69.2014.05.13.08.52.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 08:52:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id sa20so687468veb.37 for ; Tue, 13 May 2014 08:52:05 -0700 (PDT) X-Received: by 10.52.93.201 with SMTP id cw9mr403938vdb.80.1399996325099; Tue, 13 May 2014 08:52:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp162077vcb; Tue, 13 May 2014 08:52:04 -0700 (PDT) X-Received: by 10.52.141.74 with SMTP id rm10mr24885116vdb.6.1399996324631; Tue, 13 May 2014 08:52:04 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id sq9si2711496vdc.125.2014.05.13.08.52.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 May 2014 08:52:04 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WkEyn-000081-9v; Tue, 13 May 2014 15:50:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WkEyl-0008WQ-UQ for xen-devel@lists.xenproject.org; Tue, 13 May 2014 15:50:56 +0000 Received: from [85.158.139.211:3349] by server-8.bemta-5.messagelabs.com id AA/DB-11310-F5F32735; Tue, 13 May 2014 15:50:55 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1399996254!4010313!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4401 invoked from network); 13 May 2014 15:50:54 -0000 Received: from mail-ee0-f54.google.com (HELO mail-ee0-f54.google.com) (74.125.83.54) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 13 May 2014 15:50:54 -0000 Received: by mail-ee0-f54.google.com with SMTP id b57so568923eek.13 for ; Tue, 13 May 2014 08:50:54 -0700 (PDT) X-Received: by 10.14.225.73 with SMTP id y49mr42341460eep.43.1399996254341; Tue, 13 May 2014 08:50:54 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id m44sm41054917eeh.14.2014.05.13.08.50.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 08:50:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 13 May 2014 16:50:27 +0100 Message-Id: <1399996230-18201-12-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399996230-18201-1-git-send-email-julien.grall@linaro.org> References: <1399996230-18201-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v5 11/14] xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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 259f2f3..ddbb88d 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 @@ -835,6 +836,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"))) = { \