All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: OpenBSD 4.1 failes with kvm-45
       [not found] ` <200710101500.27733.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
@ 2007-10-10 10:56   ` Izik Eidus
       [not found]     ` <470CAFD2.80803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Izik Eidus @ 2007-10-10 10:56 UTC (permalink / raw)
  To: Oliver Kowalke; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Oliver Kowalke wrote:
> Hi,
> I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in) with 
> kvm-45 running.
> WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
> I've only a problem running OpenBSD-4.1 (i386). The installation succeeded, 
> but if I start OpenBSD I get following error:
>
> cpu0: QEMU Virtual CPU version 0.9.0 
> cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault trap, 
> code=0
>   
can you try runing it with -no-kvm?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]     ` <470CAFD2.80803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-10-10 12:17       ` Alexey Eremenko
       [not found]         ` <7fac565a0710100517x68f4149av8d6a63741cda07bd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2007-10-10 12:34       ` Dan Kenigsberg
  1 sibling, 1 reply; 12+ messages in thread
From: Alexey Eremenko @ 2007-10-10 12:17 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On 10/10/07, Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> Oliver Kowalke wrote:
> > Hi,
> > I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in) with
> > kvm-45 running.
> > WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
> > I've only a problem running OpenBSD-4.1 (i386). The installation succeeded,
> > but if I start OpenBSD I get following error:
> >
> > cpu0: QEMU Virtual CPU version 0.9.0
> > cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault trap,
> > code=0

This is strange, because I have OpenBSD running fine on KVM-45.

Which CPU ? Intel or AMD?

please do:
modinfo kvm_intel
modinfo kvm_amd

-- 
-Alexey Eremenko "Technologov"

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]     ` <470CAFD2.80803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  2007-10-10 12:17       ` Alexey Eremenko
@ 2007-10-10 12:34       ` Dan Kenigsberg
       [not found]         ` <200710102211.03162.oliver.kowalke@gmx.de>
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Kenigsberg @ 2007-10-10 12:34 UTC (permalink / raw)
  To: Izik Eidus; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Oliver Kowalke

On Wed, Oct 10, 2007 at 12:56:18PM +0200, Izik Eidus wrote:
> Oliver Kowalke wrote:
> > Hi,
> > I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in) with 
> > kvm-45 running.
> > WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
> > I've only a problem running OpenBSD-4.1 (i386). The installation succeeded, 
> > but if I start OpenBSD I get following error:
> >
> > cpu0: QEMU Virtual CPU version 0.9.0 
> > cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault trap, 
> > code=0
> >   
> can you try runing it with -no-kvm?

It might also be useful to try the following patch, that lets you choose
the cpu that is exposed to your guest. (try the option -cpu pentium2 )

==================

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 4d0bb93..bf4d35a 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -683,7 +683,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
-                     int pci_enabled)
+                     int pci_enabled, const char *cpu_model)
 {
     char buf[1024];
     int ret, linux_boot, i;
@@ -705,6 +705,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     linux_boot = (kernel_filename != NULL);
 
     /* init CPUs */
+    if (cpu_model == NULL)
+        cpu_model = "basic";
+    
+    if (x86_find_cpu_by_name(cpu_model)) {
+        fprintf(stderr, "Unable to find x86 CPU definition\n");
+        exit(1);
+    }
     for(i = 0; i < smp_cpus; i++) {
         env = cpu_init();
         if (i != 0)
@@ -1008,7 +1015,7 @@ static void pc_init_pci(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 1);
+             initrd_filename, 1, cpu_model);
 }
 
 static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size, int boot_device,
@@ -1022,7 +1029,7 @@ static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 0);
+             initrd_filename, 0, cpu_model);
 }
 
 QEMUMachine pc_machine = {
diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index de2669e..7517699 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -280,21 +280,56 @@
 #define CPUID_CMOV (1 << 15)
 #define CPUID_PAT  (1 << 16)
 #define CPUID_PSE36   (1 << 17)
+#define CPUID_PN   (1 << 18)
 #define CPUID_CLFLUSH (1 << 19)
-/* ... */
+#define CPUID_DTS (1 << 21)
+#define CPUID_ACPI (1 << 22)
 #define CPUID_MMX  (1 << 23)
 #define CPUID_FXSR (1 << 24)
 #define CPUID_SSE  (1 << 25)
 #define CPUID_SSE2 (1 << 26)
+#define CPUID_SS (1 << 27)
+#define CPUID_HT (1 << 28)
+#define CPUID_TM (1 << 29)
+#define CPUID_IA64 (1 << 30)
+#define CPUID_PBE (1 << 31)
 
 #define CPUID_EXT_SSE3     (1 << 0)
 #define CPUID_EXT_MONITOR  (1 << 3)
+#define CPUID_EXT_DSCPL    (1 << 4)
+#define CPUID_EXT_VMX      (1 << 5)
+#define CPUID_EXT_SMX      (1 << 6)
+#define CPUID_EXT_EST      (1 << 7)
+#define CPUID_EXT_TM2      (1 << 8)
+#define CPUID_EXT_SSSE3    (1 << 9)
+#define CPUID_EXT_CID      (1 << 10)
 #define CPUID_EXT_CX16     (1 << 13)
+#define CPUID_EXT_XTPR     (1 << 14)
+#define CPUID_EXT_DCA      (1 << 17)
+#define CPUID_EXT_POPCNT   (1 << 22)
 
 #define CPUID_EXT2_SYSCALL (1 << 11)
+#define CPUID_EXT2_MP      (1 << 19)
 #define CPUID_EXT2_NX      (1 << 20)
+#define CPUID_EXT2_MMXEXT  (1 << 22)
 #define CPUID_EXT2_FFXSR   (1 << 25)
+#define CPUID_EXT2_PDPE1GB (1 << 26)
+#define CPUID_EXT2_RDTSCP  (1 << 27)
 #define CPUID_EXT2_LM      (1 << 29)
+#define CPUID_EXT2_3DNOWEXT (1 << 30)
+#define CPUID_EXT2_3DNOW   (1 << 31)
+
+#define CPUID_EXT3_LAHF_LM (1 << 0)
+#define CPUID_EXT3_CMP_LEG (1 << 1)
+#define CPUID_EXT3_SVM     (1 << 2)
+#define CPUID_EXT3_EXTAPIC (1 << 3)
+#define CPUID_EXT3_CR8LEG  (1 << 4)
+#define CPUID_EXT3_ABM     (1 << 5)
+#define CPUID_EXT3_SSE4A   (1 << 6)
+#define CPUID_EXT3_MISALIGNSSE (1 << 7)
+#define CPUID_EXT3_3DNOWPREFETCH (1 << 8)
+#define CPUID_EXT3_OSVW    (1 << 9)
+#define CPUID_EXT3_IBS     (1 << 10)
 
 #define CPUID_EXT3_SVM     (1 << 2)
 
@@ -581,6 +616,9 @@ typedef struct CPUX86State {
 CPUX86State *cpu_x86_init(void);
 int cpu_x86_exec(CPUX86State *s);
 void cpu_x86_close(CPUX86State *s);
+int x86_find_cpu_by_name (const unsigned char *name);
+void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt,
+                                                 ...));
 int cpu_get_pic_interrupt(CPUX86State *s);
 /* MSDOS compatibility mode FPU exception support */
 void cpu_set_ferr(CPUX86State *s);
diff --git a/qemu/target-i386/helper2.c b/qemu/target-i386/helper2.c
index b0e9692..ca8d5ed 100644
--- a/qemu/target-i386/helper2.c
+++ b/qemu/target-i386/helper2.c
@@ -52,6 +52,76 @@ int modify_ldt(int func, void *ptr, unsigned long bytecount)
 
 extern const char *cpu_vendor_string;
 
+static struct x86_def_t *x86_cpu_def;
+typedef struct x86_def_t x86_def_t;
+static int cpu_x86_register (CPUX86State *env, const x86_def_t *def);
+
+static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, uint32_t *ext_features, uint32_t *ext2_features, uint32_t *ext3_features)
+{
+    int i;
+    /* feature flags taken from "Intel Processor Identification and the CPUID
+     * Instruction" and AMD's "CPUID Specification". In cases of disagreement 
+     * about feature names, the Linux name is used. */
+    const char *feature_name[] = {
+        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
+        "pat", "pse36", "pn" /* Intel psn */, "clflush" /* Intel clfsh */, NULL, "ds" /* Intel dts */, "acpi", "mmx",
+        "fxsr", "sse", "sse2", "ss", "ht" /* Intel htt */, "tm", "ia64", "pbe",
+    };
+    const char *ext_feature_name[] = {
+	"pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
+	"tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
+	NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    };
+    const char *ext2_feature_name[] = {
+	"fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+	"cx8" /* AMD CMPXCHG8B */, "apic", NULL, "syscall", "mttr", "pge", "mca", "cmov",
+	"pat", "pse36", NULL, NULL /* Linux mp */, "nx" /* Intel xd */, NULL, "mmxext", "mmx",
+	"fxsr", "fxsr_opt" /* AMD ffxsr */, "pdpe1gb" /* AMD Page1GB */, "rdtscp", NULL, "lm" /* Intel 64 */, "3dnowext", "3dnow",
+    };
+    const char *ext3_feature_name[] = {
+	"lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD ExtApicSpace */, "cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
+	"3dnowprefetch", "osvw", NULL /* Linux ibs */, NULL, "skinit", "wdt", NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    };
+
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
+            *features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
+            *ext_features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
+            *ext2_features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext3_features[i] && !strcmp (flagname, ext3_feature_name[i])) {
+            *ext3_features |= 1 << i;
+            return;
+        }
+    fprintf(stderr, "CPU feature %s not found\n", flagname);
+}
+
+#if defined(HOST_I386) || defined(HOST_X86_64)
+static void host_cpuid (uint32_t function, uint32_t *ax,uint32_t *bx, uint32_t *cx, uint32_t *dx)
+{
+    asm("cpuid"
+        : "=a" (*ax),
+          "=b" (*bx),
+          "=c" (*cx),
+          "=d" (*dx)
+        : "a" (function));
+}
+#endif
+
 CPUX86State *cpu_x86_init(void)
 {
     CPUX86State *env;
@@ -86,70 +156,7 @@ CPUX86State *cpu_x86_init(void)
         asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7));
     }
 #endif
-    {
-        int family, model, stepping;
-#ifdef TARGET_X86_64
-        env->cpuid_vendor1 = 0x68747541; /* "Auth" */
-        env->cpuid_vendor2 = 0x69746e65; /* "enti" */
-        env->cpuid_vendor3 = 0x444d4163; /* "cAMD" */
-        family = 6;
-        model = 2;
-        stepping = 3;
-#else
-        env->cpuid_vendor1 = 0x756e6547; /* "Genu" */
-        env->cpuid_vendor2 = 0x49656e69; /* "ineI" */
-        env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */
-#if 0
-        /* pentium 75-200 */
-        family = 5;
-        model = 2;
-        stepping = 11;
-#else
-        /* pentium pro */
-        family = 6;
-        model = 3;
-        stepping = 3;
-#endif
-#endif
-        env->cpuid_level = 2;
-        env->cpuid_version = (family << 8) | (model << 4) | stepping;
-        env->cpuid_features = (CPUID_FP87 | CPUID_DE | CPUID_PSE |
-                               CPUID_TSC | CPUID_MSR | CPUID_MCE |
-                               CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
-                               CPUID_PAT);
-        env->pat = 0x0007040600070406ULL;
-        env->cpuid_ext3_features = CPUID_EXT3_SVM;
-        env->cpuid_ext_features = CPUID_EXT_SSE3;
-        env->cpuid_features |= CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 | CPUID_PAE | CPUID_SEP;
-        env->cpuid_features |= CPUID_APIC;
-        env->cpuid_xlevel = 0x8000000e;
-        {
-            const char *model_id = "QEMU Virtual CPU version " QEMU_VERSION;
-            int c, len, i;
-
-            if (cpu_vendor_string != NULL)
-		model_id = cpu_vendor_string;
-
-            len = strlen(model_id);
-            for(i = 0; i < 48; i++) {
-                if (i >= len)
-                    c = '\0';
-                else
-                    c = model_id[i];
-                env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
-            }
-        }
-#ifdef TARGET_X86_64
-        /* currently not enabled for std i386 because not fully tested */
-        env->cpuid_ext2_features = (env->cpuid_features & 0x0183F3FF);
-        env->cpuid_ext2_features |= CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX;
-
-        /* these features are needed for Win64 and aren't fully implemented */
-        env->cpuid_features |= CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA;
-        /* this feature is needed for Solaris and isn't fully implemented */
-        env->cpuid_features |= CPUID_PSE36;
-#endif
-    }
+    cpu_x86_register(env, x86_cpu_def);
     cpu_reset(env);
 #ifdef USE_KQEMU
     kqemu_init(env);
@@ -166,6 +173,252 @@ CPUX86State *cpu_x86_init(void)
     return env;
 }
 
+struct x86_def_t {
+    const char *name;
+    uint32_t vendor1, vendor2, vendor3;
+    int family;
+    int model;
+    int stepping;
+    uint32_t features, ext_features, ext2_features, ext3_features;
+    uint32_t xlevel;
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    int hostlike;
+#endif
+};
+
+#define PPRO_FEATURES (CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC | \
+          CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV | \
+          CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 | \
+          CPUID_PAE | CPUID_SEP | CPUID_APIC)
+static x86_def_t x86_defs[] = {
+#ifdef TARGET_X86_64
+    {
+        .name = "basic",
+        .vendor1 = 0x68747541, /* "Auth" */
+        .vendor2 = 0x69746e65, /* "enti" */
+        .vendor3 = 0x444d4163, /* "cAMD" */
+        .family = 6,
+        .model = 2,
+        .stepping = 3,
+        .features = PPRO_FEATURES | 
+        /* these features are needed for Win64 and aren't fully implemented */
+            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
+        /* this feature is needed for Solaris and isn't fully implemented */
+            CPUID_PSE36,
+        .ext_features = CPUID_EXT_SSE3,
+        .ext2_features = (PPRO_FEATURES & 0x0183F3FF) | 
+            CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
+        .xlevel = 0x80000008,
+    },
+#else
+    {
+        .name = "basic",
+        .family = 6,
+        .model = 3,
+        .stepping = 3,
+        .features = PPRO_FEATURES,
+        .ext_features = CPUID_EXT_SSE3,
+        .xlevel = 0,
+    },
+#endif
+    {
+        .name = "486",
+        .family = 4,
+        .model = 0,
+        .stepping = 0,
+        .features = 0x0000000B,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium",
+        .family = 5,
+        .model = 4,
+        .stepping = 3,
+        .features = 0x008001BF,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium2",
+        .family = 6,
+        .model = 5,
+        .stepping = 2,
+        .features = 0x0183F9FF,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium3",
+        .family = 6,
+        .model = 7,
+        .stepping = 3,
+        .features = 0x0383F9FF,
+        .xlevel = 0,
+    },
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    {
+        .name = "host",
+        .hostlike = 1,
+    },
+#endif
+};
+
+int x86_find_cpu_by_name(const unsigned char *cpu_model)
+{
+    int ret;
+    unsigned int i;
+
+    char *s = strdup(cpu_model);
+    char *featurestr, *name = strtok(s, ",");
+    uint32_t plus_features = 0, plus_ext_features = 0, plus_ext2_features = 0, plus_ext3_features = 0;
+    uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0;
+    int family = -1, model = -1, stepping = -1;
+
+    ret = -1;
+    x86_cpu_def = NULL;
+    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) {
+        if (strcasecmp(name, x86_defs[i].name) == 0) {
+            x86_cpu_def = &x86_defs[i];
+            ret = 0;
+            break;
+        }
+    }
+    if (!x86_cpu_def)
+        goto error;
+ 
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    if (x86_cpu_def->hostlike) {
+        uint32_t ax, bx, cx, dx;
+        host_cpuid(0, &ax, &bx, &cx, &dx);
+        /* we ignore ax and take level=2 always */;
+        x86_cpu_def->vendor1 = bx;
+        x86_cpu_def->vendor2 = dx;
+        x86_cpu_def->vendor3 = cx;
+
+        host_cpuid(1, &ax, &bx, &cx, &dx);
+        x86_cpu_def->stepping = ax & 0xf;
+        x86_cpu_def->model = (ax >> 4) & 0xf;
+        x86_cpu_def->family = ax >> 8;
+        x86_cpu_def->features = dx & ~CPUID_ACPI; /* acpi panics linux guests */
+        x86_cpu_def->ext_features = cx & ~CPUID_EXT_VMX; /* vmx is not recursive */
+
+        /* host_cpuid(0x80000000, &ax, &bx, &cx, &dx); */
+        x86_cpu_def->xlevel = 0x80000008 /*ax*/;
+
+        host_cpuid(0x80000001, &ax, &bx, &cx, &dx);
+        /* svm is not recursive - unless Alexander Graf's SVM patch is applied */
+        x86_cpu_def->ext3_features = cx & ~CPUID_EXT3_SVM;
+        x86_cpu_def->ext2_features = dx;
+    }
+#endif
+
+    featurestr = strtok(NULL, ",");
+
+    while (featurestr) {
+        char *val;
+        if (featurestr[0] == '+') {
+            add_flagname_to_bitmaps(featurestr + 1, &plus_features, &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+        } else if (featurestr[0] == '-') {
+            add_flagname_to_bitmaps(featurestr + 1, &minus_features, &minus_ext_features, &minus_ext2_features, &minus_ext3_features);
+        } else if ((val = strchr(featurestr, '='))) {
+            *val = 0; val++;
+            if (!strcmp(featurestr, "family")) {
+                char *err;
+                family = strtol(val, &err, 10);
+                if (!*val || *err || family < 0) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->family = family;
+            } else if (!strcmp(featurestr, "model")) {
+                char *err;
+                model = strtol(val, &err, 10);
+                if (!*val || *err || model < 0 || model > 0xf) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->model = model;
+            } else if (!strcmp(featurestr, "stepping")) {
+                char *err;
+                stepping = strtol(val, &err, 10);
+                if (!*val || *err || stepping < 0 || stepping > 0xf) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->stepping = stepping;
+            } else {
+                fprintf(stderr, "unregnized feature %s\n", featurestr);
+                x86_cpu_def = 0;
+                goto error;
+            }
+        } else {
+            fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
+            x86_cpu_def = 0;
+            goto error;
+        }
+        featurestr = strtok(NULL, ",");
+    }
+    x86_cpu_def->features |= plus_features;
+    x86_cpu_def->ext_features |= plus_ext_features;
+    x86_cpu_def->ext2_features |= plus_ext2_features;
+    x86_cpu_def->ext3_features |= plus_ext3_features;
+    x86_cpu_def->features &= ~minus_features;
+    x86_cpu_def->ext_features &= ~minus_ext_features;
+    x86_cpu_def->ext2_features &= ~minus_ext2_features;
+    x86_cpu_def->ext3_features &= ~minus_ext3_features;
+
+error:
+    free(s);
+    return ret;
+}
+
+void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+{
+    unsigned int i;
+
+    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++)
+        (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name);
+}
+
+int cpu_x86_register (CPUX86State *env, const x86_def_t *def)
+{
+    if (def->vendor1) {
+        env->cpuid_vendor1 = def->vendor1;
+        env->cpuid_vendor2 = def->vendor2;
+        env->cpuid_vendor3 = def->vendor3;
+    } else {
+        env->cpuid_vendor1 = 0x756e6547; /* "Genu" */
+        env->cpuid_vendor2 = 0x49656e69; /* "ineI" */
+        env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */
+    }
+    env->cpuid_level = 2;
+    env->cpuid_version = (def->family << 8) | (def->model << 4) | def->stepping;
+    env->cpuid_features = def->features;
+    env->pat = 0x0007040600070406ULL;
+    env->cpuid_ext_features = def->ext_features;
+    env->cpuid_ext2_features = def->ext2_features;
+    env->cpuid_xlevel = def->xlevel;
+    env->cpuid_ext3_features = def->ext3_features;
+    {
+        const char *model_id = "QEMU Virtual CPU version " QEMU_VERSION;
+        int c, len, i;
+
+        if (cpu_vendor_string != NULL)
+            model_id = cpu_vendor_string;
+
+        len = strlen(model_id);
+        for(i = 0; i < 48; i++) {
+            if (i >= len)
+                c = '\0';
+            else
+                c = model_id[i];
+            env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
+        }
+    }
+    return 0;
+}
+
 /* NOTE: must be called outside the CPU execute loop */
 void cpu_reset(CPUX86State *env)
 {
@@ -203,7 +456,7 @@ void cpu_reset(CPUX86State *env)
     cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffff, 0);
 
     env->eip = 0xfff0;
-    env->regs[R_EDX] = 0x600; /* indicate P6 processor */
+    env->regs[R_EDX] = env->cpuid_version;
 
     env->eflags = 0x2;
 
diff --git a/qemu/vl.c b/qemu/vl.c
index 634fb34..afda3f2 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8087,6 +8087,8 @@ int main(int argc, char **argv)
                     mips_cpu_list(stdout, &fprintf);
 #elif defined(TARGET_SPARC)
                     sparc_cpu_list(stdout, &fprintf);
+#elif defined(TARGET_I386)
+                    x86_cpu_list(stdout, &fprintf);
 #endif
                     exit(0);
                 } else {

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* OpenBSD 4.1 failes with kvm-45
@ 2007-10-10 13:00 Oliver Kowalke
       [not found] ` <200710101500.27733.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kowalke @ 2007-10-10 13:00 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,
I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in) with 
kvm-45 running.
WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
I've only a problem running OpenBSD-4.1 (i386). The installation succeeded, 
but if I start OpenBSD I get following error:

cpu0: QEMU Virtual CPU version 0.9.0 
cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault trap, 
code=0

It was started with:

/opt/kvm/bin/kvm \
-hda /srv/openbsd_4.1_32.qcow \
-full-screen \
-boot c \
-localtime \
-m 1024 \
-no-acpi \
-soundhw es1370 \
-usb -usbdevice tablet \
-net nic,vlan=0 \
-net tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup

Any hint to solve this problem?!

kind regards, Oliver

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]             ` <200710101936.10007.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
@ 2007-10-10 15:39               ` Avi Kivity
  0 siblings, 0 replies; 12+ messages in thread
From: Avi Kivity @ 2007-10-10 15:39 UTC (permalink / raw)
  To: Oliver Kowalke; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Oliver Kowalke wrote:
> Am Mittwoch, 10. Oktober 2007 14:17:56 schrieb Alexey Eremenko:
>   
>> On 10/10/07, Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>>     
>>> Oliver Kowalke wrote:
>>>       
>>>> Hi,
>>>> I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in)
>>>> with kvm-45 running.
>>>> WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
>>>> I've only a problem running OpenBSD-4.1 (i386). The installation
>>>> succeeded, but if I start OpenBSD I get following error:
>>>>
>>>> cpu0: QEMU Virtual CPU version 0.9.0
>>>> cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault
>>>> trap, code=0
>>>>         
>> This is strange, because I have OpenBSD running fine on KVM-45.
>>
>> Which CPU ? Intel or AMD?
>>
>> please do:
>> modinfo kvm_intel
>> modinfo kvm_amd
>>     
>
> Hi,
> I'm using Intel c2d 6600 and I've compiled the kvm spport into the kernel (so 
> no modules).
>   

That means you're using a fairly old version of the kvm kernel 
components.  Perhaps a bug that openbsd hit was fixed later on.

I suggest you try with the kvm-45 modules to be sure.


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]         ` <7fac565a0710100517x68f4149av8d6a63741cda07bd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2007-10-10 17:36           ` Oliver Kowalke
       [not found]             ` <200710101936.10007.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kowalke @ 2007-10-10 17:36 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Am Mittwoch, 10. Oktober 2007 14:17:56 schrieb Alexey Eremenko:
> On 10/10/07, Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> > Oliver Kowalke wrote:
> > > Hi,
> > > I've Debian/Lenny (amd64) with kernel 2.6.22-9 (kvm-support build in)
> > > with kvm-45 running.
> > > WinXP, FreeBSD-6.2 (i386) and NetBSD-3.1 (i386) are working.
> > > I've only a problem running OpenBSD-4.1 (i386). The installation
> > > succeeded, but if I start OpenBSD I get following error:
> > >
> > > cpu0: QEMU Virtual CPU version 0.9.0
> > > cpu0: unknown i686 model 2, can't get bus clockkernel: protection fault
> > > trap, code=0
>
> This is strange, because I have OpenBSD running fine on KVM-45.
>
> Which CPU ? Intel or AMD?
>
> please do:
> modinfo kvm_intel
> modinfo kvm_amd

Hi,
I'm using Intel c2d 6600 and I've compiled the kvm spport into the kernel (so 
no modules).
regards, Oliver

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]               ` <200710101938.55042.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
@ 2007-10-11  7:57                 ` Dan Kenigsberg
       [not found]                   ` <20071011075719.GA7547-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Kenigsberg @ 2007-10-11  7:57 UTC (permalink / raw)
  To: Oliver Kowalke; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

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

On Wed, Oct 10, 2007 at 07:38:55PM +0200, Oliver Kowalke wrote:
> Will this patch be included into the new kvm version (46)?
> 

No. Hopefully it will be included in a near future version of kvm.

> 
> hmm - Iget an error:
> patch -p1 < ./qemu.patch
> 
> patching file qemu/hw/pc.c
> patch: **** malformed patch at line 6:                       DisplayState *ds, 
> const char **fd_filename, int snapshot,
> 
> regards, Oliver

I might be wrong, but this sounds like a patch gone bad by the mail
system, since here I get clean and quite patch relative to both kvm-45
and kvm-46. I'll try to resend as attachment.

Regards,

Dan.

[-- Attachment #2: cpuid.diff --]
[-- Type: text/plain, Size: 19449 bytes --]

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 4d0bb93..bf4d35a 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -683,7 +683,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
-                     int pci_enabled)
+                     int pci_enabled, const char *cpu_model)
 {
     char buf[1024];
     int ret, linux_boot, i;
@@ -705,6 +705,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     linux_boot = (kernel_filename != NULL);
 
     /* init CPUs */
+    if (cpu_model == NULL)
+        cpu_model = "basic";
+    
+    if (x86_find_cpu_by_name(cpu_model)) {
+        fprintf(stderr, "Unable to find x86 CPU definition\n");
+        exit(1);
+    }
     for(i = 0; i < smp_cpus; i++) {
         env = cpu_init();
         if (i != 0)
@@ -1008,7 +1015,7 @@ static void pc_init_pci(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 1);
+             initrd_filename, 1, cpu_model);
 }
 
 static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size, int boot_device,
@@ -1022,7 +1029,7 @@ static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size, int boot_device,
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 0);
+             initrd_filename, 0, cpu_model);
 }
 
 QEMUMachine pc_machine = {
diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index de2669e..7517699 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -280,21 +280,56 @@
 #define CPUID_CMOV (1 << 15)
 #define CPUID_PAT  (1 << 16)
 #define CPUID_PSE36   (1 << 17)
+#define CPUID_PN   (1 << 18)
 #define CPUID_CLFLUSH (1 << 19)
-/* ... */
+#define CPUID_DTS (1 << 21)
+#define CPUID_ACPI (1 << 22)
 #define CPUID_MMX  (1 << 23)
 #define CPUID_FXSR (1 << 24)
 #define CPUID_SSE  (1 << 25)
 #define CPUID_SSE2 (1 << 26)
+#define CPUID_SS (1 << 27)
+#define CPUID_HT (1 << 28)
+#define CPUID_TM (1 << 29)
+#define CPUID_IA64 (1 << 30)
+#define CPUID_PBE (1 << 31)
 
 #define CPUID_EXT_SSE3     (1 << 0)
 #define CPUID_EXT_MONITOR  (1 << 3)
+#define CPUID_EXT_DSCPL    (1 << 4)
+#define CPUID_EXT_VMX      (1 << 5)
+#define CPUID_EXT_SMX      (1 << 6)
+#define CPUID_EXT_EST      (1 << 7)
+#define CPUID_EXT_TM2      (1 << 8)
+#define CPUID_EXT_SSSE3    (1 << 9)
+#define CPUID_EXT_CID      (1 << 10)
 #define CPUID_EXT_CX16     (1 << 13)
+#define CPUID_EXT_XTPR     (1 << 14)
+#define CPUID_EXT_DCA      (1 << 17)
+#define CPUID_EXT_POPCNT   (1 << 22)
 
 #define CPUID_EXT2_SYSCALL (1 << 11)
+#define CPUID_EXT2_MP      (1 << 19)
 #define CPUID_EXT2_NX      (1 << 20)
+#define CPUID_EXT2_MMXEXT  (1 << 22)
 #define CPUID_EXT2_FFXSR   (1 << 25)
+#define CPUID_EXT2_PDPE1GB (1 << 26)
+#define CPUID_EXT2_RDTSCP  (1 << 27)
 #define CPUID_EXT2_LM      (1 << 29)
+#define CPUID_EXT2_3DNOWEXT (1 << 30)
+#define CPUID_EXT2_3DNOW   (1 << 31)
+
+#define CPUID_EXT3_LAHF_LM (1 << 0)
+#define CPUID_EXT3_CMP_LEG (1 << 1)
+#define CPUID_EXT3_SVM     (1 << 2)
+#define CPUID_EXT3_EXTAPIC (1 << 3)
+#define CPUID_EXT3_CR8LEG  (1 << 4)
+#define CPUID_EXT3_ABM     (1 << 5)
+#define CPUID_EXT3_SSE4A   (1 << 6)
+#define CPUID_EXT3_MISALIGNSSE (1 << 7)
+#define CPUID_EXT3_3DNOWPREFETCH (1 << 8)
+#define CPUID_EXT3_OSVW    (1 << 9)
+#define CPUID_EXT3_IBS     (1 << 10)
 
 #define CPUID_EXT3_SVM     (1 << 2)
 
@@ -581,6 +616,9 @@ typedef struct CPUX86State {
 CPUX86State *cpu_x86_init(void);
 int cpu_x86_exec(CPUX86State *s);
 void cpu_x86_close(CPUX86State *s);
+int x86_find_cpu_by_name (const unsigned char *name);
+void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt,
+                                                 ...));
 int cpu_get_pic_interrupt(CPUX86State *s);
 /* MSDOS compatibility mode FPU exception support */
 void cpu_set_ferr(CPUX86State *s);
diff --git a/qemu/target-i386/helper2.c b/qemu/target-i386/helper2.c
index b0e9692..ca8d5ed 100644
--- a/qemu/target-i386/helper2.c
+++ b/qemu/target-i386/helper2.c
@@ -52,6 +52,76 @@ int modify_ldt(int func, void *ptr, unsigned long bytecount)
 
 extern const char *cpu_vendor_string;
 
+static struct x86_def_t *x86_cpu_def;
+typedef struct x86_def_t x86_def_t;
+static int cpu_x86_register (CPUX86State *env, const x86_def_t *def);
+
+static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, uint32_t *ext_features, uint32_t *ext2_features, uint32_t *ext3_features)
+{
+    int i;
+    /* feature flags taken from "Intel Processor Identification and the CPUID
+     * Instruction" and AMD's "CPUID Specification". In cases of disagreement 
+     * about feature names, the Linux name is used. */
+    const char *feature_name[] = {
+        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
+        "pat", "pse36", "pn" /* Intel psn */, "clflush" /* Intel clfsh */, NULL, "ds" /* Intel dts */, "acpi", "mmx",
+        "fxsr", "sse", "sse2", "ss", "ht" /* Intel htt */, "tm", "ia64", "pbe",
+    };
+    const char *ext_feature_name[] = {
+	"pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
+	"tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
+	NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    };
+    const char *ext2_feature_name[] = {
+	"fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+	"cx8" /* AMD CMPXCHG8B */, "apic", NULL, "syscall", "mttr", "pge", "mca", "cmov",
+	"pat", "pse36", NULL, NULL /* Linux mp */, "nx" /* Intel xd */, NULL, "mmxext", "mmx",
+	"fxsr", "fxsr_opt" /* AMD ffxsr */, "pdpe1gb" /* AMD Page1GB */, "rdtscp", NULL, "lm" /* Intel 64 */, "3dnowext", "3dnow",
+    };
+    const char *ext3_feature_name[] = {
+	"lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD ExtApicSpace */, "cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
+	"3dnowprefetch", "osvw", NULL /* Linux ibs */, NULL, "skinit", "wdt", NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    };
+
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
+            *features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
+            *ext_features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
+            *ext2_features |= 1 << i;
+            return;
+        }
+    for ( i = 0 ; i < 32 ; i++ ) 
+        if (ext3_features[i] && !strcmp (flagname, ext3_feature_name[i])) {
+            *ext3_features |= 1 << i;
+            return;
+        }
+    fprintf(stderr, "CPU feature %s not found\n", flagname);
+}
+
+#if defined(HOST_I386) || defined(HOST_X86_64)
+static void host_cpuid (uint32_t function, uint32_t *ax,uint32_t *bx, uint32_t *cx, uint32_t *dx)
+{
+    asm("cpuid"
+        : "=a" (*ax),
+          "=b" (*bx),
+          "=c" (*cx),
+          "=d" (*dx)
+        : "a" (function));
+}
+#endif
+
 CPUX86State *cpu_x86_init(void)
 {
     CPUX86State *env;
@@ -86,70 +156,7 @@ CPUX86State *cpu_x86_init(void)
         asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7));
     }
 #endif
-    {
-        int family, model, stepping;
-#ifdef TARGET_X86_64
-        env->cpuid_vendor1 = 0x68747541; /* "Auth" */
-        env->cpuid_vendor2 = 0x69746e65; /* "enti" */
-        env->cpuid_vendor3 = 0x444d4163; /* "cAMD" */
-        family = 6;
-        model = 2;
-        stepping = 3;
-#else
-        env->cpuid_vendor1 = 0x756e6547; /* "Genu" */
-        env->cpuid_vendor2 = 0x49656e69; /* "ineI" */
-        env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */
-#if 0
-        /* pentium 75-200 */
-        family = 5;
-        model = 2;
-        stepping = 11;
-#else
-        /* pentium pro */
-        family = 6;
-        model = 3;
-        stepping = 3;
-#endif
-#endif
-        env->cpuid_level = 2;
-        env->cpuid_version = (family << 8) | (model << 4) | stepping;
-        env->cpuid_features = (CPUID_FP87 | CPUID_DE | CPUID_PSE |
-                               CPUID_TSC | CPUID_MSR | CPUID_MCE |
-                               CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
-                               CPUID_PAT);
-        env->pat = 0x0007040600070406ULL;
-        env->cpuid_ext3_features = CPUID_EXT3_SVM;
-        env->cpuid_ext_features = CPUID_EXT_SSE3;
-        env->cpuid_features |= CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 | CPUID_PAE | CPUID_SEP;
-        env->cpuid_features |= CPUID_APIC;
-        env->cpuid_xlevel = 0x8000000e;
-        {
-            const char *model_id = "QEMU Virtual CPU version " QEMU_VERSION;
-            int c, len, i;
-
-            if (cpu_vendor_string != NULL)
-		model_id = cpu_vendor_string;
-
-            len = strlen(model_id);
-            for(i = 0; i < 48; i++) {
-                if (i >= len)
-                    c = '\0';
-                else
-                    c = model_id[i];
-                env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
-            }
-        }
-#ifdef TARGET_X86_64
-        /* currently not enabled for std i386 because not fully tested */
-        env->cpuid_ext2_features = (env->cpuid_features & 0x0183F3FF);
-        env->cpuid_ext2_features |= CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX;
-
-        /* these features are needed for Win64 and aren't fully implemented */
-        env->cpuid_features |= CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA;
-        /* this feature is needed for Solaris and isn't fully implemented */
-        env->cpuid_features |= CPUID_PSE36;
-#endif
-    }
+    cpu_x86_register(env, x86_cpu_def);
     cpu_reset(env);
 #ifdef USE_KQEMU
     kqemu_init(env);
@@ -166,6 +173,252 @@ CPUX86State *cpu_x86_init(void)
     return env;
 }
 
+struct x86_def_t {
+    const char *name;
+    uint32_t vendor1, vendor2, vendor3;
+    int family;
+    int model;
+    int stepping;
+    uint32_t features, ext_features, ext2_features, ext3_features;
+    uint32_t xlevel;
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    int hostlike;
+#endif
+};
+
+#define PPRO_FEATURES (CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC | \
+          CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV | \
+          CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 | \
+          CPUID_PAE | CPUID_SEP | CPUID_APIC)
+static x86_def_t x86_defs[] = {
+#ifdef TARGET_X86_64
+    {
+        .name = "basic",
+        .vendor1 = 0x68747541, /* "Auth" */
+        .vendor2 = 0x69746e65, /* "enti" */
+        .vendor3 = 0x444d4163, /* "cAMD" */
+        .family = 6,
+        .model = 2,
+        .stepping = 3,
+        .features = PPRO_FEATURES | 
+        /* these features are needed for Win64 and aren't fully implemented */
+            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
+        /* this feature is needed for Solaris and isn't fully implemented */
+            CPUID_PSE36,
+        .ext_features = CPUID_EXT_SSE3,
+        .ext2_features = (PPRO_FEATURES & 0x0183F3FF) | 
+            CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
+        .xlevel = 0x80000008,
+    },
+#else
+    {
+        .name = "basic",
+        .family = 6,
+        .model = 3,
+        .stepping = 3,
+        .features = PPRO_FEATURES,
+        .ext_features = CPUID_EXT_SSE3,
+        .xlevel = 0,
+    },
+#endif
+    {
+        .name = "486",
+        .family = 4,
+        .model = 0,
+        .stepping = 0,
+        .features = 0x0000000B,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium",
+        .family = 5,
+        .model = 4,
+        .stepping = 3,
+        .features = 0x008001BF,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium2",
+        .family = 6,
+        .model = 5,
+        .stepping = 2,
+        .features = 0x0183F9FF,
+        .xlevel = 0,
+    },
+    {
+        .name = "pentium3",
+        .family = 6,
+        .model = 7,
+        .stepping = 3,
+        .features = 0x0383F9FF,
+        .xlevel = 0,
+    },
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    {
+        .name = "host",
+        .hostlike = 1,
+    },
+#endif
+};
+
+int x86_find_cpu_by_name(const unsigned char *cpu_model)
+{
+    int ret;
+    unsigned int i;
+
+    char *s = strdup(cpu_model);
+    char *featurestr, *name = strtok(s, ",");
+    uint32_t plus_features = 0, plus_ext_features = 0, plus_ext2_features = 0, plus_ext3_features = 0;
+    uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0;
+    int family = -1, model = -1, stepping = -1;
+
+    ret = -1;
+    x86_cpu_def = NULL;
+    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) {
+        if (strcasecmp(name, x86_defs[i].name) == 0) {
+            x86_cpu_def = &x86_defs[i];
+            ret = 0;
+            break;
+        }
+    }
+    if (!x86_cpu_def)
+        goto error;
+ 
+#if defined(HOST_I386) || defined(HOST_X86_64)
+    if (x86_cpu_def->hostlike) {
+        uint32_t ax, bx, cx, dx;
+        host_cpuid(0, &ax, &bx, &cx, &dx);
+        /* we ignore ax and take level=2 always */;
+        x86_cpu_def->vendor1 = bx;
+        x86_cpu_def->vendor2 = dx;
+        x86_cpu_def->vendor3 = cx;
+
+        host_cpuid(1, &ax, &bx, &cx, &dx);
+        x86_cpu_def->stepping = ax & 0xf;
+        x86_cpu_def->model = (ax >> 4) & 0xf;
+        x86_cpu_def->family = ax >> 8;
+        x86_cpu_def->features = dx & ~CPUID_ACPI; /* acpi panics linux guests */
+        x86_cpu_def->ext_features = cx & ~CPUID_EXT_VMX; /* vmx is not recursive */
+
+        /* host_cpuid(0x80000000, &ax, &bx, &cx, &dx); */
+        x86_cpu_def->xlevel = 0x80000008 /*ax*/;
+
+        host_cpuid(0x80000001, &ax, &bx, &cx, &dx);
+        /* svm is not recursive - unless Alexander Graf's SVM patch is applied */
+        x86_cpu_def->ext3_features = cx & ~CPUID_EXT3_SVM;
+        x86_cpu_def->ext2_features = dx;
+    }
+#endif
+
+    featurestr = strtok(NULL, ",");
+
+    while (featurestr) {
+        char *val;
+        if (featurestr[0] == '+') {
+            add_flagname_to_bitmaps(featurestr + 1, &plus_features, &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+        } else if (featurestr[0] == '-') {
+            add_flagname_to_bitmaps(featurestr + 1, &minus_features, &minus_ext_features, &minus_ext2_features, &minus_ext3_features);
+        } else if ((val = strchr(featurestr, '='))) {
+            *val = 0; val++;
+            if (!strcmp(featurestr, "family")) {
+                char *err;
+                family = strtol(val, &err, 10);
+                if (!*val || *err || family < 0) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->family = family;
+            } else if (!strcmp(featurestr, "model")) {
+                char *err;
+                model = strtol(val, &err, 10);
+                if (!*val || *err || model < 0 || model > 0xf) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->model = model;
+            } else if (!strcmp(featurestr, "stepping")) {
+                char *err;
+                stepping = strtol(val, &err, 10);
+                if (!*val || *err || stepping < 0 || stepping > 0xf) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    x86_cpu_def = 0;
+                    goto error;
+                }
+                x86_cpu_def->stepping = stepping;
+            } else {
+                fprintf(stderr, "unregnized feature %s\n", featurestr);
+                x86_cpu_def = 0;
+                goto error;
+            }
+        } else {
+            fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
+            x86_cpu_def = 0;
+            goto error;
+        }
+        featurestr = strtok(NULL, ",");
+    }
+    x86_cpu_def->features |= plus_features;
+    x86_cpu_def->ext_features |= plus_ext_features;
+    x86_cpu_def->ext2_features |= plus_ext2_features;
+    x86_cpu_def->ext3_features |= plus_ext3_features;
+    x86_cpu_def->features &= ~minus_features;
+    x86_cpu_def->ext_features &= ~minus_ext_features;
+    x86_cpu_def->ext2_features &= ~minus_ext2_features;
+    x86_cpu_def->ext3_features &= ~minus_ext3_features;
+
+error:
+    free(s);
+    return ret;
+}
+
+void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+{
+    unsigned int i;
+
+    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++)
+        (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name);
+}
+
+int cpu_x86_register (CPUX86State *env, const x86_def_t *def)
+{
+    if (def->vendor1) {
+        env->cpuid_vendor1 = def->vendor1;
+        env->cpuid_vendor2 = def->vendor2;
+        env->cpuid_vendor3 = def->vendor3;
+    } else {
+        env->cpuid_vendor1 = 0x756e6547; /* "Genu" */
+        env->cpuid_vendor2 = 0x49656e69; /* "ineI" */
+        env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */
+    }
+    env->cpuid_level = 2;
+    env->cpuid_version = (def->family << 8) | (def->model << 4) | def->stepping;
+    env->cpuid_features = def->features;
+    env->pat = 0x0007040600070406ULL;
+    env->cpuid_ext_features = def->ext_features;
+    env->cpuid_ext2_features = def->ext2_features;
+    env->cpuid_xlevel = def->xlevel;
+    env->cpuid_ext3_features = def->ext3_features;
+    {
+        const char *model_id = "QEMU Virtual CPU version " QEMU_VERSION;
+        int c, len, i;
+
+        if (cpu_vendor_string != NULL)
+            model_id = cpu_vendor_string;
+
+        len = strlen(model_id);
+        for(i = 0; i < 48; i++) {
+            if (i >= len)
+                c = '\0';
+            else
+                c = model_id[i];
+            env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
+        }
+    }
+    return 0;
+}
+
 /* NOTE: must be called outside the CPU execute loop */
 void cpu_reset(CPUX86State *env)
 {
@@ -203,7 +456,7 @@ void cpu_reset(CPUX86State *env)
     cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffff, 0);
 
     env->eip = 0xfff0;
-    env->regs[R_EDX] = 0x600; /* indicate P6 processor */
+    env->regs[R_EDX] = env->cpuid_version;
 
     env->eflags = 0x2;
 
diff --git a/qemu/vl.c b/qemu/vl.c
index 634fb34..afda3f2 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8087,6 +8087,8 @@ int main(int argc, char **argv)
                     mips_cpu_list(stdout, &fprintf);
 #elif defined(TARGET_SPARC)
                     sparc_cpu_list(stdout, &fprintf);
+#elif defined(TARGET_I386)
+                    x86_cpu_list(stdout, &fprintf);
 #endif
                     exit(0);
                 } else {

[-- Attachment #3: Type: text/plain, Size: 314 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]                   ` <20071011075719.GA7547-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
@ 2007-10-12 23:36                     ` Oliver Kowalke
       [not found]                       ` <200710130136.57068.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kowalke @ 2007-10-12 23:36 UTC (permalink / raw)
  To: Dan Kenigsberg, kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,
I've applied the patch now the kernel detects:
cpu0: Intel Pentium Pro, II or III...
cpu0: FPU,V86,...
But I get in the next line:
kernel: page fault trap, code=0
Stopped at trap+0x16f: testb $0x3,0x38(%ecx)
I don't know what that means.
Hopefuly you could help.
kind regards, Oliver

Am Donnerstag, 11. Oktober 2007 09:57:19 schrieben Sie:
> On Wed, Oct 10, 2007 at 07:38:55PM +0200, Oliver Kowalke wrote:
> > Will this patch be included into the new kvm version (46)?
>
> No. Hopefully it will be included in a near future version of kvm.
>
> > hmm - Iget an error:
> > patch -p1 < ./qemu.patch
> >
> > patching file qemu/hw/pc.c
> > patch: **** malformed patch at line 6:                       DisplayState
> > *ds, const char **fd_filename, int snapshot,
> >
> > regards, Oliver
>
> I might be wrong, but this sounds like a patch gone bad by the mail
> system, since here I get clean and quite patch relative to both kvm-45
> and kvm-46. I'll try to resend as attachment.
>
> Regards,
>
> Dan.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]                       ` <200710130136.57068.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
@ 2007-10-13 20:56                         ` Carlo Marcelo Arenas Belon
  2007-10-14  8:15                           ` Oliver Kowalke
  2007-10-14  7:41                         ` Dan Kenigsberg
  1 sibling, 1 reply; 12+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2007-10-13 20:56 UTC (permalink / raw)
  To: Oliver Kowalke; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Sat, Oct 13, 2007 at 01:36:56AM +0200, Oliver Kowalke wrote:
> Hopefuly you could help.
> kind regards, Oliver

Oliver

several of us are using the newer kvm module with OpenBSD successfully, the
version of kvm included in the debian kernel is the problematic one.

To fix that, remove kvm from your kernel configuration, rebuild your kernel 
and reboot with it, then compile the kvm module provided with kvm and use
that instead.

Carlo

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]                       ` <200710130136.57068.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
  2007-10-13 20:56                         ` Carlo Marcelo Arenas Belon
@ 2007-10-14  7:41                         ` Dan Kenigsberg
       [not found]                           ` <20071014074144.GA32540-iWbx9bcAnq+Hk9JtIoIkgNBPR1lH4CV8@public.gmane.org>
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Kenigsberg @ 2007-10-14  7:41 UTC (permalink / raw)
  To: Oliver Kowalke; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Sat, Oct 13, 2007 at 01:36:56AM +0200, Oliver Kowalke wrote:
> Hi,
> I've applied the patch now the kernel detects:

> cpu0: Intel Pentium Pro, II or III...
> cpu0: FPU,V86,...
> But I get in the next line:
> kernel: page fault trap, code=0
> Stopped at trap+0x16f: testb $0x3,0x38(%ecx)

Apparently, the first two lines that complained on the cpu emulation
have nothing to do with the page fault. Sorry for my wrong lead.

How about first trying kvm-46 as a module, and after this succeeds try
building it into your favorite kernel?

Dan.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
  2007-10-13 20:56                         ` Carlo Marcelo Arenas Belon
@ 2007-10-14  8:15                           ` Oliver Kowalke
  0 siblings, 0 replies; 12+ messages in thread
From: Oliver Kowalke @ 2007-10-14  8:15 UTC (permalink / raw)
  To: Carlo Marcelo Arenas Belon, danken-atKUWr5tajBWk0Htik3J/w,
	kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Am Samstag, 13. Oktober 2007 22:56:08 schrieben Sie:
> On Sat, Oct 13, 2007 at 01:36:56AM +0200, Oliver Kowalke wrote:
> > Hopefuly you could help.
> > kind regards, Oliver
>
> Oliver
>
> several of us are using the newer kvm module with OpenBSD successfully, the
> version of kvm included in the debian kernel is the problematic one.
>
> To fix that, remove kvm from your kernel configuration, rebuild your kernel
> and reboot with it, then compile the kvm module provided with kvm and use
> that instead.
>
> Carlo

Hi Carlo,
I'm not using the kvm modules provided by debian. I'm using the new 2.6.22-9 
kernel (kvm build into the kernel - not as a module).
Doesn't contain the newest kernel the newest kvm?

regards, Oliver

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

* Re: OpenBSD 4.1 failes with kvm-45
       [not found]                           ` <20071014074144.GA32540-iWbx9bcAnq+Hk9JtIoIkgNBPR1lH4CV8@public.gmane.org>
@ 2007-10-17 11:15                             ` Oliver Kowalke
  0 siblings, 0 replies; 12+ messages in thread
From: Oliver Kowalke @ 2007-10-17 11:15 UTC (permalink / raw)
  To: Dan Kenigsberg, kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,
with the new kernel 2.6.23.1 OpenBSD 4.1 works.
Becuase you wrote I should use the nwe modules instead - I didn't got kernel 
modules from kvm-46 taf file. Do I've to download another archive for the 
kernel modules?
regards,
Oliver



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

end of thread, other threads:[~2007-10-17 11:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-10 13:00 OpenBSD 4.1 failes with kvm-45 Oliver Kowalke
     [not found] ` <200710101500.27733.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
2007-10-10 10:56   ` Izik Eidus
     [not found]     ` <470CAFD2.80803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-10 12:17       ` Alexey Eremenko
     [not found]         ` <7fac565a0710100517x68f4149av8d6a63741cda07bd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-10-10 17:36           ` Oliver Kowalke
     [not found]             ` <200710101936.10007.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
2007-10-10 15:39               ` Avi Kivity
2007-10-10 12:34       ` Dan Kenigsberg
     [not found]         ` <200710102211.03162.oliver.kowalke@gmx.de>
     [not found]           ` <200710101938.55042.oliver.kowalke@gmx.de>
     [not found]             ` <200710102211.03162.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
     [not found]               ` <200710101938.55042.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
2007-10-11  7:57                 ` Dan Kenigsberg
     [not found]                   ` <20071011075719.GA7547-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
2007-10-12 23:36                     ` Oliver Kowalke
     [not found]                       ` <200710130136.57068.oliver.kowalke-Mmb7MZpHnFY@public.gmane.org>
2007-10-13 20:56                         ` Carlo Marcelo Arenas Belon
2007-10-14  8:15                           ` Oliver Kowalke
2007-10-14  7:41                         ` Dan Kenigsberg
     [not found]                           ` <20071014074144.GA32540-iWbx9bcAnq+Hk9JtIoIkgNBPR1lH4CV8@public.gmane.org>
2007-10-17 11:15                             ` Oliver Kowalke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.