From patchwork Wed Dec 11 18:30:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 300300 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 247202C00AE for ; Thu, 12 Dec 2013 06:19:53 +1100 (EST) Received: from localhost ([::1]:59362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqoa1-0002Ab-RK for incoming@patchwork.ozlabs.org; Wed, 11 Dec 2013 13:32:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoVD-0004lD-IZ for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:27:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqoV7-0000My-47 for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:27:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoV6-0000Ms-RS for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:27:13 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBBIRBME013497 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Dec 2013 13:27:11 -0500 Received: from redhat.com (vpn1-4-46.ams2.redhat.com [10.36.4.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id rBBIR9xx016829; Wed, 11 Dec 2013 13:27:09 -0500 Date: Wed, 11 Dec 2013 20:30:52 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1386786509-29966-14-git-send-email-mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Luiz Capitulino Subject: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide 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: Paolo Bonzini As an alternative to commit 818f86b (exec: limit system memory size, 2013-11-04) let's just make all address spaces 64-bit wide. This eliminates problems with phys_page_find ignoring bits above TARGET_PHYS_ADDR_SPACE_BITS and address_space_translate_internal consequently messing up the computations. In Luiz's reported crash, at startup gdb attempts to read from address 0xffffffffffffffe6 to 0xffffffffffffffff inclusive. The region it gets is the newly introduced master abort region, which is as big as the PCI address space (see pci_bus_init). Due to a typo that's only 2^63-1, not 2^64. But we get it anyway because phys_page_find ignores the upper bits of the physical address. In address_space_translate_internal then diff = int128_sub(section->mr->size, int128_make64(addr)); *plen = int128_get64(int128_min(diff, int128_make64(*plen))); diff becomes negative, and int128_get64 booms. The size of the PCI address space region should be fixed anyway. Reported-by: Luiz Capitulino Signed-off-by: Paolo Bonzini Signed-off-by: Michael S. Tsirkin --- exec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 7e5ce93..f907f5f 100644 --- a/exec.c +++ b/exec.c @@ -94,7 +94,7 @@ struct PhysPageEntry { #define PHYS_MAP_NODE_NIL (((uint32_t)~0) >> 6) /* Size of the L2 (and L3, etc) page tables. */ -#define ADDR_SPACE_BITS TARGET_PHYS_ADDR_SPACE_BITS +#define ADDR_SPACE_BITS 64 #define P_L2_BITS 10 #define P_L2_SIZE (1 << P_L2_BITS) @@ -1861,11 +1861,7 @@ static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); - assert(ADDR_SPACE_BITS <= 64); - - memory_region_init(system_memory, NULL, "system", - ADDR_SPACE_BITS == 64 ? - UINT64_MAX : (0x1ULL << ADDR_SPACE_BITS)); + memory_region_init(system_memory, NULL, "system", UINT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io));