Support for out-of-code cpu definitions
This patch series adds support for out-of-code cpu definitions. This helps us move the definitions out of target-i386/helper.c. The result is we can store the definitions in plain-text; add, modify the definitions without having to recompile and most importantly, some management servers can define their own CPU types based on the network topology to create migration-safe cpu types.
The first patch in the series was sent earlier, just converts the usage of bios_dir to get_datafile_dir(), as the path that's referred to stores more than just the bios (keymaps, and now, the cpudefs).
The cpudef file currently is very similar to the code that was in helper.c.
Comments welcome on the format.
PATCH 1/4 Introduce get_datafile_dir() to replace bios_dir
bios_dir really is $(PREFIX)/share/qemu/ (or the dir. specified by -L). It currently stores some firmware images and keymaps, so the name bios_dir is really a misnomer.
Replace it with a helper, get_datafile_dir().
--- qemu/hw/mips_jazz.c | 2 +- qemu/hw/mips_malta.c | 2 +- qemu/hw/mips_mipssim.c | 2 +- qemu/hw/mips_r4k.c | 2 +- qemu/hw/pc.c | 8 +++++--- qemu/hw/ppc405_boards.c | 4 ++-- qemu/hw/ppc440_bamboo.c | 6 ++++-- qemu/hw/ppc_chrp.c | 4 ++-- qemu/hw/ppc_oldworld.c | 4 ++-- qemu/hw/ppc_prep.c | 2 +- qemu/hw/sun4m.c | 6 +++--- qemu/hw/sun4u.c | 2 +- qemu/keymaps.c | 2 +- qemu/sysemu.h | 2 +- qemu/vl.c | 19 ++++++++++++++++--- 15 files changed, 42 insertions(+), 25 deletions(-)
qemu/hw/mips_jazz.c +1 -1
@@ -165,7 +165,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size, bios_offset = ram_size + vga_ram_size;if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >MAGNUM_BIOS_SIZE ) { fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
qemu/hw/mips_malta.c +1 -1
@@ -850,7 +850,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,/* Load a BIOS image. */ if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if ((bios_size <0 || bios_size >BIOS_SIZE ) && !kernel_filename) { fprintf(stderr,
qemu/hw/mips_mipssim.c +1 -1
@@ -139,7 +139,7 @@ mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size, bios_offset = ram_size + vga_ram_size;if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if ((bios_size <0 || bios_size >BIOS_SIZE ) && !kernel_filename) {/* Bail out if we have neither a kernel image nor boot vector code. */
qemu/hw/mips_r4k.c +1 -1
@@ -199,7 +199,7 @@ void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size, bios_offset = ram_size + vga_ram_size;if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if ((bios_size >0 ) && (bios_size <=BIOS_SIZE )) { cpu_register_physical_memory(0x1fc00000,
qemu/hw/pc.c +5 -3
@@ -838,7 +838,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,/* BIOS load */ if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =get_image_size (buf);if (bios_size <=0 || (bios_size %65536 ) !=0 ) {
@@ -855,9 +855,11 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {/* VGA BIOS load */ if (cirrus_vga_enabled) { -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir,VGABIOS_CIRRUS_FILENAME ); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), +VGABIOS_CIRRUS_FILENAME ); }else { -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir,VGABIOS_FILENAME ); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), +VGABIOS_FILENAME ); } vga_bios_size =get_image_size (buf);if (vga_bios_size <=0 || vga_bios_size >65536 )
qemu/hw/ppc405_boards.c +2 -2
@@ -238,7 +238,7 @@ static void ref405ep_init (ram_addr_t ram_size, int vga_ram_size,#endif if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >BIOS_SIZE ) {fprintf (stderr,"qemu: could not load PowerPC bios '%s'\n" , buf);
@@ -550,7 +550,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, int vga_ram_size,#endif if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >BIOS_SIZE ) {fprintf (stderr,"qemu: could not load PowerPC bios '%s'\n" , buf);
qemu/hw/ppc440_bamboo.c +4 -2
@@ -40,10 +40,12 @@ static void *bamboo_load_device_tree(void *addr,int pathlen;int ret; - pathlen =snprintf (NULL ,0 ,"%s/%s" , bios_dir,BINARY_DEVICE_TREE_FILE ) +1 ; + pathlen =snprintf (NULL ,0 ,"%s/%s" ,get_datafile_dir (), +BINARY_DEVICE_TREE_FILE ) +1 ; path =qemu_malloc (pathlen); -snprintf (path, pathlen,"%s/%s" , bios_dir,BINARY_DEVICE_TREE_FILE ); +snprintf (path, pathlen,"%s/%s" ,get_datafile_dir (), +BINARY_DEVICE_TREE_FILE ); fdt =load_device_tree (path, addr);free (path);
qemu/hw/ppc_chrp.c +2 -2
@@ -144,7 +144,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, bios_offset =qemu_ram_alloc (BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >BIOS_SIZE ) {cpu_abort (env,"qemu: could not load PowerPC bios '%s'\n" , buf);
@@ -160,7 +160,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,/* allocate and load VGA BIOS */ vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir,VGABIOS_FILENAME ); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (),VGABIOS_FILENAME ); vga_bios_size =load_image (buf, phys_ram_base + vga_bios_offset +8 );if (vga_bios_size <0 ) {/* if no bios is present, we can still work */
qemu/hw/ppc_oldworld.c +2 -2
@@ -178,7 +178,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, bios_offset =qemu_ram_alloc (BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name);cpu_register_physical_memory (PROM_ADDR ,BIOS_SIZE , bios_offset |IO_MEM_ROM );/* Load OpenBIOS (ELF) */
@@ -190,7 +190,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,/* allocate and load VGA BIOS */ vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir,VGABIOS_FILENAME ); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (),VGABIOS_FILENAME ); vga_bios_size =load_image (buf, phys_ram_base + vga_bios_offset +8 );if (vga_bios_size <0 ) {/* if no bios is present, we can still work */
qemu/hw/ppc_prep.c +1 -1
@@ -583,7 +583,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size, bios_offset = ram_size + vga_ram_size;if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >BIOS_SIZE ) {cpu_abort (env,"qemu: could not load PPC PREP bios '%s'\n" , buf);
qemu/hw/sun4m.c +3 -3
@@ -490,7 +490,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,if (bios_name ==NULL ) bios_name =PROM_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); ret =load_elf (buf, hwdef->slavio_base -PROM_VADDR ,NULL ,NULL ,NULL );if (ret <0 || ret >PROM_SIZE_MAX ) ret =load_image_targphys (buf, hwdef->slavio_base,PROM_SIZE_MAX );
@@ -1286,7 +1286,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,if (bios_name ==NULL ) bios_name =PROM_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); ret =load_elf (buf, hwdef->slavio_base -PROM_VADDR ,NULL ,NULL ,NULL );if (ret <0 || ret >PROM_SIZE_MAX ) ret =load_image_targphys (buf, hwdef->slavio_base,PROM_SIZE_MAX );
@@ -1493,7 +1493,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,if (bios_name ==NULL ) bios_name =PROM_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); ret =load_elf (buf, hwdef->slavio_base -PROM_VADDR ,NULL ,NULL ,NULL );if (ret <0 || ret >PROM_SIZE_MAX ) ret =load_image_targphys (buf, hwdef->slavio_base,PROM_SIZE_MAX );
qemu/hw/sun4u.c +1 -1
@@ -449,7 +449,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,if (bios_name ==NULL ) bios_name =PROM_FILENAME ; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +snprintf (buf,sizeof (buf),"%s/%s" ,get_datafile_dir (), bios_name); ret =load_elf (buf, hwdef->prom_addr -PROM_VADDR ,NULL ,NULL ,NULL );if (ret <0 ) { ret = load_image_targphys(buf, hwdef->prom_addr,
qemu/keymaps.c +1 -1
@@ -82,7 +82,7 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,int len;snprintf (file_name,sizeof (file_name), -"%s/keymaps/%s" , bios_dir, language); +"%s/keymaps/%s" ,get_datafile_dir (), language);if (!k) k =qemu_mallocz (sizeof (kbd_layout_t));
qemu/sysemu.h +1 -1
@@ -4,7 +4,7 @@/* vl.c */ extern const char *bios_name; -extern const char *bios_dir; +extern char *get_datafile_dir (void );extern int vm_running;extern const char *qemu_name;
qemu/vl.c +16 -3
@@ -172,7 +172,7 @@/* XXX: use a two level table to limit memory usage */ #define MAX_IOPORTS 65536 -const char *bios_dir =CONFIG_QEMU_SHAREDIR ; +static char datafile_dir[512 ];const char *bios_name =NULL ;static void *ioport_opaque[MAX_IOPORTS ];static IOPortReadFunc *ioport_read_table[3 ][MAX_IOPORTS ];
@@ -4529,6 +4529,17 @@ static void termsig_setup(void)#endif +static void set_datafile_dir (const char *dir) +{ +strncpy (datafile_dir, dir,sizeof (datafile_dir) -1 ); + datafile_dir[sizeof (datafile_dir) -1 ] =0 ; +} + +char *get_datafile_dir (void ) +{ +return datafile_dir; +} +int main (int argc,char **argv,char **envp) {#ifdef CONFIG_GDBSTUB
@@ -4603,6 +4614,7 @@ int main(int argc, char **argv, char **envp) }#endif +set_datafile_dir (CONFIG_QEMU_SHAREDIR );register_machines (); machine = first_machine; cpu_model =NULL ;
@@ -4953,7 +4965,7 @@ int main(int argc, char **argv, char **envp)break ;#endif case QEMU_OPTION_L : - bios_dir = optarg; +set_datafile_dir (optarg);break ;case QEMU_OPTION_bios: bios_name = optarg;
@@ -5373,7 +5385,8 @@ int main(int argc, char **argv, char **envp)if (net_boot & (1 << i)) {if (model ==NULL ) model ="ne2k_pci" ; -snprintf (buf,sizeof (buf),"%s/pxe-%s.bin" , bios_dir, model); +snprintf (buf,sizeof (buf),"%s/pxe-%s.bin" ,get_datafile_dir (), + model);if (get_image_size (buf) >0 ) {if (nb_option_roms >=MAX_OPTION_ROMS ) {fprintf (stderr,"Too many option ROMs\n" );
Signature · 1 line
1.6.0.6
PATCH 2/4 Add independent cpu definitions for the coreduo and core2duo cpu types
Add these cpu definitions in a separate file which facilitates them to be modified and updated without having to recompile. New definitions can also be added without the need to recompile.
The support to actually use these files comes from the patches that follow in this series
--- qemu/target-i386/cpudefs/core2duo | 18 ++++++++++++++++++ qemu/target-i386/cpudefs/coreduo | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-) create mode 100644 qemu/target-i386/cpudefs/core2duo create mode 100644 qemu/target-i386/cpudefs/coreduo
qemu/target-i386/cpudefs/core2duo new file +18 -0
@@ -0,0 +1,18 @@ +level 10 +family 6 +model 15 +stepping 11 + +# The original CPU also implements these features: +# vme dts acpi ss ht tm pbe + +features ppro_features mtrr clflush mca pse36 pni monitor ssse3 lm syscall nx + +# The original CPU also implements these ext features: +# CPUID_EXT_DTES64, ds_cpl vmx est tm2 cx16 xtpr CPUID_EXT_PDCM + +# The original CPU also implements these ext3 features: +# lahf_lm + +xlevel 0x80000008 +model_id "Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz"
qemu/target-i386/cpudefs/coreduo new file +15 -0
@@ -0,0 +1,15 @@ +level 10 +family 6 +model 14 +stepping 8 + +# The original CPU also implements these features: +# dts acpi ss ht tm pbe + +features ppro_features vme mtrr clflush mca pni monitor nx + +# The original CPU also implements these ext features: +# vmx est tm2 xtpr CPUID_EXT_PDCM + +xlevel 0x80000008, +model_id "Genuine Intel(R) CPU T2600 @ 2.16GHz"
Signature · 1 line
1.6.0.6
PATCH 3/4 Update Makefile to copy the cpudef files to install location
The x86 cpudef files are to be copied in $(PREFIX)/share/qemu/cpudefs/
--- qemu/Makefile | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
qemu/Makefile +4 -0
@@ -246,6 +246,10 @@ ifndef CONFIG_WIN32 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \ done endif + + mkdir -p "$(DESTDIR)$(datadir)/cpudefs" + $(INSTALL) -m 644 $(SRC_PATH)/target-i386/cpudefs/* "$(DESTDIR)$(datadir)/cpudefs"; + for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ done
Signature · 1 line
1.6.0.6
PATCH 4/4 Support for cpudef files placed in the share/ directory
This patch adds support to use cpudefs placed in the $(PREFIX)/share/qemu/cpudefs directory.
The various cpu definitions in the code can now be placed there, making things simpler.
--- qemu/target-i386/helper.c | 172 +++++++++++++++++++++++++++++++++----------- 1 files changed, 129 insertions(+), 43 deletions(-)
qemu/target-i386/helper.c +129 -43
@@ -28,6 +28,7 @@#include "cpu.h" #include "exec-all.h" #include "qemu-common.h" +#include "sysemu.h" #include "kvm.h" //#define DEBUG_MMU
@@ -164,27 +165,6 @@ static x86_def_t x86_defs[] = { .xlevel = 0x8000001A, .model_id = "AMD Phenom(tm) 9550 Quad-Core Processor" }, - { - .name = "core2duo", - .level = 10, - .family = 6, - .model = 15, - .stepping = 11, - /* The original CPU also implements these features: - CPUID_VME, CPUID_DTS, CPUID_ACPI, CPUID_SS, CPUID_HT, - CPUID_TM, CPUID_PBE */ - .features = PPRO_FEATURES | - CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | - CPUID_PSE36, - /* The original CPU also implements these ext features: - CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_VMX, CPUID_EXT_EST, - CPUID_EXT_TM2, CPUID_EXT_CX16, CPUID_EXT_XTPR, CPUID_EXT_PDCM */ - .ext_features = CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_SSSE3, - .ext2_features = CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, - /* Missing: .ext3_features = CPUID_EXT3_LAHF_LM */ - .xlevel = 0x80000008, - .model_id = "Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz", - },#endif { .name = "qemu32",
@@ -198,25 +178,6 @@ static x86_def_t x86_defs[] = { .model_id = "QEMU Virtual CPU version " QEMU_VERSION, }, { - .name = "coreduo", - .level = 10, - .family = 6, - .model = 14, - .stepping = 8, -/* The original CPU also implements these features: -CPUID_DTS, CPUID_ACPI, CPUID_SS, CPUID_HT, -CPUID_TM, CPUID_PBE */ - .features =PPRO_FEATURES |CPUID_VME | - CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA, -/* The original CPU also implements these ext features: -CPUID_EXT_VMX, CPUID_EXT_EST, CPUID_EXT_TM2, CPUID_EXT_XTPR, -CPUID_EXT_PDCM */ - .ext_features = CPUID_EXT_SSE3 | CPUID_EXT_MONITOR, - .ext2_features = CPUID_EXT2_NX, - .xlevel = 0x80000008, - .model_id = "Genuine Intel(R) CPU T2600 @ 2.16GHz", - }, - { .name = "486", .level = 0, .family = 4,
@@ -290,6 +251,127 @@ static x86_def_t x86_defs[] = { }, }; +static long get_cpudef_value (char *line,int base) +{ +char *string; + + string =strchr (line,' ' ); +if (!string) +return -1 ; +return strtol (string,NULL , base); +} + +static int get_cpudef_from_file (x86_def_t *x86_cpu_def,const char *cpu_model) +{ +char cpudef_path[1024 ], line[1024 ]; +FILE *fp; + +snprintf (cpudef_path,sizeof (cpudef_path),"%s/cpudefs/%s" , +get_datafile_dir (), cpu_model); + + fp =fopen (cpudef_path,"r" ); +if (!fp) +return -1 ; + + x86_cpu_def->features = x86_cpu_def->ext_features =0 ; + x86_cpu_def->ext2_features = x86_cpu_def->ext3_features =0 ; + +for (;;) { +if (fgets (line,1024 , fp) ==NULL ) +break ; +if (line[0 ] =='#' ) +continue ; +if (!strncmp (line,"level " ,6 )) { + x86_cpu_def->level =get_cpudef_value (line,10 ); +continue ; + } +if (!strncmp (line,"family " ,7 )) { + x86_cpu_def->family =get_cpudef_value (line,10 ); +continue ; + } +if (!strncmp (line,"model " ,6 )) { + x86_cpu_def->model =get_cpudef_value (line,10 ); +continue ; + } +if (!strncmp (line,"stepping " ,9 )) { + x86_cpu_def->stepping =get_cpudef_value (line,10 ); +continue ; + } +if (!strncmp (line,"xlevel " ,7 )) { + x86_cpu_def->xlevel =get_cpudef_value (line,16 ); +continue ; + } +if (!strncmp (line,"model_id " ,9 )) { +char *substr =strchr (line,' ' ); +int i =0 ; + +while (*substr) { +if (*substr =='\n' ) +break ; + +/* Skip to first quote mark */ +if (*substr !='\"' ) { + substr++; +continue ; + } + substr++; +while (i <48 && *substr && *substr !='\"' + && *substr !='\n' ) + x86_cpu_def->model_id[i++] = *substr++; + +break ; + } +continue ; + } +if (!strncmp (line,"features " ,9 )) { +char *substr =strchr (line,' ' ); +char feat[20 ]; + +while (*substr) { +int i; + +if (*substr =='\n' ) +break ; +/* Skip to next feature string */ +else if (!isalnum (*substr)) { + substr++; +continue ; + } + + i =0 ; +/* +* Features only have alphanumeric values (and +* underscores, in some cases). Only allow these +* values. +*/ +while (*substr && (isalnum (*substr) || *substr =='_' )) + feat[i++] = *substr++; + feat[i] =0 ; + +if (!strncmp (feat,"i486_features" ,13 )) + x86_cpu_def->features |=I486_FEATURES ; +else if (!strncmp (feat,"pentium_features" ,16 )) + x86_cpu_def->features |=PENTIUM_FEATURES ; +else if (!strncmp (feat,"pentium2_features" ,17 )) + x86_cpu_def->features |=PENTIUM2_FEATURES ; +else if (!strncmp (feat,"pentium3_features" ,18 )) + x86_cpu_def->features |=PENTIUM3_FEATURES ; +else if (!strncmp (feat,"ppro_features" ,13 )) { + x86_cpu_def->features |=PPRO_FEATURES ; + x86_cpu_def->ext_features |= +PPRO_FEATURES &0x0183F3FF ; + }else +add_flagname_to_bitmaps (feat, &x86_cpu_def->features, + &x86_cpu_def->ext_features, + &x86_cpu_def->ext2_features, + &x86_cpu_def->ext3_features); + } + } +continue ; + } +return 0 ; +} +static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;
@@ -308,9 +390,13 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)break ; } } -if (!def) - goto error; -memcpy (x86_cpu_def, def,sizeof (*def)); +if (!def) { +int r; + r =get_cpudef_from_file (x86_cpu_def, cpu_model); +if (r <0 ) + goto error; + }else +memcpy (x86_cpu_def, def,sizeof (*def)); featurestr =strtok (NULL ,"," );
Signature · 1 line
1.6.0.6
Quoted 8 lines · Amit Shah
This patch series adds support for out-of-code cpu definitions. This helps us move the definitions out of
target-i386/helper.c. The result is we can store the definitions in plain-text; add, modify the definitions without having to recompile and most importantly, some management servers can define their own CPU types based on the network topology to create migration-safe cpu types.
Quoted 7 lines
The first patch in the series was sent earlier, just converts the usage of
bios_dirtoget_datafile_dir(), as the path that's referred to stores more than just the bios (keymaps, and now, the cpudefs).The cpudef file currently is very similar to the code that was in
helper.c.Comments welcome on the format.
Instead of this change, IMHO we should wait for either the configuration file format to be fixed, or use FDT for all HW definitions. This format is not generic enough, definitely not suitable for Sparc CPU features. But if the config or FDT does not appear, we could use this as a starting point.
Quoted 15 lines · Blue Swirl
Quoted 13 lines · Amit Shah
This patch series adds support for out-of-code cpu definitions. This helps us move the definitions out of
target-i386/helper.c. The result is we can store the definitions in plain-text; add, modify the definitions without having to recompile and most importantly, some management servers can define their own CPU types based on the network topology to create migration-safe cpu types.The first patch in the series was sent earlier, just converts the usage of
bios_dirtoget_datafile_dir(), as the path that's referred to stores more than just the bios (keymaps, and now, the cpudefs).The cpudef file currently is very similar to the code that was in
helper.c.
Quoted 9 lines
Quoted 2 lines
Comments welcome on the format.
Instead of this change, IMHO we should wait for either the configuration file format to be fixed, or use FDT for all HW definitions. This format is not generic enough, definitely not suitable for Sparc CPU features. But if the config or FDT does not appear, we could use this as a starting point.
I agree. If you switch cpudef to FDT, that could provide an intermediate step between what we have today and a full machine description.
Regards,
Anthony Liguori