qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Help writing a trivial device


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] Help writing a trivial device
Date: Tue, 27 Sep 2011 08:08:02 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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;

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]