From: Stefan Hajnoczi <stefanha@gmail.com>
To: qemu-devel@nongnu.org
Cc: Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] Help writing a trivial device
Date: Tue, 27 Sep 2011 08:08:02 +0100 [thread overview]
Message-ID: <20110927070802.GA8740@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <87d3enp4f3.fsf@ginnungagap.bsc.es>
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
next prev parent reply other threads:[~2011-09-27 8:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-25 22:23 [Qemu-devel] Help writing a trivial device Lluís Vilanova
2011-09-26 7:51 ` Stefan Hajnoczi
2011-09-26 12:54 ` Lluís Vilanova
2011-09-26 18:03 ` Lluís Vilanova
2011-09-27 7:08 ` Stefan Hajnoczi [this message]
2011-09-27 13:03 ` Lluís Vilanova
2011-09-27 6:15 ` Zhi Yong Wu
2011-09-27 6:38 ` Avi Kivity
2011-09-27 6:34 ` Zhi Yong Wu
2011-09-27 13:05 ` Lluís Vilanova
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110927070802.GA8740@stefanha-thinkpad.localdomain \
--to=stefanha@gmail.com \
--cc=avi@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).