From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Andi Kleen" <ak@suse.de>
Cc: hancockr@shaw.ca, rajesh.shah@intel.com,
jbarnes@virtuousgeek.org, greg@kroah.com, patches@x86-64.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [9/50] i386: validate against ACPI motherboard resources
Date: Fri, 21 Sep 2007 23:49:19 -0700 [thread overview]
Message-ID: <86802c440709212349l3d968d1bgdc89e7c7415b54da@mail.gmail.com> (raw)
In-Reply-To: <20070921223207.7BBE71479D@wotan.suse.de>
On 9/21/07, Andi Kleen <ak@suse.de> wrote:
>
> From: Robert Hancock <hancockr@shaw.ca>
>
> This path adds validation of the MMCONFIG table against the ACPI reserved
> motherboard resources. If the MMCONFIG table is found to be reserved in
> ACPI, we don't bother checking the E820 table. The PCI Express firmware
> spec apparently tells BIOS developers that reservation in ACPI is required
> and E820 reservation is optional, so checking against ACPI first makes
> sense. Many BIOSes don't reserve the MMCONFIG region in E820 even though
> it is perfectly functional, the existing check needlessly disables MMCONFIG
> in these cases.
>
> In order to do this, MMCONFIG setup has been split into two phases. If PCI
> configuration type 1 is not available then MMCONFIG is enabled early as
> before. Otherwise, it is enabled later after the ACPI interpreter is
> enabled, since we need to be able to execute control methods in order to
> check the ACPI reserved resources. Presently this is just triggered off
> the end of ACPI interpreter initialization.
>
> There are a few other behavioral changes here:
>
> - Validate all MMCONFIG configurations provided, not just the first one.
>
> - Validate the entire required length of each configuration according to
> the provided ending bus number is reserved, not just the minimum required
> allocation.
>
> - Validate that the area is reserved even if we read it from the chipset
> directly and not from the MCFG table. This catches the case where the
> BIOS didn't set the location properly in the chipset and has mapped it
> over other things it shouldn't have.
>
> This also cleans up the MMCONFIG initialization functions so that they
> simply do nothing if MMCONFIG is not compiled in.
>
> Based on an original patch by Rajesh Shah from Intel.
>
> [akpm@linux-foundation.org: many fixes and cleanups]
> Signed-off-by: Robert Hancock <hancockr@shaw.ca>
> Signed-off-by: Andi Kleen <ak@suse.de>
> Cc: Rajesh Shah <rajesh.shah@intel.com>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Andi Kleen <ak@suse.de>
> Cc: Greg KH <greg@kroah.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> arch/i386/pci/init.c | 4 -
> arch/i386/pci/mmconfig-shared.c | 151 +++++++++++++++++++++++++++++++++++-----
> arch/i386/pci/pci.h | 1
> drivers/acpi/bus.c | 2
> include/linux/pci.h | 8 ++
> 5 files changed, 144 insertions(+), 22 deletions(-)
>
> Index: linux/arch/i386/pci/init.c
> ===================================================================
> --- linux.orig/arch/i386/pci/init.c
> +++ linux/arch/i386/pci/init.c
> @@ -11,9 +11,7 @@ static __init int pci_access_init(void)
> #ifdef CONFIG_PCI_DIRECT
> type = pci_direct_probe();
> #endif
> -#ifdef CONFIG_PCI_MMCONFIG
> - pci_mmcfg_init(type);
> -#endif
> + pci_mmcfg_early_init(type);
> if (raw_pci_ops)
> return 0;
> #ifdef CONFIG_PCI_BIOS
> Index: linux/arch/i386/pci/mmconfig-shared.c
> ===================================================================
> --- linux.orig/arch/i386/pci/mmconfig-shared.c
> +++ linux/arch/i386/pci/mmconfig-shared.c
> @@ -206,9 +206,78 @@ static void __init pci_mmcfg_insert_reso
> pci_mmcfg_resources_inserted = 1;
> }
>
> -static void __init pci_mmcfg_reject_broken(int type)
> +static acpi_status __init check_mcfg_resource(struct acpi_resource *res,
> + void *data)
> +{
> + struct resource *mcfg_res = data;
> + struct acpi_resource_address64 address;
> + acpi_status status;
> +
> + if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
> + struct acpi_resource_fixed_memory32 *fixmem32 =
> + &res->data.fixed_memory32;
> + if (!fixmem32)
> + return AE_OK;
> + if ((mcfg_res->start >= fixmem32->address) &&
> + (mcfg_res->end < (fixmem32->address +
> + fixmem32->address_length))) {
> + mcfg_res->flags = 1;
> + return AE_CTRL_TERMINATE;
> + }
> + }
> + if ((res->type != ACPI_RESOURCE_TYPE_ADDRESS32) &&
> + (res->type != ACPI_RESOURCE_TYPE_ADDRESS64))
> + return AE_OK;
> +
> + status = acpi_resource_to_address64(res, &address);
> + if (ACPI_FAILURE(status) ||
> + (address.address_length <= 0) ||
> + (address.resource_type != ACPI_MEMORY_RANGE))
> + return AE_OK;
> +
> + if ((mcfg_res->start >= address.minimum) &&
> + (mcfg_res->end < (address.minimum + address.address_length))) {
> + mcfg_res->flags = 1;
> + return AE_CTRL_TERMINATE;
> + }
> + return AE_OK;
> +}
> +
> +static acpi_status __init find_mboard_resource(acpi_handle handle, u32 lvl,
> + void *context, void **rv)
> +{
> + struct resource *mcfg_res = context;
> +
> + acpi_walk_resources(handle, METHOD_NAME__CRS,
> + check_mcfg_resource, context);
> +
> + if (mcfg_res->flags)
> + return AE_CTRL_TERMINATE;
> +
> + return AE_OK;
> +}
> +
> +static int __init is_acpi_reserved(unsigned long start, unsigned long end)
> +{
> + struct resource mcfg_res;
> +
> + mcfg_res.start = start;
> + mcfg_res.end = end;
> + mcfg_res.flags = 0;
> +
> + acpi_get_devices("PNP0C01", find_mboard_resource, &mcfg_res, NULL);
> +
> + if (!mcfg_res.flags)
> + acpi_get_devices("PNP0C02", find_mboard_resource, &mcfg_res,
> + NULL);
> +
> + return mcfg_res.flags;
> +}
> +
> +static void __init pci_mmcfg_reject_broken(void)
> {
> typeof(pci_mmcfg_config[0]) *cfg;
> + int i;
>
> if ((pci_mmcfg_config_num == 0) ||
> (pci_mmcfg_config == NULL) ||
> @@ -229,17 +298,37 @@ static void __init pci_mmcfg_reject_brok
> goto reject;
> }
>
> - /*
> - * Only do this check when type 1 works. If it doesn't work
> - * assume we run on a Mac and always use MCFG
> - */
> - if (type == 1 && !e820_all_mapped(cfg->address,
> - cfg->address + MMCONFIG_APER_MIN,
> - E820_RESERVED)) {
> - printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not"
> - " E820-reserved\n", cfg->address);
> - goto reject;
> + for (i = 0; i < pci_mmcfg_config_num; i++) {
> + u32 size = (cfg->end_bus_number + 1) << 20;
> + cfg = &pci_mmcfg_config[i];
> + printk(KERN_NOTICE "PCI: MCFG configuration %d: base %lu "
> + "segment %hu buses %u - %u\n",
> + i, (unsigned long)cfg->address, cfg->pci_segment,
> + (unsigned int)cfg->start_bus_number,
> + (unsigned int)cfg->end_bus_number);
> + if (is_acpi_reserved(cfg->address, cfg->address + size - 1)) {
> + printk(KERN_NOTICE "PCI: MCFG area at %Lx reserved "
> + "in ACPI motherboard resources\n",
> + cfg->address);
> + } else {
> + printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not"
> + " reserved in ACPI motherboard resources\n",
> + cfg->address);
> + /* Don't try to do this check unless configuration
> + type 1 is available. */
> + if ((pci_probe & PCI_PROBE_CONF1) &&
> + e820_all_mapped(cfg->address,
> + cfg->address + size - 1,
> + E820_RESERVED))
> + printk(KERN_NOTICE
> + "PCI: MCFG area at %Lx reserved in "
> + "E820\n",
> + cfg->address);
> + else
> + goto reject;
> + }
> }
> +
> return;
>
> reject:
> @@ -249,20 +338,46 @@ reject:
> pci_mmcfg_config_num = 0;
> }
>
> -void __init pci_mmcfg_init(int type)
> +void __init pci_mmcfg_early_init(int type)
> +{
> + if ((pci_probe & PCI_PROBE_MMCONF) == 0)
> + return;
> +
> + /* If type 1 access is available, no need to enable MMCONFIG yet, we can
> + defer until later when the ACPI interpreter is available to better
> + validate things. */
> + if (type == 1)
> + return;
> +
> + acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
> +
> + if ((pci_mmcfg_config_num == 0) ||
> + (pci_mmcfg_config == NULL) ||
> + (pci_mmcfg_config[0].address == 0))
> + return;
> +
> + if (pci_mmcfg_arch_init())
> + pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
> +}
> +
> +void __init pci_mmcfg_late_init(void)
> {
> int known_bridge = 0;
>
> + /* MMCONFIG disabled */
> if ((pci_probe & PCI_PROBE_MMCONF) == 0)
> return;
>
> - if (type == 1 && pci_mmcfg_check_hostbridge())
> - known_bridge = 1;
> + /* MMCONFIG already enabled */
> + if (!(pci_probe & PCI_PROBE_MASK & ~PCI_PROBE_MMCONF))
> + return;
>
> - if (!known_bridge) {
> + if ((pci_probe & PCI_PROBE_CONF1) && pci_mmcfg_check_hostbridge())
> + known_bridge = 1;
> + else
> acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
> - pci_mmcfg_reject_broken(type);
> - }
> +
> + pci_mmcfg_reject_broken();
>
> if ((pci_mmcfg_config_num == 0) ||
> (pci_mmcfg_config == NULL) ||
> @@ -270,7 +385,7 @@ void __init pci_mmcfg_init(int type)
> return;
>
> if (pci_mmcfg_arch_init()) {
> - if (type == 1)
> + if (pci_probe & PCI_PROBE_CONF1)
> unreachable_devices();
> if (known_bridge)
> pci_mmcfg_insert_resources(IORESOURCE_BUSY);
> Index: linux/arch/i386/pci/pci.h
> ===================================================================
> --- linux.orig/arch/i386/pci/pci.h
> +++ linux/arch/i386/pci/pci.h
> @@ -91,7 +91,6 @@ extern int pci_conf1_read(unsigned int s
> extern int pci_direct_probe(void);
> extern void pci_direct_init(int type);
> extern void pci_pcbios_init(void);
> -extern void pci_mmcfg_init(int type);
> extern void pcibios_sort(void);
>
> /* pci-mmconfig.c */
> Index: linux/drivers/acpi/bus.c
> ===================================================================
> --- linux.orig/drivers/acpi/bus.c
> +++ linux/drivers/acpi/bus.c
> @@ -35,6 +35,7 @@
> #ifdef CONFIG_X86
> #include <asm/mpspec.h>
> #endif
> +#include <linux/pci.h>
> #include <acpi/acpi_bus.h>
> #include <acpi/acpi_drivers.h>
>
> @@ -757,6 +758,7 @@ static int __init acpi_init(void)
> result = acpi_bus_init();
>
> if (!result) {
> + pci_mmcfg_late_init();
No!
MMCONFIG will not work with acpi=off any more.
because acpi_init==>pci_mmcfg_late_init==>pci_mmcfg_check_hostbridge...
can you move pci_mmcfg_later_init out of acpi_init and just call
somewhere after acpi_init...
or put pci_mmcfg_check_hostbridge back to pci_mmcfg_early_init?
YH
next prev parent reply other threads:[~2007-09-22 6:49 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 22:31 [PATCH] [0/50] x86 2.6.24 patches review II Andi Kleen
2007-09-21 22:31 ` [PATCH] [1/50] x86_64: store core id bits in cpuinfo_x8 Andi Kleen
2007-09-21 22:31 ` [PATCH] [2/50] x86_64: use core id bits for apicid_to_node initialization Andi Kleen
2007-09-21 22:32 ` [PATCH] [3/50] x86_64: remove never used apic_mapped Andi Kleen
2007-09-21 22:32 ` [PATCH] [4/50] x86: add cpu codenames for Kconfig.cpu Andi Kleen
2007-09-21 22:45 ` Dave Jones
2007-09-21 23:52 ` Alan Cox
2007-09-22 6:57 ` Sam Ravnborg
2007-09-22 9:46 ` Jan Engelhardt
2007-09-22 14:23 ` Dave Jones
2007-09-22 17:40 ` Randy Dunlap
2007-09-30 10:09 ` Andi Kleen
2007-09-22 17:50 ` Thomas Gleixner
2007-10-01 11:17 ` Andi Kleen
2007-09-21 22:32 ` [PATCH] [5/50] i386: change order in Kconfig.cpu Andi Kleen
2007-09-21 22:32 ` [PATCH] [6/50] i386: clean up oops/bug reports Andi Kleen
2007-09-21 22:41 ` Chuck Ebbert
2007-09-22 9:47 ` Jan Engelhardt
2007-09-22 2:51 ` Killing printk calls for size (Re: [PATCH] [6/50] i386: clean up oops/bug reports) Oleg Verych
2007-09-21 22:32 ` [PATCH] [7/50] x86: expand /proc/interrupts to include missing vectors, v2 Andi Kleen
2007-09-22 3:35 ` possible corrections in the docs (Re: [PATCH] [7/50] x86: expand /proc/interrupts to include missing vectors, v2) Oleg Verych
2007-09-22 3:52 ` Joe Korty
2007-09-21 22:32 ` [PATCH] [8/50] x86_64: remove x86_cpu_to_log_apicid Andi Kleen
2007-09-21 22:32 ` [PATCH] [9/50] i386: validate against ACPI motherboard resources Andi Kleen
2007-09-22 6:49 ` Yinghai Lu [this message]
2007-09-22 6:56 ` Yinghai Lu
2007-09-22 16:28 ` Robert Hancock
2007-09-22 18:01 ` Thomas Gleixner
2007-09-22 18:42 ` Robert Hancock
2007-09-22 20:40 ` Yinghai Lu
2007-09-22 20:56 ` H. Peter Anvin
2007-09-22 21:27 ` Robert Hancock
2007-09-23 1:20 ` Yinghai Lu
2007-09-23 1:34 ` Yinghai Lu
2007-09-22 20:47 ` Yinghai Lu
2007-09-21 22:32 ` [PATCH] [10/50] x86_64: install unstripped copies of compat vdso on disk Andi Kleen
2007-09-21 22:32 ` [PATCH] [11/50] x86_64: Install unstripped copy of 64bit vdso to disk Andi Kleen
2007-09-21 22:32 ` [PATCH] [12/50] x86_64: Untable __init references between IO data Andi Kleen
2007-09-22 5:37 ` [patches] " Yinghai Lu
2007-09-21 22:32 ` [PATCH] [13/50] x86: Fix and reenable CLFLUSH support in change_page_attr() Andi Kleen
2007-09-22 5:47 ` Oleg Verych
2007-10-01 10:59 ` Andi Kleen
2007-09-24 8:23 ` [patches] [PATCH] [13/50] x86: Fix and reenable CLFLUSH support inchange_page_attr() Jan Beulich
2007-10-01 10:38 ` Andi Kleen
2007-09-21 22:32 ` [PATCH] [14/50] x86: Minor code-style cleanups to change_page_attr Andi Kleen
2007-09-21 22:32 ` [PATCH] [15/50] x86_64: Return EINVAL for unknown address in change_page_attr Andi Kleen
2007-09-24 8:32 ` [patches] [PATCH] [15/50] x86_64: Return EINVAL for unknown addressin change_page_attr Jan Beulich
2007-09-21 22:32 ` [PATCH] [16/50] x86: Use macros to modify the PG_arch_1 page flags in change_page_attr Andi Kleen
2007-09-21 22:32 ` [PATCH] [17/50] x86_64: remove STR() macros Andi Kleen
2007-09-21 22:32 ` [PATCH] [18/50] x86_64: Save registers in saved_context during suspend and hibernation Andi Kleen
2007-09-21 22:32 ` [PATCH] [19/50] Experimental: detect if SVM is disabled by BIOS Andi Kleen
2007-09-22 6:59 ` Sam Ravnborg
2007-09-22 9:17 ` Joerg Roedel
2007-10-01 16:47 ` Andi Kleen
2007-10-01 20:12 ` Joerg Roedel
2007-10-01 21:45 ` [patches] " Andi Kleen
2007-10-01 22:13 ` Joerg Roedel
2007-09-22 19:05 ` Thomas Gleixner
2007-09-21 22:32 ` [PATCH] [20/50] x86_64: Fix some broken white space in arch/x86_64/mm/init.c Andi Kleen
2007-09-22 19:17 ` Thomas Gleixner
2007-09-23 1:47 ` Oleg Verych
2007-09-21 22:32 ` [PATCH] [21/50] i386: Misc cpuinit annotations Andi Kleen
2007-09-21 22:32 ` [PATCH] [22/50] " Andi Kleen
2007-09-21 22:32 ` [PATCH] [23/50] x86_64: Implement missing x86_64 function smp_call_function_mask() Andi Kleen
2007-09-21 22:32 ` [PATCH] [24/50] x86_64: Eliminate result signage problem in asm-x86_64/bitops.h Andi Kleen
2007-09-21 22:32 ` [PATCH] [25/50] x86_64: Add parenthesis to IRQ vector macros Andi Kleen
2007-09-21 22:32 ` [PATCH] [26/50] i386: export i386 smp_call_function_mask() to modules Andi Kleen
2007-09-21 22:32 ` [PATCH] [27/50] x86_64: Remove duplicated vsyscall nsec update Andi Kleen
2007-09-21 22:32 ` [PATCH] [28/50] i386: remove stub early_printk.c Andi Kleen
2007-09-21 22:32 ` [PATCH] [29/50] x86: honor _PAGE_PSE bit on page walks Andi Kleen
2007-09-21 22:32 ` [PATCH] [30/50] x86_64: remove some dead code Andi Kleen
2007-09-21 22:32 ` [PATCH] [31/50] x86_64: honor notify_die() returning NOTIFY_STOP Andi Kleen
2007-09-22 19:23 ` Thomas Gleixner
2007-09-21 22:32 ` [PATCH] [32/50] x86: Show last exception from/to register contents Andi Kleen
2007-09-21 22:32 ` [PATCH] [33/50] x86: rename .i assembler includes to .h Andi Kleen
2007-09-21 22:32 ` [PATCH] [34/50] i386: Fix argument signedness warnings Andi Kleen
2007-09-22 5:06 ` Satyam Sharma
2007-09-22 10:01 ` Jan Engelhardt
2007-09-22 17:42 ` Randy Dunlap
2007-09-21 22:32 ` [PATCH] [35/50] i386: Do cpuid_device_create() in CPU_UP_PREPARE instead of CPU_ONLINE Andi Kleen
2007-09-22 19:33 ` Thomas Gleixner
2007-09-23 1:52 ` Akinobu Mita
2007-09-23 7:52 ` Thomas Gleixner
2007-09-21 22:32 ` [PATCH] [36/50] x86: Use raw locks during oopses Andi Kleen
2007-09-21 22:32 ` [PATCH] [37/50] x86_64: Clean up mce= argument parsing slightly Andi Kleen
2007-09-21 22:32 ` [PATCH] [38/50] x86_64: fix off-by-one in find_next_zero_string Andi Kleen
2007-09-21 22:32 ` [PATCH] [39/50] i386: fix 4 bit apicid assumption of mach-default Andi Kleen
2007-09-21 22:32 ` [PATCH] [40/50] i386: Fix section mismatch Andi Kleen
2007-09-21 22:32 ` [PATCH] [41/50] i386: fix section mismatch warning in intel.c Andi Kleen
2007-09-21 22:32 ` [PATCH] [42/50] i386: constify wd_ops Andi Kleen
2007-09-21 22:32 ` [PATCH] [43/50] x86: multi-byte single instruction NOPs Andi Kleen
2007-09-21 22:32 ` [PATCH] [44/50] i386: Introduce "used_vectors" bitmap which can be used to reserve vectors Andi Kleen
2007-09-21 22:32 ` [PATCH] [45/50] x86_64: configure HPET_EMULATE_RTC automatically Andi Kleen
2007-09-21 22:32 ` [PATCH] [46/50] x86: also show non-zero IRQ counts for vectors that currently don't have a handler Andi Kleen
2007-09-21 22:32 ` [PATCH] [47/50] i386: avoid temporarily inconsistent pte-s Andi Kleen
2007-09-21 22:32 ` [PATCH] [48/50] x86_64: return correct error code from child_rip in x86_64 entry.S Andi Kleen
2007-09-21 22:32 ` [PATCH] [49/50] x86_64: Initialize 64bit registers for a.out executables Andi Kleen
2007-09-21 22:32 ` [PATCH] [50/50] x86_64: Remove fpu io port resource Andi Kleen
2007-09-21 23:00 ` Jeff Garzik
2007-10-01 10:40 ` Andi Kleen
2007-10-01 11:30 ` Jeff Garzik
2007-10-01 11:48 ` Andi Kleen
2007-10-01 13:33 ` Jeff Garzik
2007-10-01 14:16 ` Mark Lord
2007-10-02 14:37 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86802c440709212349l3d968d1bgdc89e7c7415b54da@mail.gmail.com \
--to=yhlu.kernel@gmail.com \
--cc=ak@suse.de \
--cc=greg@kroah.com \
--cc=hancockr@shaw.ca \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@x86-64.org \
--cc=rajesh.shah@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®