Received: by 10.213.65.68 with SMTP id h4csp2116270imn; Sun, 8 Apr 2018 20:07:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49pQa+CAcw4Cl61qLoylZbIcFzFgzvRzuGXwFkHgb4JqYbD+ieU7sPMjJsjHbQyIomw6ho8 X-Received: by 10.101.102.3 with SMTP id w3mr23230485pgv.200.1523243226279; Sun, 08 Apr 2018 20:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243226; cv=none; d=google.com; s=arc-20160816; b=gbv66Z58JmIMB4vwI+L0NwaNX6PiaPEWhv2gqpzHWlrfniLtsH+RtpUGeEvdFHQi4G lUwVXwJ7w8v9DiIQNCQyBBwaTQBwcpSpwPEC0viRdjagJtjH8pG94WGovCpEoMefrvaB PEaxgEq8rXWodvc8OgFDUQtIBrzL/HhphoIu1VM1B8xpt6emZ3Xus7OA6Ge32zD63BnJ 2CYKpur2yQfP2ZcabBQOn5PULKTUeOu3VacUWFd5J/DdUFGGRsqBbZJmhQWctbCNLt+p VpS8aa8gFbZKhGtX78Clv98mN4GRPWpFfUjMiImbvdl8/b8hQWhnGfNhN1skEz3tBeS/ z/6w== 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=q8u3pRn++KgFV3ubIduQRk/aj3QzkibPd3X866kGobA=; b=Blqf0diGxpyJ6dydWeXSyXJLLqYjHGEkQXZFkMYP9NXrlHt7aWmhQxr3KPUyd5FRfX JN0I1c1TBsvCD8GA2Ge5RgYxvN+NXPQwnF14BcGH9ac3rjVEMlh/t1AbrG2SgGBgcj1K T7HHISh3a+xyeg9jJp8VDT7XWgcL294VlYi2WHL58BgqKvhLkQOOdJ/UjvogyhP0sV6e a3XioA5vCRaOA1XFwP2dsyZZ48uIG3gX0u8XMyYoQXT97zNk+Po+My8yAg4MsCii/ACy 76iLzZb3cALhJ5nZzA3Bbz4xi8zJjdQ9693MPmiORfgeeHgs/bHJ4hkj0cs6UCwI3mu/ 6SwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=DM6eXcWw; 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 i10si2182554pfa.164.2018.04.08.20.06.29; Sun, 08 Apr 2018 20:07:06 -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=DM6eXcWw; 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 S1757221AbeDIBOy (ORCPT + 99 others); Sun, 8 Apr 2018 21:14:54 -0400 Received: from mail-bl2nam02on0103.outbound.protection.outlook.com ([104.47.38.103]:27456 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932891AbeDIAh4 (ORCPT ); Sun, 8 Apr 2018 20:37:56 -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=q8u3pRn++KgFV3ubIduQRk/aj3QzkibPd3X866kGobA=; b=DM6eXcWwpH9LXwTTbUeRUsQ3HJfDTEfdPTDJ+QUKWoteMecWHc9fTaohU46d9hNlbFhFbneDnJYR+/Fo6AQX3yS+zhDrt+NesZnFFOTU5sI4B5nzPDRUMoXZk7BZFFWhI2vPQ1t/wjEIbTVxVEG6Ap8oeYgviwfsKOugvre9CQw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1110.namprd21.prod.outlook.com (52.132.131.167) 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:37:51 +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:37:51 +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.4 115/162] iommu/vt-d: Use domain instead of cache fetching Thread-Topic: [PATCH AUTOSEL for 4.4 115/162] iommu/vt-d: Use domain instead of cache fetching Thread-Index: AQHTz5nJEFZLe6LXrEGOvLuQ/SmPIQ== Date: Mon, 9 Apr 2018 00:29:14 +0000 Message-ID: <20180409002738.163941-115-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB1110;7:WD+zA/pOvB0sg0f+4ad5VZQ/2Z1xUU3MYWR9GJOro463nOrDeR6ugARV0YEPNeUccTS3OC+hgttcroFZ/0ENL2qJAfmG/9pCK9zOstwOUD/jAgXwosSetrCj5ob/SiNWdx0vnebar8ePMcU0Pl8O5ccqDnmkbRxHip0JzCTpqYf30o9t1/N2Y/K9Gb4PKeJLCvMbQHnLaeZGTs8dTkrrFmrlzfh6m1MXiUH5eyo6YrmDrkI64ryk+4XSkHb6T+eC;20:gnVli8M3iNf0ETRds+QuIRzPYErd6kpw+iQi4uMlejhKOUqzqBO0B/fK/k8CaYBgB4rzxrDR0V3v0Tq3v3S2cdg0z43EiHg2ebat4iit3tTkHzF2djJ5FpS1QFwRfsc/tf1+RvFy7ozkvbXc2bLxsciOMJKq0M7/botDOKxdDx0= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: da97e614-7b6a-445a-7954-08d59db2208c x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1110; x-ms-traffictypediagnostic: DM5PR2101MB1110: 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:DM5PR2101MB1110;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1110; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(39380400002)(346002)(396003)(376002)(366004)(199004)(189003)(51234002)(377424004)(53936002)(6306002)(186003)(5250100002)(105586002)(966005)(11346002)(99286004)(476003)(66066001)(6512007)(86362001)(575784001)(3660700001)(1076002)(54906003)(68736007)(110136005)(3280700002)(316002)(305945005)(4326008)(107886003)(22452003)(14454004)(7736002)(446003)(6666003)(2501003)(10290500003)(3846002)(6116002)(72206003)(106356001)(25786009)(6486002)(6436002)(8936002)(478600001)(5660300001)(86612001)(8676002)(81156014)(59450400001)(2906002)(102836004)(81166006)(6506007)(2900100001)(76176011)(2616005)(486006)(26005)(36756003)(10090500001)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1110;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: BZdp0idVvZaE8jEo7XK8Toa1FlFbL8ECIyf3NTRo7kMkoTgtzClw5ZXI1hEfla4cyRr1AGeWXMDUWMrJL1xqbwztwQtPCnmp46WAD+ttUzFUUKpF3oYtpnQVtcs6qC0SXNCc2OdUJvo5xWq1GJ9wq+z9nre5d0KJq24UfRipifMzWfbxDPjO5k9Z0liVeORNf4qy2bWf46vdQDas579Aam3xj0MGrYrUuA1zsZaqY90+NcBW9EXB+VZYLxm1bJZIEL3z0gMEEyOA213UknZfrbwlJpoYNI7GMUCs7e7n5OfW3h0gIOF1Lr5e/z7qIf1TEUcynaZhj88Dh4DMJIiIa5dds5aQNsR8soUBQijmYUe232a33iRHkCEvhBgoDcHzKZ1znpznnJaFXEpJJrhsF2jeDPi2zdCaql0uDzrmLKg= 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: da97e614-7b6a-445a-7954-08d59db2208c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:29:14.1617 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1110 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 4efec2db4ee2..0a63a8bd6a8f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1573,8 +1573,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