]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tool: Change kvm->ram_size to real mapped size.
authorHongyong Zang <zanghongyong@huawei.com>
Fri, 6 Jan 2012 02:06:26 +0000 (10:06 +0800)
committerPekka Enberg <penberg@kernel.org>
Fri, 6 Jan 2012 14:06:01 +0000 (16:06 +0200)
If a guest's ram_size exceeds KVM_32BIT_GAP_START, the corresponding kvm tool's
virtual address size should be (ram_size + KVM_32BIT_GAP_SIZE), rather than ram_size.
Use macro define KVM_32BIT_MAX_MEM_SIZE instead of magic number "0x100000000ULL".

Signed-off-by: Hongyong Zang <zanghongyong@huawei.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/x86/bios.c
tools/kvm/x86/include/kvm/kvm-arch.h
tools/kvm/x86/kvm.c

index 64a072c2d114c2518e5e288b01d0c7dd75cfc8b8..0f1bd85f685f71bd818c2bd5efe648cd9b2a5444 100644 (file)
@@ -92,8 +92,8 @@ static void e820_setup(struct kvm *kvm)
                        .type           = E820_RAM,
                };
                mem_map[i++]    = (struct e820entry) {
-                       .addr           = 0x100000000ULL,
-                       .size           = kvm->ram_size - KVM_32BIT_GAP_START,
+                       .addr           = KVM_32BIT_MAX_MEM_SIZE,
+                       .size           = kvm->ram_size - KVM_32BIT_MAX_MEM_SIZE,
                        .type           = E820_RAM,
                };
        }
index 244d36c5f75f44cbae8d4a29cad4fa53bdf130ea..ba04561e7c1b4a9669436cc98aea4348c89a55ad 100644 (file)
@@ -11,8 +11,9 @@
 /*
  * The hole includes VESA framebuffer and PCI memory.
  */
+#define KVM_32BIT_MAX_MEM_SIZE  (1ULL << 32)
 #define KVM_32BIT_GAP_SIZE     (768 << 20)
-#define KVM_32BIT_GAP_START    ((1ULL << 32) - KVM_32BIT_GAP_SIZE)
+#define KVM_32BIT_GAP_START    (KVM_32BIT_MAX_MEM_SIZE - KVM_32BIT_GAP_SIZE)
 
 #define KVM_MMIO_START         KVM_32BIT_GAP_START
 
index 286f106c45dca6db4fcdd2e511a142fa62eaf59e..a21888123e998d172d055881fde9483af60be175 100644 (file)
@@ -109,8 +109,8 @@ void kvm__init_ram(struct kvm *kvm)
 
                /* Second RAM range from 4GB to the end of RAM: */
 
-               phys_start = 0x100000000ULL;
-               phys_size  = kvm->ram_size - phys_size;
+               phys_start = KVM_32BIT_MAX_MEM_SIZE;
+               phys_size  = kvm->ram_size - phys_start;
                host_mem   = kvm->ram_start + phys_start;
 
                kvm__register_mem(kvm, phys_start, phys_size, host_mem);
@@ -155,12 +155,12 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
        if (ret < 0)
                die_perror("KVM_CREATE_PIT2 ioctl");
 
-       kvm->ram_size = ram_size;
-
-       if (kvm->ram_size < KVM_32BIT_GAP_START) {
+       if (ram_size < KVM_32BIT_GAP_START) {
+        kvm->ram_size = ram_size;
                kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size);
        } else {
                kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);
+        kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
                if (kvm->ram_start != MAP_FAILED)
                        /*
                         * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that