aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-15 15:27:03 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-15 15:27:03 +0000
commit4dbc422b55858f6465c38dd0d1b9fbeac856ff43 (patch)
tree483fb3b267dadc6097de4b1a94fb4c8839b7ad55 /linux-user
parent6376fa993c1252c7206f73e027199bdc7fb4ff9b (diff)
x86_64 fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3650 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/main.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index cfe2a0e369..bfb270b2dd 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -153,14 +153,14 @@ uint64_t idt_table[512];
static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
uint64_t addr, unsigned int sel)
{
- unsigned int e1, e2;
- uint32_t *p;
+ uint32_t *p, e1, e2;
e1 = (addr & 0xffff) | (sel << 16);
e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
p = ptr;
- p[0] = tswapl(e1);
- p[1] = tswapl(e2);
- p[2] = addr >> 32;
+ p[0] = tswap32(e1);
+ p[1] = tswap32(e2);
+ p[2] = tswap32(addr >> 32);
+ p[3] = 0;
}
/* only dpl matters as we do only user space emulation */
static void set_idt(int n, unsigned int dpl)
@@ -173,13 +173,12 @@ uint64_t idt_table[256];
static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
uint32_t addr, unsigned int sel)
{
- unsigned int e1, e2;
- uint32_t *p;
+ uint32_t *p, e1, e2;
e1 = (addr & 0xffff) | (sel << 16);
e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
p = ptr;
- p[0] = tswapl(e1);
- p[1] = tswapl(e2);
+ p[0] = tswap32(e1);
+ p[1] = tswap32(e2);
}
/* only dpl matters as we do only user space emulation */
@@ -2113,9 +2112,13 @@ int main(int argc, char **argv)
env->hflags |= HF_OSFXSR_MASK;
}
#ifndef TARGET_ABI32
- /* enable 64 bit mode */
+ /* enable 64 bit mode if possible */
+ if (!(env->cpuid_ext2_features & CPUID_EXT2_LM)) {
+ fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
+ exit(1);
+ }
env->cr[4] |= CR4_PAE_MASK;
- env->efer |= MSR_EFER_LMA;
+ env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
env->hflags |= HF_LMA_MASK;
#endif