From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A473AC43603 for ; Tue, 17 Dec 2019 20:50:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A1A42146E for ; Tue, 17 Dec 2019 20:50:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NZJi5kGx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbfLQUuD (ORCPT ); Tue, 17 Dec 2019 15:50:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28115 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726252AbfLQUuC (ORCPT ); Tue, 17 Dec 2019 15:50:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576615801; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=J73YVZfMxZAcikPu3TQX3XB3CLXiyf6r8SXyDPM2a/Q=; b=NZJi5kGx134qHbNoJ4n6jjWQmYY75BmORKtJBKaOb0K8WXFQnQRndcskqOmxcg9cNJeZfA fyIMmZhDt9XgIogxWawF+f9G+PZWMEkxzfg1p7jOMprYC/PzwNcevc7Bo149RS+DTenwW4 8pXLrXHQj/8T/XdiOz9mAVOlwbtJgDM= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-6lyTJg9zNtmTU3VKamd73w-1; Tue, 17 Dec 2019 15:50:00 -0500 X-MC-Unique: 6lyTJg9zNtmTU3VKamd73w-1 Received: by mail-yb1-f197.google.com with SMTP id a14so4389958ybh.14 for ; Tue, 17 Dec 2019 12:50:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:reply-to :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=J73YVZfMxZAcikPu3TQX3XB3CLXiyf6r8SXyDPM2a/Q=; b=KBgXA8krv3i+xgHmXT87ocPBZdScr5FhDTANo7tZaPhx3Xua2g/XCuJiTTfVydGIoA ug0ACgmyB4u7pMRitRfnoDBvff8Tq8pHsrnrmaLRHQjLuIXSFreHX3qicS/pRjINOqgy 5AI65I2lDOiYWnSivKTBBU4AS9UdxFtaQ3193oBopin5HBAIQc/6ulIKNaOMR0+iZdT4 LiuvCFVisCnA9xbTVF1Qsd88hKShgbrNFq8s9XfBZqsVY32LW59+JKmNVpLaxZ8/VJPb P4/X8/baQMPB65a6EHCqN9Nkz8auKfuisoa7PF/ZinA/KQdVCAhzZkNeIVI6tKeeSfbW 7t1Q== X-Gm-Message-State: APjAAAUxQfFFJ6zYdwJlaTSlgSHZg3k4YaFPZp767mDQh5qHTepFi0gD JLBuY1XKsY1boUCYW03gzlXOw5z5C0GBzi1+BdhIs5wO3neBZh1mJVOTb7cxPJegbRw7BX5w+Gb /P/4Ekj1ni6DtuUyefViiYZxI X-Received: by 2002:a81:a7c3:: with SMTP id e186mr544966ywh.7.1576615799115; Tue, 17 Dec 2019 12:49:59 -0800 (PST) X-Google-Smtp-Source: APXvYqw2euIojC/x9hatXJUaQw8cCQt9qSXTwZErl80ZyUUPVkzXxI5EZizUVgOUgo9pf9yiFFJMOw== X-Received: by 2002:a81:a7c3:: with SMTP id e186mr544945ywh.7.1576615798795; Tue, 17 Dec 2019 12:49:58 -0800 (PST) Received: from localhost (ip70-163-223-149.ph.ph.cox.net. [70.163.223.149]) by smtp.gmail.com with ESMTPSA id 144sm7031975ywy.20.2019.12.17.12.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2019 12:49:58 -0800 (PST) Date: Tue, 17 Dec 2019 13:49:48 -0700 From: Jerry Snitselaar To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Joerg Roedel , David Woodhouse , stable@vger.kernel.org Subject: Re: [RFC PATCH] iommu/vt-d: avoid panic in __dmar_remove_one_dev_info Message-ID: <20191217204948.p6pgnls2rrlr2nnk@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Joerg Roedel , David Woodhouse , stable@vger.kernel.org References: <20191217175542.22187-1-jsnitsel@redhat.com> <20191217203954.6xfaw5jto75q4nxm@cantor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <20191217203954.6xfaw5jto75q4nxm@cantor> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue Dec 17 19, Jerry Snitselaar wrote: >On Tue Dec 17 19, Jerry Snitselaar wrote: >>In addition to checking for a null pointer, verify that >>info does not have the value DEFER_DEVICE_DOMAIN_INFO or >>DUMMY_DEVICE_DOMAIN_INFO. If info has one of those values >>__dmar_remove_one_dev_info will panic when trying to access >>a member of the device_domain_info struct. >> >> [ 1.464241] BUG: unable to handle kernel NULL pointer dereference at 000000000000004e >> [ 1.464241] PGD 0 P4D 0 >> [ 1.464241] Oops: 0000 [#1] SMP PTI >> [ 1.464241] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W --------- - - 4.18.0-160.el8.x86_64 #1 >> [ 1.464241] Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 Gen9, BIOS P89 07/21/2019 >> [ 1.464241] RIP: 0010:__dmar_remove_one_dev_info+0x27/0x250 >> [ 1.464241] Code: 00 00 00 0f 1f 44 00 00 8b 05 35 ec 75 01 41 56 41 55 41 54 55 53 85 c0 0f 84 99 01 00 00 48 85 ff 0f 84 92 01 00 00 48 89 fb <4c> 8b 67 50 48 8b 6f 58 $ >> [ 1.464241] RSP: 0000:ffffc900000dfd10 EFLAGS: 00010082 >> [ 1.464241] RAX: 0000000000000001 RBX: fffffffffffffffe RCX: 0000000000000000 >> [ 1.464241] RDX: 0000000000000001 RSI: 0000000000000004 RDI: fffffffffffffffe >> [ 1.464241] RBP: ffff88ec7a72f368 R08: 0000000000000457 R09: 0000000000000039 >> [ 1.464241] R10: 0000000000000000 R11: ffffc900000dfa58 R12: ffff88ec7a0eec20 >> [ 1.464241] R13: ffff88ec6fd0eab0 R14: ffffffff81eae980 R15: 0000000000000000 >> [ 1.464241] FS: 0000000000000000(0000) GS:ffff88ec7a600000(0000) knlGS:0000000000000000 >> [ 1.464241] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> [ 1.464241] CR2: 000000000000004e CR3: 0000006c7900a001 C 00000000001606b0 >> [ 1.464241] Call Trace: >> [ 1.464241] dmar_remove_one_dev_info.isra.68+0x27/0x40 >> [ 1.464241] intel_iommu_add_device+0x124/0x180 >> [ 1.464241] ? iommu_probe_device+0x40/0x40 >> [ 1.464241] add_iommu_group+0xa/0x20 >> [ 1.464241] bus_for_each_dev+0x77/0xc0 >> [ 1.464241] ? down_write+0xe/0x40 >> [ 1.464241] bus_set_iommu+0x85/0xc0 >> [ 1.464241] intel_iommu_init+0x4b4/0x777 >> [ 1.464241] ? e820__memblock_setup+0x63/0x63 >> [ 1.464241] ? do_early_param+0x91/0x91 >> [ 1.464241] pci_iommu_init+0x19/0x45 >> [ 1.464241] do_one_initcall+0x46/0x1c3 >> [ 1.464241] ? do_early_param+0x91/0x91 >> [ 1.464241] kernel_init_freeable+0x1af/0x258 >> [ 1.464241] ? rest_init+0xaa/0xaa >> [ 1.464241] kernel_init+0xa/0x107 >> [ 1.464241] ret_from_fork+0x35/0x40 >> [ 1.464241] Modules linked in: >> [ 1.464241] CR2: 000000000000004e >> [ 1.464241] ---[ end trace 0927d2ba8b8032b5 ]--- >> >>Cc: Joerg Roedel >>Cc: Lu Baolu >>Cc: David Woodhouse >>Cc: stable@vger.kernel.org # v5.3+ >>Cc: iommu@lists.linux-foundation.org >>Fixes: ae23bfb68f28 ("iommu/vt-d: Detach domain before using a private one") >>Signed-off-by: Jerry Snitselaar >>--- >>drivers/iommu/intel-iommu.c | 3 ++- >>1 file changed, 2 insertions(+), 1 deletion(-) >> >>diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c >>index 0c8d81f56a30..e42a09794fa2 100644 >>--- a/drivers/iommu/intel-iommu.c >>+++ b/drivers/iommu/intel-iommu.c >>@@ -5163,7 +5163,8 @@ static void dmar_remove_one_dev_info(struct device *dev) >> >> spin_lock_irqsave(&device_domain_lock, flags); >> info = dev->archdata.iommu; >>- if (info) >>+ if (info && info != DEFER_DEVICE_DOMAIN_INFO >>+ && info != DUMMY_DEVICE_DOMAIN_INFO) >> __dmar_remove_one_dev_info(info); >> spin_unlock_irqrestore(&device_domain_lock, flags); >>} >>-- >>2.24.0 >> >>_______________________________________________ >>iommu mailing list >>iommu@lists.linux-foundation.org >>https://lists.linuxfoundation.org/mailman/listinfo/iommu >> > >Nack this. > >Apparently the issue is just being seen with the kdump kernel. I'm >wondering if it is already solved by 6c3a44ed3c55 ("iommu/vt-d: Turn >off translations at shutdown"). Testing a 5.5 build now. And a minute later I got a response. The 5.5 kernel hits the original panic when booting into the kdump kernel. I need to test with this patch on 5.5, but with a test build of our kernel with this patch the problem just moves to: [ 3.742317] pci 0000:01:00.0: Using iommu dma mapping [ 3.744020] pci 0000:01:00.1: Adding to iommu group 86 [ 3.746697] NMI watchdog: Watchdog detected hard LOCKUP on cpu 0Modules linked in: [ 3.746697] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-167.el8.iommu6.x86_64 #1 [ 3.746697] Hardware name: HP ProLiant DL560 Gen9/ProLiant DL560 Gen9, BIOS P85 07/21/2019 [ 3.746697] RIP: 0010:native_queued_spin_lock_slowpath+0x5d/0x1d0 [ 3.746697] Code: 0f ba 2f 08 0f 92 c0 0f b6 c0 c1 e0 08 89 c2 8b 07 30 e4 09 d0 a9 00 01 ff ff 75 47 85 c$ [ 3.746697] RSP: 0000:ffffc900000f3bd8 EFLAGS: 00000002 [ 3.746697] RAX: 0000000000000101 RBX: 0000000000000046 RCX: ffff88887f170000 [ 3.746697] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff82e8a600 [ 3.746697] RBP: ffff88886fd0ec00 R08: 0000000000000004 R09: ffffc900000f3b94 [ 3.746697] R10: 0000000000000001 R11: ffff88887a4e3200 R12: ffff88887cbf6540 [ 3.746697] R13: 0000000000000001 R14: ffff88887a4e3480 R15: 0000000000000001 [ 3.746697] FS: 0000000000000000(0000) GS:ffff88887f600000(0000) knlGS:0000000000000000 [ 3.746697] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 3.746697] CR2: 0000000000000000 CR3: 000000087de0a001 CR4: 00000000003606b0 [ 3.746697] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 3.746697] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 3.746697] Call Trace: [ 3.746697] _raw_spin_lock_irqsave+0x32/0x40 [ 3.746697] dmar_insert_one_dev_info+0xa3/0x4d0 [ 3.746697] ? free_unref_page_commit+0x91/0x100 [ 3.746697] ? device_to_iommu+0x1a3/0x220 [ 3.746697] domain_add_dev_info+0x50/0x90 [ 3.746697] intel_iommu_attach_device+0xb7/0x140 [ 3.746697] find_domain+0x41/0x60 [ 3.746697] dmar_insert_one_dev_info+0xaf/0x4d0 [ 3.746697] ? device_to_iommu+0x1a3/0x220 [ 3.746697] domain_add_dev_info+0x50/0x90 [ 3.746697] intel_iommu_add_device+0x137/0x180 [ 3.746697] ? iommu_probe_device+0x40/0x [ 3.746697] add_iommu_group+0xa/0x20 [ 3.746697] bus_for_each_dev+0x77/0xc0 [ 3.746697] ? down_write+0xe/0x40 [ 3.746697] bus_set_iommu+0x85/0xc0 [ 3.746697] intel_iommu_init+0x4b4/0x777 [ 3.746697] ? e820__memblock_setup+0x63/0x63 [ 3.746697] ? do_early_param+0x91/0x91 [ 3.746697] pci_iommu_init+0x19/0x45 [ 3.746697] do_one_initcall+0x46/0x1c3 [ 3.746697] ? do_early_param+0x91/0x91 [ 3.746697] kernel_init_freeable+0x1af/0x258 [ 3.746697] ? rest_init+0xaa/0xaa [ 3.746697] kernel_init+0xa/0x103 [ 3.746697] ret_from_fork+0x35/0x40