From patchwork Mon Nov 29 18:30:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 365102 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oATIbki0011573 for ; Mon, 29 Nov 2010 18:37:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753950Ab0K2Sh1 (ORCPT ); Mon, 29 Nov 2010 13:37:27 -0500 Received: from g6t0185.atlanta.hp.com ([15.193.32.62]:40868 "EHLO g6t0185.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903Ab0K2Sh0 (ORCPT ); Mon, 29 Nov 2010 13:37:26 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 29 Nov 2010 18:37:47 +0000 (UTC) X-Greylist: delayed 434 seconds by postgrey-1.27 at vger.kernel.org; Mon, 29 Nov 2010 13:37:26 EST Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g6t0185.atlanta.hp.com (Postfix) with ESMTP id 4293E24474; Mon, 29 Nov 2010 18:32:55 +0000 (UTC) Received: from ldl (ldl.usa.hp.com [16.125.112.222]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 54CFF140FB; Mon, 29 Nov 2010 18:30:10 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 062ACCF0010; Mon, 29 Nov 2010 11:30:10 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id urDZ8uJJEP1v; Mon, 29 Nov 2010 11:30:09 -0700 (MST) Received: from eh.fc.hp.com (bob.lnx.usa.hp.com [16.125.112.218]) by ldl (Postfix) with ESMTP id E3376CF000A; Mon, 29 Nov 2010 11:30:09 -0700 (MST) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id C2B1626119; Mon, 29 Nov 2010 11:30:09 -0700 (MST) Subject: [PATCH] x86/PCI: never allocate PCI space from the last 1M below 4G To: "H. Peter Anvin" From: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jesse Barnes , Thomas Gleixner , Linus Torvalds , Ingo Molnar , Matthew Garrett Date: Mon, 29 Nov 2010 11:30:09 -0700 Message-ID: <20101129183009.11256.33739.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index 5be1542..c1e908f 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h @@ -72,6 +72,9 @@ struct e820map { #define BIOS_BEGIN 0x000a0000 #define BIOS_END 0x00100000 +#define BIOS_ROM_BASE 0xfff00000 +#define BIOS_ROM_END 0x100000000ULL + #ifdef __KERNEL__ /* see comment in arch/x86/kernel/e820.c */ extern struct e820map e820; diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index c4bb261..6890241 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -65,8 +65,14 @@ pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) { struct pci_dev *dev = data; - resource_size_t start = round_down(res->end - size + 1, align); + resource_size_t start, end = res->end; + /* Make sure we don't allocate from the last 1M before 4G */ + if (res->flags & IORESOURCE_MEM) { + if (end >= BIOS_ROM_BASE && end < BIOS_ROM_END) + end = BIOS_ROM_BASE - 1; + } + start = round_down(end - size + 1, align); if (res->flags & IORESOURCE_IO) { /* @@ -80,6 +86,8 @@ pcibios_align_resource(void *data, const struct resource *res, } else if (res->flags & IORESOURCE_MEM) { if (start < BIOS_END) start = res->end; /* fail; no space */ + if (start >= BIOS_ROM_BASE && start < BIOS_ROM_END) + start = ALIGN(BIOS_ROM_END, align); } return start; }