From patchwork Tue May 21 10:57:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 245270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6B84D2C0098 for ; Tue, 21 May 2013 21:03:33 +1000 (EST) Received: from localhost ([::1]:49689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekLr-0003SX-3j for incoming@patchwork.ozlabs.org; Tue, 21 May 2013 07:03:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekGr-0004lw-M0 for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UekGq-0005TO-Lr for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:21 -0400 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:58448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekGq-0005TE-Fb for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:20 -0400 Received: by mail-ea0-f174.google.com with SMTP id z7so293574eaf.19 for ; Tue, 21 May 2013 03:58:19 -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=mat+fnrXf4YwIptmfq+PZG/pCIXLxjVmi5zg8qSjKkg=; b=bxaOmDREKEdTOdW3f28dQsYf2zUewCFSQgTco/McIdW7E/SU+CtGQooiiIs1XRbTls MYR7HeNHT+iPOsbeUgl5b4QTgau7wdkpt4t078xmGD5fyY+RuPnDWNC0lH6I3sgE7bbu tJUGiT6sOPxuUu9XZXjYq7LY33jnLYRsAmbGv9mMkB8ZMGxqnw3lRIfIYnsDcRmo2qxd 4iFiafmlwBPrRmO16AaDMe1rM1IvyDA5qIkeJGbLEUwWXmcY9s2cWv3GvYWVN3v2DIYO BMjKybxDnjr7MiAIpcYA3itb3KPursWua+hQDMqm7shc7MtJt0tVb/01uoy/u/OlPQBM sL7w== X-Received: by 10.14.111.5 with SMTP id v5mr5247288eeg.27.1369133899712; Tue, 21 May 2013 03:58:19 -0700 (PDT) Received: from playground.lan (net-37-116-223-193.cust.dsl.vodafone.it. [37.116.223.193]) by mx.google.com with ESMTPSA id a5sm2754398ees.6.2013.05.21.03.58.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 May 2013 03:58:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 May 2013 12:57:20 +0200 Message-Id: <1369133851-1894-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> References: <1369133851-1894-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:c01::22e Cc: peter.maydell@linaro.org, jan.kiszka@gmail.com, Jan Kiszka , David Gibson Subject: [Qemu-devel] [PATCH 19/30] 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 Reviewed-by: Peter Maydell --- exec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 4cc5ecb..a29dec5 100644 --- a/exec.c +++ b/exec.c @@ -198,13 +198,19 @@ static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr index return &phys_sections[lp.ptr]; } +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) { MemoryRegionSection *section; - 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; *plen = MIN(section->size - addr, *plen);