From nobody Sat May 4 03:11:48 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1566303877; cv=none; d=zoho.com; s=zohoarc; b=kFromrFZu7HdDlk+OYa10YwyUCe/1r9DIsFEhsC5V8zT3yz51a754VbsxxAud12/XmU5QsbVjRvvDtw0L4qS9GdZpkp2Z0w9LqBIREdaLvC1SSKPnIgszqpT6LBa7C7Gwhl8YrueQGmrtXT4/tZB1vwzrZsr3M2SbHsYikNOJrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566303877; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=QB3oyMFJUb58PYwBTcrr9XdxEiSBNZ8QLAztfhWrwE8=; b=F1nHId5lj4ReRPip4jeEzPDnaTazNLLcBRQopHSTOCCF4T2pwN19SHHoqg9qRuJLHiiC/Zi4CIhEQ2Tjn4ZE2p/sBWSbbmjPNGQiEtHMnIN6q/oWecqcXJkrHFeT1CPXzV2mDufmqXse87r+ZL7atXrhBlhWTTBmQ1l0QNGlk34= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1566303877533906.5775851914657; Tue, 20 Aug 2019 05:24:37 -0700 (PDT) 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 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) X-Inumbo-ID: 4230662e-c345-11e9-8bf7-12813bfff9fa 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 Reviewed-by: Stefano Stabellini Tested-by: Oleksandr Tyshchenko --- Cc: Oleksandr Tyshchenko Basically, this is similar to forcing the use of IOMMU (i.e iommu=3Dforce). 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 =3D gnttab_dom0_frames(), .max_maptrack_frames =3D opt_max_maptrack_frames, }; + int rc; =20 dcache_line_bytes =3D read_dcache_line_bytes(); =20 @@ -892,7 +893,9 @@ void __init start_xen(unsigned long boot_phys_offset, =20 setup_virt_paging(); =20 - iommu_setup(); + rc =3D iommu_setup(); + if ( !iommu_enabled && rc !=3D -ENODEV ) + panic("Couldn't configure correctly all the IOMMUs."); =20 do_initcalls(); =20 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 =3D 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 !=3D -EBADF && rc !=3D -ENODEV ) + return rc; } =20 return ( num_iommus > 0 ) ? 0 : -ENODEV; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel