+    if (len > 0) {
+        ptr = mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+        if (ptr == MAP_FAILED) {
+            fprintf(stderr, "create_userspace_phys_mem: %s",
+                strerror(errno));
+            return 0;
+        }

You're using 'len == 0' here to change the semantics of the function.
It would be better to have two different APIs (perhaps sharing some of
the implementation by calling a helper).


Actually, this is a fix of a bug that is probably exposed only by the direct 
mmio code.
Here is the problem (in the existing code):
kvm_destroy_phys_mem calls kvm_create_phys_mem(kvm, phys_start, 0, 0, 0);
kvm_create_phys_mem calls kvm_create_userspace_phys_mem which is calling

mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
                if (ptr == MAP_FAILED)

now, if len = 0 it fails.

We could have sent is as a separate patch,
and we could have made more changes to fix it differently,
for example, not to let kvm_destroy_phys_mem call kvm_create_phys_mem
(which seems strange in general...).
We wanted to minimize the amount of changes that we make, so we choose this 
option.

What do you recommend?

Thanks,
Ben
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to