Stefan Hajnoczi writes:

> On Mon, Sep 26, 2011 at 08:03:12PM +0200, Lluís Vilanova wrote:
>> #if 1                                   /* KVM doesn't like it */
>> s-> data_ptr = g_malloc(s->size);
>> memory_region_init_ram_ptr(&s->data, &s->dev.qdev, "backdoor.data",
>>                            s-> size, s->data_ptr);
>> pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->data);
>> #endif

> Have you tried page-aligning data_ptr with qemu_memalign() or doing an
> anonymous mmap instead of g_malloc()?

> From virt/kvm/kvm_main.c:__kvm_set_memory_region():

> /* General sanity checks */
> if (mem->memory_size & (PAGE_SIZE - 1))
>       goto out;
> if (mem->guest_phys_addr & (PAGE_SIZE - 1))
>       goto out;
> /* We can read the guest memory with __xxx_user() later on. */
> if (user_alloc &&
>     ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
>      !access_ok(VERIFY_WRITE,
>               (void __user *)(unsigned long)mem->userspace_addr, mem-> 
> memory_size)))
>       goto out;

Damn! It's so obvious I even feel ashamed :)


Thanks a lot,
    Lluis

-- 
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth

Reply via email to