[PATCH 7/9] cleanup kvm memory registration

Glauber Costa
2008-08-13T00:54:51Z

Remove all references to kvm_cpu_register_physical_memory(),
since it is called from within cpu_register_physical_memory().

FIXME: There are leftovers in ppc and ia64. Technicaly, anyone should
test it in one of those arches, to make sure it work.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
qemu/exec.c | 2 +-
qemu/hw/ipf.c | 7 -------
qemu/hw/pc.c | 23 ++---------------------
qemu/hw/ppc440_bamboo.c | 2 --
qemu/qemu-kvm.c | 6 ------
5 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/qemu/exec.c b/qemu/exec.c
index 14c3852..0cba1a3 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -2197,7 +2197,7 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr,
}
#endif

- __kvm_cpu_register_physical_memory(start_addr, size, phys_offset);
+ kvm_cpu_register_physical_memory(start_addr, size, phys_offset);

size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
end_addr = start_addr + (target_phys_addr_t)size;
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index b11e328..80e6315 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -421,18 +421,14 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
if (kvm_enabled() && kvm_qemu_check_extension(KVM_CAP_USER_MEMORY)) {
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
- kvm_cpu_register_physical_memory(0, 0xa0000, ram_addr);

ram_addr = qemu_ram_alloc(0x20000); // Workaround 0xa0000-0xc0000

ram_addr = qemu_ram_alloc(0x40000);
cpu_register_physical_memory(0xc0000, 0x40000, ram_addr);
- kvm_cpu_register_physical_memory(0xc0000, 0x40000, ram_addr);

ram_addr = qemu_ram_alloc(ram_size - 0x100000);
cpu_register_physical_memory(0x100000, ram_size - 0x100000, ram_addr);
- kvm_cpu_register_physical_memory(0x100000, ram_size - 0x100000,
- ram_addr);
} else
#endif
{
@@ -446,9 +442,6 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
if (above_4g_mem_size > 0) {
ram_addr = qemu_ram_alloc(above_4g_mem_size);
cpu_register_physical_memory(0x100000000, above_4g_mem_size, ram_addr);
- if (kvm_enabled())
- kvm_cpu_register_physical_memory(0x100000000, above_4g_mem_size,
- ram_addr);
}

/*Load firware to its proper position.*/
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 3a8269b..98c279f 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -740,9 +740,6 @@ static int load_option_rom(const char *filename, int offset, int type)
size = (size + 4095) & ~4095;
cpu_register_physical_memory(0xd0000 + offset,
size, option_rom_offset | type);
- if (kvm_enabled())
- kvm_cpu_register_physical_memory(0xd0000 + offset,
- size, option_rom_offset | type);
return size;
}

@@ -817,16 +814,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
if (kvm_enabled() && kvm_qemu_check_extension(KVM_CAP_USER_MEMORY)) {
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
- kvm_cpu_register_physical_memory(0, 0xa0000, ram_addr);

ram_addr = qemu_ram_alloc(0x100000 - 0xa0000); // hole
ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
ram_addr);
- kvm_cpu_register_physical_memory(0x100000,
- below_4g_mem_size - 0x100000,
- ram_addr);
+
/* above 4giga memory allocation */
if (above_4g_mem_size > 0) {
ram_addr = qemu_ram_alloc(above_4g_mem_size);
@@ -842,9 +836,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
cpu_register_physical_memory(0x100000000ULL,
above_4g_mem_size,
ram_addr);
- kvm_cpu_register_physical_memory(0x100000000ULL,
- above_4g_mem_size,
- ram_addr);
}
} else
#endif
@@ -899,9 +890,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
/* setup basic memory access */
cpu_register_physical_memory(0xc0000, 0x10000,
vga_bios_offset | IO_MEM_ROM);
- if (kvm_enabled())
- kvm_cpu_register_physical_memory(0xc0000, 0x10000,
- vga_bios_offset | IO_MEM_ROM);

/* map the last 128KB of the BIOS in ISA space */
isa_bios_size = bios_size;
@@ -913,10 +901,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
cpu_register_physical_memory(0x100000 - isa_bios_size,
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) /* | IO_MEM_ROM */);
- if (kvm_enabled())
- kvm_cpu_register_physical_memory(0x100000 - isa_bios_size,
- isa_bios_size,
- (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);

/* XXX: for DDIM support, "ROM space" should be writable during
initialization, and (optionally) marked readonly by the BIOS
@@ -939,10 +923,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
int r;
#ifdef KVM_CAP_USER_MEMORY
r = kvm_qemu_check_extension(KVM_CAP_USER_MEMORY);
- if (r)
- kvm_cpu_register_physical_memory((uint32_t)(-bios_size),
- bios_size, bios_offset | IO_MEM_ROM);
- else
+ if (!r)
#endif
{
bios_mem = kvm_cpu_create_phys_mem((uint32_t)(-bios_size),
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
index 9ff6f7d..deafc5f 100644
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -93,8 +93,6 @@ void bamboo_init(ram_addr_t ram_size, int vga_ram_size,

/* Register mem */
cpu_register_physical_memory(0, ram_size, 0);
- if (kvm_enabled())
- kvm_cpu_register_physical_memory(0, ram_size, 0);

/* load kernel with uboot loader */
printf("%s: load kernel\n", __func__);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 225fbe6..96b622b 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -776,12 +776,6 @@ void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
unsigned long size,
unsigned long phys_offset)
{
-}
-
-void __kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
- unsigned long size,
- unsigned long phys_offset)
-{
#ifdef KVM_CAP_USER_MEMORY
int r = 0;

--
1.5.5.1