Commit 4dbc422b55858f6465c38dd0d1b9fbeac856ff43

Authored by bellard
1 parent 6376fa99

x86_64 fixes


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3650 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 14 additions and 11 deletions
linux-user/main.c
... ... @@ -153,14 +153,14 @@ uint64_t idt_table[512];
153 153 static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
154 154 uint64_t addr, unsigned int sel)
155 155 {
156   - unsigned int e1, e2;
157   - uint32_t *p;
  156 + uint32_t *p, e1, e2;
158 157 e1 = (addr & 0xffff) | (sel << 16);
159 158 e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
160 159 p = ptr;
161   - p[0] = tswapl(e1);
162   - p[1] = tswapl(e2);
163   - p[2] = addr >> 32;
  160 + p[0] = tswap32(e1);
  161 + p[1] = tswap32(e2);
  162 + p[2] = tswap32(addr >> 32);
  163 + p[3] = 0;
164 164 }
165 165 /* only dpl matters as we do only user space emulation */
166 166 static void set_idt(int n, unsigned int dpl)
... ... @@ -173,13 +173,12 @@ uint64_t idt_table[256];
173 173 static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
174 174 uint32_t addr, unsigned int sel)
175 175 {
176   - unsigned int e1, e2;
177   - uint32_t *p;
  176 + uint32_t *p, e1, e2;
178 177 e1 = (addr & 0xffff) | (sel << 16);
179 178 e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
180 179 p = ptr;
181   - p[0] = tswapl(e1);
182   - p[1] = tswapl(e2);
  180 + p[0] = tswap32(e1);
  181 + p[1] = tswap32(e2);
183 182 }
184 183  
185 184 /* only dpl matters as we do only user space emulation */
... ... @@ -2113,9 +2112,13 @@ int main(int argc, char **argv)
2113 2112 env->hflags |= HF_OSFXSR_MASK;
2114 2113 }
2115 2114 #ifndef TARGET_ABI32
2116   - /* enable 64 bit mode */
  2115 + /* enable 64 bit mode if possible */
  2116 + if (!(env->cpuid_ext2_features & CPUID_EXT2_LM)) {
  2117 + fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
  2118 + exit(1);
  2119 + }
2117 2120 env->cr[4] |= CR4_PAE_MASK;
2118   - env->efer |= MSR_EFER_LMA;
  2121 + env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
2119 2122 env->hflags |= HF_LMA_MASK;
2120 2123 #endif
2121 2124  
... ...