From patchwork Thu Oct 17 15:48:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 284294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 094302C00BC for ; Fri, 18 Oct 2013 02:57:37 +1100 (EST) Received: from localhost ([::1]:53002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWpx8-0001wW-UG for incoming@patchwork.ozlabs.org; Thu, 17 Oct 2013 11:57:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppZ-0007UR-Rg for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWppR-0000sq-DW for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:45 -0400 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]:39182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppR-0000rz-3O for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:37 -0400 Received: by mail-ee0-f46.google.com with SMTP id c13so1168836eek.19 for ; Thu, 17 Oct 2013 08:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=tl8oSiuV/QQimUOJhvL1NzSBoRdB9ZmaCNpjKaH9nuY=; b=c7kq5xBYhEOkYl5y+mPFvCJyqnOatSr5gGky5g8JpqJ6rQ5GKZJmhDIhzb8vOWijED 65dtTf7kVPMjPqfVkpanU5Lc+KaYGizyJ06wm5WP3egimDq7wkTrjh+l31S+/XLmJVxy 6MFmDHQuKr20cWOWFPKysPOcnRgmK8wFIz0Efkh1XLXtgoHhCgshxVdE19bByI+610lp 6Ji76lvsCgSZZ2pGJOBwZVmxP3JPf56hqGc4Ezca96lMDpa55iAyDQofK5W7RqfJutNC Ej4GKuNCwNKGy7X2AZErZu7Ttzb3G0jSqOMT1FTU6jspFpGM00enXh/RKcYJoK/SGVcU 0jWg== X-Received: by 10.14.210.8 with SMTP id t8mr13371375eeo.39.1382024976086; Thu, 17 Oct 2013 08:49:36 -0700 (PDT) Received: from playground.lan (net-37-116-196-7.cust.dsl.vodafone.it. [37.116.196.7]) by mx.google.com with ESMTPSA id a43sm194431296eep.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 17 Oct 2013 08:49:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 17 Oct 2013 17:48:55 +0200 Message-Id: <1382024935-28297-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1382024935-28297-1-git-send-email-pbonzini@redhat.com> References: <1382024935-28297-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::22e Subject: [Qemu-devel] [PULL 17/17] exec: remove qemu_safe_ram_ptr 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 This is not needed since the RAM list is not modified anymore by qemu_get_ram_ptr. Replace it with qemu_get_ram_block. Signed-off-by: Paolo Bonzini --- exec.c | 97 +++++++++++++++++++----------------------------------------------- 1 file changed, 28 insertions(+), 69 deletions(-) diff --git a/exec.c b/exec.c index bea2cff..2e31ffc 100644 --- a/exec.c +++ b/exec.c @@ -129,7 +129,6 @@ static PhysPageMap next_map; static void io_mem_init(void); static void memory_map_init(void); -static void *qemu_safe_ram_ptr(ram_addr_t addr); static MemoryRegion io_mem_watch; #endif @@ -626,22 +625,39 @@ void cpu_abort(CPUArchState *env, const char *fmt, ...) } #if !defined(CONFIG_USER_ONLY) +static RAMBlock *qemu_get_ram_block(ram_addr_t addr) +{ + RAMBlock *block; + + /* The list is protected by the iothread lock here. */ + block = ram_list.mru_block; + if (block && addr - block->offset < block->length) { + goto found; + } + QTAILQ_FOREACH(block, &ram_list.blocks, next) { + if (addr - block->offset < block->length) { + goto found; + } + } + + fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr); + abort(); + +found: + ram_list.mru_block = block; + return block; +} + static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t end, uintptr_t length) { - uintptr_t start1; + RAMBlock *block; + ram_addr_t start1; - /* we modify the TLB cache so that the dirty bit will be set again - when accessing the range */ - start1 = (uintptr_t)qemu_safe_ram_ptr(start); - /* Check that we don't span multiple blocks - this breaks the - address comparisons below. */ - if ((uintptr_t)qemu_safe_ram_ptr(end - 1) - start1 - != (end - 1) - start) { - abort(); - } + block = qemu_get_ram_block(start); + assert(block == qemu_get_ram_block(end - 1)); + start1 = (uintptr_t)block->host + (start - block->offset); cpu_tlb_reset_dirty_all(start1, length); - } /* Note: start and end must be within the same ram block. */ @@ -1269,29 +1285,6 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) } #endif /* !_WIN32 */ -static RAMBlock *qemu_get_ram_block(ram_addr_t addr) -{ - RAMBlock *block; - - /* The list is protected by the iothread lock here. */ - block = ram_list.mru_block; - if (block && addr - block->offset < block->length) { - goto found; - } - QTAILQ_FOREACH(block, &ram_list.blocks, next) { - if (addr - block->offset < block->length) { - goto found; - } - } - - fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr); - abort(); - -found: - ram_list.mru_block = block; - return block; -} - /* Return a host pointer to ram allocated with qemu_ram_alloc. With the exception of the softmmu code in this file, this should only be used for local memory (e.g. video ram) that the device owns, @@ -1319,40 +1312,6 @@ void *qemu_get_ram_ptr(ram_addr_t addr) return block->host + (addr - block->offset); } -/* Return a host pointer to ram allocated with qemu_ram_alloc. Same as - * qemu_get_ram_ptr but do not touch ram_list.mru_block. - * - * ??? Is this still necessary? - */ -static void *qemu_safe_ram_ptr(ram_addr_t addr) -{ - RAMBlock *block; - - /* The list is protected by the iothread lock here. */ - QTAILQ_FOREACH(block, &ram_list.blocks, next) { - if (addr - block->offset < block->length) { - if (xen_enabled()) { - /* We need to check if the requested address is in the RAM - * because we don't want to map the entire memory in QEMU. - * In that case just map until the end of the page. - */ - if (block->offset == 0) { - return xen_map_cache(addr, 0, 0); - } else if (block->host == NULL) { - block->host = - xen_map_cache(block->offset, block->length, 1); - } - } - return block->host + (addr - block->offset); - } - } - - fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr); - abort(); - - return NULL; -} - /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr * but takes a size argument */ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)