Skip to contentSkip to conversation

libkvm: fix physical_memory calculation

PATCH In review Jan Kiszka 2 participants 2 messages Apr 30, 2008 – May 2, 2008 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 libkvm: fix physical_memory calculation

This looks bogus, but it is so far without practical impact (phys_start is always 0 when we do the calculation).

---
 libkvm/libkvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libkvm/libkvm.c +1 -1
Index: b/libkvm/libkvm.c
===================================================================
@@ -550,7 +550,7 @@ int kvm_register_userspace_phys_mem(kvm_
 	int r;
 
 	if (!kvm->physical_memory)
-		kvm->physical_memory = userspace_addr - phys_start;
+		kvm->physical_memory = userspace_addr + phys_start;
 
 	memory.slot = get_free_slot(kvm);
 	r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &memory);

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#1 lore raw
Quoted 13 lines · Jan Kiszka

This looks bogus, but it is so far without practical impact (phys_start is always 0 when we do the calculation).

---
 libkvm/libkvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/libkvm/libkvm.c
===================================================================

libkvm/libkvm.c int kvm_register_userspace_phys_mem(kvm_ · line 555

Quoted 7 lines
libkvm/libkvm.c +1 -1
@@ -550,7 +550,7 @@ int kvm_register_userspace_phys_mem(kvm_
 	int r;
 
 	if (!kvm->physical_memory)
-		kvm->physical_memory = userspace_addr - phys_start;
+		kvm->physical_memory = userspace_addr + phys_start;
 
 

I think it's correct. The intent (probably) was that kvm->physical_memory[x] would refer to the contents of physical memory address x.

In another way, it's incorrect, since nothing guarantees (now) that memory is contiguous.

Signature · 9 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone