From patchwork Tue Jul 25 17:26:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9862577 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 E89E76038F for ; Tue, 25 Jul 2017 17:30:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAF46285A8 for ; Tue, 25 Jul 2017 17:30:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF9BB285F0; Tue, 25 Jul 2017 17:30:09 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, 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 09927286F5 for ; Tue, 25 Jul 2017 17:30:04 +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 1da3cA-00007g-DI; Tue, 25 Jul 2017 17:27:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da3c9-0008Uy-Au for xen-devel@lists.xenproject.org; Tue, 25 Jul 2017 17:27:21 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F3/CA-03044-97F77795; Tue, 25 Jul 2017 17:27:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsVyMfS6s25FfXm kwYE9Ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aDvnfsBfPFKnomPGRvYPwg2MXIxSEkMINR 4uv0J0wgDovASxaJ23d/soA4EgL9rBJzzz9n7WLkBHLiJJb0XWGBsCskNvSsYQSxhQSUJF7v3 MwEMWo2k8TCf/1gDWwCBhL73z1hB7FFgIrurZrMBGIzC5xilPj40hXEFhbwk9g9vQ0sziKgKv GrawpYPa+Ai8TBrYegFstJ3DzXyQxicwLFt37axgKx2Fli/bEDzBMYBRYwMqxi1ChOLSpLLdI 1MtVLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMLgYg2MG4akHgIUZJDiYlUd5v uuWRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4t9YC5QSLUtNTK9Iyc4BhDpOW4OBREuF9BZLmL S5IzC3OTIdInWK05LhyZd0XJo4pB7YDyVcT/n9jEmLJy89LlRLn9akDahAAacgozYMbB4vFS4 yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmTQSZwpOZVwK39RXQQUxAB82ZUQpyUEkiQkqqgbH 0mezl6t46SYuqbz0SZ4IY9GLeHdB33aG48Y34n/PHdoe7qJx3X8x5Y9091XczBXeFfX+1u2iC 7+tnIjbXuoK+NpeXHTcs2Xbtd4fq5Ftye5cfuLQiJqV7zcEkQ2+5lm09Iof3nt21XnTl7YmzF J9I/JqQIdMY8V/Xd+2zhmQ7hkniqmvtLKOVWIozEg21mIuKEwFRvq8ZwAIAAA== X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1501003639!62927602!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49861 invoked from network); 25 Jul 2017 17:27:20 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Jul 2017 17:27:20 -0000 Received: by mail-lf0-f67.google.com with SMTP id w199so3023339lff.2 for ; Tue, 25 Jul 2017 10:27:20 -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=XyTEeyfwI82jUMgjUeR6OS/aiVDvzipTyLsaWc/O/R0=; b=WeX8XO0wlh2GvTqnixkU7nURH+G1IxSkOyX3BVbbUT1i5KUlqHBQ2Vs6QN6Oujdiqn iW/xKBqpbqYSsELo6cbx285Wd3LVQ94AF4qpPgX4WvUtggHvswk3E3QTCt+xCaOTOTTq T0gotI5fVb4LHZEwhsuLryI4hgbBiFtq23FfvFrw/izTEVPBgtEorK2mi5rSRzVAp0xB 1RiqHGVZReL97MhvRFNTv2po8xvXK+qWoL/XDT9DNEy2zKEnW046gsklM9s3Ljw0Lf2s 9/yeIU+qLY7CNk7g7WIx89WqlMqM4ru3VrCmhNXBzJlLoDPhJsvhoO3tJKJOzi65aEEF eQDg== 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=XyTEeyfwI82jUMgjUeR6OS/aiVDvzipTyLsaWc/O/R0=; b=FUa+iHGs1PIMJVJ7/XuRyqsQNCCf5pqhV+OVq5fwGF5YvTlvtOy5neTsUnhSQ5xt/n BahyrL7z0mNP1lRIPXAwFNr+D77uY0j4XP3ssjPrlUY0jYfLEd2au0FBk84e9yxzhaXJ 67qxSbXJT0JOb2eDB98mWPePZLAoC8kY4dn04iT0ncX5mB6blrCR2nBekyQo3JpkK0AC XEv/GA5Zx1m4XmX/218+8G/iVXCXzBR2n8uadqsMkcBYx5NNZTg9nI5wV6M1R5OPJL5v XKrwNG5KDUVTWjjYHfGQvw/ck/+kY5cqNbqB4h15Ih9+mY06IT92SnEQg4I8LQJjx3v2 GGJQ== X-Gm-Message-State: AIVw111zmpgvt8TZTSctEHJKGuegJ7jbVw8VU9gzYgS2DSw08iNT1JPS yueqIQZTa4RKW+tl X-Received: by 10.25.22.32 with SMTP id m32mr6752045lfi.204.1501003639039; Tue, 25 Jul 2017 10:27:19 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-59.209.223.85.sovam.net.ua. [85.223.209.59]) by smtp.gmail.com with ESMTPSA id v145sm411748lfa.21.2017.07.25.10.27.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 10:27:18 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 25 Jul 2017 20:26:51 +0300 Message-Id: <1501003615-15274-10-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> References: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> Cc: Oleksandr Tyshchenko , Julien Grall , Ian Jackson , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v2 09/13] 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 IOMMU is expected to be used 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 Acked-by: Wei Liu Acked-by: Julien Grall --- 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. Changes in V2: - Cosmetic fixes. --- tools/libxl/libxl_arm.c | 8 ++++++++ xen/arch/arm/domain.c | 2 +- xen/include/public/arch-arm.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..cb9fe05 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -78,6 +78,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } + if (d_config->num_dtdevs || d_config->num_pcidevs) + xc_config->use_iommu = 1; + else + xc_config->use_iommu = 0; + + LOG(DEBUG, "IOMMU %s expected to be used 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..3079bbe 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)) != 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..b1fae45 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 + * IOMMU is expected to be used for this domain. + */ + uint8_t use_iommu; }; #endif /* __XEN__ || __XEN_TOOLS__ */