Received: from eggs.gnu.org ([140.186.70.92]:57943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8XKM-0008CD-Vd for qemu-devel@nongnu.org; Tue, 27 Sep 2011 09:04:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8XKH-0001R5-5e for qemu-devel@nongnu.org; Tue, 27 Sep 2011 09:04:02 -0400 Received: from gw.ac.upc.es ([147.83.30.3]:59636 helo=gw.ac.upc.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8XKG-0001Ql-Qb for qemu-devel@nongnu.org; Tue, 27 Sep 2011 09:03:57 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <87litcs1ly.fsf@ginnungagap.bsc.es> <20110926075159.GA6455@stefanha-thinkpad.localdomain> <87r533piq5.fsf@ginnungagap.bsc.es> <87d3enp4f3.fsf@ginnungagap.bsc.es> <20110927070802.GA8740@stefanha-thinkpad.localdomain> Date: Tue, 27 Sep 2011 15:03:54 +0200 Message-ID: <87bou687d1.fsf@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Help writing a trivial device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Avi Kivity Stefan Hajnoczi writes: > On Mon, Sep 26, 2011 at 08:03:12PM +0200, Llu=C3=ADs Vilanova wrote: >> #if 1 /* KVM doesn't like it */ >> s-> data_ptr =3D 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 --=20 "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