From patchwork Tue Mar 11 15:49:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 26031 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3441820068 for ; Tue, 11 Mar 2014 15:51:24 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id r5sf21220355qcx.1 for ; Tue, 11 Mar 2014 08:51:23 -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=AoeSJZuIq/+0G1QyWgJBfBJiLqbHkZxgxb8dgdLh0Qc=; b=dWqEYlnvmN0evChtqm/VsfOjUBXAaLSRWWK029nTqslmEmc2JIMMVL9HMP8TAYl+Wj Uv4Z32pp0FYtBTznTuLSnGXOOFcNatJpc4EkAUpZu2GV8ufBiuoy4KCqYhEn8SsysfBB FRvDJnzXlwlr5nPHDbDLyTqeew5KPaTEepH4ZRXPDpgDugDEd9+fktTXN05D+JG98rne Awgbx4LHszJywM2b/I4CS64MdE8kmbzqV/3sMcRwT3yMimQbdjoppiINtvFnehMhERRp REQj3hA77/irKiKfKEePUKzFu5EOyJLZrZEg428Z4rh/7PXWDLlfhmtNdCqfvocJPAyY mOdg== X-Gm-Message-State: ALoCoQl05FIiYrsMk5fEBKqnTA0Gjjl1cJGoxgeJb6WIsJUURBKp6MdpQeqtSUWFWF/4RqIAfXPU X-Received: by 10.236.69.35 with SMTP id m23mr15090214yhd.6.1394553083764; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.50 with SMTP id l47ls2535832qga.49.gmail; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) X-Received: by 10.58.220.161 with SMTP id px1mr28995641vec.13.1394553083662; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id f5si5872347vej.149.2014.03.11.08.51.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Mar 2014 08:51:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id ld13so3449705vcb.19 for ; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) X-Received: by 10.52.110.196 with SMTP id ic4mr7538998vdb.27.1394553083545; Tue, 11 Mar 2014 08:51:23 -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.78.9 with SMTP id i9csp215028vck; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) X-Received: by 10.52.250.4 with SMTP id yy4mr124987vdc.56.1394553083172; Tue, 11 Mar 2014 08:51:23 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id sq4si6551507vdc.67.2014.03.11.08.51.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 08:51:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) 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 1WNOww-00077J-Cf; Tue, 11 Mar 2014 15:50:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNOwv-00075Z-14 for xen-devel@lists.xenproject.org; Tue, 11 Mar 2014 15:50:37 +0000 Received: from [85.158.137.68:7832] by server-13.bemta-3.messagelabs.com id C7/6B-26923-CC03F135; Tue, 11 Mar 2014 15:50:36 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1394553035!7135410!1 X-Originating-IP: [209.85.212.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3863 invoked from network); 11 Mar 2014 15:50:35 -0000 Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 11 Mar 2014 15:50:35 -0000 Received: by mail-wi0-f169.google.com with SMTP id hm4so1007104wib.2 for ; Tue, 11 Mar 2014 08:50:35 -0700 (PDT) X-Received: by 10.194.109.68 with SMTP id hq4mr37777638wjb.12.1394553035252; Tue, 11 Mar 2014 08:50:35 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id bm8sm62454537wjc.12.2014.03.11.08.50.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Mar 2014 08:50:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 11 Mar 2014 15:49:57 +0000 Message-Id: <1394552999-14171-12-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394552999-14171-1-git-send-email-julien.grall@linaro.org> References: <1394552999-14171-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 v3 11/13] 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=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 229954b..2438aa0 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 @@ -822,6 +823,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"))) = { \