From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Saf-0003jc-SL for qemu-devel@nongnu.org; Tue, 27 Sep 2011 04:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8Sae-0000aS-LM for qemu-devel@nongnu.org; Tue, 27 Sep 2011 04:00:33 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:59330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Sae-0000aH-99 for qemu-devel@nongnu.org; Tue, 27 Sep 2011 04:00:32 -0400 Received: by bkbzv15 with SMTP id zv15so6822499bkb.4 for ; Tue, 27 Sep 2011 01:00:31 -0700 (PDT) Date: Tue, 27 Sep 2011 08:08:02 +0100 From: Stefan Hajnoczi Message-ID: <20110927070802.GA8740@stefanha-thinkpad.localdomain> References: <87litcs1ly.fsf@ginnungagap.bsc.es> <20110926075159.GA6455@stefanha-thinkpad.localdomain> <87r533piq5.fsf@ginnungagap.bsc.es> <87d3enp4f3.fsf@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87d3enp4f3.fsf@ginnungagap.bsc.es> Subject: Re: [Qemu-devel] Help writing a trivial device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Avi Kivity 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