Received: by 10.213.65.68 with SMTP id h4csp2119675imn; Sun, 8 Apr 2018 20:11:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/QNwjn0Cf6qZ90v+pmANPNUPYbPcKNgm2SNO4OxA5RtnXmbmIveONFAIh08EbaK85OnDnL X-Received: by 10.98.68.135 with SMTP id m7mr27841561pfi.57.1523243409634; Sun, 08 Apr 2018 20:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243409; cv=none; d=google.com; s=arc-20160816; b=nEej3UYc9puwHY/4k14U9k5MGz244Newe4PUzUzFmuH/UuP7ruNvH8ukIsG2cx02Y5 paD9JNuQgiyB/vLjeN6M4UCF1WnmQMNRE9V6zTz5rRWHfwfT/HikHQ6vq4Nq9iIWseP+ JgEDJjY9QjDLgbuDD5zJRRk054yh/erCwSeW6I8Xa7RUDJxsaqcdKzM4mA6cExAjSRMe 4iYPV7ONiF8zrb6Vx3a33lna5E6xkUWUgGlXmZnJ6VeZPsNQO9Pa9xL5Ck9KdQFAmnUH UFZKi0g4k7SyGzLOlv1ipE63vxiaFfPlmPMdNE+OJpxmcudrlre+pZBiQ5EBDFTYEjUg ZMWA== 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=6cClNf0bx1whA9cTDpVrpB/075VI+pSaiSoCKNvG23U=; b=zvSeKWreEdyl9XF0TUQHkpxdPHC6AuFbC4wWy6GWyFPvOs4gRxAnPnOtLmBbqzy3P4 XSvAroeGfIieP2cJtwzTIPJJYV5ul7Vd1T/bOblPFzkGMhcnJSjDtn9zEtkQZAimvtP1 UUFnVBvmqvZp2Us93CQdPxJ4swOUd4GT+RHVqkWinqeuDwWU+ghdhJhRyDI6DNnm5QW4 EgF+fpOURz0aw0BlByYecY5Eik/FKdh9yGr1UPp7W8j48XrdDJphNaube36vEI/SrisL PaSAQILmjjyXC9LMU3yBR9EZxAmg2Xi4UhsoxpN6n0eIKyU7i/bWeWSEeOpgvE2ZRCtv hqyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cWvgcoLZ; 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 f2si4614135pgn.320.2018.04.08.20.09.33; Sun, 08 Apr 2018 20:10:09 -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=cWvgcoLZ; 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 S932663AbeDIBzL (ORCPT + 98 others); Sun, 8 Apr 2018 21:55:11 -0400 Received: from mail-sn1nam01on0097.outbound.protection.outlook.com ([104.47.32.97]:22599 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932181AbeDIAc6 (ORCPT ); Sun, 8 Apr 2018 20:32:58 -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=6cClNf0bx1whA9cTDpVrpB/075VI+pSaiSoCKNvG23U=; b=cWvgcoLZmYFIL0E6N2EdcoqyyN6g1z8o/NetMC1aNzqs84s6Q0DLEFo9KCnXW9QdytVTH+vh6MwIu/1vhsRDidC9jTGpJZuCjqpby0zFh0XvNc9HKf1AdZeoqQqVtpdeurTH7Sthp/mWw/9kKOPVzBKYpixy3peanE7bXF3NZRo= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0902.namprd21.prod.outlook.com (52.132.132.159) 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:32:55 +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:32:55 +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.9 225/293] iommu/vt-d: Use domain instead of cache fetching Thread-Topic: [PATCH AUTOSEL for 4.9 225/293] iommu/vt-d: Use domain instead of cache fetching Thread-Index: AQHTz5lP1woQVTyB90WDDW4RIOg6TQ== Date: Mon, 9 Apr 2018 00:25:49 +0000 Message-ID: <20180409002239.163177-225-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0902;7:lDRdiHAaJjznCQrdMKgjoSUnIMHrGEBk+7nWf93qjC+53g9UaP/xw/rMZifMUZUR7e0FMLJyeXeAyYtHs9yZ1KKREELbjTgOkwS+Da31WgZQ0cct4hqIL2lq/JI8JClnpKqsVB1LD2v5xKnE9E36f4End/s2t+87g6tRTExIKf9niPqv7Ing/RVr6PVhhC+24v0JePv9FpAUslhn3iMoEGjWcuDg1h7u6+/GFC/bLleZiGxTari6dQ6HIIQpb48B;20:eizc163p535dWPy3Gkvv2GBgjPTWDK6C+GqUjV+c25kpZNMvYc04cDQynxUCJB8kw4DR7LGX0yXJh/z7pTJlXaeq1r1UihGSRFAc1RORWx9fYf3//K5e3C+tbfwHe8tD/fZNlx3pgDMo4ftVVV0xNkeicbhZFVIbu5n60WvaW9s= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 54e5cb92-e3e7-4729-8d90-08d59db16fc9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0902; x-ms-traffictypediagnostic: DM5PR2101MB0902: 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)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0902;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0902; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39860400002)(39380400002)(346002)(51234002)(377424004)(199004)(189003)(5660300001)(478600001)(86612001)(3846002)(6116002)(106356001)(25786009)(6486002)(72206003)(10290500003)(8936002)(6436002)(76176011)(2616005)(6506007)(2900100001)(97736004)(26005)(486006)(10090500001)(36756003)(81166006)(8676002)(81156014)(59450400001)(102836004)(2906002)(99286004)(11346002)(476003)(3660700001)(66066001)(6512007)(575784001)(86362001)(6306002)(53936002)(966005)(105586002)(186003)(5250100002)(14454004)(22452003)(6666003)(2501003)(446003)(7736002)(316002)(1076002)(110136005)(3280700002)(68736007)(54906003)(107886003)(4326008)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0902;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: /Ku7ru4MqY7fl1L9XRjSGma244GQaOVKg9NantN8bx2jA1OtkBxE1yV6MqeLoB/1IBvf6blrwwi+Y5SkrAGkQqnUwoj2BgxNHcLplfJ7nFoCvCrW6OoseCJe2tCo4/C0+O1xzps3D4u9so696BzzdQWtTQSb/hUm0MPElw4Ep9ffcjycH/QtzY4fQfmzUBKx/0fxP4nOSJcLHmqPxp2r4BlPo6GTeRsZAEsxpdumH3QPp5mwy6BWquWSQciQ6EXbD0K45BW2l7TJYHk4qxJ18DOVC/t3HQGPliMkCuRGkyqzEKZ7n3Np2EepTHGB3HEcepDnIvNM9ahfQ5OkaJe5pc+xv/cRUmR8PN5INp0ClEMpk0W7HN2eqJOsxcVQd6bOrlFdndylTUGvedk48HulxnTGaQJJi8nWjf/4ytw/1NQ= 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: 54e5cb92-e3e7-4729-8d90-08d59db16fc9 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:49.8473 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0902 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 88bbc8ccc5e3..1612d3a22d42 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1612,8 +1612,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_disable_protect_mem_regions(struct intel_iommu *iommu) --=20 2.15.1