From nobody Tue Feb 10 21:03:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1714650664; cv=none; d=zohomail.com; s=zohoarc; b=A+w8UKQXYvXHsZIDIB4YeD9vn9H7Lk6E01drJjqwEbtfkqWlyT6BwwgOqtS38xxumbFD4rGZDrcMteAfsYB2urJIfGqcxc3OZpy1Zyjn8hxrNgyjDFADBF7SvAE5ybY5NIaTGeW1jJ3qvqYYSA7deCiTQ+sfVdp8J3L2CCGho3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714650664; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BkBrlgwIFh4FEHp4gI0dRjqZ/EeBYAdyEfWwsVz4QbU=; b=m6puX8YPCOnF3MJFNzlVr6da/OvbCAXZRooz83uAzbDss8ecw5uvXboR+FxUQXCyY/PDJBtZ2ccmJLuY8JyEf8cn8+gMlmHaNf7BUkBWIcuyA7tkbaDunGhl1NPfzH3dkXMAI4VHCUIgoDkChGRumU9QS4/7g7D/9Fn+k8YiNeY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1714650664659734.6498277940735; Thu, 2 May 2024 04:51:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.715762.1117639 (Exim 4.92) (envelope-from ) id 1s2Uxe-0003Ef-91; Thu, 02 May 2024 11:50:50 +0000 Received: by outflank-mailman (output) from mailman id 715762.1117639; Thu, 02 May 2024 11:50:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2Uxe-0003EY-5E; Thu, 02 May 2024 11:50:50 +0000 Received: by outflank-mailman (input) for mailman id 715762; Thu, 02 May 2024 11:50:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2Uxc-0003EJ-6l for xen-devel@lists.xenproject.org; Thu, 02 May 2024 11:50:48 +0000 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [2a00:1450:4864:20::430]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35edd9cd-087a-11ef-b4bb-af5377834399; Thu, 02 May 2024 13:50:45 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-34e0d8b737eso481267f8f.1 for ; Thu, 02 May 2024 04:50:45 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id p12-20020adfe60c000000b0034ccd06a6a3sm1091868wrm.18.2024.05.02.04.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 04:50:44 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 35edd9cd-087a-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714650645; x=1715255445; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BkBrlgwIFh4FEHp4gI0dRjqZ/EeBYAdyEfWwsVz4QbU=; b=cXnZodqZVJoO6C1BjQdh1fYFR+FNQpzkMFMrAvF+k54foMKwAx8auC7hAa1mk2QHA8 EdU3LL08B0U3ymeZEHYYC40usvQnOnmv8Muwwcm/7Niw6gCBoiTUFy8Fut9OnCivJUt6 HYiQuqYYuaDxPqkRf5WiQF7BQZ04PP1hRWw2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714650645; x=1715255445; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BkBrlgwIFh4FEHp4gI0dRjqZ/EeBYAdyEfWwsVz4QbU=; b=L7aEU2ywPrWHNY7pDPg3q2PeYx27+BEYCBY5HYdugi3r/gk0+SODzFqbRni84sXnuy 6lO+ub+e2bLSMN5vmhV5q6tu8XDqMVdUFmJMFSRmXdxwa6fuqK3ETHh+k0Q/GIFnvDM/ dnLSjtj7zXCNH5qIWbXYrJZu5mlfM4ZmcWgukbxc+E4ttV0KELmyfERIWF7czUyhApQX 2GHjd3s3+VBgrS4RzBRphFQfTFNYIC9sQ0ufGUyLoFzFJ5mm0PFtWbRjOBbmRyKajUUT luhokM7xWEhdFjr4E+SLkRGB/fBlDroXKs9PXKdQUgDVL0uQcV2DYO1hNlMBZ3VS7upN DCpw== X-Gm-Message-State: AOJu0Yx55eEmV+mHmE03MZDmc0hNFtajYOBsMHX1IwGrEfpnGSI3ryn5 tkI3KYGNYgT1FIYNCx2RhTp9046SXx/Xs4VHGKwUDNIdHOMEswzNMp5Rj5pjTROtOZOvBIPTSeX w X-Google-Smtp-Source: AGHT+IGnHCm7STGcxijw75NO54366Q4LybvB65nqrM/je2OsY+GSS0bkBL+ETGffElucilhYoOyERg== X-Received: by 2002:a5d:5145:0:b0:34d:af19:2373 with SMTP id u5-20020a5d5145000000b0034daf192373mr1995958wrt.16.1714650644756; Thu, 02 May 2024 04:50:44 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Anthony PERARD , Jan Beulich , Andrew Cooper , Oleksii Kurochko Subject: [PATCH for-4.19 v2] tools/xen-cpuid: switch to use cpu-policy defined names Date: Thu, 2 May 2024 13:49:22 +0200 Message-ID: <20240502114922.94288-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1714650666197100001 Like it was done recently for libxl, switch to using the auto-generated fea= ture names by the processing of cpufeatureset.h, this allows removing the open-c= oded feature names, and unifies the feature naming with libxl and the hypervisor. Introduce a newly auto-generated array that contains the feature names inde= xed at featureset bit position, otherwise using the existing INIT_FEATURE_NAMES would require iterating over the array elements until a match with the expe= cted bit position is found. Note that leaf names need to be kept, as the current auto-generated data doesn't contain the leaf names. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v1: - Modify gen-cpuid.py to generate an array of strings with the feature nam= es. - Introduce and use __maybe_unused. --- tools/include/xen-tools/common-macros.h | 4 + tools/misc/xen-cpuid.c | 320 +++--------------------- xen/tools/gen-cpuid.py | 26 ++ 3 files changed, 68 insertions(+), 282 deletions(-) diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-to= ols/common-macros.h index 07aed92684b5..3e6a66080a4f 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -83,6 +83,10 @@ #define __packed __attribute__((__packed__)) #endif =20 +#ifndef __maybe_unused +# define __maybe_unused __attribute__((__unused__)) +#endif + #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member) *mptr__ =3D (ptr); \ (type *)((char *)mptr__ - offsetof(type, member)); \ diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 8893547bebce..2a1ac0ee8326 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -12,282 +12,33 @@ =20 #include =20 -static uint32_t nr_features; - -static const char *const str_1d[32] =3D -{ - [ 0] =3D "fpu", [ 1] =3D "vme", - [ 2] =3D "de", [ 3] =3D "pse", - [ 4] =3D "tsc", [ 5] =3D "msr", - [ 6] =3D "pae", [ 7] =3D "mce", - [ 8] =3D "cx8", [ 9] =3D "apic", - /* [10] */ [11] =3D "sysenter", - [12] =3D "mtrr", [13] =3D "pge", - [14] =3D "mca", [15] =3D "cmov", - [16] =3D "pat", [17] =3D "pse36", - [18] =3D "psn", [19] =3D "clflush", - /* [20] */ [21] =3D "ds", - [22] =3D "acpi", [23] =3D "mmx", - [24] =3D "fxsr", [25] =3D "sse", - [26] =3D "sse2", [27] =3D "ss", - [28] =3D "htt", [29] =3D "tm", - [30] =3D "ia64", [31] =3D "pbe", -}; - -static const char *const str_1c[32] =3D -{ - [ 0] =3D "sse3", [ 1] =3D "pclmulqdq", - [ 2] =3D "dtes64", [ 3] =3D "monitor", - [ 4] =3D "ds-cpl", [ 5] =3D "vmx", - [ 6] =3D "smx", [ 7] =3D "est", - [ 8] =3D "tm2", [ 9] =3D "ssse3", - [10] =3D "cntx-id", [11] =3D "sdgb", - [12] =3D "fma", [13] =3D "cx16", - [14] =3D "xtpr", [15] =3D "pdcm", - /* [16] */ [17] =3D "pcid", - [18] =3D "dca", [19] =3D "sse41", - [20] =3D "sse42", [21] =3D "x2apic", - [22] =3D "movebe", [23] =3D "popcnt", - [24] =3D "tsc-dl", [25] =3D "aesni", - [26] =3D "xsave", [27] =3D "osxsave", - [28] =3D "avx", [29] =3D "f16c", - [30] =3D "rdrnd", [31] =3D "hyper", -}; - -static const char *const str_e1d[32] =3D -{ - [ 0] =3D "fpu", [ 1] =3D "vme", - [ 2] =3D "de", [ 3] =3D "pse", - [ 4] =3D "tsc", [ 5] =3D "msr", - [ 6] =3D "pae", [ 7] =3D "mce", - [ 8] =3D "cx8", [ 9] =3D "apic", - /* [10] */ [11] =3D "syscall", - [12] =3D "mtrr", [13] =3D "pge", - [14] =3D "mca", [15] =3D "cmov", - [16] =3D "fcmov", [17] =3D "pse36", - /* [18] */ [19] =3D "mp", - [20] =3D "nx", /* [21] */ - [22] =3D "mmx+", [23] =3D "mmx", - [24] =3D "fxsr", [25] =3D "fxsr+", - [26] =3D "pg1g", [27] =3D "rdtscp", - /* [28] */ [29] =3D "lm", - [30] =3D "3dnow+", [31] =3D "3dnow", -}; - -static const char *const str_e1c[32] =3D -{ - [ 0] =3D "lahf-lm", [ 1] =3D "cmp", - [ 2] =3D "svm", [ 3] =3D "extapic", - [ 4] =3D "cr8d", [ 5] =3D "lzcnt", - [ 6] =3D "sse4a", [ 7] =3D "msse", - [ 8] =3D "3dnowpf", [ 9] =3D "osvw", - [10] =3D "ibs", [11] =3D "xop", - [12] =3D "skinit", [13] =3D "wdt", - /* [14] */ [15] =3D "lwp", - [16] =3D "fma4", [17] =3D "tce", - /* [18] */ [19] =3D "nodeid", - /* [20] */ [21] =3D "tbm", - [22] =3D "topoext", [23] =3D "perfctr-core", - [24] =3D "perfctr-nb", /* [25] */ - [26] =3D "dbx", [27] =3D "perftsc", - [28] =3D "pcx-l2i", [29] =3D "monitorx", - [30] =3D "addr-msk-ext", -}; - -static const char *const str_7b0[32] =3D -{ - [ 0] =3D "fsgsbase", [ 1] =3D "tsc-adj", - [ 2] =3D "sgx", [ 3] =3D "bmi1", - [ 4] =3D "hle", [ 5] =3D "avx2", - [ 6] =3D "fdp-exn", [ 7] =3D "smep", - [ 8] =3D "bmi2", [ 9] =3D "erms", - [10] =3D "invpcid", [11] =3D "rtm", - [12] =3D "pqm", [13] =3D "depfpp", - [14] =3D "mpx", [15] =3D "pqe", - [16] =3D "avx512f", [17] =3D "avx512dq", - [18] =3D "rdseed", [19] =3D "adx", - [20] =3D "smap", [21] =3D "avx512-ifma", - [22] =3D "pcommit", [23] =3D "clflushopt", - [24] =3D "clwb", [25] =3D "proc-trace", - [26] =3D "avx512pf", [27] =3D "avx512er", - [28] =3D "avx512cd", [29] =3D "sha", - [30] =3D "avx512bw", [31] =3D "avx512vl", -}; - -static const char *const str_Da1[32] =3D -{ - [ 0] =3D "xsaveopt", [ 1] =3D "xsavec", - [ 2] =3D "xgetbv1", [ 3] =3D "xsaves", -}; - -static const char *const str_7c0[32] =3D -{ - [ 0] =3D "prefetchwt1", [ 1] =3D "avx512-vbmi", - [ 2] =3D "umip", [ 3] =3D "pku", - [ 4] =3D "ospke", [ 5] =3D "waitpkg", - [ 6] =3D "avx512-vbmi2", [ 7] =3D "cet-ss", - [ 8] =3D "gfni", [ 9] =3D "vaes", - [10] =3D "vpclmulqdq", [11] =3D "avx512-vnni", - [12] =3D "avx512-bitalg", - [14] =3D "avx512-vpopcntdq", - - [22] =3D "rdpid", - /* 24 */ [25] =3D "cldemote", - /* 26 */ [27] =3D "movdiri", - [28] =3D "movdir64b", [29] =3D "enqcmd", - [30] =3D "sgx-lc", [31] =3D "pks", -}; - -static const char *const str_e7d[32] =3D -{ - /* 6 */ [ 7] =3D "hw-pstate", - [ 8] =3D "itsc", [ 9] =3D "cpb", - [10] =3D "efro", -}; - -static const char *const str_e8b[32] =3D -{ - [ 0] =3D "clzero", - [ 2] =3D "rstr-fp-err-ptrs", - - /* [ 8] */ [ 9] =3D "wbnoinvd", - - [12] =3D "ibpb", - [14] =3D "ibrs", [15] =3D "amd-stibp", - [16] =3D "ibrs-always", [17] =3D "stibp-always", - [18] =3D "ibrs-fast", [19] =3D "ibrs-same-mode", - - [20] =3D "no-lmsl", - /* [22] */ [23] =3D "ppin", - [24] =3D "amd-ssbd", [25] =3D "virt-ssbd", - [26] =3D "ssb-no", - [28] =3D "psfd", [29] =3D "btc-no", - [30] =3D "ibpb-ret", -}; - -static const char *const str_7d0[32] =3D -{ - [ 2] =3D "avx512-4vnniw", [ 3] =3D "avx512-4fmaps", - [ 4] =3D "fsrm", - - [ 8] =3D "avx512-vp2intersect", [ 9] =3D "srbds-ctrl", - [10] =3D "md-clear", [11] =3D "rtm-always-abort", - /* 12 */ [13] =3D "tsx-force-abort", - [14] =3D "serialize", [15] =3D "hybrid", - [16] =3D "tsxldtrk", - [18] =3D "pconfig", - [20] =3D "cet-ibt", - /* 22 */ [23] =3D "avx512-fp16", - - [26] =3D "ibrsb", [27] =3D "stibp", - [28] =3D "l1d-flush", [29] =3D "arch-caps", - [30] =3D "core-caps", [31] =3D "ssbd", -}; - -static const char *const str_7a1[32] =3D -{ - [ 0] =3D "sha512", [ 1] =3D "sm3", - [ 2] =3D "sm4", - [ 4] =3D "avx-vnni", [ 5] =3D "avx512-bf16", - - [10] =3D "fzrm", [11] =3D "fsrs", - [12] =3D "fsrcs", - - /* 18 */ [19] =3D "wrmsrns", +#include =20 - /* 22 */ [23] =3D "avx-ifma", -}; - -static const char *const str_e21a[32] =3D -{ - [ 0] =3D "no-nest-bp", [ 1] =3D "fs-gs-ns", - [ 2] =3D "lfence+", - [ 6] =3D "nscb", - [ 8] =3D "auto-ibrs", - [10] =3D "amd-fsrs", [11] =3D "amd-fsrc", - - /* 16 */ [17] =3D "cpuid-user-dis", - [18] =3D "epsf", [19] =3D "fsrsc", - [20] =3D "amd-prefetchi", - - /* 26 */ [27] =3D "sbpb", - [28] =3D "ibpb-brtype", [29] =3D "srso-no", -}; - -static const char *const str_7b1[32] =3D -{ - [ 0] =3D "ppin", -}; - -static const char *const str_7c1[32] =3D -{ -}; - -static const char *const str_7d1[32] =3D -{ - [ 4] =3D "avx-vnni-int8", [ 5] =3D "avx-ne-convert", - - [10] =3D "avx-vnni-int16", - - [14] =3D "prefetchi", - - [18] =3D "cet-sss", -}; - -static const char *const str_7d2[32] =3D -{ - [ 0] =3D "intel-psfd", [ 1] =3D "ipred-ctrl", - [ 2] =3D "rrsba-ctrl", [ 3] =3D "ddp-ctrl", - [ 4] =3D "bhi-ctrl", [ 5] =3D "mcdt-no", -}; - -static const char *const str_m10Al[32] =3D -{ - [ 0] =3D "rdcl-no", [ 1] =3D "eibrs", - [ 2] =3D "rsba", [ 3] =3D "skip-l1dfl", - [ 4] =3D "intel-ssb-no", [ 5] =3D "mds-no", - [ 6] =3D "if-pschange-mc-no", [ 7] =3D "tsx-ctrl", - [ 8] =3D "taa-no", [ 9] =3D "mcu-ctrl", - [10] =3D "misc-pkg-ctrl", [11] =3D "energy-ctrl", - [12] =3D "doitm", [13] =3D "sbdr-ssdp-no", - [14] =3D "fbsdp-no", [15] =3D "psdp-no", - /* 16 */ [17] =3D "fb-clear", - [18] =3D "fb-clear-ctrl", [19] =3D "rrsba", - [20] =3D "bhi-no", [21] =3D "xapic-status", - /* 22 */ [23] =3D "ovrclk-status", - [24] =3D "pbrsb-no", [25] =3D "gds-ctrl", - [26] =3D "gds-no", [27] =3D "rfds-no", - [28] =3D "rfds-clear", -}; - -static const char *const str_m10Ah[32] =3D -{ -}; +static uint32_t nr_features; =20 static const struct { const char *name; const char *abbr; - const char *const *strs; -} decodes[] =3D +} leaf_names[] =3D { - { "CPUID 0x00000001.edx", "1d", str_1d }, - { "CPUID 0x00000001.ecx", "1c", str_1c }, - { "CPUID 0x80000001.edx", "e1d", str_e1d }, - { "CPUID 0x80000001.ecx", "e1c", str_e1c }, - { "CPUID 0x0000000d:1.eax", "Da1", str_Da1 }, - { "CPUID 0x00000007:0.ebx", "7b0", str_7b0 }, - { "CPUID 0x00000007:0.ecx", "7c0", str_7c0 }, - { "CPUID 0x80000007.edx", "e7d", str_e7d }, - { "CPUID 0x80000008.ebx", "e8b", str_e8b }, - { "CPUID 0x00000007:0.edx", "7d0", str_7d0 }, - { "CPUID 0x00000007:1.eax", "7a1", str_7a1 }, - { "CPUID 0x80000021.eax", "e21a", str_e21a }, - { "CPUID 0x00000007:1.ebx", "7b1", str_7b1 }, - { "CPUID 0x00000007:2.edx", "7d2", str_7d2 }, - { "CPUID 0x00000007:1.ecx", "7c1", str_7c1 }, - { "CPUID 0x00000007:1.edx", "7d1", str_7d1 }, - { "MSR_ARCH_CAPS.lo", "m10Al", str_m10Al }, - { "MSR_ARCH_CAPS.hi", "m10Ah", str_m10Ah }, + { "CPUID 0x00000001.edx", "1d" }, + { "CPUID 0x00000001.ecx", "1c" }, + { "CPUID 0x80000001.edx", "e1d" }, + { "CPUID 0x80000001.ecx", "e1c" }, + { "CPUID 0x0000000d:1.eax", "Da1" }, + { "CPUID 0x00000007:0.ebx", "7b0" }, + { "CPUID 0x00000007:0.ecx", "7c0" }, + { "CPUID 0x80000007.edx", "e7d" }, + { "CPUID 0x80000008.ebx", "e8b" }, + { "CPUID 0x00000007:0.edx", "7d0" }, + { "CPUID 0x00000007:1.eax", "7a1" }, + { "CPUID 0x80000021.eax", "e21a" }, + { "CPUID 0x00000007:1.ebx", "7b1" }, + { "CPUID 0x00000007:2.edx", "7d2" }, + { "CPUID 0x00000007:1.ecx", "7c1" }, + { "CPUID 0x00000007:1.edx", "7d1" }, + { "MSR_ARCH_CAPS.lo", "m10Al" }, + { "MSR_ARCH_CAPS.hi", "m10Ah" }, }; =20 #define COL_ALIGN "24" @@ -305,12 +56,6 @@ static void dump_leaf(uint32_t leaf, const char *const = *strs) { unsigned i; =20 - if ( !strs ) - { - printf(" ???"); - return; - } - for ( i =3D 0; i < 32; ++i ) if ( leaf & (1u << i) ) { @@ -326,6 +71,7 @@ static void decode_featureset(const uint32_t *features, const char *name, bool detail) { + static const uint32_t __maybe_unused known_features[] =3D INIT_KNOWN_F= EATURES; unsigned int i; =20 printf("%-"COL_ALIGN"s ", name); @@ -336,11 +82,21 @@ static void decode_featureset(const uint32_t *features, if ( !detail ) return; =20 - for ( i =3D 0; i < length && i < ARRAY_SIZE(decodes); ++i ) + /* Ensure leaf names stay in sync with the policy leaf count. */ + BUILD_BUG_ON(ARRAY_SIZE(known_features) !=3D ARRAY_SIZE(leaf_names)); + + for ( i =3D 0; i < length && i < ARRAY_SIZE(leaf_names); ++i ) { - printf(" [%02u] %-"COL_ALIGN"s", i, decodes[i].name ?: "= "); - if ( decodes[i].name ) - dump_leaf(features[i], decodes[i].strs); + static const char *const feature_names[] =3D INIT_FEATURE_NAME_ARR= AY; + + /* Ensure feature names stays in sync with number of feature words= . */ + BUILD_BUG_ON(ARRAY_SIZE(feature_names) !=3D + ARRAY_SIZE(leaf_names) * sizeof(*features) * 8); + + printf(" [%02u] %-"COL_ALIGN"s", i, leaf_names[i].name ?: ""); + + /* Attempt to print features anyway even if the leaf name is unkno= wn. */ + dump_leaf(features[i], &feature_names[i * 32]); printf("\n"); } } @@ -355,8 +111,8 @@ static void dump_info(xc_interface *xch, bool detail) if ( !detail ) { printf(" %"COL_ALIGN"s ", "KEY"); - for ( i =3D 0; i < ARRAY_SIZE(decodes); ++i ) - printf("%-8s ", decodes[i].abbr ?: "???"); + for ( i =3D 0; i < ARRAY_SIZE(leaf_names); ++i ) + printf("%-8s ", leaf_names[i].abbr ?: "???"); printf("\n"); } =20 diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py index 380b9d973a67..c0caa3bdebef 100755 --- a/xen/tools/gen-cpuid.py +++ b/xen/tools/gen-cpuid.py @@ -475,6 +475,32 @@ def write_results(state): state.output.write( """} =20 +""") + + state.output.write( +""" +#define INIT_FEATURE_NAME_ARRAY { \\ +""") + + try: + _tmp =3D state.names.iteritems() + except AttributeError: + _tmp =3D state.names.items() + + for bit, name in sorted(_tmp): + state.output.write( + ' [%s] =3D "%s",\\\n' % (bit, name.lower().replace("_", "-"= )) + ) + + #=C2=A0Ensure array size matches featureset size. + if not state.names.get(state.nr_entries * 32 - 1, ""): + state.output.write( + ' [%s] =3D NULL,\\\n' % (state.nr_entries * 32 - 1) + ) + + state.output.write( +"""} + """) =20 for idx, text in enumerate(state.bitfields): --=20 2.44.0