From patchwork Tue Aug 20 12:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 171798 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4343653ily; Tue, 20 Aug 2019 05:24:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUflI7DdqX1fTviwCX5pLPXLjArz4mV4yBBs8lcfnjMVpx/dnH7ArXwnZHIha8WUFO1CRQ X-Received: by 2002:a6b:6516:: with SMTP id z22mr7938457iob.7.1566303891160; Tue, 20 Aug 2019 05:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566303891; cv=none; d=google.com; s=arc-20160816; b=Nlw8BfPCjKWugdvd1IfYlqdLJk0ERMd+7zgCEwCfPmh80jHJlB5640R23OrSOWElEy FcM4fMnp+AvA3I2d9k28qZZ2b2FAa2FgemIig7R9+ulLMvmuUfg5wgHQyYGTdQ+bx0/b MO5b7UP8WMfb2qoyeJTnjaoPDlOdErlrx5mtW509ugd/wwY+3qZbyvIlSi+ZTH48JxlY D6TDX+ewyX9fYp+UdZThyGRLNkNrf4wwUJLHTCfBGxWEtkdt7Grh9061irCjzmPtRAjk mzP7hfn/z6rt5c8p4XFCajLqAsnX80lAn9IwVK7VShjZMTbiB43C48CMoIvWn9CVa2B4 n3uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:message-id:date:to:from; bh=QB3oyMFJUb58PYwBTcrr9XdxEiSBNZ8QLAztfhWrwE8=; b=PGy9XS7OmUSfO+RsMiHNUXNS8O8LETqDJiy2mxUjxheFtjpQ3GxOsTTiw58vDlhnZb b6TfvGnZHoj8rHTifUUfcoQ5pWROZIATiPFriJ0KNXm3bXHDnGj9UXmMkLH2EFa5YRwG 2PwEt8QSqO1eeqduGpdmc7iODxHNNh43gZ3yx5UepoozfHuvGnP1w9cvO8lL8YpR0zye 69+yCM1+c0eqdBIA9UpS4pabKNvMb6cYmVvlDag/Z2gQwkCbB6zFAcschMBspUDdny1o DJRUS2SInf9k9Hbyz/6qN2rubDghpKlUXIDJlSHHZ2A+R/rPcY8h5JbJbpue8QE+rClC CrJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x25si22022205jan.59.2019.08.20.05.24.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 05:24:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1i03AJ-0006SX-Iy; Tue, 20 Aug 2019 12:23:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i03AI-0006SS-Ag for xen-devel@lists.xenproject.org; Tue, 20 Aug 2019 12:23:06 +0000 X-Inumbo-ID: 4230662e-c345-11e9-8bf7-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 4230662e-c345-11e9-8bf7-12813bfff9fa; Tue, 20 Aug 2019 12:23:04 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D3ACC344; Tue, 20 Aug 2019 05:23:03 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1191D3F246; Tue, 20 Aug 2019 05:23:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 20 Aug 2019 13:22:55 +0100 Message-Id: <20190820122255.9864-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PATCH] xen/arm: iommu: Panic if not all IOMMUs are initialized 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: Oleksandr Tyshchenko , Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, the platform can come up with only part of the IOMMUs initialized. This could lead to a failure later on when building the hardware domain or even trying to assign a device to a guest. To avoid unwanted behavior, Xen will not continue if one of the IOMMUs has not been initialized correctly. Signed-off-by: Julien Grall Tested-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini --- Cc: Oleksandr Tyshchenko Basically, this is similar to forcing the use of IOMMU (i.e iommu=force). Maybe we should drop the panic in setup.c and just set force_iommu. Any opinion? --- xen/arch/arm/setup.c | 5 ++++- xen/drivers/passthrough/arm/iommu.c | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 7509d76dd4..f8a4064d3e 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -755,6 +755,7 @@ void __init start_xen(unsigned long boot_phys_offset, .max_grant_frames = gnttab_dom0_frames(), .max_maptrack_frames = opt_max_maptrack_frames, }; + int rc; dcache_line_bytes = read_dcache_line_bytes(); @@ -892,7 +893,9 @@ void __init start_xen(unsigned long boot_phys_offset, setup_virt_paging(); - iommu_setup(); + rc = iommu_setup(); + if ( !iommu_enabled && rc != -ENODEV ) + panic("Couldn't configure correctly all the IOMMUs."); do_initcalls(); diff --git a/xen/drivers/passthrough/arm/iommu.c b/xen/drivers/passthrough/arm/iommu.c index 2135233736..f219de9ac3 100644 --- a/xen/drivers/passthrough/arm/iommu.c +++ b/xen/drivers/passthrough/arm/iommu.c @@ -51,6 +51,14 @@ int __init iommu_hardware_setup(void) rc = device_init(np, DEVICE_IOMMU, NULL); if ( !rc ) num_iommus++; + /* + * Ignore the following error codes: + * - EBADF: Indicate the current not is not an IOMMU + * - ENODEV: The IOMMU is not present or cannot be used by + * Xen. + */ + else if ( rc != -EBADF && rc != -ENODEV ) + return rc; } return ( num_iommus > 0 ) ? 0 : -ENODEV;