From: Yinghai Lu <yinghai@kernel.org>
To: Matt Fleming <matt.fleming@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@suse.de>, Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Jiri Kosina <jkosina@suse.cz>, Chun-Yi Lee <jlee@suse.com>,
linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
linux-pci@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH v3 7/8] x86, boot, PCI: Copy SETUP_PCI rom to kernel space
Date: Sat, 7 Mar 2015 16:56:20 -0800 [thread overview]
Message-ID: <1425776181-10219-8-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1425776181-10219-1-git-send-email-yinghai@kernel.org>
As EFI stub code could put them high when on 32bit or with exactmap=
on 64bit conf.
Check if the range is mapped, otherwise allocate new one and have
the rom data copied. So we could access them directly.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/pci/common.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 67dc2a9..15e1b3f 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -697,6 +697,48 @@ struct firmware_setup_pci_entry {
static LIST_HEAD(setup_pci_entries);
+static phys_addr_t check_copy(phys_addr_t start, unsigned long size)
+{
+ unsigned long start_pfn = PFN_DOWN(start);
+ unsigned long end_pfn = PFN_UP(start + size);
+ unsigned char *p, *q;
+ phys_addr_t pa_p, pa_q;
+ long sz = size;
+
+ if (pfn_range_is_mapped(start_pfn, end_pfn))
+ return start;
+
+ /* allocate and copy */
+ pa_p = memblock_alloc(size, PAGE_SIZE);
+ if (!pa_p)
+ return start;
+
+ p = phys_to_virt(pa_p);
+
+ pa_q = start;
+ while (sz > 0) {
+ long chunk_size = 64<<10;
+
+ if (chunk_size > sz)
+ chunk_size = sz;
+
+ q = early_memremap(pa_q, chunk_size);
+ if (!q) {
+ memblock_free(pa_p, size);
+ return start;
+ }
+ memcpy(p, q, chunk_size);
+ early_memunmap(q, chunk_size);
+ p += chunk_size;
+ pa_q += chunk_size;
+ sz -= chunk_size;
+ }
+
+ memblock_free(start, size);
+
+ return pa_p;
+}
+
int __init fill_setup_pci_entries(void)
{
struct setup_data *data;
@@ -726,8 +768,9 @@ int __init fill_setup_pci_entries(void)
entry->vendor = rom->vendor;
entry->devid = rom->devid;
entry->pcilen = rom->pcilen;
- entry->romdata = pa_data +
- offsetof(struct pci_setup_rom, romdata);
+ entry->romdata = check_copy(pa_data +
+ offsetof(struct pci_setup_rom, romdata),
+ rom->pcilen);
list_add(&entry->list, &setup_pci_entries);
--
1.8.4.5
next prev parent reply other threads:[~2015-03-08 0:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-08 0:56 [PATCH v3 0/8] x86, boot: clean up setup_data handling Yinghai Lu
2015-03-08 0:56 ` Yinghai Lu
2015-03-08 0:56 ` [PATCH v3 1/8] x86: Kill E820_RESERVED_KERN Yinghai Lu
[not found] ` <1425776181-10219-2-git-send-email-yinghai-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-03-08 1:59 ` David Rientjes
2015-03-08 1:59 ` David Rientjes
[not found] ` <alpine.DEB.2.10.1503071748530.5739-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2015-03-08 6:51 ` Yinghai Lu
2015-03-08 6:51 ` Yinghai Lu
2015-03-09 0:18 ` joeyli
2015-03-09 0:18 ` joeyli
2015-03-08 0:56 ` [PATCH v3 2/8] x86, efi: Copy SETUP_EFI data and access directly Yinghai Lu
2015-03-08 0:56 ` [PATCH v3 3/8] x86, of: Let add_dtb reserve setup_data locally Yinghai Lu
2015-03-08 0:56 ` [PATCH v3 4/8] x86, boot: Add add_pci handler for SETUP_PCI Yinghai Lu
2015-03-08 0:56 ` [PATCH v3 5/8] x86: Kill not used setup_data handling code Yinghai Lu
[not found] ` <1425776181-10219-1-git-send-email-yinghai-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-03-08 0:56 ` [PATCH v3 6/8] x86, boot, PCI: Convert SETUP_PCI data to list Yinghai Lu
2015-03-08 0:56 ` Yinghai Lu
2015-03-08 0:56 ` Yinghai Lu [this message]
2015-03-08 0:56 ` [PATCH v3 8/8] x86, boot, PCI: Export SETUP_PCI data via sysfs Yinghai Lu
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=1425776181-10219-8-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=bhelgaas@google.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=jkosina@suse.cz \
--cc=jlee@suse.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.