From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] pc: add pci64 memory hole
Date: Wed, 29 Feb 2012 12:32:12 +0100 [thread overview]
Message-ID: <1330515133-32759-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1330515133-32759-1-git-send-email-kraxel@redhat.com>
This patch adds a address space hole for 64bit PCI ressources.
It starts at 0x8000000000 (512 GB) and ends at 0x10000000000 (1 TB),
thus has 512 GB in size. This matches what the experimental seabios
patches[1] are using.
[1] http://www.kraxel.org/cgit/seabios/commit/?h=pci64
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 17 ++++++++++++++---
hw/pc.h | 6 ++++++
hw/pc_piix.c | 22 ++++++++++------------
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 59a7f39..b283a80 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -972,12 +972,13 @@ void pc_memory_init(MemoryRegion *system_memory,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
+ ram_addr_t above_1t_mem_size,
MemoryRegion *rom_memory,
MemoryRegion **ram_memory)
{
int linux_boot, i;
MemoryRegion *ram, *option_rom_mr;
- MemoryRegion *ram_below_4g, *ram_above_4g;
+ MemoryRegion *ram_below_4g, *ram_above_4g, *ram_above_1t;
void *fw_cfg;
linux_boot = (kernel_filename != NULL);
@@ -988,7 +989,9 @@ void pc_memory_init(MemoryRegion *system_memory,
*/
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "pc.ram",
- below_4g_mem_size + above_4g_mem_size);
+ below_4g_mem_size +
+ above_4g_mem_size +
+ above_1t_mem_size);
vmstate_register_ram_global(ram);
*ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
@@ -999,9 +1002,17 @@ void pc_memory_init(MemoryRegion *system_memory,
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
- memory_region_add_subregion(system_memory, 0x100000000ULL,
+ memory_region_add_subregion(system_memory, PCI_HOLE_END,
ram_above_4g);
}
+ if (above_1t_mem_size > 0) {
+ ram_above_1t = g_malloc(sizeof(*ram_above_1t));
+ memory_region_init_alias(ram_above_1t, "ram-above-1t", ram,
+ below_4g_mem_size + above_4g_mem_size,
+ above_1t_mem_size);
+ memory_region_add_subregion(system_memory, PCI_HOLE64_END,
+ ram_above_1t);
+ }
/* Initialize PC system firmware */
diff --git a/hw/pc.h b/hw/pc.h
index 74d3369..0c5e14e 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -12,6 +12,11 @@
/* PC-style peripherals (also used by other machines). */
+#define PCI_HOLE_START 0x0000e0000000ULL
+#define PCI_HOLE_END 0x000100000000ULL
+#define PCI_HOLE64_START 0x008000000000ULL
+#define PCI_HOLE64_END 0x010000000000ULL
+
/* serial.c */
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
@@ -112,6 +117,7 @@ void pc_memory_init(MemoryRegion *system_memory,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
+ ram_addr_t above_1t_mem_size,
MemoryRegion *rom_memory,
MemoryRegion **ram_memory);
qemu_irq *pc_allocate_cpu_irq(void);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 5e11d15..3c40d90 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -131,7 +131,7 @@ static void pc_init1(MemoryRegion *system_memory,
int kvmclock_enabled)
{
int i;
- ram_addr_t below_4g_mem_size, above_4g_mem_size;
+ ram_addr_t below_4g_mem_size, above_4g_mem_size, above_1t_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
@@ -156,13 +156,10 @@ static void pc_init1(MemoryRegion *system_memory,
kvmclock_create();
}
- if (ram_size >= 0xe0000000 ) {
- above_4g_mem_size = ram_size - 0xe0000000;
- below_4g_mem_size = 0xe0000000;
- } else {
- above_4g_mem_size = 0;
- below_4g_mem_size = ram_size;
- }
+ below_4g_mem_size = MIN(ram_size, PCI_HOLE_START);
+ above_4g_mem_size = MIN(ram_size - below_4g_mem_size,
+ PCI_HOLE64_START - PCI_HOLE_END);
+ above_1t_mem_size = ram_size - below_4g_mem_size - above_4g_mem_size;
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
@@ -177,7 +174,7 @@ static void pc_init1(MemoryRegion *system_memory,
if (!xen_enabled()) {
pc_memory_init(system_memory,
kernel_filename, kernel_cmdline, initrd_filename,
- below_4g_mem_size, above_4g_mem_size,
+ below_4g_mem_size, above_4g_mem_size, above_1t_mem_size,
pci_enabled ? rom_memory : system_memory, &ram_memory);
}
@@ -194,11 +191,12 @@ static void pc_init1(MemoryRegion *system_memory,
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, ram_size,
below_4g_mem_size,
- 0x100000000ULL - below_4g_mem_size,
- 0x100000000ULL + above_4g_mem_size,
+ PCI_HOLE_END - below_4g_mem_size,
+ PCI_HOLE_END + above_4g_mem_size,
(sizeof(target_phys_addr_t) == 4
? 0
- : ((uint64_t)1 << 62)),
+ : (PCI_HOLE64_END - PCI_HOLE_END -
+ above_4g_mem_size)),
pci_memory, ram_memory);
} else {
pci_bus = NULL;
--
1.7.1
next prev parent reply other threads:[~2012-02-29 11:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 11:32 [Qemu-devel] [PATCH 0/3] 64bit pci patches Gerd Hoffmann
2012-02-29 11:32 ` [Qemu-devel] [PATCH 1/3] i44fx: fix pci_hole64 parameter passing Gerd Hoffmann
2012-02-29 11:32 ` Gerd Hoffmann [this message]
2012-02-29 11:32 ` [Qemu-devel] [PATCH 3/3] ivshmem: add 64bit option Gerd Hoffmann
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=1330515133-32759-3-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).