Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp92406pxk; Tue, 22 Sep 2020 20:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKHY7Yz/UMXYz8wdZXsKFrho9k+bQvIB63p+4j2iSnNZfrHiQRAHVXxIcns/jUKDbw0qc7 X-Received: by 2002:aa7:c0d3:: with SMTP id j19mr7559286edp.40.1600830066859; Tue, 22 Sep 2020 20:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600830066; cv=none; d=google.com; s=arc-20160816; b=YVUJquYqtJO3TdjlmwqgVRo2HmMCYdalUeV9QKkP5cGrpPf0Rya+BgEuU6A5gjXJIi TEL3PhQ+8TI11U0AI16lmkU7NhUy4+e8ptFA/Xv29zxyiZSVdJDbx/aw7x3hEnsyCLFq TwpMGeEUxExHWjs26x7OzeNraPmCqFClB9jpu4BZS7WWc+c2tKF3KXYe1yL71AWa1LQS OzxOljd/fiLVefA1JNQ1hcIC5qCv6clH67etYc77jlkmhQBtT1Kq/2KQuhZhrbvkj3+1 Al8Eblo5TPemb6Qu9O6WxcdmE1w3wLpERK6RtSbcrVuS2ThRBzs4EDB5o1Qs7TBvvRru fljw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=d1zwNE/FijiTofGwoi7ffclzRV65K5GjqX+0bKQ26Fw=; b=MWztLzeXgxpbUH33tOcRPLMAO3gP8cQ0A3fZrrfgwqd8HcW7HF8DN6ByYJVXax6NiO SjCSWwdeNuBB4QS5PP16jYiIxq4N/LP+RUAFS9hHzKLT2lgk6tDOvo4f+x084dnhXb7M QMHP1y1vg2Eu7R6hP+MevbLoyS7cEzX2sG8iTISAdu+WWdh95RMULIOMDzXHH1Fs32jR TL1zA8tEwLlyTg0c79D+mNamDPXmbYx2mmnWcZIUXZacNmfwR/uF9KPRuVjFpLchb7nR 3Zsceg2M0FSZsUDOg60grkhzVaVSucWkJjX+C35q/b5iTrWZndi6ysgrViCrnFXWUt9O iM8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e+RQeWHE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si12372822edy.251.2020.09.22.20.00.43; Tue, 22 Sep 2020 20:01:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e+RQeWHE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727246AbgIWC1F (ORCPT + 99 others); Tue, 22 Sep 2020 22:27:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49458 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726893AbgIWC1F (ORCPT ); Tue, 22 Sep 2020 22:27:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600828023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=d1zwNE/FijiTofGwoi7ffclzRV65K5GjqX+0bKQ26Fw=; b=e+RQeWHE0Gf3iSgehb0xrsN+s7RrTAl9JWBqczmy2vuUo99sJKTX8FJqQZSn8RJM2nSOKt 5dvDGXImS58KOid4A8VNAPwQIj1o44nXBLL3vwyKrEJ9zSrt8VwEkMaRvJxMItDCwgdK8J XHrxFwbXVCs3+2qhqJue6FdeDRH8svA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-L6uzC-czO9mRA6XpsP-sbw-1; Tue, 22 Sep 2020 22:27:00 -0400 X-MC-Unique: L6uzC-czO9mRA6XpsP-sbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0A2C8027E1; Wed, 23 Sep 2020 02:26:58 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-42.pek2.redhat.com [10.72.12.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33E3A277B0; Wed, 23 Sep 2020 02:26:56 +0000 (UTC) From: Baoquan He To: joro@8bytes.org, ahuang12@lenovo.com Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "iommu/amd: Treat per-device exclusion ranges as r/w unity-mapped regions" Date: Wed, 23 Sep 2020 10:26:55 +0800 Message-Id: <20200923022655.750-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A regression failure of kdump kernel boot was reported on a HPE system. Bisect points at commit 387caf0b759ac43 ("iommu/amd: Treat per-device exclusion ranges as r/w unity-mapped regions") as criminal. Reverting it fix the failure. With the commit, kdump kernel will always print below error message, then naturally AMD iommu can't function normally during kdump kernel bootup. ~~~~~~~~~ AMD-Vi: [Firmware Bug]: IVRS invalid checksum Why commit 387caf0b759ac43 causing it haven't been made clear. From the commit log, a discussion thread link is pasted. In that discussion thread, Adrian told the fix is for a system with already broken BIOS, and Joerg suggested two options. Finally option 2) is taken. Maybe option 1) should be the right approach? 1) Bail out and disable the IOMMU as the BIOS screwed up 2) Treat per-device exclusion ranges just as r/w unity-mapped regions. https://lists.linuxfoundation.org/pipermail/iommu/2019-November/040117.html Signed-off-by: Baoquan He --- drivers/iommu/amd/init.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 9aa1eae26634..bbe7ceae5949 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -1109,17 +1109,22 @@ static int __init add_early_maps(void) */ static void __init set_device_exclusion_range(u16 devid, struct ivmd_header *m) { + struct amd_iommu *iommu = amd_iommu_rlookup_table[devid]; + if (!(m->flags & IVMD_FLAG_EXCL_RANGE)) return; - /* - * Treat per-device exclusion ranges as r/w unity-mapped regions - * since some buggy BIOSes might lead to the overwritten exclusion - * range (exclusion_start and exclusion_length members). This - * happens when there are multiple exclusion ranges (IVMD entries) - * defined in ACPI table. - */ - m->flags = (IVMD_FLAG_IW | IVMD_FLAG_IR | IVMD_FLAG_UNITY_MAP); + if (iommu) { + /* + * We only can configure exclusion ranges per IOMMU, not + * per device. But we can enable the exclusion range per + * device. This is done here + */ + set_dev_entry_bit(devid, DEV_ENTRY_EX); + iommu->exclusion_start = m->range_start; + iommu->exclusion_length = m->range_length; + } + } /* -- 2.17.2