Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5351899ybi; Tue, 28 May 2019 11:32:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/Cl7tjBMpOoIBWHiYWko9QoQvM2KjFHnvJxLH2EI+g+2dVZKvIwCtcGs9U8lifnrBtP/H X-Received: by 2002:a17:902:a98b:: with SMTP id bh11mr63379830plb.8.1559068319363; Tue, 28 May 2019 11:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559068319; cv=none; d=google.com; s=arc-20160816; b=JrF0mLSFeA8+ggSNo3FmPPSgNuIxmaxVYDGJOcEHmqWzCliAI+nYqslbDVZrkiv1TU aVRCfJ/eZ0sbo1HXKgplnmJeapufrzsDC9F9W3N9Z0AJlRgzaB8G+fRidA26V3J2KBwV JKRTngj+vmcLoh5h6ZA1slFmliyuBv6XGQVyo+wr05bqZUuAETxy1/YLjvhHSL/zU5LO 6yjs3CuObI9ff3de/WOC2ReN00QxWX+B1HwqMW4PVLOzzcY7EclJW4MwYAVCJBb27uOF bJ2Y0TROD44eBeG7TslIVdS3t7w4XUxM0dGXt80FNZbkJrWaNHJCMEe5GwoBTf/icCq0 BCLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0YAEwRV8pxaKDZriNp5u14v56Dsy6P+WWcBl+ItO2zQ=; b=PDq558Wr81pRmyyliQZqEjIxHzrVT+1JN1ISALA/eMuArwy6Q8WL+feoJCGwg054+m 3B7nMc+vJM+8+b76v7XLqh14fkHV5FolXKoSG59C4EHkJlBMlZxOEaFEVKWAXOkBNrlj FZW5EwdCnBhO4ZHzQmmyWICwNj0rDDcLLVa/FBlhhxIS/x4TArftlOReKFQf2PC/0t1f bfOJZJbFEalYe1sppmbjl8q8DSgtaOSodBv/Yr/JjhSjfIThhnK6aM9Ohp/GjpO5jYRk jLEWHwjYmUy0CPwaGf0bne076Bn5/wB+vyQb/ZEnbV7igRaIENIcxVvT4sGXkzIquc8H lVeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=CPcnMefj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t70si4646635pjb.21.2019.05.28.11.31.42; Tue, 28 May 2019 11:31:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=CPcnMefj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728181AbfE1SaD (ORCPT + 99 others); Tue, 28 May 2019 14:30:03 -0400 Received: from smtp.aristanetworks.com ([54.193.82.35]:38956 "EHLO uscaw2-clmxp01.aristanetworks.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728160AbfE1SaC (ORCPT ); Tue, 28 May 2019 14:30:02 -0400 Received: from uscaw2-clmxp01.aristanetworks.com (localhost [127.0.0.1]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id 3327921459D0; Tue, 28 May 2019 11:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1559068202; bh=0YAEwRV8pxaKDZriNp5u14v56Dsy6P+WWcBl+ItO2zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CPcnMefjLP+bA9kVccxdr6eJyVU7FozZXFEiVVUdiIzZDrWwjiROptZ4c53QaNP5G Sb1uKj3D2NLw1peoM9MgppiBynctpeDgScb+WQhc3y/fumEztSgibXEfIUwTyqBn7q vadn06vPi7Ejxq0lFwj/lYZ/q1QIR6laoVm2vw7B/xDHfqqkRWAxGiJd8DrSysrMk0 nQBUBM9PqX2xihlaVLENurpttKXhXsfeZnhPNoR/CsKURUYTMFDfSLxNlMouCQ0yr+ U4hYjpj22+0prOqjPKRtCE50h3xGtDYFtN2JGJ3IFuQJFBNpqHtc7V2w+ky8YnkxTx XL3jOF/OrHKGA== Received: from chmeee (unknown [10.95.80.198]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id 2ABD13134185; Tue, 28 May 2019 11:30:02 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hVgrJ-0000xP-F8; Tue, 28 May 2019 11:30:01 -0700 From: Kevin Mitchell To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Kevin Mitchell Subject: [PATCH 1/3] iommu/amd: make iommu_disable safer Date: Tue, 28 May 2019 11:29:56 -0700 Message-Id: <20190528182958.3623-2-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528182958.3623-1-kevmitch@arista.com> References: <20190528182958.3623-1-kevmitch@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make it safe to call iommu_disable during early init error conditions before mmio_base is set, but after the struct amd_iommu has been added to the amd_iommu_list. For example, this happens if firmware fails to fill in mmio_phys in the ACPI table leading to a NULL pointer dereference in iommu_feature_disable. Signed-off-by: Kevin Mitchell --- drivers/iommu/amd_iommu_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index f773792d77fd..3798d7303c99 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -424,6 +424,9 @@ static void iommu_enable(struct amd_iommu *iommu) static void iommu_disable(struct amd_iommu *iommu) { + if (!iommu->mmio_base) + return; + /* Disable command buffer */ iommu_feature_disable(iommu, CONTROL_CMDBUF_EN); -- 2.20.1