linux-user: Turn gdt_table into local variable
PATCH 1/1 linux-user: Turn gdt_table into local variable
qemu_malloc[z] does not return memory suited for direct guest access, but that is mandatory for gdt_table. Local host variables are safe, so re-convert that (small) table.
This patch, together with the one for page_find_alloc, fixes the reported qemu-i386 regression [1].
[1] http://permalink.gmane.org/gmane.comp.emulators.qemu/26987
--- linux-user/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/main.c +3 -3
@@ -258,6 +258,8 @@ void fork_end(int child)/***********************************************************/ /* CPUX86 core interface */ +uint64_t gdt_table[TARGET_GDT_ENTRIES ]; +void cpu_smm_update (CPUState *env) { }
@@ -2470,9 +2472,7 @@ int main(int argc, char **argv)/* 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 =h2g (gdt_table); env->gdt.limit =sizeof (uint64_t ) *TARGET_GDT_ENTRIES -1 ;#ifdef TARGET_ABI32 write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
Quoted 2 lines · Jan Kiszka
qemu_malloc[z] does not return memory suited for direct guest access, but that is mandatory for
gdt_table. Local host variables are safe,
No they aren't.
Paul
Quoted 5 lines · Paul Brook
Quoted 2 lines · Jan Kiszka
qemu_malloc[z] does not return memory suited for direct guest access, but that is mandatory for
gdt_table. Local host variables are safe,No they aren't.
Well, right (even when renaming local to global - what I actually meant). It is safer, but some risk remains that global variables are mapped to high addresses.
Due to this and also because of some further bug of that kind I found in the meantime a better series is on the way.
Jan