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: 796435 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xMX2R3NDnz9sRm for ; Wed, 2 Aug 2017 09:04:31 +1000 (AEST) 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 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();