Commit 0e4b179d3308382e9da91a3b8f443d0b72eb0db4

Authored by bellard
1 parent 77fef8c1

experimental code copy support - fixed A20 emulation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@621 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 28 additions and 1 deletions
target-i386/helper2.c
... ... @@ -31,6 +31,13 @@
31 31  
32 32 //#define DEBUG_MMU
33 33  
  34 +#ifdef USE_CODE_COPY
  35 +#include <asm/ldt.h>
  36 +#include <linux/unistd.h>
  37 +
  38 +_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)
  39 +#endif
  40 +
34 41 CPUX86State *cpu_x86_init(void)
35 42 {
36 43 CPUX86State *env;
... ... @@ -84,6 +91,26 @@ CPUX86State *cpu_x86_init(void)
84 91 inited = 1;
85 92 optimize_flags_init();
86 93 }
  94 +#ifdef USE_CODE_COPY
  95 + /* testing code for code copy case */
  96 + {
  97 + struct modify_ldt_ldt_s ldt;
  98 +
  99 + ldt.entry_number = 1;
  100 + ldt.base_addr = (unsigned long)env;
  101 + ldt.limit = (sizeof(CPUState) + 0xfff) >> 12;
  102 + ldt.seg_32bit = 1;
  103 + ldt.contents = MODIFY_LDT_CONTENTS_DATA;
  104 + ldt.read_exec_only = 0;
  105 + ldt.limit_in_pages = 1;
  106 + ldt.seg_not_present = 0;
  107 + ldt.useable = 1;
  108 + modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */
  109 +
  110 + asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7));
  111 + cpu_single_env = env;
  112 + }
  113 +#endif
87 114 return env;
88 115 }
89 116  
... ... @@ -213,7 +240,7 @@ void cpu_x86_set_a20(CPUX86State *env, int a20_state)
213 240 #endif
214 241 /* if the cpu is currently executing code, we must unlink it and
215 242 all the potentially executing TB */
216   - cpu_interrupt(env, 0);
  243 + cpu_interrupt(env, CPU_INTERRUPT_EXITTB);
217 244  
218 245 /* when a20 is changed, all the MMU mappings are invalid, so
219 246 we must flush everything */
... ...