From patchwork Thu Jun 20 07:54:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 252788 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 251E92C035E for ; Thu, 20 Jun 2013 17:58:17 +1000 (EST) Received: from localhost ([::1]:44314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpZl1-0006IW-3H for incoming@patchwork.ozlabs.org; Thu, 20 Jun 2013 03:58:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpZhe-000116-F5 for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpZhY-00068a-IR for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:54:46 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:39039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpZhY-00068I-BP for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:54:40 -0400 Received: from blackfin.pond.sub.org (p5B32AC8A.dip0.t-ipconnect.de [91.50.172.138]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 47DFDA62D7; Thu, 20 Jun 2013 09:54:39 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 37A77200B6; Thu, 20 Jun 2013 09:54:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 20 Jun 2013 09:54:33 +0200 Message-Id: <1371714876-2317-6-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1371714876-2317-1-git-send-email-armbru@redhat.com> References: <1371714876-2317-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: peter.maydell@linaro.org, stefano.stabellini@eu.citrix.com, mtosatti@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de, rth@twiddle.net Subject: [Qemu-devel] [PATCH v2 5/8] exec: Drop incorrect & dead S390 code in qemu_ram_remap() 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 Old S390 KVM wants guest RAM mapped in a peculiar way. Commit 6b02494 implemented that. When qemu_ram_remap() got added in commit cd19cfa, its code carefully mimicked the allocation code: peculiar way if defined(TARGET_S390X) && defined(CONFIG_KVM), else normal way. For new S390 KVM, we actually want the normal way. Commit fdec991 changed qemu_ram_alloc_from_ptr() accordingly, but forgot to update qemu_ram_remap(). If qemu_ram_alloc_from_ptr() maps RAM the normal way, but qemu_ram_remap() remaps it the peculiar way, remapping changes protection and flags, which it shouldn't. Fortunately, this can't happen, as we never remap on S390. Replace the incorrect code with an assertion. Thanks to Christian Borntraeger for help with assessing the bug's (non-)impact. Acked-by: Christian Borntraeger Signed-off-by: Markus Armbruster --- exec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index c45eb33..366ac6a 100644 --- a/exec.c +++ b/exec.c @@ -1229,15 +1229,16 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) area = mmap(vaddr, length, PROT_READ | PROT_WRITE, flags, block->fd, offset); } else { -#if defined(TARGET_S390X) && defined(CONFIG_KVM) - flags |= MAP_SHARED | MAP_ANONYMOUS; - area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE, - flags, -1, 0); -#else + /* + * Remap needs to match alloc. Accelerators that + * set phys_mem_alloc never remap. If they did, + * we'd need a remap hook here. + */ + assert(phys_mem_alloc == qemu_anon_ram_alloc); + flags |= MAP_PRIVATE | MAP_ANONYMOUS; area = mmap(vaddr, length, PROT_READ | PROT_WRITE, flags, -1, 0); -#endif } if (area != vaddr) { fprintf(stderr, "Could not remap addr: "