From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Mitchell via iommu Subject: [PATCH 0/3] handle init errors more gracefully in amd_iommu Date: Thu, 18 Apr 2019 10:57:43 -0700 Message-ID: <20190418175744.6229-1-kevmitch@arista.com> Reply-To: Kevin Mitchell Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: iommu@lists.linux-foundation.org This series makes error handling more robust in the amd_iommu init code. It was initially motivated by problematic firmware that does not set up the physical address of the iommu. This led to a NULL dereference panic when iommu_disable was called during cleanup. While the first patch is sufficient to avoid the panic, the subsequent two move the cleanup closer to the actual error and avoid calling the cleanup code twice when amd_iommu=off is specified on the command line. I have tested this series on a variety of AMD CPUs with firmware exhibiting the issue. I have additionally tested on platforms where the firmware has been fixed. I tried both with and without amd_iommu=off. I have also tested on older CPUs where no IOMMU is detected and even one where the GART driver ends up running. Thanks, Kevin Kevin Mitchell (3): iommu/amd: make iommu_disable safer iommu/amd: move gart fallback to amd_iommu_init iommu/amd: only free resources once on init error drivers/iommu/amd_iommu_init.c | 45 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07438C10F14 for ; Thu, 18 Apr 2019 18:22:25 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (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 C05C620643 for ; Thu, 18 Apr 2019 18:22:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="PQdcUONt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C05C620643 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lists.linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 792521BFF; Thu, 18 Apr 2019 18:22:24 +0000 (UTC) Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A434E1ACC for ; Thu, 18 Apr 2019 18:22:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from usvae2-clmxp01.aristanetworks.com (smtp.aristanetworks.com [52.0.43.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 59C7E854 for ; Thu, 18 Apr 2019 18:22:02 +0000 (UTC) Received: from usvae2-clmxp01.aristanetworks.com (localhost [127.0.0.1]) by usvae2-clmxp01.aristanetworks.com (Postfix) with ESMTP id 303F330C1544; Thu, 18 Apr 2019 11:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1555611291; bh=gZKRKJcuRQSwe2TyYVhO9ixqNktFM8piGcLI2AKiDUY=; h=From:To:Cc:Subject:Date; b=PQdcUONtqO60OTMOPax126YZzHGTYv4/yNhybwcUoFmDLb0oBAPy+8RdtoMuLi1EQ ujwRPI9Amej+D9Zp6PNrJK1T4+El39dEAUrCImDOr41dBsfXaWPNe7OyslEMqsm85/ V6KkH1M/ELP6dM5oWXFrOiL9iOCNsp14L3WSRiDvKDfOlqsIXjya/aay8jPr4eDAo3 VCKwgdxh0ATtlSVP5CRUnz2OU+/Uon97Kb3wLTyo54DZh13rQiJ5IY3zbYLMU/boo8 0OzQXxkwMxuwIUkX1DSu77AUlaebbrbagfjUI252fQNeGTgTzfsGcId0MvdxmAMv8W fOEurSylj4jCQ== Received: from chmeee (unknown [10.80.4.152]) by usvae2-clmxp01.aristanetworks.com (Postfix) with ESMTP id 15FBC30C1542; Thu, 18 Apr 2019 11:14:51 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hHBJS-0001Dz-U2; Thu, 18 Apr 2019 10:59:06 -0700 To: iommu@lists.linux-foundation.org Subject: [PATCH 0/3] handle init errors more gracefully in amd_iommu Date: Thu, 18 Apr 2019 10:57:43 -0700 Message-Id: <20190418175744.6229-1-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Kevin Mitchell via iommu Reply-To: Kevin Mitchell Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Sender: iommu-bounces@lists.linux-foundation.org Errors-To: iommu-bounces@lists.linux-foundation.org Message-ID: <20190418175743.2wJCSMKFlpwqBDF_HFfNzaC84SvtTqttE8Ecl9-kEiU@z> This series makes error handling more robust in the amd_iommu init code. It was initially motivated by problematic firmware that does not set up the physical address of the iommu. This led to a NULL dereference panic when iommu_disable was called during cleanup. While the first patch is sufficient to avoid the panic, the subsequent two move the cleanup closer to the actual error and avoid calling the cleanup code twice when amd_iommu=off is specified on the command line. I have tested this series on a variety of AMD CPUs with firmware exhibiting the issue. I have additionally tested on platforms where the firmware has been fixed. I tried both with and without amd_iommu=off. I have also tested on older CPUs where no IOMMU is detected and even one where the GART driver ends up running. Thanks, Kevin Kevin Mitchell (3): iommu/amd: make iommu_disable safer iommu/amd: move gart fallback to amd_iommu_init iommu/amd: only free resources once on init error drivers/iommu/amd_iommu_init.c | 45 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) -- 2.20.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu