qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Turn gdt_table into local variable
@ 2008-07-13 20:28 Jan Kiszka
  2008-07-13 22:11 ` Paul Brook
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2008-07-13 20:28 UTC (permalink / raw)
  To: qemu-devel

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

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
 linux-user/main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: b/linux-user/main.c
===================================================================
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Turn gdt_table into local variable
  2008-07-13 20:28 [Qemu-devel] [PATCH] linux-user: Turn gdt_table into local variable Jan Kiszka
@ 2008-07-13 22:11 ` Paul Brook
  2008-07-14  7:14   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Brook @ 2008-07-13 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jan Kiszka

On Sunday 13 July 2008, Jan Kiszka wrote:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Turn gdt_table into local variable
  2008-07-13 22:11 ` Paul Brook
@ 2008-07-14  7:14   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2008-07-14  7:14 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

Paul Brook wrote:
> On Sunday 13 July 2008, Jan Kiszka wrote:
>> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-14  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-13 20:28 [Qemu-devel] [PATCH] linux-user: Turn gdt_table into local variable Jan Kiszka
2008-07-13 22:11 ` Paul Brook
2008-07-14  7:14   ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).