From patchwork Tue Aug 1 22:55:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9875659 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 212A260365 for ; Tue, 1 Aug 2017 23:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D051FEBD for ; Tue, 1 Aug 2017 23:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04F3E28747; Tue, 1 Aug 2017 23:04:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB5E41FEBD for ; Tue, 1 Aug 2017 23:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751630AbdHAXEa (ORCPT ); Tue, 1 Aug 2017 19:04:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:43946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbdHAXE3 (ORCPT ); Tue, 1 Aug 2017 19:04:29 -0400 Received: from localhost (unknown [69.71.4.159]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9A262133F; Tue, 1 Aug 2017 22:55:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9A262133F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Tue, 1 Aug 2017 17:55:56 -0500 From: Bjorn Helgaas To: Prarit Bhargava Cc: linux-pci@vger.kernel.org Subject: Re: [PATCH] pci: Add WARN_ON() for some pci= kernel parameters Message-ID: <20170801225556.GD26498@bhelgaas-glaptop.roam.corp.google.com> References: <1489513617-9833-1-git-send-email-prarit@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1489513617-9833-1-git-send-email-prarit@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Mar 14, 2017 at 01:46:57PM -0400, Prarit Bhargava wrote: > Bjorn, sorry for not getting back to this. I forgot about it and was > reminded of it in a bug where someone had disabled ACPI and was wondering > why their system wouldn't boot. As you can see, I didn't exactly deal with this promptly myself. I was hoping for something that made the whitelist most explicit and easier to understand. What do you think of the following? commit 8b3dd031d5622d3dbe369c9d054392e8a52f933e Author: Bjorn Helgaas Date: Tue Aug 1 17:00:27 2017 -0500 PCI: Taint and warn for pci= kernel parameters Many pci= kernel parameters are used to work around BIOS and platform issues. Using the parameter may result in a system which boots, but the problem is never reported back and future users will have to rediscover the parameter. Print a warning and taint the kernel when these parameters are used. Some parameters are for things Linux is not smart enough to figure out automatically. Whitelist those so we don't warn about them. Based-on-patch-by: Prarit Bhargava Signed-off-by: Bjorn Helgaas diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index af0cc3456dc1..88204b251a08 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5396,12 +5396,51 @@ void __weak pci_fixup_cardbus(struct pci_bus *bus) } EXPORT_SYMBOL(pci_fixup_cardbus); +static __initdata const char * const pci_opt_whitelist[] = { + "earlydump", + "rom", + "norom", + "irqmask=", + "pcie_bus_tune_off", + "pcie_bus_safe", + "pcie_bus_perf", + "pcie_bus_peer2peer", + "cbiosize=", + "cbmemsize=", + "hpiosize=", + "hpmemsize=", + "hpbussize=", + "resource_alignment=", + "realloc", + "realloc=", +}; + +static int __init pci_opt_whitelisted(char *str) +{ + int i; + const char *opt; + + for (i = 0; i < ARRAY_SIZE(pci_opt_whitelist); i++) { + opt = pci_opt_whitelist[i]; + if (!strncmp(str, opt, strlen(opt))) + return 1; + } + + return 0; +} + static int __init pci_setup(char *str) { while (str) { char *k = strchr(str, ','); if (k) *k++ = 0; + if (*str && !pci_opt_whitelisted(str)) { + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); + pr_warning("PCI: Tainting kernel because pci=%s option used\n", + str); + pr_warning("PCI: If your system requires this option, please report it so future kernels can handle this automatically\n"); + } if (*str && (str = pcibios_setup(str)) && *str) { if (!strcmp(str, "nomsi")) { pci_no_msi();