Re: [Qemu-devel] [PATCH 1/7] target-i386: Move feature name arrays inside FeatureWordInfo

2016-09-23 Thread Richard Henderson

On 09/23/2016 12:45 PM, Eduardo Habkost wrote:

It makes it easier to guarantee the arrays are the right size,
and to find information when looking at the code.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 370 +-
 1 file changed, 170 insertions(+), 200 deletions(-)


Reviewed-by: Richard Henderson 


 static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
 [FEAT_1_EDX] = {
-.feat_names = feature_name,
+.feat_names = {
+"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",
+},


Unrelated, but can we make this feature_word_info structure const?  It may 
require the addition of const to other function parameters, in which case the 
change should be a separate patch.



r~



[Qemu-devel] [PATCH 1/7] target-i386: Move feature name arrays inside FeatureWordInfo

2016-09-23 Thread Eduardo Habkost
It makes it easier to guarantee the arrays are the right size,
and to find information when looking at the code.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 370 +-
 1 file changed, 170 insertions(+), 200 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a5d3b1a..cc07fdb 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -181,185 +181,6 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t 
vendor1,
 dst[CPUID_VENDOR_SZ] = '\0';
 }
 
-/* feature flags taken from "Intel Processor Identification and the CPUID
- * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
- * between feature naming conventions, aliases may be added.
- */
-static 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",
-};
-static const char *ext_feature_name[] = {
-"pni|sse3" /* Intel,AMD sse3 */, "pclmulqdq|pclmuldq", "dtes64", "monitor",
-"ds_cpl", "vmx", "smx", "est",
-"tm2", "ssse3", "cid", NULL,
-"fma", "cx16", "xtpr", "pdcm",
-NULL, "pcid", "dca", "sse4.1|sse4_1",
-"sse4.2|sse4_2", "x2apic", "movbe", "popcnt",
-"tsc-deadline", "aes", "xsave", "osxsave",
-"avx", "f16c", "rdrand", "hypervisor",
-};
-/* Feature names that are already defined on feature_name[] but are set on
- * CPUID[8000_0001].EDX on AMD CPUs don't have their names on
- * ext2_feature_name[]. They are copied automatically to cpuid_ext2_features
- * if and only if CPU vendor is AMD.
- */
-static const char *ext2_feature_name[] = {
-NULL /* fpu */, NULL /* vme */, NULL /* de */, NULL /* pse */,
-NULL /* tsc */, NULL /* msr */, NULL /* pae */, NULL /* mce */,
-NULL /* cx8 */ /* AMD CMPXCHG8B */, NULL /* apic */, NULL, "syscall",
-NULL /* mtrr */, NULL /* pge */, NULL /* mca */, NULL /* cmov */,
-NULL /* pat */, NULL /* pse36 */, NULL, NULL /* Linux mp */,
-"nx|xd", NULL, "mmxext", NULL /* mmx */,
-NULL /* fxsr */, "fxsr_opt|ffxsr", "pdpe1gb" /* AMD Page1GB */, "rdtscp",
-NULL, "lm|i64", "3dnowext", "3dnow",
-};
-static const char *ext3_feature_name[] = {
-"lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD 
ExtApicSpace */,
-"cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
-"3dnowprefetch", "osvw", "ibs", "xop",
-"skinit", "wdt", NULL, "lwp",
-"fma4", "tce", NULL, "nodeid_msr",
-NULL, "tbm", "topoext", "perfctr_core",
-"perfctr_nb", NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-};
-
-static const char *ext4_feature_name[] = {
-NULL, NULL, "xstore", "xstore-en",
-NULL, NULL, "xcrypt", "xcrypt-en",
-"ace2", "ace2-en", "phe", "phe-en",
-"pmm", "pmm-en", NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-};
-
-static const char *kvm_feature_name[] = {
-"kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
-"kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", "kvm_pv_unhalt",
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-"kvmclock-stable-bit", NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-};
-
-static const char *hyperv_priv_feature_name[] = {
-NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refcount_access 
*/,
-NULL /* hv_msr_synic_access */, NULL /* hv_msr_stimer_access */,
-NULL /* hv_msr_apic_access */, NULL /* hv_msr_hypercall_access */,
-NULL /* hv_vpindex_access */, NULL /* hv_msr_reset_access */,
-NULL /* hv_msr_stats_access */, NULL /* hv_reftsc_access */,
-NULL /* hv_msr_idle_access */, NULL /* hv_msr_frequency_access */,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-};
-
-static const char *hyperv_ident_feature_name[] = {
-NULL /* hv_create_partitions */, NULL /* hv_access_partition_id */,
-NULL /* hv_access_memory_pool */, NULL /* hv_adjust_message_buffers */,
-NULL /* hv_post_messages */, NULL /* hv_signal_events */,
-NULL /* hv_create_port */, NULL /* hv_connect_port */,
-NULL /* hv_access_stats */, NULL, NULL, NULL /* hv_debugging */,
-NULL /* hv_cpu_power_management */, NULL /* hv_configure_profiler */,
-NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
-};
-
-static const char *hyperv_misc_feature_name[] = {
-NULL /* hv_mwait */, NULL /* hv_guest_debugging */,
-NULL /* hv_perf_monitor */, NULL /* hv_cpu_dynamic_part */,
-NULL /* hv_hypercall_params_xmm */, NULL /*