Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KzMwC-0003vC-Oh for qemu-devel@nongnu.org; Sun, 09 Nov 2008 21:55:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KzMwC-0003uv-60 for qemu-devel@nongnu.org; Sun, 09 Nov 2008 21:55:36 -0500 Received: from [199.232.76.173] (port=35719 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzMwC-0003us-3J for qemu-devel@nongnu.org; Sun, 09 Nov 2008 21:55:36 -0500 Received: from savannah.gnu.org ([199.232.41.3]:35530 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 1KzMwB-0002lP-K4 for qemu-devel@nongnu.org; Sun, 09 Nov 2008 21:55:35 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KzMwA-0007pA-VM for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:55:35 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KzMwA-0007p5-HV for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:55:34 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Mon, 10 Nov 2008 02:55:34 +0000 Subject: [Qemu-devel] [5666] use target_mmap() to allocate idt, gdt and ldt (Kirill A. 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: 5666 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5666 Author: balrog Date: 2008-11-10 02:55:33 +0000 (Mon, 10 Nov 2008) Log Message: ----------- use target_mmap() to allocate idt, gdt and ldt (Kirill A. Shutemov). env->*dt.base should fit target address space, so we should use target_mmap to allocate them. Signed-off-by: Kirill A. Shutemov Modified Paths: -------------- trunk/linux-user/main.c trunk/linux-user/syscall.c Modified: trunk/linux-user/main.c =================================================================== --- trunk/linux-user/main.c 2008-11-10 01:34:27 UTC (rev 5665) +++ trunk/linux-user/main.c 2008-11-10 02:55:33 UTC (rev 5666) @@ -23,6 +23,7 @@ #include #include #include +#include #include "qemu.h" #include "qemu-common.h" @@ -282,9 +283,8 @@ p[1] = tswap32(e2); } +static uint64_t *idt_table; #ifdef TARGET_X86_64 -static uint64_t idt_table[512]; - static void set_gate64(void *ptr, unsigned int type, unsigned int dpl, uint64_t addr, unsigned int sel) { @@ -303,8 +303,6 @@ set_gate64(idt_table + n * 2, 0, dpl, 0, 0); } #else -static uint64_t idt_table[256]; - static void set_gate(void *ptr, unsigned int type, unsigned int dpl, uint32_t addr, unsigned int sel) { @@ -2465,8 +2463,15 @@ #endif /* linux interrupt setup */ - env->idt.base = h2g(idt_table); - env->idt.limit = sizeof(idt_table) - 1; +#ifndef TARGET_ABI32 + env->idt.limit = 511; +#else + env->idt.limit = 255; +#endif + env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1), + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + idt_table = g2h(env->idt.base); set_idt(0, 0); set_idt(1, 0); set_idt(2, 0); @@ -2492,9 +2497,11 @@ /* linux segment setup */ { uint64_t *gdt_table; - gdt_table = qemu_mallocz(sizeof(uint64_t) * TARGET_GDT_ENTRIES); - env->gdt.base = h2g((unsigned long)gdt_table); + env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES, + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1; + gdt_table = g2h(env->gdt.base); #ifdef TARGET_ABI32 write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | Modified: trunk/linux-user/syscall.c =================================================================== --- trunk/linux-user/syscall.c 2008-11-10 01:34:27 UTC (rev 5665) +++ trunk/linux-user/syscall.c 2008-11-10 02:55:33 UTC (rev 5666) @@ -2565,12 +2565,16 @@ } /* allocate the LDT */ if (!ldt_table) { - ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); - if (!ldt_table) + env->ldt.base = target_mmap(0, + TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE, + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (env->ldt.base == -1) return -TARGET_ENOMEM; - memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); - env->ldt.base = h2g((unsigned long)ldt_table); + memset(g2h(env->ldt.base), 0, + TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); env->ldt.limit = 0xffff; + ldt_table = g2h(env->ldt.base); } /* NOTE: same code as Linux kernel */