From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyn-0002wg-NC for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rcdyj-0001wA-2P for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyi-0001vg-Pd for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:09 -0500 From: Avi Kivity Date: Mon, 19 Dec 2011 16:13:42 +0200 Message-Id: <1324304024-11220-22-git-send-email-avi@redhat.com> In-Reply-To: <1324304024-11220-1-git-send-email-avi@redhat.com> References: <1324304024-11220-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 21/23] virtio-balloon: avoid cpu_get_physical_page_desc() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini , qemu-devel@nongnu.org, "Michael S. Tsirkin" Cc: xen-devel@lists.xensource.com, kvm@vger.kernel.org This reaches into the innards of the memory core, which are being changed. Switch to a memory API version. Signed-off-by: Avi Kivity --- hw/virtio-balloon.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index e24a2bf..bb4a8dd 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -21,6 +21,7 @@ #include "balloon.h" #include "virtio-balloon.h" #include "kvm.h" +#include "exec-memory.h" #if defined(__linux__) #include @@ -70,6 +71,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) { VirtIOBalloon *s = to_virtio_balloon(vdev); VirtQueueElement elem; + MemoryRegionSection section; while (virtqueue_pop(vq, &elem)) { size_t offset = 0; @@ -82,13 +84,17 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) pa = (ram_addr_t)ldl_p(&pfn) << VIRTIO_BALLOON_PFN_SHIFT; offset += 4; - addr = cpu_get_physical_page_desc(pa); - if ((addr & ~TARGET_PAGE_MASK) != IO_MEM_RAM) + /* FIXME: remove get_system_memory(), but how? */ + section = memory_region_find(get_system_memory(), pa, 1); + if (!section.mr || !memory_region_is_ram(section.mr)) continue; - /* Using qemu_get_ram_ptr is bending the rules a bit, but + /* Using memory_region_get_ram_ptr is bending the rules a bit, but should be OK because we only want a single page. */ - balloon_page(qemu_get_ram_ptr(addr), !!(vq == s->dvq)); + addr -= section.offset_within_address_space; + addr += section.offset_within_region; + balloon_page(memory_region_get_ram_ptr(section.mr) + addr, + !!(vq == s->dvq)); } virtqueue_push(vq, &elem, offset); -- 1.7.7.1