From patchwork Wed May 10 14:03:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9719905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9588E6035D for ; Wed, 10 May 2017 14:06:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8796A28602 for ; Wed, 10 May 2017 14:06:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C42228609; Wed, 10 May 2017 14:06:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09DD428602 for ; Wed, 10 May 2017 14:06:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDS-0007De-Ib; Wed, 10 May 2017 14:03:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDR-0007AQ-6l for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:03:45 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id F4/1F-03587-0CD13195; Wed, 10 May 2017 14:03:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRvkpHtAVjj SYPYzEYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePh9JmMBYvFK9q7+pgbGO8LdTFycQgJTGOU 2DrxFTOIwyLwkkWib84ndhBHQqCfVWLy7NlADieQEyfROKONBcKulFh85QSYLSSgJPF652Ymi FGzmCSmPvrHBJJgEzCQ2P/uCVizCFDRvVWTweLMAuUSPTOXsYHYwgJ+EpvO3gCyOYBWq0rcPy ADEuYVcJGY1n2UCWKXnMTNc53MIDYnUHzH6ztQe50l/n/8zjqBUWABI8MqRo3i1KKy1CJdI0u 9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2MBxYFHmKU5GBSEuXV3SUU KcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC10tGOFJIsCg1PbUiLTMHGOQwaQkOHiUR3qMSQGne4 oLE3OLMdIjUKUZdjkcrf7xnEmLJy89LlRLnFQKZIQBSlFGaBzcCFnGXGGWlhHkZgY4S4ilILc rNLEGVf8UozsGoJMyrADKFJzOvBG7TK6AjmICOCGQQADmiJBEhJdXAmLG2r1x8652JcofMS6q Xfnp58+8q1p0iee6MZ+f87uH9LRn3eX2LichPpU8h78LuHpU/oBRlVi5V8vvsLZ2wP3UKLrlM qi/bbaq9r3y4yHXga5XTW9sT6dxvSj+xxtq5fedYfHeZ/IQcs6hY9oCdHQ6Pz0f8nrwmWPa5e MP6Lc8Z9l43n8MeqcRSnJFoqMVcVJwIADcNLMCzAgAA X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1494425024!67645645!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14684 invoked from network); 10 May 2017 14:03:44 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:03:44 -0000 Received: by mail-wm0-f66.google.com with SMTP id d127so45156wmf.1 for ; Wed, 10 May 2017 07:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=c0wwtO0PQ56qLEah2KSw6XVF8tdgQhYUzGZVl1cyTOA=; b=Jh7eJfMTXoAKcmENPkqHrSdd8kQeA98GshnDfld608xFL59CICSKDBKz5o6PNUG53h v7DTMtTbfjc0A8annlKs0x8Ls8LQW6nfKwRMmxQ1tmEVSvZsZ34IIZRZiqLaRZ1SqUj4 083nAeDMVSKsUjRevvURnG7eipgghNkZKG3iZ8i1oRdJkXL3HSwcnd5O9ow4gV4kFYxo NwteOlyX+W3tO1dYFxPtCpzUk4tAfghFrCJtd0IodXrWZoz0y1ekBnf+aSJeFoIpcQ4A 2KFK45VsZXKuFa7yZqB2/FcchDwbgv1ZOmB7mar0+0xoHIkdD32cmWUTUuc3mzCIa6Gk zSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c0wwtO0PQ56qLEah2KSw6XVF8tdgQhYUzGZVl1cyTOA=; b=P8I6Dj000WCOiEPSMG8m+yDbW/cInEDaI/PIxCHQ2MBCJ7ekCgu0F2MUhIZ9RNnBYd bN97XgGemNzqy/kdgUc3NCPWL3IarXDJX+iEi3okS8tMTVsWkSoW0BDAq3+gdQTipCcm pW1zwuiMGSPXw0qVZz/LXNrbbhtYXASvb4EJcFIXmOY3O0ErEVCKFbupE4UQpaCO2x4k Fb8vGBVY1WJjVZByQHVWTQSHUcvHcr3BQr4JR0Dx9dYOIUZN4F3O7Nhy/7BHtlYQwsgn i+rkA9Xh8vVgtaRu0cUB45/sVFQwUxKzKWE7lU3RzNbR18I15r14lq5mLrLnvlATkh4d BRRQ== X-Gm-Message-State: AODbwcA42oMCtjFTosb1gwteYSesYbVOn0LwOlDE2t1kVqR3wtivDLib iwaYOLMMG0YMmA== X-Received: by 10.28.98.131 with SMTP id w125mr3662902wmb.74.1494425024010; Wed, 10 May 2017 07:03:44 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-54.209.223.85.sovam.net.ua. [85.223.209.54]) by smtp.gmail.com with ESMTPSA id c34sm3378304wrc.7.2017.05.10.07.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:03:43 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 17:03:13 +0300 Message-Id: <1494424994-26232-10-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> References: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> Cc: wei.liu2@citrix.com, julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v1 09/10] xen/arm: Add use_iommu flag to xen_arch_domainconfig X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko This flag is intended to let Xen know that the guest has devices which will most likely be used for passthrough and as the result the use of IOMMU is expected for this domain. The primary aim of this knowledge is to help the IOMMUs that don't share page tables with the CPU on ARM be ready before P2M code starts updating IOMMU mapping. So, if this flag is set the non-shared IOMMUs will populate their page tables at the domain creation time and thereby will be able to handle IOMMU mapping updates from *the very beginning*. In order to retain the current behavior for x86 still call iommu_domain_init() with use_iommu flag being forced to false. Signed-off-by: Oleksandr Tyshchenko CC: Jan Beulich CC: Julien Grall CC: Ian Jackson CC: Wei Liu --- Changes in V1: - Treat use_iommu flag as the ARM decision only. Don't use common domain creation flag for it, use ARM config instead. - Clarify patch subject/description. --- tools/libxl/libxl_arm.c | 10 ++++++++++ xen/arch/arm/domain.c | 2 +- xen/include/public/arch-arm.h | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..9c4705e 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -78,6 +78,16 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } + /* TODO Are these assumptions enough to make decision about using IOMMU? */ + if ((d_config->num_dtdevs && d_config->dtdevs) || + (d_config->num_pcidevs && d_config->pcidevs)) + xc_config->use_iommu = 1; + else + xc_config->use_iommu = 0; + + LOG(DEBUG, "The use of IOMMU %s expected for this domain", + xc_config->use_iommu ? "is" : "isn't"); + return 0; } diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index ec19310..81c4b90 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -569,7 +569,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, ASSERT(config != NULL); /* p2m_init relies on some value initialized by the IOMMU subsystem */ - if ( (rc = iommu_domain_init(d, false)) != 0 ) + if ( (rc = iommu_domain_init(d, config->use_iommu ? true : false)) != 0 ) goto fail; if ( (rc = p2m_init(d)) != 0 ) diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..cb33f75 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -322,6 +322,11 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + /* + * IN + * Inform the hypervisor that the use of IOMMU is expected for this domain. + */ + uint8_t use_iommu; }; #endif /* __XEN__ || __XEN_TOOLS__ */