From patchwork Wed Jul 31 13:11:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 263702 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 22FAE2C00B9 for ; Wed, 31 Jul 2013 23:25:52 +1000 (EST) Received: from localhost ([::1]:43054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4WPW-000074-3V for incoming@patchwork.ozlabs.org; Wed, 31 Jul 2013 09:25:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4WOy-0008Lg-Cl for qemu-devel@nongnu.org; Wed, 31 Jul 2013 09:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4WBT-0006U9-04 for qemu-devel@nongnu.org; Wed, 31 Jul 2013 09:11:28 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:60932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4WBS-0006Tg-MW for qemu-devel@nongnu.org; Wed, 31 Jul 2013 09:11:18 -0400 Received: from blackfin.pond.sub.org (p5B32B152.dip0.t-ipconnect.de [91.50.177.82]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 60C6BA460F; Wed, 31 Jul 2013 15:11:16 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C38F5200BA; Wed, 31 Jul 2013 15:11:12 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2013 15:11:09 +0200 Message-Id: <1375276272-15988-6-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1375276272-15988-1-git-send-email-armbru@redhat.com> References: <1375276272-15988-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, mkletzan@redhat.com, pbonzini@redhat.com, afaerber@suse.de, rth@twiddle.net Subject: [Qemu-devel] [PATCH v3 for 1.6 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 dc87cce..dea4b1a 100644 --- a/exec.c +++ b/exec.c @@ -1266,15 +1266,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: "