Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5259028ybf; Wed, 4 Mar 2020 20:55:15 -0800 (PST) X-Google-Smtp-Source: ADFU+vv3Bm6jFxPiC4L/hH+kFIiKWou4iJkhrL9i/Eb3z/1/RLXKIRgnu4UZ4EjECEzF/B3THs25 X-Received: by 2002:a05:6830:18ee:: with SMTP id d14mr4968782otf.298.1583384115199; Wed, 04 Mar 2020 20:55:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583384115; cv=none; d=google.com; s=arc-20160816; b=w6+0RcdlkHHxKs6e9xXySzK/sFRQFH96W9//44zwM30BkIL1unMuoDk4SrZ6Ozdswk zrIPj6kMJbupYKTh5ERdq6jdiZEfhhax4tqNJj4Fe+v3ZyouIAhozfFWcOnRYBau9M7R ExwrIMjYoahDEKvzV5dyK0DqZpwXgJp6Un4W+yj+XLdASREEz4HFsMi7x57+Vjy+fJBW zRD4xO5F8j26GKTkLJ6l1K6fhE7RNPPKr2yM32U7sZBvtNRIQh7XgiUfZfsGnuGfF3Gs 0aYUVTygi8zzHpl+FHKucbZ10EE4o2eqHSxAOB7VxgHGdHTLvHOOco+6qnt3NPaK2Ems m/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ijl3mOJKjXQOlvfNdI9J8WHV9omrENAd5cs2bOM6kiw=; b=Rayq03BM/4NpGCkViyb7eobyanPYBEaegBaNm4BIMHBlQ3aOweJcdficx/A3eXpEnc vN28uMHi7WKDSQRZmcRmo1JA6DVUCA/5Ank8KPSUUKCj+wjNFFqab4OhkXONUF9Ww0KM YiSmqDyf7wUdrhk2xFgeE7YzzA1CaJEd3dR+vlPMUovUuF0JOmXaBCOEBrHycqgqD+NX BsbTYyqRg1tXyZLkUC40WkV5FvAD9UvoLRLWn/2o0dnwCtpIRvVEP6cByP7/4Ktw454z 0WNQr7iEHqbPrEfLcWN0Y4xPvxyS6PcmHaPdqwwqSYl7LVlX66dqHCzHljaWYTXPtx9P 75Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Md4ocL49; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z184si2545508oia.217.2020.03.04.20.55.04; Wed, 04 Mar 2020 20:55:15 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Md4ocL49; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725953AbgCEExl (ORCPT + 99 others); Wed, 4 Mar 2020 23:53:41 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:33662 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbgCEExl (ORCPT ); Wed, 4 Mar 2020 23:53:41 -0500 Received: by mail-io1-f66.google.com with SMTP id r15so5084453iog.0; Wed, 04 Mar 2020 20:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ijl3mOJKjXQOlvfNdI9J8WHV9omrENAd5cs2bOM6kiw=; b=Md4ocL49tyh2taM4R+ydAETsDonhCdHdH91uX9e4oi/Smwy1T1bHdZtXo7pzLeKUlE ATgUMwec8xfNgs5wZ9tS84sDUDhEToc97J4DZerin2iZrSMMAhcxvbF/9ENyfBsNsafY yz94ZWfU7TIs8zo9/UBF6u5ojhc8bdHjSnD0e+FdhwM3Osjj3y3414ubipw/nhkrYbBI MMcTqCF21Ez4VEwoCYUC80WTIWDvErT+VcgO4lzV+XTvsr9PkEzOXASMarW3Rh9XIqAv 5pcFUzaSqJ6l25COcDCNqZdTAAu27JXSDDhWQhHCzoxrM74HmRDTlNXnOTitQprHYfMO Ie8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ijl3mOJKjXQOlvfNdI9J8WHV9omrENAd5cs2bOM6kiw=; b=uoZmVe0WOw+JmWeZKwGT+dBUeiU2UDZdKupMm8h/iZ9TCSceR4BPWawyuY/EmRZO/F CupSmGEPGtzuKKBtD+0psKmoBAxITeQ4d2qWDK4DGY3DkhGWFLIt0aYdexOOdukXju6e k5ERDtv3tUBshA9+faammOEkVe/m9nDCp3/PET42zA616GseEMCJOhjT2EuQj522G+oz x3sJEQHHbJ4ZTUhRpmuANQdfSiXQGZ9IlvHtPrc7aSa/che8ZVvxEZKic2VvkG95qEA1 nSoAZwRt3ZMI0gXVyGDXRMNLX/0yty75aV4vxqzuQy6hv7of8wOwTo7fjdKZ390Hs0Wd X9ig== X-Gm-Message-State: ANhLgQ3ZbqKp+NkXiSysTcM85Cd6rJvQuCuxz0nukzwIEcYeolQK7wrJ 1Wh0svEYZersm7gg/kOG9uvnYOuE87GZRRkjFCc= X-Received: by 2002:a02:cc84:: with SMTP id s4mr5976154jap.5.1583384020211; Wed, 04 Mar 2020 20:53:40 -0800 (PST) MIME-Version: 1.0 References: <20191225192118.283637-1-kasong@redhat.com> <20200222165631.GA213225@google.com> <20200305035329.GD4433@MiWiFi-R3L-srv> In-Reply-To: <20200305035329.GD4433@MiWiFi-R3L-srv> From: Deepa Dinamani Date: Wed, 4 Mar 2020 20:53:29 -0800 Message-ID: Subject: Re: [RFC PATCH] PCI, kdump: Clear bus master bit upon shutdown in kdump kernel To: Baoquan He Cc: Kairui Song , Bjorn Helgaas , Khalid Aziz , Linux Kernel Mailing List , linux-pci@vger.kernel.org, kexec@lists.infradead.org, Jerry Hoemann , Randy Wright , Dave Young , Myron Stowe , jroedel@suse.de Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 4, 2020 at 7:53 PM Baoquan He wrote: > > +Joerg to CC. > > On 03/03/20 at 01:01pm, Deepa Dinamani wrote: > > I looked at this some more. Looks like we do not clear irqs when we do > > a kexec reboot. And, the bootup code maintains the same table for the > > kexec-ed kernel. I'm looking at the following code in > > I guess you are talking about kdump reboot here, right? Kexec and kdump > boot take the similar mechanism, but differ a little. Right I meant kdump kernel here. And, clearly the is_kdump_kernel() case below. > > > intel_irq_remapping.c: > > > > if (ir_pre_enabled(iommu)) { > > if (!is_kdump_kernel()) { > > pr_warn("IRQ remapping was enabled on %s but > > we are not in kdump mode\n", > > iommu->name); > > clear_ir_pre_enabled(iommu); > > iommu_disable_irq_remapping(iommu); > > } else if (iommu_load_old_irte(iommu)) > > Here, it's for kdump kernel to copy old ir table from 1st kernel. Correct. > > pr_err("Failed to copy IR table for %s from > > previous kernel\n", > > iommu->name); > > else > > pr_info("Copied IR table for %s from previous kernel\n", > > iommu->name); > > } > > > > Would cleaning the interrupts(like in the non kdump path above) just > > before shutdown help here? This should clear the interrupts enabled > > for all the devices in the current kernel. So when kdump kernel > > starts, it starts clean. This should probably help block out the > > interrupts from a device that does not have a driver. > > I think stopping those devices out of control from continue sending > interrupts is a good idea. While not sure if only clearing the interrupt > will be enough. Those devices which will be initialized by their driver > will brake, but devices which drivers are not loaded into kdump kernel > may continue acting. Even though interrupts are cleaning at this time, > the on-flight DMA could continue triggerring interrupt since the ir > table and iopage table are rebuilt. This should be handled by the IOMMU, right? And, hence you are getting UR. This seems like the correct execution flow to me. Anyway, you could just test this theory by removing the is_kdump_kernel() check above and see if it solves your problem. Obviously, check the VT-d spec to figure out the exact sequence to turn off the IR. Note that the device that is causing the problem here is a legit device. We want to have interrupts from devices we don't know about blocked anyway because we can have compromised firmware/ devices that could cause a DoS attack. So blocking the unwanted interrupts seems like the right thing to do here. -Deepa