Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7141638ybi; Thu, 13 Jun 2019 10:15:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzf2b5II839NV1l50ijLJZq0Q7bcVJt+cj4twCtIf3p+AXJngitqF1Fl/6BN0ODK+V+kLuL X-Received: by 2002:a17:902:6b44:: with SMTP id g4mr74061496plt.35.1560446118383; Thu, 13 Jun 2019 10:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560446118; cv=none; d=google.com; s=arc-20160816; b=uVXyxSMHUn4II8DgIGs594UWFBBkWnbigAyXbFY24Akrw4VO0WtymbZ0n/DZua5wTC 0YI1BkZieF/PMxGbCfmAmX4DmLCAz1CyBsn2d6yUZKEhnl7ep5Iilz5TVuOm9M/6Cgpr b1RhOxpQaLZxlkf2oC5iifLPX7IBcjR403A2erGXmPvLfCI7LEVq6L/u6ZBJNw5536bM IXSu5ZonJ6Eayvu4dK7X2iSwam1ntJ5hV//lmljPakoxR2B3tWlIq8VXx1+rhGMwaNf8 KavFLaOMKr8XUl6OisQeDy71qX8iVPD4A7Ug10ifTAu+LjIDHlG1XH1eKE1ZnuHHEsLR zkLA== 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=0iH6GQlzGKw8fjxBaWQiJSGzvOf9z3+C1/EOWPUaKSXHwnZDHRbxxQaRyfqbsGlKOc a/yPk8L42UDbLghtfr9Tq4lDyVfeWrZEus57+xKaXMJuzgJ+J0JWnQE47DLDnW/xxWp9 dhyOXDtrlUaU67u0nQWQej27xlUW02Rzm7rlPc1s7lEg+Bfzk9xgW/Dw7YmmJerlfjwf BkqkQEfxosiMnc1h912dW/JX5KhyJqnLC+b5kVksG0eOQpb5is46AzbFWbp331XBoijK oJYDvQc1XyShrIKJmftc8qAPQmyto6DLTTLV+3LtxG38NsoHwDp9XIwWWu05gWUP8da0 ATWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=o0tcrE69; 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 n8si54227pfa.223.2019.06.13.10.15.01; Thu, 13 Jun 2019 10:15:18 -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=o0tcrE69; 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 S2393589AbfFMRO5 (ORCPT + 99 others); Thu, 13 Jun 2019 13:14:57 -0400 Received: from smtp.aristanetworks.com ([52.0.43.43]:48988 "EHLO smtp.aristanetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728803AbfFLVwd (ORCPT ); Wed, 12 Jun 2019 17:52:33 -0400 Received: from smtp.aristanetworks.com (localhost [127.0.0.1]) by smtp.aristanetworks.com (Postfix) with ESMTP id 4416C30DD5A8; Wed, 12 Jun 2019 14:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1560376352; bh=0YAEwRV8pxaKDZriNp5u14v56Dsy6P+WWcBl+ItO2zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o0tcrE69nlTRCy8oBfpiQeJnWgJI43UMXL1JcrYTR2TXwxuLOjTUIkPuuv7MXRqf3 YDdo4KeSF7MlOXZXb7AcDS73JCOrcTPDsNRD4rK+wv47rTdNi/Dc4KogK0ScKquYPV Ayw16OMjHVDyyC60fkrTALrVED6wYi0cwq1M46w3MRBQiHsWK1VL5/PNAqeW/k71J+ 4XnRx4EtiNG+hmSo4aT7WSqrihEBBWcbcaJ+WnRm/tK4ynARFh/fm+IltVeyrfW6d2 B0MazUx5XKO6Am0eX+nacKTrwXnAepR4LkQz0xllOJX0zJAdCpdDjGtbXR9W0xEe3g 5b148ONyu7h9A== Received: from chmeee (unknown [10.80.4.152]) by smtp.aristanetworks.com (Postfix) with ESMTP id 2AD1730DD5A5; Wed, 12 Jun 2019 14:52:32 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hbBAV-0003KF-JQ; Wed, 12 Jun 2019 14:52:31 -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: Wed, 12 Jun 2019 14:52:03 -0700 Message-Id: <20190612215203.12711-2-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612215203.12711-1-kevmitch@arista.com> References: <20190612215203.12711-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