[PATCH 2/9] experimental change to avoid doing the same thing twice

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

qemu/qemu-kvm.c | 31 +++++++++++--------------------
1 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 1d07650..f24c436 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -779,28 +779,19 @@ void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
#ifdef KVM_CAP_USER_MEMORY
int r = 0;

+
r = kvm_check_extension(kvm_context, KVM_CAP_USER_MEMORY);
if (r) {
- if (!(phys_offset & ~TARGET_PAGE_MASK)) {
- r = kvm_is_allocated_mem(kvm_context, start_addr, size);
- if (r)
- return;
- r = kvm_is_intersecting_mem(kvm_context, start_addr);
- if (r)
- kvm_create_mem_hole(kvm_context, start_addr, size);
- r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
- phys_ram_base + phys_offset,
- size, 0);
- }
- if (phys_offset & IO_MEM_ROM) {
- phys_offset &= ~IO_MEM_ROM;
- r = kvm_is_intersecting_mem(kvm_context, start_addr);
- if (r)
- kvm_create_mem_hole(kvm_context, start_addr, size);
- r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
- phys_ram_base + phys_offset,
- size, 0);
- }
+ phys_offset &= ~IO_MEM_ROM;
+ r = kvm_is_allocated_mem(kvm_context, start_addr, size);
+ if (r)
+ return;
+ r = kvm_is_intersecting_mem(kvm_context, start_addr);
+ if (r)
+ kvm_create_mem_hole(kvm_context, start_addr, size);
+ r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
+ phys_ram_base + phys_offset,
+ size, 0);
if (r < 0) {
printf("kvm_cpu_register_physical_memory: failed\n");
exit(1);
--
1.5.5.1