Revision 51b0c606

b/kvm-all.c
373 373
            break;
374 374
        }
375 375

  
376
        size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS), HOST_LONG_BITS) / 8;
376
        /* XXX bad kernel interface alert
377
         * For dirty bitmap, kernel allocates array of size aligned to
378
         * bits-per-long.  But for case when the kernel is 64bits and
379
         * the userspace is 32bits, userspace can't align to the same
380
         * bits-per-long, since sizeof(long) is different between kernel
381
         * and user space.  This way, userspace will provide buffer which
382
         * may be 4 bytes less than the kernel will use, resulting in
383
         * userspace memory corruption (which is not detectable by valgrind
384
         * too, in most cases).
385
         * So for now, let's align to 64 instead of HOST_LONG_BITS here, in
386
         * a hope that sizeof(long) wont become >8 any time soon.
387
         */
388
        size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS),
389
                     /*HOST_LONG_BITS*/ 64) / 8;
377 390
        if (!d.dirty_bitmap) {
378 391
            d.dirty_bitmap = qemu_malloc(size);
379 392
        } else if (size > allocated_size) {

Also available in: Unified diff