From patchwork Wed Oct 16 10:08:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 11192831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43D96112B for ; Wed, 16 Oct 2019 10:10:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1EE8B20650 for ; Wed, 16 Oct 2019 10:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JmNPddfF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EE8B20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iKgEG-0006Xa-N2; Wed, 16 Oct 2019 10:08:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iKgEE-0006XV-K8 for xen-devel@lists.xenproject.org; Wed, 16 Oct 2019 10:08:26 +0000 X-Inumbo-ID: e419fd68-effc-11e9-beca-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e419fd68-effc-11e9-beca-bc764e2007e4; Wed, 16 Oct 2019 10:08:25 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id d1so23306305ljl.13 for ; Wed, 16 Oct 2019 03:08:25 -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; bh=Ey0gJAWT8ZHXWHmoB9yq8/ELLpfh8IwG0AKsCTAprZA=; b=JmNPddfFfv5pCC+/lAcIzqQnkTjpWlv4W8wL7oOf/auYQxxC+kkHsm9Z4/V3LhIMPU e7fjyGdFk8y1GI0Cr+q6H3YfQk2WOn3kbAdwJXl1SHtWLIQVeGB4EA0pdxm38jVUoOsE hHgM1c1mzJdUrBNY4t0D0s/vcSwCfp4qEDjFNC1GVFX5lzUcY/q3BA9irx85ms7tk3CI OFmq56mmlmCYKhAW9NkJuYPn3aUiCSon0b5Pqt7PWZoC2MZzXz3kMj1ohAeNHVvxkpd6 QhfUZ03B5B9JWdu4pPsaR512YLSV1NCUTpmqxIbMNQjDGQ4YDs537g+BjQytaRlA8n1p KHBg== 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; bh=Ey0gJAWT8ZHXWHmoB9yq8/ELLpfh8IwG0AKsCTAprZA=; b=GRTUr/n7WttRH0smhGWUbfhPns3W7LhoMN73cmwfJ4bWCsoHyuPMRq7zXiGiBn4dQ1 gZ3Ioe01bY4FxeymxIEg0E3/DK2M3/r7Aff+rr/AVod1l11wW7RsZR490o6KNtfz4TIg RMAyA6V3rCZvN5B8MdeggfOczf7JmQ059sfcn7GFgaLPp9qL4Y/NtGxopF2+TksjxuQ3 qhyK+sMzNa7E89koyFyteJs/wgcNJpx3tuK3WLQ22NHWZpErBHjFiGPCw5HBCQ0fAMKL g7HGfvS10JJGqk3PbMpteCbNnG5BX38aeBanU7cW3fuhgQs78lUTTfm+keRQOU20lHFX Sa8w== X-Gm-Message-State: APjAAAWz8+PNU7Y8FNibPO7ty4CRH1T/Y7ZZEIehfMl7+ZT34r8h4UYL 4PsK1VAjCs5qU7UZ66P2NbdbI7NZhQc= X-Google-Smtp-Source: APXvYqzHyfI3OGKzeRz4S0M5sUsa4ScSrntLphRHvDCcuAcss99g8jbSAOa/uwmg8oRFVbEFElSjgA== X-Received: by 2002:a2e:a166:: with SMTP id u6mr25419005ljl.209.1571220504183; Wed, 16 Oct 2019 03:08:24 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id v21sm1317853lfi.22.2019.10.16.03.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Oct 2019 03:08:23 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 16 Oct 2019 13:08:07 +0300 Message-Id: <1571220487-6582-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH for-4.13 v3] xen/arm: domain_build: Don't expose IOMMU specific properties to hwdom X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org, volodymyr_babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Tyshchenko We always skip the IOMMU device when creating DT for hwdom if there is an appropriate driver for it in Xen (device_get_class(iommu_node) returns DEVICE_IOMMU). So, even if it is not used by Xen it will be skipped. We should also skip the IOMMU specific properties of the master device behind that IOMMU in order to avoid exposing an half complete IOMMU bindings to hwdom. According to the Linux's docs: 1. Documentation/devicetree/bindings/iommu/iommu.txt 2. Documentation/devicetree/bindings/pci/pci-iommu.txt Signed-off-by: Oleksandr Tyshchenko Acked-by: Julien Grall --- Changes V2 [2] -> V3: - Gather two conditions in one "if" - Clarify patch subject/comment in code Changes V1 [1] -> V2: - Only skip IOMMU specific properties of the master device if we skip the corresponding IOMMU device - Use "hwdom" over "Dom0" [1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html [2] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00673.html --- xen/arch/arm/domain_build.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 1d5eac9..6e85ef4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -480,10 +480,25 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_property *prop, *status = NULL; int res = 0; int had_dom0_bootargs = 0; + struct dt_device_node *iommu_node; if ( kinfo->cmdline && kinfo->cmdline[0] ) bootargs = &kinfo->cmdline[0]; + /* + * We always skip the IOMMU device when creating DT for hwdom if there is + * an appropriate driver for it in Xen (device_get_class(iommu_node) + * returns DEVICE_IOMMU). + * We should also skip the IOMMU specific properties of the master device + * behind that IOMMU in order to avoid exposing an half complete IOMMU + * bindings to hwdom. + * Use "iommu_node" as an indicator of the master device which properties + * should be skipped. + */ + iommu_node = dt_parse_phandle(node, "iommus", 0); + if ( iommu_node && device_get_class(iommu_node) != DEVICE_IOMMU ) + iommu_node = NULL; + dt_for_each_property_node (node, prop) { const void *prop_data = prop->value; @@ -540,6 +555,19 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo, continue; } + if ( iommu_node ) + { + /* Don't expose IOMMU specific properties to hwdom */ + if ( dt_property_name_is_equal(prop, "iommus") ) + continue; + + if ( dt_property_name_is_equal(prop, "iommu-map") ) + continue; + + if ( dt_property_name_is_equal(prop, "iommu-map-mask") ) + continue; + } + res = fdt_property(kinfo->fdt, prop->name, prop_data, prop_len); if ( res )