Spelling fix, by Stefan Weil.
[qemu] / kqemu.c
diff --git a/kqemu.c b/kqemu.c
index 846a89d..c6b2e69 100644 (file)
--- a/kqemu.c
+++ b/kqemu.c
@@ -26,6 +26,9 @@
 #include <sys/mman.h>
 #include <sys/ioctl.h>
 #endif
+#ifdef HOST_SOLARIS
+#include <sys/ioccom.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -44,7 +47,7 @@
 
 #include <unistd.h>
 #include <fcntl.h>
-#include "kqemu/kqemu.h"
+#include "kqemu.h"
 
 /* compatibility stuff */
 #ifndef KQEMU_RET_SYSCALL
@@ -119,7 +122,7 @@ static int is_cpuid_supported(void)
 
 static void kqemu_update_cpuid(CPUState *env)
 {
-    int critical_features_mask, features;
+    int critical_features_mask, features, ext_features, ext_features_mask;
     uint32_t eax, ebx, ecx, edx;
 
     /* the following features are kept identical on the host and
@@ -130,11 +133,14 @@ static void kqemu_update_cpuid(CPUState *env)
         CPUID_CMOV | CPUID_CX8 | 
         CPUID_FXSR | CPUID_MMX | CPUID_SSE | 
         CPUID_SSE2 | CPUID_SEP;
+    ext_features_mask = CPUID_EXT_SSE3 | CPUID_EXT_MONITOR;
     if (!is_cpuid_supported()) {
         features = 0;
+        ext_features = 0;
     } else {
         cpuid(1, eax, ebx, ecx, edx);
         features = edx;
+        ext_features = ecx;
     }
 #ifdef __x86_64__
     /* NOTE: on x86_64 CPUs, SYSENTER is not supported in
@@ -144,6 +150,8 @@ static void kqemu_update_cpuid(CPUState *env)
 #endif
     env->cpuid_features = (env->cpuid_features & ~critical_features_mask) |
         (features & critical_features_mask);
+    env->cpuid_ext_features = (env->cpuid_ext_features & ~ext_features_mask) |
+        (ext_features & ext_features_mask);
     /* XXX: we could update more of the target CPUID state so that the
        non accelerated code sees exactly the same CPU features as the
        accelerated code */
@@ -169,7 +177,8 @@ int kqemu_init(CPUState *env)
     kqemu_fd = open(KQEMU_DEVICE, O_RDWR);
 #endif
     if (kqemu_fd == KQEMU_INVALID_FD) {
-        fprintf(stderr, "Could not open '%s' - QEMU acceleration layer not activated\n", KQEMU_DEVICE);
+        fprintf(stderr, "Could not open '%s' - QEMU acceleration layer not activated: %s\n",
+                KQEMU_DEVICE, strerror(errno));
         return -1;
     }
     version = 0;
@@ -465,13 +474,17 @@ static int do_syscall(CPUState *env,
     selector = (env->star >> 32) & 0xffff;
 #ifdef __x86_64__
     if (env->hflags & HF_LMA_MASK) {
+        int code64;
+
         env->regs[R_ECX] = kenv->next_eip;
         env->regs[11] = env->eflags;
 
+        code64 = env->hflags & HF_CS64_MASK;
+
         cpu_x86_set_cpl(env, 0);
         cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 
                                0, 0xffffffff, 
-                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK |
+                               DESC_G_MASK | DESC_P_MASK |
                                DESC_S_MASK |
                                DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK | DESC_L_MASK);
         cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc, 
@@ -480,7 +493,7 @@ static int do_syscall(CPUState *env,
                                DESC_S_MASK |
                                DESC_W_MASK | DESC_A_MASK);
         env->eflags &= ~env->fmask;
-        if (env->hflags & HF_CS64_MASK)
+        if (code64)
             env->eip = env->lstar;
         else
             env->eip = env->cstar;
@@ -598,12 +611,12 @@ void kqemu_record_dump(void)
         perror("/tmp/kqemu.stats");
         exit(1);
     }
-    fprintf(f, "total: %lld\n", total);
+    fprintf(f, "total: %" PRId64 "\n", total);
     sum = 0;
     for(i = 0; i < nb_pc_records; i++) {
         r = pr[i];
         sum += r->count;
-        fprintf(f, "%08lx: %lld %0.2f%% %0.2f%%\n", 
+        fprintf(f, "%08lx: %" PRId64 " %0.2f%% %0.2f%%\n", 
                 r->pc, 
                 r->count, 
                 (double)r->count / (double)total * 100.0,