From patchwork Mon Jan 2 16:33:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 133885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8ADB1B6F9C for ; Tue, 3 Jan 2012 04:37:28 +1100 (EST) Received: from localhost ([::1]:45525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RhkqN-0007OH-Gb for incoming@patchwork.ozlabs.org; Mon, 02 Jan 2012 11:34:39 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhkpe-0005aD-6t for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:34:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rhkpc-0007I2-Dt for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:33:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhkpb-0007Ha-Rw for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:33:52 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q02GXpNo013232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Jan 2012 11:33:51 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q02GXmVv006546 for ; Mon, 2 Jan 2012 11:33:50 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 4B078250BA7; Mon, 2 Jan 2012 18:33:43 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Mon, 2 Jan 2012 18:33:28 +0200 Message-Id: <1325522015-503-10-git-send-email-avi@redhat.com> In-Reply-To: <1325522015-503-1-git-send-email-avi@redhat.com> References: <1325522015-503-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/16] Switch cpu_register_physical_memory_log() to use MemoryRegions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Still internally using ram_addr. Signed-off-by: Avi Kivity --- exec-obsolete.h | 24 +++--------------------- exec.c | 24 +++++++++++++++++++----- memory.c | 44 ++++++++++++++++---------------------------- 3 files changed, 38 insertions(+), 54 deletions(-) diff --git a/exec-obsolete.h b/exec-obsolete.h index 79f989c..e08e750 100644 --- a/exec-obsolete.h +++ b/exec-obsolete.h @@ -36,27 +36,9 @@ int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read, void *opaque); void cpu_unregister_io_memory(int table_address); -void cpu_register_physical_memory_log(target_phys_addr_t start_addr, - ram_addr_t size, - ram_addr_t phys_offset, - ram_addr_t region_offset, - bool log_dirty); - -static inline void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, - ram_addr_t size, - ram_addr_t phys_offset, - ram_addr_t region_offset) -{ - cpu_register_physical_memory_log(start_addr, size, phys_offset, - region_offset, false); -} - -static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, - ram_addr_t size, - ram_addr_t phys_offset) -{ - cpu_register_physical_memory_offset(start_addr, size, phys_offset, 0); -} +struct MemoryRegionSection; +void cpu_register_physical_memory_log(struct MemoryRegionSection *section, + bool readable, bool readonly); void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); diff --git a/exec.c b/exec.c index 2c2ba0e..c8c839a 100644 --- a/exec.c +++ b/exec.c @@ -2510,18 +2510,32 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, start_addr and region_offset are rounded down to a page boundary before calculating this offset. This should not be a problem unless the low bits of start_addr and region_offset differ. */ -void cpu_register_physical_memory_log(target_phys_addr_t start_addr, - ram_addr_t size, - ram_addr_t phys_offset, - ram_addr_t region_offset, - bool log_dirty) +void cpu_register_physical_memory_log(MemoryRegionSection *section, + bool readable, bool readonly) { + target_phys_addr_t start_addr = section->offset_within_address_space; + ram_addr_t size = section->size; + ram_addr_t phys_offset = section->mr->ram_addr; + ram_addr_t region_offset = section->offset_within_region; target_phys_addr_t addr, end_addr; PhysPageDesc *p; CPUState *env; ram_addr_t orig_size = size; subpage_t *subpage; + if (memory_region_is_ram(section->mr)) { + phys_offset += region_offset; + region_offset = 0; + } + + if (!readable) { + phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD; + } + + if (readonly) { + phys_offset |= io_mem_rom.ram_addr; + } + assert(size); if (phys_offset == io_mem_unassigned.ram_addr) { diff --git a/memory.c b/memory.c index a6c37c9..e34bc65 100644 --- a/memory.c +++ b/memory.c @@ -305,38 +305,26 @@ static void access_with_adjusted_size(target_phys_addr_t addr, static void as_memory_range_add(AddressSpace *as, FlatRange *fr) { - ram_addr_t phys_offset, region_offset; - - phys_offset = fr->mr->ram_addr; - region_offset = fr->offset_in_region; - /* cpu_register_physical_memory_log() wants region_offset for - * mmio, but prefers offseting phys_offset for RAM. Humour it. - */ - if (memory_region_is_ram(fr->mr)) { - phys_offset += region_offset; - region_offset = 0; - } - - if (!fr->readable) { - phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD; - } - - if (fr->readonly) { - phys_offset |= io_mem_rom.ram_addr; - } + MemoryRegionSection section = { + .mr = fr->mr, + .offset_within_address_space = int128_get64(fr->addr.start), + .offset_within_region = fr->offset_in_region, + .size = int128_get64(fr->addr.size), + }; - cpu_register_physical_memory_log(int128_get64(fr->addr.start), - int128_get64(fr->addr.size), - phys_offset, - region_offset, - fr->dirty_log_mask); + cpu_register_physical_memory_log(§ion, fr->readable, fr->readonly); } static void as_memory_range_del(AddressSpace *as, FlatRange *fr) { - cpu_register_physical_memory(int128_get64(fr->addr.start), - int128_get64(fr->addr.size), - io_mem_unassigned.ram_addr); + MemoryRegionSection section = { + .mr = &io_mem_unassigned, + .offset_within_address_space = int128_get64(fr->addr.start), + .offset_within_region = int128_get64(fr->addr.start), + .size = int128_get64(fr->addr.size), + }; + + cpu_register_physical_memory_log(§ion, true, false); } static void as_memory_log_start(AddressSpace *as, FlatRange *fr)