Skip to contentSkip to conversation

fix warnings on i386 build

PATCH In review Glauber Costa 2 participants 2 messages Nov 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix warnings on i386 build

i386 builds of kvm shouts warnings about type mismatches this patch fixes them.

---
 kvm-all.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kvm-all.c +2 -2
index 18e9361..d3fcf8b 100644
@@ -338,7 +338,7 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
 
             /* Not splitting */
             if ((phys_offset - (start_addr - mem->guest_phys_addr)) == 
-                ((uint8_t *)mem->userspace_addr - phys_ram_base))
+                (mem->userspace_addr - (ram_addr_t)phys_ram_base))
                 return;
 
             /* unregister whole slot */
@@ -349,7 +349,7 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
             /* register prefix slot */
             mem_start = slot.guest_phys_addr;
             mem_size = start_addr - slot.guest_phys_addr;
-            mem_offset = (uint8_t *)slot.userspace_addr - phys_ram_base;
+            mem_offset = slot.userspace_addr - (ram_addr_t)phys_ram_base;
             if (mem_size)
                 kvm_set_phys_mem(mem_start, mem_size, mem_offset);
 
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 13 lines · Glauber Costa

i386 builds of kvm shouts warnings about type mismatches this patch fixes them.

---
 kvm-all.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kvm-all.c +0 -0
index 18e9361..d3fcf8b 100644

kvm-all.c void kvm_set_phys_mem(target_phys_addr_t start_addr, · line 342

Quoted 6 lines
kvm-all.c +1 -1
@@ -338,7 +338,7 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
 
             /* Not splitting */
             if ((phys_offset - (start_addr - mem->guest_phys_addr)) == 
-                ((uint8_t *)mem->userspace_addr - phys_ram_base))
+                (mem->userspace_addr - (ram_addr_t)phys_ram_base))
 

This isn't quite right. There's no reason ram_addr_t has to be 64-bit. If it were 32-bit, this would break badly.

I think a better fix is:

(ram_addr_t)((uint8_t *)mem->userspace_addr - phys_ram_base))

A proper fix would probably be to introduce a real KVMSlot structure that used the proper types instead of uint64_t.

Regards,

Anthony Liguori

Quoted 13 lines
kvm-all.c +0 -0
                 return;
 
             /* unregister whole slot */
kvm-all.c +1 -1
@@ -349,7 +349,7 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
             /* register prefix slot */
             mem_start = slot.guest_phys_addr;
             mem_size = start_addr - slot.guest_phys_addr;
-            mem_offset = (uint8_t *)slot.userspace_addr - phys_ram_base;
+            mem_offset = slot.userspace_addr - (ram_addr_t)phys_ram_base;
             if (mem_size)
                 kvm_set_phys_mem(mem_start, mem_size, mem_offset);