Received: by 10.213.65.68 with SMTP id h4csp2202516imn; Sun, 8 Apr 2018 22:23:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/6rPSrUtwetZsQYaWDHz3nFIiwfv4Coj3lleusE1ns2BciJbXO/XBtLR4WOd5R3yzeGAAE X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr4437026plz.314.1523251436111; Sun, 08 Apr 2018 22:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251436; cv=none; d=google.com; s=arc-20160816; b=1Km1e5+mI+fRto6QV/MfjoB/G5Y8bOE13WsbtmXlwUNc0lx2eptpXh0zLkigDNhnn2 vWX8ST0YRnR8547EC605iTJnmeKYhxqeam86XtJy75m7jSeyG+mYj9eOx+nzwMqlmnh6 9haUk2nyNQDEgZZiEbFM3pGPuRXwXyha3OXAzFrEDr7M/GQOe+Qqs8zBiqq+pyXy/Lpa 9ZEr9z2fzc/lnkFtWCahRvlpN3TlOryOCdWIfIOKcsuf5Wgsur78YA9RSilsoAkSOXHG ETO8U2mZ8/RXK85ELZM7HtKVE7L5cOR4Zo3l8uqH1X2llrhI8r3aEbVfMMnALxxzldVV +88w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=nm9bJ4A1WsnFUejPNtYvF2Sx5gDpkDE6HjYaBGqKyKM=; b=RQ6HRsXtQhEcAIR62ZMt/gvhiUKwDdkqqhxxHyMy3UnH4V6i/QaqUdAWvWMwWeFuPJ 3B0BhnSfKmaPNaorMij3ApHJuK6UoIANQS7+onRKTdi1cjB0IzBf0suUAyN4Js/T7dQF V8O4IAovKVT9RKbkdtVnwsCK+AU+8OgUj+9+Ce/gjLlF4nxGVDDvTLIIPZ/MqwEgPZ55 9IairMKQzQHinBmqOYAA6/8Bkvb93BUb0xaHzKi6FsnmJx6AhYsGpNVUKZEc01BmrrM0 jE47/Lkl7Pf8IxO3tzKzkPkQ0P5eSOJPRQoB+fWPGylxDZYwYF2jr0aVc/LWB8Jn6XrW 5dRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=BICHZ/jF; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t190si10792569pgd.101.2018.04.08.22.23.19; Sun, 08 Apr 2018 22:23:56 -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=@microsoft.com header.s=selector1 header.b=BICHZ/jF; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754774AbeDIAW5 (ORCPT + 99 others); Sun, 8 Apr 2018 20:22:57 -0400 Received: from mail-sn1nam01on0122.outbound.protection.outlook.com ([104.47.32.122]:20813 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754726AbeDIAWs (ORCPT ); Sun, 8 Apr 2018 20:22:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nm9bJ4A1WsnFUejPNtYvF2Sx5gDpkDE6HjYaBGqKyKM=; b=BICHZ/jF9N8Npg5QNd+jvYf/fqdLJAWuIzZNn3tP+UbGky09YsVvTwpbzPfXoj3bErWX3Tm0di8+HGijSVCBHOk3Xxw6Fs+6MX9SoPsZrvcisX+Q5mwcxUW1wuu30GSif3VQ8a5ZnwXHkJ0o0Pa4mf6YDR6mddtAg08PjP7kM4k= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0966.namprd21.prod.outlook.com (52.132.133.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:22:44 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:22:44 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Peter Xu , Alex Williamson , Joerg Roedel , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 031/161] iommu/vt-d: Use domain instead of cache fetching Thread-Topic: [PATCH AUTOSEL for 4.14 031/161] iommu/vt-d: Use domain instead of cache fetching Thread-Index: AQHTz5iD6b67OjwHNESCNoTmcm53wA== Date: Mon, 9 Apr 2018 00:20:07 +0000 Message-ID: <20180409001936.162706-31-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0966;7:Fv/bfK2OW035A/7O+NL/MByxe9zwE1DL5myUMI7wfLx/hziyNUzKSJMCuRzOxeErhm8bLME6TDnldy3FBq6SwJM7NEOOwmi4KepGgEaSyVSLrq+GVjxdZecU6wKJo4OXabfQsePYXvLkRips41DUvsGKAQnLHsTiOnZFk07kGLn4ssRvslu3GMw4YFk0J0lE/qzPrBhbUo3TI/K1JOf0SB9+tzpiGmdKk1dyTzkZacxolIOEMq6BkMTmg32mlrek;20:obrLWiFLzL8hVA32Sr/vfOQAKDDjzooQ4pXiUrh2jeHQ7HLb4lkKep3nvuzjOY+LXXD20FyhZqqcJ9BmALRDy3RJMzQzbkYfUMq5Hho8CDhLxF+dORTbaGq8Sdt/YyGIg/xg7bVJt3F1ndXDRuVPXmAG/Phu0qvHtWBVneSqVHU= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 796ad28c-e51e-4908-a02a-08d59db00399 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0966; x-ms-traffictypediagnostic: DM5PR2101MB0966: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(83566789882024); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0966;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0966; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(39860400002)(39380400002)(396003)(366004)(51234002)(199004)(189003)(377424004)(6512007)(316002)(59450400001)(6436002)(186003)(6306002)(6666003)(2900100001)(966005)(8936002)(486006)(6486002)(6506007)(10290500003)(81166006)(22452003)(25786009)(1076002)(81156014)(53936002)(106356001)(10090500001)(5250100002)(107886003)(102836004)(76176011)(8676002)(66066001)(2501003)(446003)(476003)(36756003)(99286004)(575784001)(478600001)(86362001)(72206003)(2616005)(68736007)(5660300001)(305945005)(3846002)(6116002)(26005)(86612001)(14454004)(97736004)(3660700001)(4326008)(2906002)(110136005)(54906003)(3280700002)(105586002)(7736002)(11346002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0966;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 9kT8tcT6rpviQBw47xT25lGGkf79gF5RIXV5IvvesS5pKICnMoigGznm2zhtNJrxIK0cgDOdmD4aQ9vBpPQh3pRFnqEKtR0TG/Y7LV07/QWGlEChJllaBSTzLDjJgYiaGfN2AwlowWcqC69yDlxi4aAFl+atwoWdOQXjrwunsHeYbJlN4/J4eNWhczf3ULm2mG75AC7KNylhJ0dPnbhVOqoZ0Rt8axHNhscFyjvHkPT7RnircUvGCs8NoRHVU5JrPO0wBKMKp5jwEC3IOHtKlVh/LXT9eFKl09+d2w4aGvDrpMR391grXK/zigEeJsQN4+459tbRwwWwpFNlh03dW6em9jIucFmZa75S2NQnQ16/dQcIz16UkdMyAGCOVDvHs4kZ3OF6R3d838p31a9eLXpv1l2BWbIi3H1IoHhVHsc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 796ad28c-e51e-4908-a02a-08d59db00399 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:07.7228 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0966 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Xu [ Upstream commit 9d2e6505f6d6934e681aed502f566198cb25c74a ] after commit a1ddcbe93010 ("iommu/vt-d: Pass dmar_domain directly into iommu_flush_iotlb_psi", 2015-08-12), we have domain pointer as parameter to iommu_flush_iotlb_psi(), so no need to fetch it from cache again. More importantly, a NULL reference pointer bug is reported on RHEL7 (and it can be reproduced on some old upstream kernels too, e.g., v4.13) by unplugging an 40g nic from a VM (hard to test unplug on real host, but it should be the same): https://bugzilla.redhat.com/show_bug.cgi?id=3D1531367 [ 24.391863] pciehp 0000:00:03.0:pcie004: Slot(0): Attention button press= ed [ 24.393442] pciehp 0000:00:03.0:pcie004: Slot(0): Powering off due to bu= tton press [ 29.721068] i40evf 0000:01:00.0: Unable to send opcode 2 to PF, err I40E= _ERR_QUEUE_EMPTY, aq_err OK [ 29.783557] iommu: Removing device 0000:01:00.0 from group 3 [ 29.784662] BUG: unable to handle kernel NULL pointer dereference at 000= 0000000000304 [ 29.785817] IP: iommu_flush_iotlb_psi+0xcf/0x120 [ 29.786486] PGD 0 [ 29.786487] P4D 0 [ 29.786812] [ 29.787390] Oops: 0000 [#1] SMP [ 29.787876] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 = xt_conntrack ip_set nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6= table_ng [ 29.795371] CPU: 0 PID: 156 Comm: kworker/0:2 Not tainted 4.13.0 #14 [ 29.796366] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.1= 1.0-1.el7 04/01/2014 [ 29.797593] Workqueue: pciehp-0 pciehp_power_thread [ 29.798328] task: ffff94f5745b4a00 task.stack: ffffb326805ac000 [ 29.799178] RIP: 0010:iommu_flush_iotlb_psi+0xcf/0x120 [ 29.799919] RSP: 0018:ffffb326805afbd0 EFLAGS: 00010086 [ 29.800666] RAX: ffff94f5bc56e800 RBX: 0000000000000000 RCX: 00000002000= 00025 [ 29.801667] RDX: ffff94f5bc56e000 RSI: 0000000000000082 RDI: 00000000000= 00000 [ 29.802755] RBP: ffffb326805afbf8 R08: 0000000000000000 R09: ffff94f5bc8= 6bbf0 [ 29.803772] R10: ffffb326805afba8 R11: 00000000000ffdc4 R12: ffff94f5bc8= 6a400 [ 29.804789] R13: 0000000000000000 R14: 00000000ffdc4000 R15: 00000000000= 00000 [ 29.805792] FS: 0000000000000000(0000) GS:ffff94f5bfc00000(0000) knlGS:= 0000000000000000 [ 29.806923] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.807736] CR2: 0000000000000304 CR3: 000000003499d000 CR4: 00000000000= 006f0 [ 29.808747] Call Trace: [ 29.809156] flush_unmaps_timeout+0x126/0x1c0 [ 29.809800] domain_exit+0xd6/0x100 [ 29.810322] device_notifier+0x6b/0x70 [ 29.810902] notifier_call_chain+0x4a/0x70 [ 29.812822] __blocking_notifier_call_chain+0x47/0x60 [ 29.814499] blocking_notifier_call_chain+0x16/0x20 [ 29.816137] device_del+0x233/0x320 [ 29.817588] pci_remove_bus_device+0x6f/0x110 [ 29.819133] pci_stop_and_remove_bus_device+0x1a/0x20 [ 29.820817] pciehp_unconfigure_device+0x7a/0x1d0 [ 29.822434] pciehp_disable_slot+0x52/0xe0 [ 29.823931] pciehp_power_thread+0x8a/0xa0 [ 29.825411] process_one_work+0x18c/0x3a0 [ 29.826875] worker_thread+0x4e/0x3b0 [ 29.828263] kthread+0x109/0x140 [ 29.829564] ? process_one_work+0x3a0/0x3a0 [ 29.831081] ? kthread_park+0x60/0x60 [ 29.832464] ret_from_fork+0x25/0x30 [ 29.833794] Code: 85 ed 74 0b 5b 41 5c 41 5d 41 5e 41 5f 5d c3 49 8b 54 = 24 60 44 89 f8 0f b6 c4 48 8b 04 c2 48 85 c0 74 49 45 0f b6 ff 4a 8b 3c f8 = <80> bf [ 29.838514] RIP: iommu_flush_iotlb_psi+0xcf/0x120 RSP: ffffb326805afbd0 [ 29.840362] CR2: 0000000000000304 [ 29.841716] ---[ end trace b10ec0d6900868d3 ]--- This patch fixes that problem if applied to v4.13 kernel. The bug does not exist on latest upstream kernel since it's fixed as a side effect of commit 13cf01744608 ("iommu/vt-d: Make use of iova deferred flushing", 2017-08-15). But IMHO it's still good to have this patch upstream. CC: Alex Williamson Signed-off-by: Peter Xu Fixes: a1ddcbe93010 ("iommu/vt-d: Pass dmar_domain directly into iommu_flus= h_iotlb_psi") Reviewed-by: Alex Williamson Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel-iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 83f3d4831f94..e8414bcf8390 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1603,8 +1603,7 @@ static void iommu_flush_iotlb_psi(struct intel_iommu = *iommu, * flush. However, device IOTLB doesn't need to be flushed in this case. */ if (!cap_caching_mode(iommu->cap) || !map) - iommu_flush_dev_iotlb(get_iommu_domain(iommu, did), - addr, mask); + iommu_flush_dev_iotlb(domain, addr, mask); } =20 static void iommu_flush_iova(struct iova_domain *iovad) --=20 2.15.1