From patchwork Thu May 26 08:49:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9136807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D70BC6075C for ; Thu, 26 May 2016 08:50:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD03527D11 for ; Thu, 26 May 2016 08:50:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1DDB28299; Thu, 26 May 2016 08:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6454027D11 for ; Thu, 26 May 2016 08:50:33 +0000 (UTC) Received: from localhost ([::1]:37447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5qzw-0005t5-Er for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 May 2016 04:50:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5qzQ-0005qJ-HH for qemu-devel@nongnu.org; Thu, 26 May 2016 04:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5qzH-0007KE-Ie for qemu-devel@nongnu.org; Thu, 26 May 2016 04:50:00 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5qzH-0007Jz-7z for qemu-devel@nongnu.org; Thu, 26 May 2016 04:49:51 -0400 Received: by mail-wm0-x242.google.com with SMTP id n129so2832998wmn.1 for ; Thu, 26 May 2016 01:49:50 -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:in-reply-to:references; bh=ZdBqBgkj732gE3CyYKA3UowkFdhj1ju1fdwerdPc9ts=; b=y30JbjmE70Xx9uRwXgUkCh+szXob62+3FUILQkNPTtLjvDcKt034tp9dQ2URYAjvRr ieiJSXGI57Kv7C6mGqUNKTH7OyC7QGoCpgYqCEmixUjxEfsmtxuJLmW0lM4oFDrBc47n 8zXPikU2qKjd0CtjFaltaDBr3wAdHddDAajg9n0lfiisTIh4R6cJA0Se0ij+J2IB7N4a yAUJ6l2RDP57Ttv/cnjtNSZk6uvxlOSqzKnKbWFQMkWoGLE8NT8o2+4Bsvym4nzqf7R4 8b6QwNEaIxIBoiyI7zjUP3bOf003SvwGSqOlTc77dcs1e5gVgGJDEVI95BElXfE9dOx9 e2qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZdBqBgkj732gE3CyYKA3UowkFdhj1ju1fdwerdPc9ts=; b=JYH/AxNQNDmmvHZaCQWs8aotgcY3Y8Y3eZK0wMM7GgGH49SaHyOQ72bTEpGdQqDACB KRh1AygX3OQUQLE1IrW/8srqb9DGJY0JwbisoPuIhAcLT67gBhY+0ce2eYxeptjryrHx y/SG61yCBrIHIiWnATV6U2WdbiAhlWlHX3XQiVQMGrLvvDgR0WNOzk+C1Ly4+jBTVchs 7WZSUwApEEv/HQeM5KpD2r0J5JXpLWSvTR5s6jBSd+eHrYpS0qH9EfwXHkzPXsp+22W6 8SEksIX1cn55VptrZJMBqRHeBeEc6eAbkXyhvpKidNgOx4T2R3cDKQIvdkl7wmLzdPv5 3t/w== X-Gm-Message-State: ALyK8tKREIy0HDLYttnIMXXyIU6GJv6QfKkOCB7T57RI46By4OHaDa+vwbYoUENlJUKszQ== X-Received: by 10.28.170.21 with SMTP id t21mr2601800wme.0.1464252590121; Thu, 26 May 2016 01:49:50 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id c2sm2385115wme.4.2016.05.26.01.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 May 2016 01:49:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 26 May 2016 10:49:42 +0200 Message-Id: <1464252584-30832-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464252584-30832-1-git-send-email-pbonzini@redhat.com> References: <1464252584-30832-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH 2/4] exec: remove ram_addr argument from qemu_ram_block_from_host X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, arei.gonglei@huawei.com, famz@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Of the two callers, one does not use it, and the other can compute it itself based on the other output argument (offset) and the RAMBlock. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-André Lureau --- exec.c | 13 ++++++------- include/exec/cpu-common.h | 2 +- migration/postcopy-ram.c | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/exec.c b/exec.c index 3330e7d..65bad53 100644 --- a/exec.c +++ b/exec.c @@ -1897,16 +1897,16 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, * ram_addr_t. */ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, - ram_addr_t *ram_addr, ram_addr_t *offset) { RAMBlock *block; uint8_t *host = ptr; if (xen_enabled()) { + ram_addr_t ram_addr; rcu_read_lock(); - *ram_addr = xen_ram_addr_from_mapcache(ptr); - block = qemu_get_ram_block(*ram_addr); + ram_addr = xen_ram_addr_from_mapcache(ptr); + block = qemu_get_ram_block(ram_addr); if (block) { *offset = (host - block->host); } @@ -1938,7 +1938,6 @@ found: if (round_offset) { *offset &= TARGET_PAGE_MASK; } - *ram_addr = block->offset + *offset; rcu_read_unlock(); return block; } @@ -1968,10 +1967,10 @@ RAMBlock *qemu_ram_block_by_name(const char *name) MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr) { RAMBlock *block; - ram_addr_t offset; /* Not used */ - - block = qemu_ram_block_from_host(ptr, false, ram_addr, &offset); + ram_addr_t offset; + block = qemu_ram_block_from_host(ptr, false, &offset); + *ram_addr = block->offset + offset; if (!block) { return NULL; } diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index a2c3b92..fc609ad 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -60,7 +60,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); RAMBlock *qemu_ram_block_by_name(const char *name); RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, - ram_addr_t *ram_addr, ram_addr_t *offset); + ram_addr_t *offset); void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev); void qemu_ram_unset_idstr(RAMBlock *block); const char *qemu_ram_get_idstr(RAMBlock *rb); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index fbd0064..cf7dcd2 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -407,7 +407,6 @@ static void *postcopy_ram_fault_thread(void *opaque) while (true) { ram_addr_t rb_offset; - ram_addr_t in_raspace; struct pollfd pfd[2]; /* @@ -459,7 +458,7 @@ static void *postcopy_ram_fault_thread(void *opaque) rb = qemu_ram_block_from_host( (void *)(uintptr_t)msg.arg.pagefault.address, - true, &in_raspace, &rb_offset); + true, &rb_offset); if (!rb) { error_report("postcopy_ram_fault_thread: Fault outside guest: %" PRIx64, (uint64_t)msg.arg.pagefault.address);