From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCKk0-0003CA-VH for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCKk0-0003B5-Bh for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:20 -0400 Received: from [199.232.76.173] (port=51163 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCKjz-0003AJ-J6 for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:19 -0400 Received: from mx1.redhat.com ([66.187.233.31]:55971) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KCKjz-00081m-R5 for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:20 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m5RKeIUd014635 for ; Fri, 27 Jun 2008 16:40:18 -0400 Received: from pobox-2.corp.redhat.com (pobox-2.corp.redhat.com [10.11.255.15]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKeIpS006063 for ; Fri, 27 Jun 2008 16:40:18 -0400 Received: from localhost.localdomain (vpn-4-80.str.redhat.com [10.32.4.80]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKdadp004563 for ; Fri, 27 Jun 2008 16:40:17 -0400 From: Glauber Costa Date: Fri, 27 Jun 2008 17:38:20 -0300 Message-Id: <1214599103-13846-18-git-send-email-gcosta@redhat.com> In-Reply-To: <1214599103-13846-17-git-send-email-gcosta@redhat.com> References: <1214599103-13846-1-git-send-email-gcosta@redhat.com> <1214599103-13846-2-git-send-email-gcosta@redhat.com> <1214599103-13846-3-git-send-email-gcosta@redhat.com> <1214599103-13846-4-git-send-email-gcosta@redhat.com> <1214599103-13846-5-git-send-email-gcosta@redhat.com> <1214599103-13846-6-git-send-email-gcosta@redhat.com> <1214599103-13846-7-git-send-email-gcosta@redhat.com> <1214599103-13846-8-git-send-email-gcosta@redhat.com> <1214599103-13846-9-git-send-email-gcosta@redhat.com> <1214599103-13846-10-git-send-email-gcosta@redhat.com> <1214599103-13846-11-git-send-email-gcosta@redhat.com> <1214599103-13846-12-git-send-email-gcosta@redhat.com> <1214599103-13846-13-git-send-email-gcosta@redhat.com> <1214599103-13846-14-git-send-email-gcosta@redhat.com> <1214599103-13846-15-git-send-email-gcosta@redhat.com> <1214599103-13846-16-git-send-email-gcosta@redhat.com> <1214599103-13846-17-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 17/20] add hook to cpu_register_physical_memory Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org kqemu has a hook in it, so add an accel wrapper. However, we still provide a double underlined version which does not call the wrapper. That's basically because kqemu call cpu_register_physical_memory itself during its initialization. Signed-off-by: Glauber Costa --- accel.h | 11 +++++++++++ exec.c | 22 ++++++++++++---------- kqemu.c | 1 + 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/accel.h b/accel.h index 9755a9b..a9eee65 100644 --- a/accel.h +++ b/accel.h @@ -10,6 +10,9 @@ typedef struct QEMUAccel { void (*set_notdirty)(ram_addr_t addr); void (*modify_page)(ram_addr_t addr, int dirty_flags); uint64_t (*get_real_ticks)(void); + void (*register_physical_memory)(uint64_t start_addr, + ram_addr_t size, ram_addr_t phys_offset); + } QEMUAccel; typedef struct QEMUCont { @@ -124,3 +127,11 @@ static inline uint64_t accel_get_real_ticks(void) return current_accel->get_real_ticks(); return cpu_get_ticks(); } + +static inline void accel_register_phys_mem(uint64_t start_addr, + ram_addr_t size, + ram_addr_t phys_offset) +{ + if (current_accel && current_accel->register_physical_memory) + current_accel->register_physical_memory(start_addr, size, phys_offset); +} diff --git a/exec.c b/exec.c index e5d3fea..d6490ba 100644 --- a/exec.c +++ b/exec.c @@ -2064,9 +2064,9 @@ static void *subpage_init (target_phys_addr_t base, ram_addr_t *phys, /* register physical memory. 'size' must be a multiple of the target page size. If (phys_offset & ~TARGET_PAGE_MASK) != 0, then it is an io memory page */ -void cpu_register_physical_memory(target_phys_addr_t start_addr, - ram_addr_t size, - ram_addr_t phys_offset) +void __cpu_register_physical_memory(target_phys_addr_t start_addr, + ram_addr_t size, + ram_addr_t phys_offset) { target_phys_addr_t addr, end_addr; PhysPageDesc *p; @@ -2074,13 +2074,6 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr, ram_addr_t orig_size = size; void *subpage; -#ifdef USE_KQEMU - /* XXX: should not depend on cpu context */ - env = first_cpu; - if (env && env->kqemu_enabled) { - kqemu_set_phys_mem(start_addr, size, phys_offset); - } -#endif size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; end_addr = start_addr + (target_phys_addr_t)size; for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) { @@ -2138,6 +2131,15 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr, } } +void cpu_register_physical_memory(target_phys_addr_t start_addr, + ram_addr_t size, + ram_addr_t phys_offset) +{ + accel_register_phys_mem(start_addr, size, phys_offset); + + __cpu_register_physical_memory(start_addr, size, phys_offset); +} + /* XXX: temporary until new memory mapping API */ ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr) { diff --git a/kqemu.c b/kqemu.c index 783b036..e8ce6cf 100644 --- a/kqemu.c +++ b/kqemu.c @@ -448,6 +448,7 @@ QEMUAccel kqemu_accel = { because kqemu does not trap the RDTSC instruction for performance reasons */ .get_real_ticks = cpu_get_real_ticks, + .register_physical_memory = kqemu_set_phys_mem, }; static void __attribute__((constructor)) register_kqemu(void) -- 1.5.5.1