Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1326239yba; Thu, 16 May 2019 19:23:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwypJVMNJxqFm/FSsfhuHjmft7oqXDWZM6oq3SBUmNtMS/bQCiQRZ2iAu17jrwJEj5G3tMj X-Received: by 2002:a65:5c89:: with SMTP id a9mr54289124pgt.334.1558059835040; Thu, 16 May 2019 19:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558059835; cv=none; d=google.com; s=arc-20160816; b=V818KhVIzoVHk4qinSp0V7EjkLQSJ1XgBTwlB6dO7S+4rsDRcNtD2DGnFBEOnFIcfW NGntZO5mczVwUUWk7BHKIABIKLdqS92dXpZpEnTGj+5LDEI4rJwAw+bbktW4xRCrIEne hnIvVIKK6wB9kNRqszLkLxQ2fm4f4BAkyOwHVcOT+1gbsE1eydQEDukg1SsNYJvATbA0 FOF6acZTkPJ263Zpb7nJ7WnSMWvILAiu7wALrQ8zAKiG6oUpZJVwu1aLra0GABZxk0yA rEeHa2vMJQ1+j2s9rxx7w6bj5eDeNu6G/ST2Oq4kPyl7v9pvSbRlWAMHZxUbKWncYSPl NZ0g== 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=jVuIjCJoaXlNnhWxO2Ie73gcjB/r7Dcd6J2alOLMpA9SRbL4u/BSq8gcF6MLb97liF uN+5HxluwQ1bNK4LZKGHVbTiKiaPWpcHZbpiMyxc783CB7mvrl+y+KuxOxR4H1efkyr2 bu9NvA/swzj4gaQOiY5IJxcDu4md5JLX71JRHXK4i2X/uQjzC6zKsLkBvbcFdF98TxVU 3yjWHyWnWGmjgTrr0G9a9VzMz1/PHuy8IZcUs1m5Sqf9yV0zeyaPYmVfyIzB375y6erZ AQ3ARCjSVjlJXY5p9NOT4Fbycv0qhXZR08OfKqGJZibFH49m6uq7JOM1MDSDicAydU+j UlKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=yAzMLwXz; 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 o23si6308160pgm.595.2019.05.16.19.23.40; Thu, 16 May 2019 19:23:55 -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=yAzMLwXz; 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 S1727788AbfEQBAZ (ORCPT + 99 others); Thu, 16 May 2019 21:00:25 -0400 Received: from mx.aristanetworks.com ([162.210.129.12]:42693 "EHLO prod-mx.aristanetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbfEQBAY (ORCPT ); Thu, 16 May 2019 21:00:24 -0400 Received: from prod-mx.aristanetworks.com (localhost [127.0.0.1]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id DD66B41CAC0; Thu, 16 May 2019 17:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1558054427; bh=0YAEwRV8pxaKDZriNp5u14v56Dsy6P+WWcBl+ItO2zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yAzMLwXztwgoG54qdkpjOlajk7uFBwFv2KEytXFrkmlS7SD5EHt+FP7QcUEinc6l3 vqVjwE9+4RzVVITPiEK1hwsg2tL1jEvRn3LHepmF8S+TwsSfI5pi8EGV22Yx2mUZOU 5bZE+JhNROjg68WSlWv1RLBQ3WNzRBnb9jHoW63bAnOm3OfcduzAlsjdMBL7+PaayW g1LemAio75Ug6p9bgCoJM4PO7gItqfusdpnqDrsgKY4IfLlDdlOs2vtgo35OmM7pwe qqu0k9tcDvF6CMX0gybCwgoa9rO9UDRjLFpPVnLequ77jynRoZ5r6dLpt70g/KhtwZ BGVRhTxmaPbug== Received: from chmeee (unknown [10.95.92.211]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id D141D41CABA; Thu, 16 May 2019 17:53:47 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hRR7o-0001le-HJ; Thu, 16 May 2019 17:53:28 -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: Thu, 16 May 2019 17:52:40 -0700 Message-Id: <20190517005242.20257-2-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517005242.20257-1-kevmitch@arista.com> References: <20190517005242.20257-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