RFC: avoid #ifdef for target cpu list]
-------- Forwarded Message --------
Quoted 14 lines
From: J. Mayer <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: [Qemu-devel] RFC: avoid #ifdef for target cpu list
Date: Wed, 10 Oct 2007 07:14:22 +0200This tiny patch unifies the -cpu ? option for all cpu that actually can handle it.
It changes thearm_cpu_listto use the same prototype as ppc, mips and sparc and add a new definecpu_listintarget_xxx/cpu.h
As the cpu selection is not implemented for all targets, I had to protect the call tocpu_listwith a #ifdefined(cpu_list)that will have to be suppressed once all target will implement this feature.
Quoted 1 line
Please comment.
If there is no objection about it, I'll apply it today.
Signature · 2 lines
J. Mayer <[email protected]> Never organized
[Qemu-devel] RFC: avoid #ifdef for target cpu list - for x86, too.
This seems like a good excuse to send my suggested -cpu option for the x86 target. It is just like my previous "take 4", but fits to the newly unified cpu_list.
Index: hw/pc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/pc.c,v
retrieving revision 1.87
pc.c +10 -3
@@ -667,7 +667,7 @@ static void pc_init1(int ram_size, int v 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;
@@ -683,6 +683,13 @@ static void pc_init1(int ram_size, int v 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 )
@@ -951,7 +958,7 @@ static void pc_init_pci(int ram_size, inpc_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(int ram_size, int vga_ram_size, int boot_device,
@@ -965,7 +972,7 @@ static void pc_init_isa(int ram_size, inpc_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 = {
Index: target-i386/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-i386/cpu.h,v
retrieving revision 1.50
cpu.h +38 -1
@@ -274,23 +274,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 EXCP00_DIVZ 0#define EXCP01_SSTP 1
@@ -564,6 +597,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);
@@ -687,6 +723,7 @@ static inline int cpu_get_time_fast(void#define cpu_exec cpu_x86_exec#define cpu_gen_code cpu_x86_gen_code#define cpu_signal_handler cpu_x86_signal_handler +#define cpu_list x86_cpu_list#include "cpu-all.h"
Index: target-i386/helper2.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/helper2.c,v retrieving revision 1.52
helper2.c +266 -59
350 lines not on this page · raw message
Re: [Qemu-devel] RFC: avoid #ifdef for target cpu list - for x86, too.
Quoted 3 lines · Dan Kenigsberg
This seems like a good excuse to send my suggested -cpu option for the x86 target. It is just like my previous "take 4", but fits to the newly unified
cpu_list.
I don't know x86 so well to comment the x86 CPU definitions, but having this option for x86 too is welcome...
[...]
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Re: [Qemu-devel] RFC: avoid #ifdef for target cpu list - for x86, too.
In reply to Dan KenigsbergQuoted 3 lines · Dan Kenigsberg
This seems like a good excuse to send my suggested -cpu option for the x86 target. It is just like my previous "take 4", but fits to the newly unified
cpu_list.
Leads to an instant segfault for the i386 usermode emulation.
Thiemo
Re: [Qemu-devel] RFC: avoid #ifdef for target cpu list - for x86, too.
Quoted 7 lines · Thiemo Seufer
Quoted 3 lines · Dan Kenigsberg
This seems like a good excuse to send my suggested -cpu option for the x86 target. It is just like my previous "take 4", but fits to the newly unified
cpu_list.Leads to an instant segfault for the i386 usermode emulation.
Ouch. You are NOT my alpha tester, but I suspect that
target-i386/helper2.c +1 -1
@@ -97,7 +97,7 @@ static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, uint32_treturn ; }for ( i =0 ; i <32 ; i++ ) -if (ext3_feature[i] && !strcmp (flagname, ext3_feature_name[i])) { +if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) { *ext3_features |=1 << i;return ; }
is my embarrassing typo. I resubmit the whole thing below:
hw/pc.c +10 -3
@@ -667,7 +667,7 @@ static void pc_init1(int 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;
@@ -683,6 +683,13 @@ static void pc_init1(int 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 )
@@ -951,7 +958,7 @@ static void pc_init_pci(int 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(int ram_size, int vga_ram_size, int boot_device,
@@ -965,7 +972,7 @@ static void pc_init_isa(int 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 = {
target-i386/cpu.h +38 -1
@@ -274,23 +274,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 EXCP00_DIVZ 0#define EXCP01_SSTP 1
@@ -566,6 +599,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);
@@ -689,6 +725,7 @@ static inline int cpu_get_time_fast(void)#define cpu_exec cpu_x86_exec#define cpu_gen_code cpu_x86_gen_code#define cpu_signal_handler cpu_x86_signal_handler +#define cpu_list x86_cpu_list/* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel
target-i386/helper2.c +266 -59
350 lines not on this page · raw message