From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KfGRF-0002af-2d for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:56:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KfGRE-0002aD-Ei for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:56:32 -0400 Received: from [199.232.76.173] (port=50308 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfGRE-0002a6-5I for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:56:32 -0400 Received: from savannah.gnu.org ([199.232.41.3]:38324 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KfGRE-0005qs-2N for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:56:32 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KfGRD-0003Zr-1i for qemu-devel@nongnu.org; Mon, 15 Sep 2008 15:56:31 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KfGRC-0003Zn-Pc for qemu-devel@nongnu.org; Mon, 15 Sep 2008 15:56:30 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 15 Sep 2008 15:56:30 +0000 Subject: [Qemu-devel] [5227] Make page_find() return 0 for too-large addresses (Eduardo Habkost) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5227 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5227 Author: aliguori Date: 2008-09-15 15:56:30 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Make page_find() return 0 for too-large addresses (Eduardo Habkost) On some cases, such as under KVM, tb_invalidate_phys_page_range() may be called for large addresses, when qemu is configured to more than 4GB of RAM. On these cases, qemu was crashing because it was using an index too large for l1_map[], that supports only 32-bit addresses when compiling without CONFIG_USER_ONLY. Signed-off-by: Eduardo Habkost Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/exec.c Modified: trunk/exec.c =================================================================== --- trunk/exec.c 2008-09-15 15:51:35 UTC (rev 5226) +++ trunk/exec.c 2008-09-15 15:56:30 UTC (rev 5227) @@ -279,17 +279,24 @@ #endif } -static inline PageDesc *page_find_alloc(target_ulong index) +static inline PageDesc **page_l1_map(target_ulong index) { - PageDesc **lp, *p; - #if TARGET_LONG_BITS > 32 /* Host memory outside guest VM. For 32-bit targets we have already excluded high addresses. */ if (index > ((target_ulong)L2_SIZE * L1_SIZE)) return NULL; #endif - lp = &l1_map[index >> L2_BITS]; + return &l1_map[index >> L2_BITS]; +} + +static inline PageDesc *page_find_alloc(target_ulong index) +{ + PageDesc **lp, *p; + lp = page_l1_map(index); + if (!lp) + return NULL; + p = *lp; if (!p) { /* allocate if not found */ @@ -316,9 +323,12 @@ static inline PageDesc *page_find(target_ulong index) { - PageDesc *p; + PageDesc **lp, *p; + lp = page_l1_map(index); + if (!lp) + return NULL; - p = l1_map[index >> L2_BITS]; + p = *lp; if (!p) return 0; return p + (index & (L2_SIZE - 1));