From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgH-0002zA-T6 for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxEgA-0003Uj-2O for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEg9-0003UB-MQ for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:06 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1E9S5l2002932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Feb 2012 04:28:05 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1E9S3du012955 for ; Tue, 14 Feb 2012 04:28:04 -0500 From: Avi Kivity Date: Tue, 14 Feb 2012 11:27:36 +0200 Message-Id: <1329211670-11548-7-git-send-email-avi@redhat.com> In-Reply-To: <1329211670-11548-1-git-send-email-avi@redhat.com> References: <1329211670-11548-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 06/20] memory: remove first level of l1_phys_map List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org L1 and the lower levels in l1_phys_map are equivalent, except that L1 has a different size, and is always allocated. Simplify the code by removing L1. This leaves us with a tree composed solely of L2 tables, but that problem can be renamed away later. Signed-off-by: Avi Kivity --- exec.c | 29 ++++++++--------------------- 1 files changed, 8 insertions(+), 21 deletions(-) diff --git a/exec.c b/exec.c index b36c301..c541ee7 100644 --- a/exec.c +++ b/exec.c @@ -160,29 +160,21 @@ #define L2_BITS 10 #define L2_SIZE (1 << L2_BITS) +#define P_L2_LEVELS \ + (((TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - 1) / L2_BITS) + 1) + /* The bits remaining after N lower levels of page tables. */ -#define P_L1_BITS_REM \ - ((TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS) % L2_BITS) #define V_L1_BITS_REM \ ((L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS) % L2_BITS) -/* Size of the L1 page table. Avoid silly small sizes. */ -#if P_L1_BITS_REM < 4 -#define P_L1_BITS (P_L1_BITS_REM + L2_BITS) -#else -#define P_L1_BITS P_L1_BITS_REM -#endif - #if V_L1_BITS_REM < 4 #define V_L1_BITS (V_L1_BITS_REM + L2_BITS) #else #define V_L1_BITS V_L1_BITS_REM #endif -#define P_L1_SIZE ((target_phys_addr_t)1 << P_L1_BITS) #define V_L1_SIZE ((target_ulong)1 << V_L1_BITS) -#define P_L1_SHIFT (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - P_L1_BITS) #define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS) unsigned long qemu_real_host_page_size; @@ -202,7 +194,7 @@ /* This is a multi-level map on the physical address space. The bottom level has pointers to PhysPageDesc. */ -static void *l1_phys_map[P_L1_SIZE]; +static void *phys_map; static void io_mem_init(void); static void memory_map_init(void); @@ -404,11 +396,10 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) void **lp; int i; - /* Level 1. Always allocated. */ - lp = l1_phys_map + ((index >> P_L1_SHIFT) & (P_L1_SIZE - 1)); + lp = &phys_map; - /* Level 2..N-1. */ - for (i = P_L1_SHIFT / L2_BITS - 1; i > 0; i--) { + /* Level 1..N-1. */ + for (i = P_L2_LEVELS - 1; i > 0; i--) { void **p = *lp; if (p == NULL) { if (!alloc) { @@ -2560,11 +2551,7 @@ static void destroy_l2_mapping(void **lp, unsigned level) static void destroy_all_mappings(void) { - unsigned i; - - for (i = 0; i < P_L1_SIZE; ++i) { - destroy_l2_mapping(&l1_phys_map[i], P_L1_SHIFT / L2_BITS - 1); - } + destroy_l2_mapping(&phys_map, P_L2_LEVELS - 1); } /* register physical memory. -- 1.7.9