From patchwork Thu Jun 20 14:44:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 252969 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 06BC42C0090 for ; Fri, 21 Jun 2013 00:46:15 +1000 (EST) Received: from localhost ([::1]:56265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upg7o-0006ae-R6 for incoming@patchwork.ozlabs.org; Thu, 20 Jun 2013 10:46:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upg6o-0006FR-NV for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upg6i-000700-A4 for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:45:10 -0400 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:48250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upg6i-0006y1-47 for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:45:04 -0400 Received: by mail-ee0-f50.google.com with SMTP id d49so4015207eek.9 for ; Thu, 20 Jun 2013 07:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=htadS38pdrZASzPlyoeQWQ/0gaSv6wUzqLIx2LQmmG8=; b=FwDl8P96H4dMQdUWzVb6cFvkD3XnqRr5qHb8kFOpWd3VlH6QPHJKmGSqg/1v8yMwWS hNOTk575M1oB0W2+tko9BLXJ7EqESTsDeyl0dfQJSFf9QCVLR+yzQFho0k3DtqiINy7I iKXPn3Ewjf3b+pe9kBgnXboSkVOgp5eYeoiaXIL98au6W2M/fMlimMsRvkBedVxIT1T8 8tH/IQxcrxhdKwbB+iIfcZjG1EjKVzYNnKZ0sBGZIaskhoAGy7OH+NAK9lZ0FnWPkGtr mVmIEAn7HXPB2eY7OszWDlc5P/7Ghbq4gnYXk+8VAb8yW9x/fOYfyZflOBNfVvVUccLO 8clQ== X-Received: by 10.14.184.4 with SMTP id r4mr7988606eem.100.1371739503165; Thu, 20 Jun 2013 07:45:03 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id y10sm973958eev.3.2013.06.20.07.45.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 20 Jun 2013 07:45:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 20 Jun 2013 16:44:30 +0200 Message-Id: <1371739493-10187-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371739493-10187-1-git-send-email-pbonzini@redhat.com> References: <1371739493-10187-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::232 Cc: Jan Kiszka Subject: [Qemu-devel] [PATCH 02/25] memory: Introduce address_space_lookup_region 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 From: Jan Kiszka This introduces a wrapper for phys_page_find (before we complicate address_space_translate with IOMMU translation). This function will also encapsulate locking and reference counting when we introduce BQL-free dispatching. Signed-off-by: Jan Kiszka Signed-off-by: Paolo Bonzini --- exec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index eb200d0..86efed7 100644 --- a/exec.c +++ b/exec.c @@ -203,6 +203,12 @@ bool memory_region_is_unassigned(MemoryRegion *mr) && mr != &io_mem_watch; } +static MemoryRegionSection *address_space_lookup_region(AddressSpace *as, + hwaddr addr) +{ + return phys_page_find(as->dispatch, addr >> TARGET_PAGE_BITS); +} + MemoryRegionSection *address_space_translate(AddressSpace *as, hwaddr addr, hwaddr *xlat, hwaddr *plen, bool is_write) @@ -210,7 +216,7 @@ MemoryRegionSection *address_space_translate(AddressSpace *as, hwaddr addr, MemoryRegionSection *section; Int128 diff; - section = phys_page_find(as->dispatch, addr >> TARGET_PAGE_BITS); + section = address_space_lookup_region(as, addr); /* Compute offset within MemoryRegionSection */ addr -= section->offset_within_address_space;