From patchwork Fri May 10 22:39:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13661980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 387B7C25B10 for ; Fri, 10 May 2024 22:40:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720094.1123091 (Exim 4.92) (envelope-from ) id 1s5YuO-0008A2-22; Fri, 10 May 2024 22:40:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720094.1123091; Fri, 10 May 2024 22:40:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuN-00089K-UU; Fri, 10 May 2024 22:40:07 +0000 Received: by outflank-mailman (input) for mailman id 720094; Fri, 10 May 2024 22:40:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuN-000872-BN for xen-devel@lists.xenproject.org; Fri, 10 May 2024 22:40:07 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f3a152e-0f1e-11ef-909d-e314d9c70b13; Sat, 11 May 2024 00:40:05 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a59a8f0d941so604152466b.2 for ; Fri, 10 May 2024 15:40:05 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781cf60sm233915866b.14.2024.05.10.15.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:40:04 -0700 (PDT) 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: 3f3a152e-0f1e-11ef-909d-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1715380805; x=1715985605; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+3wFptMesC7scMbASW9uUHmAUxFS1IgS9Pg8ty+kfrw=; b=EpTAo49FsvSsODgxrPqrr9TrNKTloxjagvc3oiBngOaPPcakoQaQ9eM15/aGp3XLvI lURNMpM/bg0eElR/1juMUb8M+nvwc7+ecRglNqaWy6pwaaL2cSvY0z3IYTOTameYCRk1 Kst9OBeIcYid6LPIi9Kez30+hupCgQBxPqx0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715380805; x=1715985605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+3wFptMesC7scMbASW9uUHmAUxFS1IgS9Pg8ty+kfrw=; b=od3iLsbvYRnPepxP5HMVC1wTer8cJND7pHsL/3/n25FWl5i0mRpmZou2oa9kdJQRTa ZXztr9XU1w1N8zQ8GBtQFIaE+gWbVufy2LoZryg27sHxFHs3t/VqVnkxOxKrkw1LuIsw LQEk3gQFlpx7FAX64tsnmEcL5oyoCu1NYQKGSbqJolJoZXgWzxVJG8UyYu0WAfV+L/mz lFuSr1jlMVRwPnn2YttkavI8OoeNYZKYN3FgOWQPoJLhSoMWUfYyBFfF0rk8m2M02Jli H2UFvchyyDakBWNnjrnWk0INCVYEoVtyCa6binhfhF5COKMOuDvUuZmQLujD0nugR8fx h5Zw== X-Gm-Message-State: AOJu0Yw6cLT3lcJapXexiLc8qfEzGY42oX86xx2O0PgZVlPfrU42E8T+ vtcVYP8O194xiaGMeyvMVbQPLCi93i1SieAOgdFzpIytw0n7M0tr08PZEuTsNDuWLtXhZlJaPRa u X-Google-Smtp-Source: AGHT+IH0oLMFKMzpEMCVInvb1E6s+F94kooOglSc0Ol6TYVo3iWnR3bdBI+xVyJPk4/L2nL4aRjWeA== X-Received: by 2002:a17:906:22cc:b0:a59:c319:f1e3 with SMTP id a640c23a62f3a-a5a2d53ae7emr246124866b.12.1715380805100; Fri, 10 May 2024 15:40:05 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 1/4] x86/gen-cpuid: Minor cleanup Date: Fri, 10 May 2024 23:39:59 +0100 Message-Id: <20240510224002.2324578-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240510224002.2324578-1-andrew.cooper3@citrix.com> References: <20240510224002.2324578-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Rename INIT_FEATURE_NAMES to INIT_FEATURE_NAME_TO_VAL as we're about to gain a inverse mapping of the same thing. Use dict.items() unconditionally. iteritems() is a marginal perf optimsiation for Python2 only, and simply not worth the effort on a script this small. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné --- CC: Jan Beulich CC: Roger Pau Monné v3: * New --- tools/libs/light/libxl_cpuid.c | 2 +- xen/arch/x86/cpu-policy.c | 2 +- xen/tools/gen-cpuid.py | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index ce4f3c7095ba..063fe86eb72f 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -296,7 +296,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str) {NULL, 0, NA, CPUID_REG_INV, 0, 0} }; - static const struct feature_name features[] = INIT_FEATURE_NAMES; + static const struct feature_name features[] = INIT_FEATURE_NAME_TO_VAL; /* * NB: if we switch to using a cpu_policy derived object instead of a * libxl_cpuid_policy_list we could get rid of the featureset -> cpuid leaf diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index 99871b8e0e05..b96f4ee55cc4 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -43,7 +43,7 @@ static const uint32_t deep_features[] = INIT_DEEP_FEATURES; static const struct feature_name { const char *name; unsigned int bit; -} feature_names[] __initconstrel = INIT_FEATURE_NAMES; +} feature_names[] __initconstrel = INIT_FEATURE_NAME_TO_VAL; /* * Parse a list of cpuid feature names -> bool, calling the callback for any diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py index 380b9d973a67..79d7f5c8e1c9 100755 --- a/xen/tools/gen-cpuid.py +++ b/xen/tools/gen-cpuid.py @@ -459,15 +459,10 @@ def write_results(state): state.output.write( """} -#define INIT_FEATURE_NAMES { \\ +#define INIT_FEATURE_NAME_TO_VAL { \\ """) - try: - _tmp = state.values.iteritems() - except AttributeError: - _tmp = state.values.items() - - for name, bit in sorted(_tmp): + for name, bit in sorted(state.values.items()): state.output.write( ' { "%s", %sU },\\\n' % (name, bit) ) From patchwork Fri May 10 22:40:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13661979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7ADCC25B10 for ; Fri, 10 May 2024 22:40:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720095.1123106 (Exim 4.92) (envelope-from ) id 1s5YuP-00008Q-6Y; Fri, 10 May 2024 22:40:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720095.1123106; Fri, 10 May 2024 22:40:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuP-00008J-40; Fri, 10 May 2024 22:40:09 +0000 Received: by outflank-mailman (input) for mailman id 720095; Fri, 10 May 2024 22:40:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuO-000872-BY for xen-devel@lists.xenproject.org; Fri, 10 May 2024 22:40:08 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3fad9b8d-0f1e-11ef-909d-e314d9c70b13; Sat, 11 May 2024 00:40:06 +0200 (CEST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-572baf393ddso5879082a12.1 for ; Fri, 10 May 2024 15:40:06 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781cf60sm233915866b.14.2024.05.10.15.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:40:05 -0700 (PDT) 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: 3fad9b8d-0f1e-11ef-909d-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1715380806; x=1715985606; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r/L62oz/vhjY7sgRvmqLoVnO9fQ3LM/iOAHiRUewZCg=; b=ERuTKkERbxwCLDKkYxFCkSm8wi6CGoMth3NP6SDedM3m8QOLyDGg8Osm8+a2YWwIon 67FJ/F/kpVlvA2lhJSmpeKPecfsvhFfuu9soISFCUVzWmgTlbRpEG0c0f1Bct94ivBbD FbgNyB8WloExS0PvzPN4M/fyQvzpmhG0XK0aM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715380806; x=1715985606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r/L62oz/vhjY7sgRvmqLoVnO9fQ3LM/iOAHiRUewZCg=; b=AIBgRj+GqloqEhR6LdbrjucPTJD15/d7wfMVY6633BmqgaqLsJOEy+89ZTjKsT5Afg fuihdT/w01D74r/A+xEBK0FB8f7S4jrfwE2FbqeTnV1OSdkn4uHHJqcdPSUYfIRxxDBy bWsBDwwQLEVZs5bT7DrAdZLJbdmTn5+Iw4ULD4xFSyECNI5AnbU9R8itxZ43GSGYqBYw rpfZ3B/QjKuCYR0IoakaV2dfDhNsC2YDda0/c/eg1ZcCAkHivnZzGcmfZUC+SlH9/tYO 6yZcTWicSVvndLOZFLaiO6ZgyC1VuqK+AB4Kgvw2pS30hONKFGt612xUuHvS8v/w4tDA 07Ag== X-Gm-Message-State: AOJu0YwxQx3gNODqR3fRjituKynuoJEOBRMdsz0Pc1eG3as4aWXJ8HK+ I1agSNJC6iDxEHfejf0XlW8HARxiQQFekIoWdRgCcjhBHoUMpYIXqplBi6mG42kT3J8pQKtC5iM q X-Google-Smtp-Source: AGHT+IG8gv5M6eQdPRaW5RagjFQLPIwyOi6pGwQ/53qXmVlAW9nj+CYDAo9G7aWsdcVk84ybzUMJUQ== X-Received: by 2002:a17:906:2bc4:b0:a59:ac10:9be5 with SMTP id a640c23a62f3a-a5a2d292b1dmr351577666b.27.1715380805809; Fri, 10 May 2024 15:40:05 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , Jan Beulich Subject: [PATCH 2/4] tools/xen-cpuid: Rename decodes[] to leaf_info[] Date: Fri, 10 May 2024 23:40:00 +0100 Message-Id: <20240510224002.2324578-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240510224002.2324578-1-andrew.cooper3@citrix.com> References: <20240510224002.2324578-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: Roger Pau Monné Split out of subsequent patch to aid legibility. Signed-off-by: Roger Pau Monné Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné --- CC: Jan Beulich CC: Roger Pau Monné v3: * New (split out) --- tools/misc/xen-cpuid.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 8893547bebce..6ee835b22949 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -268,8 +268,7 @@ static const struct { const char *name; const char *abbr; const char *const *strs; -} decodes[] = -{ +} leaf_info[] = { { "CPUID 0x00000001.edx", "1d", str_1d }, { "CPUID 0x00000001.ecx", "1c", str_1c }, { "CPUID 0x80000001.edx", "e1d", str_e1d }, @@ -336,11 +335,11 @@ static void decode_featureset(const uint32_t *features, if ( !detail ) return; - for ( i = 0; i < length && i < ARRAY_SIZE(decodes); ++i ) + for ( i = 0; i < length && i < ARRAY_SIZE(leaf_info); ++i ) { - printf(" [%02u] %-"COL_ALIGN"s", i, decodes[i].name ?: ""); - if ( decodes[i].name ) - dump_leaf(features[i], decodes[i].strs); + printf(" [%02u] %-"COL_ALIGN"s", i, leaf_info[i].name ?: ""); + if ( leaf_info[i].name ) + dump_leaf(features[i], leaf_info[i].strs); printf("\n"); } } @@ -355,8 +354,8 @@ static void dump_info(xc_interface *xch, bool detail) if ( !detail ) { printf(" %"COL_ALIGN"s ", "KEY"); - for ( i = 0; i < ARRAY_SIZE(decodes); ++i ) - printf("%-8s ", decodes[i].abbr ?: "???"); + for ( i = 0; i < ARRAY_SIZE(leaf_info); ++i ) + printf("%-8s ", leaf_info[i].abbr ?: "???"); printf("\n"); } From patchwork Fri May 10 22:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13661983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12A78C25B77 for ; Fri, 10 May 2024 22:40:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720096.1123116 (Exim 4.92) (envelope-from ) id 1s5YuQ-0000OP-Em; Fri, 10 May 2024 22:40:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720096.1123116; Fri, 10 May 2024 22:40:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuQ-0000OI-Bw; Fri, 10 May 2024 22:40:10 +0000 Received: by outflank-mailman (input) for mailman id 720096; Fri, 10 May 2024 22:40:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuP-000872-Bd for xen-devel@lists.xenproject.org; Fri, 10 May 2024 22:40:09 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 40260fd6-0f1e-11ef-909d-e314d9c70b13; Sat, 11 May 2024 00:40:07 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a59cc765c29so559624066b.3 for ; Fri, 10 May 2024 15:40:07 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781cf60sm233915866b.14.2024.05.10.15.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:40:06 -0700 (PDT) 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: 40260fd6-0f1e-11ef-909d-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1715380806; x=1715985606; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Phw85PeYT8ClsRvMd2JBZsNjZhs23kHM7gjroo/IJSY=; b=eKxt9k9HpPpDkLmGwthZfYlmFQzLunWL9YafRWJ+NEwTtUXDdYkMg7S86W80ZQKm/r 1ZSfFQMDZzPw7X6u+wQ0AcdRSguAXAsq33oQugU6zSYvZTHtVvDXSe1tFjLWyAh03fyg 6L5KdP0T2rY+0QnmYWzXI9QO5A34nLSv+/iR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715380806; x=1715985606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Phw85PeYT8ClsRvMd2JBZsNjZhs23kHM7gjroo/IJSY=; b=utwtBdbmsfHhqI7ES8U5hzn0ERN0d/ISdjDv+ikcLwKG7T4NWd4JoyABk9yl5oGcNh tWohC3IE2itRUgKfBDPdS6Uq/lLT9clwgwjgwGtj15cJR0kX7pvBSCK8qLWo27k9a0mc Z6LbA9UzSBURBSzSmlPL/nTVNLxklrKM/LXjeyXaOhkTsMhaht1dfiMb2xU8b1e8QiAT 4t8na+IysUga5NCKRhPaUlSeS/KsiZvk8g1+WN1UC0yya/FmCQjAyEfM9sCihxX7el9s bxi2fxbSRqqwLSYqawOn3FzvG5A21mrvwPQnEtpDudfFnIfsobnrS6sP8fpkYHAKymKx otvA== X-Gm-Message-State: AOJu0YykJ1zS3nijXdp/UwsLH7Ks+6VUB+ANQ5K3N7M976MQTMnbUFvS Jc/IB5kVby7eOYMknVhYf0xONeVWcf6l07JfLXJuKzrSMAJd3EQtgXmSG6yznDf2+vLot9xQxWZ i X-Google-Smtp-Source: AGHT+IHf4xSJp8NCGGmvT9XjSTZCP+6zYExEd3Ow9Gm2SOkX5JRmY26CWDUdpoU0non11Cvmx80fkQ== X-Received: by 2002:a17:907:77c3:b0:a59:9db6:535d with SMTP id a640c23a62f3a-a5a2d67862amr251200766b.65.1715380806572; Fri, 10 May 2024 15:40:06 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , Jan Beulich Subject: [PATCH 3/4] tools/xen-cpuid: Use automatically generated feature names Date: Fri, 10 May 2024 23:40:01 +0100 Message-Id: <20240510224002.2324578-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240510224002.2324578-1-andrew.cooper3@citrix.com> References: <20240510224002.2324578-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: Roger Pau Monné Have gen-cpuid.py write out INIT_FEATURE_VAL_TO_NAME, derived from the same data source as INIT_FEATURE_NAME_TO_VAL, although both aliases of common_1d are needed. In xen-cpuid.c, have the compiler pad both leaf_info[] and feature_names[] if necessary. This avoids needing complicated cross-checks. As dump_leaf() rendered missing names as numbers, always dump leaves even if we don't have the leaf name. This conversion was argumably missed in commit 59afdb8a81d6 ("tools/misc: Tweak reserved bit handling for xen-cpuid"). Signed-off-by: Roger Pau Monné Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monné Differences in names are: sysenter -> sep tm -> tm1 ds-cpl -> dscpl est -> eist sse41 -> sse4-1 sse42 -> sse4-2 movebe -> movbe tsc-dl -> tsc-deadline rdrnd -> rdrand hyper -> hypervisor mmx+ -> mmext fxsr+ -> ffxsr pg1g -> page1gb 3dnow+ -> 3dnowext cmp -> cmp-legacy cr8d -> cr8-legacy lzcnt -> abm msse -> misalignsse 3dnowpf -> 3dnowprefetch nodeid -> nodeid-msr dbx -> dbext tsc-adj -> tsc-adjust fdp-exn -> fdp-excp-only deffp -> no-fpu-sel <24> -> bld ppin -> amd-ppin lfence+ -> lfence-dispatch ppin -> intel-ppin energy-ctrl -> energy-filtering Apparently BLD missed the update to xen-cpuid.c. It appears to be the only one. Several of the + names would be nice to keep as were, but doing so isn't nice in gen-cpuid. Any changes would alter the {dom0-}cpuid= cmdline options, but we intentionally don't list them, so I'm not worried. Thoughts? v3: * Rework somewhat. * Insert aliases of common_1d. --- tools/misc/xen-cpuid.c | 15 ++++++--------- xen/tools/gen-cpuid.py | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 6ee835b22949..2f34694e9c57 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -11,6 +11,7 @@ #include #include +#include static uint32_t nr_features; @@ -268,7 +269,7 @@ static const struct { const char *name; const char *abbr; const char *const *strs; -} leaf_info[] = { +} leaf_info[FEATURESET_NR_ENTRIES] = { { "CPUID 0x00000001.edx", "1d", str_1d }, { "CPUID 0x00000001.ecx", "1c", str_1c }, { "CPUID 0x80000001.edx", "e1d", str_e1d }, @@ -291,6 +292,9 @@ static const struct { #define COL_ALIGN "24" +static const char *const feature_names[(FEATURESET_NR_ENTRIES + 1) << 5] = + INIT_FEATURE_VAL_TO_NAME; + static const char *const fs_names[] = { [XEN_SYSCTL_cpu_featureset_raw] = "Raw", [XEN_SYSCTL_cpu_featureset_host] = "Host", @@ -304,12 +308,6 @@ static void dump_leaf(uint32_t leaf, const char *const *strs) { unsigned i; - if ( !strs ) - { - printf(" ???"); - return; - } - for ( i = 0; i < 32; ++i ) if ( leaf & (1u << i) ) { @@ -338,8 +336,7 @@ static void decode_featureset(const uint32_t *features, for ( i = 0; i < length && i < ARRAY_SIZE(leaf_info); ++i ) { printf(" [%02u] %-"COL_ALIGN"s", i, leaf_info[i].name ?: ""); - if ( leaf_info[i].name ) - dump_leaf(features[i], leaf_info[i].strs); + dump_leaf(features[i], &feature_names[i * 32]); printf("\n"); } } diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py index 79d7f5c8e1c9..d0bb2e4a229f 100755 --- a/xen/tools/gen-cpuid.py +++ b/xen/tools/gen-cpuid.py @@ -470,6 +470,27 @@ def write_results(state): state.output.write( """} +""") + + state.output.write( +""" +#define INIT_FEATURE_VAL_TO_NAME { \\ +""") + + for name, bit in sorted(state.values.items()): + state.output.write( + ' [%s] = "%s",\\\n' % (bit, name) + ) + + # Add the other alias for 1d/e1d common bits + if bit in state.common_1d: + state.output.write( + ' [%s] = "%s",\\\n' % (64 + bit, name) + ) + + state.output.write( +"""} + """) for idx, text in enumerate(state.bitfields): From patchwork Fri May 10 22:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13661981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECB97C25B74 for ; Fri, 10 May 2024 22:40:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720097.1123127 (Exim 4.92) (envelope-from ) id 1s5YuS-0000fd-Nh; Fri, 10 May 2024 22:40:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720097.1123127; Fri, 10 May 2024 22:40:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5YuS-0000fY-Js; Fri, 10 May 2024 22:40:12 +0000 Received: by outflank-mailman (input) for mailman id 720097; Fri, 10 May 2024 22:40:11 +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 1s5YuQ-0000RL-UH for xen-devel@lists.xenproject.org; Fri, 10 May 2024 22:40:10 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 40e7ea54-0f1e-11ef-b4bb-af5377834399; Sat, 11 May 2024 00:40:08 +0200 (CEST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a59a64db066so661797066b.3 for ; Fri, 10 May 2024 15:40:08 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781cf60sm233915866b.14.2024.05.10.15.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:40:06 -0700 (PDT) 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: 40e7ea54-0f1e-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1715380807; x=1715985607; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NZZNtujjN9pYr6HT0e0A2/j3Mym7RChiLwN22jfYFXQ=; b=dMcczuGdoQatw4rz5HetC7jd1Ll80NHUcG8fkCjdn2wstbs3XH4089I61pI+j1yc+x 9byQh0qXw3hHgrwZaJq9ChMZ7nkNmYZD/FIits5YxxClNmWb+dfmewkP3Ar8Ts3q6FBW CmVJ/pAyDNoLlipGv4auyRxSRz5svuz9779Tg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715380807; x=1715985607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NZZNtujjN9pYr6HT0e0A2/j3Mym7RChiLwN22jfYFXQ=; b=q/rBjAmNnQf+6nmPw0mH8EBedFvannOaxG9OwL68IJXTQCuxoDXpV4eunR4q4bIcvh CAE9fz4K9Knb4w1adgbaJxXFOZRpNZYE3VhhPQhUkpE32C6zAcaCkrc74SWM9+vyWxpA v/WYMKWrNrW9kuUCuG5oIwnOx+QYcti1+Uvu8WetWiYR+LPPcbfW5NRN1Ugl+oLSheRd cyGpXFaWCkd/tq3PCNfJUSWXmqSsx/7AoHa/6Wnt30dp9Maba6uOHAOHOP4fVoGPpmcT MJ3oqnSyx9gBoAT0xinOiLGO+HXVudOqVVNe6M6dqyZOVjVWy4EJlzyAy4YXRaqzqv6t +xgA== X-Gm-Message-State: AOJu0YywnCw8MX1NLb0HfgZAyMXE4TAb9gyFbKA6zw0FgHUOveAbw7+k kZWQBDRFhl9eSGD+DYURm7TYtD+L8tS4PkbtrlxsZal6hvGNbu1jRHABwXaDrm1xBa9rom+F5+Q M X-Google-Smtp-Source: AGHT+IFXXDmaCK9fx4msP1oV+MH9H9mEiBmmVYHwccM8SXOciaaLj3tBQWdnSEKuMH8C/e8C2XT1iw== X-Received: by 2002:a17:906:1d16:b0:a59:dd91:3417 with SMTP id a640c23a62f3a-a5a2d53b132mr250376266b.5.1715380807400; Fri, 10 May 2024 15:40:07 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , Jan Beulich Subject: [PATCH 4/4] tools/xen-cpuid: Drop old names Date: Fri, 10 May 2024 23:40:02 +0100 Message-Id: <20240510224002.2324578-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240510224002.2324578-1-andrew.cooper3@citrix.com> References: <20240510224002.2324578-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: Roger Pau Monné Not used any more. Split out of previous patch to aid legibility. Signed-off-by: Roger Pau Monné Signed-off-by: Andrew Cooper Acked-by: Roger Pau Monné --- CC: Jan Beulich CC: Roger Pau Monné v3: * New (split out) --- tools/misc/xen-cpuid.c | 287 +++-------------------------------------- 1 file changed, 18 insertions(+), 269 deletions(-) diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 2f34694e9c57..2cb5322ed9aa 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -15,279 +15,28 @@ static uint32_t nr_features; -static const char *const str_1d[32] = -{ - [ 0] = "fpu", [ 1] = "vme", - [ 2] = "de", [ 3] = "pse", - [ 4] = "tsc", [ 5] = "msr", - [ 6] = "pae", [ 7] = "mce", - [ 8] = "cx8", [ 9] = "apic", - /* [10] */ [11] = "sysenter", - [12] = "mtrr", [13] = "pge", - [14] = "mca", [15] = "cmov", - [16] = "pat", [17] = "pse36", - [18] = "psn", [19] = "clflush", - /* [20] */ [21] = "ds", - [22] = "acpi", [23] = "mmx", - [24] = "fxsr", [25] = "sse", - [26] = "sse2", [27] = "ss", - [28] = "htt", [29] = "tm", - [30] = "ia64", [31] = "pbe", -}; - -static const char *const str_1c[32] = -{ - [ 0] = "sse3", [ 1] = "pclmulqdq", - [ 2] = "dtes64", [ 3] = "monitor", - [ 4] = "ds-cpl", [ 5] = "vmx", - [ 6] = "smx", [ 7] = "est", - [ 8] = "tm2", [ 9] = "ssse3", - [10] = "cntx-id", [11] = "sdgb", - [12] = "fma", [13] = "cx16", - [14] = "xtpr", [15] = "pdcm", - /* [16] */ [17] = "pcid", - [18] = "dca", [19] = "sse41", - [20] = "sse42", [21] = "x2apic", - [22] = "movebe", [23] = "popcnt", - [24] = "tsc-dl", [25] = "aesni", - [26] = "xsave", [27] = "osxsave", - [28] = "avx", [29] = "f16c", - [30] = "rdrnd", [31] = "hyper", -}; - -static const char *const str_e1d[32] = -{ - [ 0] = "fpu", [ 1] = "vme", - [ 2] = "de", [ 3] = "pse", - [ 4] = "tsc", [ 5] = "msr", - [ 6] = "pae", [ 7] = "mce", - [ 8] = "cx8", [ 9] = "apic", - /* [10] */ [11] = "syscall", - [12] = "mtrr", [13] = "pge", - [14] = "mca", [15] = "cmov", - [16] = "fcmov", [17] = "pse36", - /* [18] */ [19] = "mp", - [20] = "nx", /* [21] */ - [22] = "mmx+", [23] = "mmx", - [24] = "fxsr", [25] = "fxsr+", - [26] = "pg1g", [27] = "rdtscp", - /* [28] */ [29] = "lm", - [30] = "3dnow+", [31] = "3dnow", -}; - -static const char *const str_e1c[32] = -{ - [ 0] = "lahf-lm", [ 1] = "cmp", - [ 2] = "svm", [ 3] = "extapic", - [ 4] = "cr8d", [ 5] = "lzcnt", - [ 6] = "sse4a", [ 7] = "msse", - [ 8] = "3dnowpf", [ 9] = "osvw", - [10] = "ibs", [11] = "xop", - [12] = "skinit", [13] = "wdt", - /* [14] */ [15] = "lwp", - [16] = "fma4", [17] = "tce", - /* [18] */ [19] = "nodeid", - /* [20] */ [21] = "tbm", - [22] = "topoext", [23] = "perfctr-core", - [24] = "perfctr-nb", /* [25] */ - [26] = "dbx", [27] = "perftsc", - [28] = "pcx-l2i", [29] = "monitorx", - [30] = "addr-msk-ext", -}; - -static const char *const str_7b0[32] = -{ - [ 0] = "fsgsbase", [ 1] = "tsc-adj", - [ 2] = "sgx", [ 3] = "bmi1", - [ 4] = "hle", [ 5] = "avx2", - [ 6] = "fdp-exn", [ 7] = "smep", - [ 8] = "bmi2", [ 9] = "erms", - [10] = "invpcid", [11] = "rtm", - [12] = "pqm", [13] = "depfpp", - [14] = "mpx", [15] = "pqe", - [16] = "avx512f", [17] = "avx512dq", - [18] = "rdseed", [19] = "adx", - [20] = "smap", [21] = "avx512-ifma", - [22] = "pcommit", [23] = "clflushopt", - [24] = "clwb", [25] = "proc-trace", - [26] = "avx512pf", [27] = "avx512er", - [28] = "avx512cd", [29] = "sha", - [30] = "avx512bw", [31] = "avx512vl", -}; - -static const char *const str_Da1[32] = -{ - [ 0] = "xsaveopt", [ 1] = "xsavec", - [ 2] = "xgetbv1", [ 3] = "xsaves", -}; - -static const char *const str_7c0[32] = -{ - [ 0] = "prefetchwt1", [ 1] = "avx512-vbmi", - [ 2] = "umip", [ 3] = "pku", - [ 4] = "ospke", [ 5] = "waitpkg", - [ 6] = "avx512-vbmi2", [ 7] = "cet-ss", - [ 8] = "gfni", [ 9] = "vaes", - [10] = "vpclmulqdq", [11] = "avx512-vnni", - [12] = "avx512-bitalg", - [14] = "avx512-vpopcntdq", - - [22] = "rdpid", - /* 24 */ [25] = "cldemote", - /* 26 */ [27] = "movdiri", - [28] = "movdir64b", [29] = "enqcmd", - [30] = "sgx-lc", [31] = "pks", -}; - -static const char *const str_e7d[32] = -{ - /* 6 */ [ 7] = "hw-pstate", - [ 8] = "itsc", [ 9] = "cpb", - [10] = "efro", -}; - -static const char *const str_e8b[32] = -{ - [ 0] = "clzero", - [ 2] = "rstr-fp-err-ptrs", - - /* [ 8] */ [ 9] = "wbnoinvd", - - [12] = "ibpb", - [14] = "ibrs", [15] = "amd-stibp", - [16] = "ibrs-always", [17] = "stibp-always", - [18] = "ibrs-fast", [19] = "ibrs-same-mode", - - [20] = "no-lmsl", - /* [22] */ [23] = "ppin", - [24] = "amd-ssbd", [25] = "virt-ssbd", - [26] = "ssb-no", - [28] = "psfd", [29] = "btc-no", - [30] = "ibpb-ret", -}; - -static const char *const str_7d0[32] = -{ - [ 2] = "avx512-4vnniw", [ 3] = "avx512-4fmaps", - [ 4] = "fsrm", - - [ 8] = "avx512-vp2intersect", [ 9] = "srbds-ctrl", - [10] = "md-clear", [11] = "rtm-always-abort", - /* 12 */ [13] = "tsx-force-abort", - [14] = "serialize", [15] = "hybrid", - [16] = "tsxldtrk", - [18] = "pconfig", - [20] = "cet-ibt", - /* 22 */ [23] = "avx512-fp16", - - [26] = "ibrsb", [27] = "stibp", - [28] = "l1d-flush", [29] = "arch-caps", - [30] = "core-caps", [31] = "ssbd", -}; - -static const char *const str_7a1[32] = -{ - [ 0] = "sha512", [ 1] = "sm3", - [ 2] = "sm4", - [ 4] = "avx-vnni", [ 5] = "avx512-bf16", - - [10] = "fzrm", [11] = "fsrs", - [12] = "fsrcs", - - /* 18 */ [19] = "wrmsrns", - - /* 22 */ [23] = "avx-ifma", -}; - -static const char *const str_e21a[32] = -{ - [ 0] = "no-nest-bp", [ 1] = "fs-gs-ns", - [ 2] = "lfence+", - [ 6] = "nscb", - [ 8] = "auto-ibrs", - [10] = "amd-fsrs", [11] = "amd-fsrc", - - /* 16 */ [17] = "cpuid-user-dis", - [18] = "epsf", [19] = "fsrsc", - [20] = "amd-prefetchi", - - /* 26 */ [27] = "sbpb", - [28] = "ibpb-brtype", [29] = "srso-no", -}; - -static const char *const str_7b1[32] = -{ - [ 0] = "ppin", -}; - -static const char *const str_7c1[32] = -{ -}; - -static const char *const str_7d1[32] = -{ - [ 4] = "avx-vnni-int8", [ 5] = "avx-ne-convert", - - [10] = "avx-vnni-int16", - - [14] = "prefetchi", - - [18] = "cet-sss", -}; - -static const char *const str_7d2[32] = -{ - [ 0] = "intel-psfd", [ 1] = "ipred-ctrl", - [ 2] = "rrsba-ctrl", [ 3] = "ddp-ctrl", - [ 4] = "bhi-ctrl", [ 5] = "mcdt-no", -}; - -static const char *const str_m10Al[32] = -{ - [ 0] = "rdcl-no", [ 1] = "eibrs", - [ 2] = "rsba", [ 3] = "skip-l1dfl", - [ 4] = "intel-ssb-no", [ 5] = "mds-no", - [ 6] = "if-pschange-mc-no", [ 7] = "tsx-ctrl", - [ 8] = "taa-no", [ 9] = "mcu-ctrl", - [10] = "misc-pkg-ctrl", [11] = "energy-ctrl", - [12] = "doitm", [13] = "sbdr-ssdp-no", - [14] = "fbsdp-no", [15] = "psdp-no", - /* 16 */ [17] = "fb-clear", - [18] = "fb-clear-ctrl", [19] = "rrsba", - [20] = "bhi-no", [21] = "xapic-status", - /* 22 */ [23] = "ovrclk-status", - [24] = "pbrsb-no", [25] = "gds-ctrl", - [26] = "gds-no", [27] = "rfds-no", - [28] = "rfds-clear", -}; - -static const char *const str_m10Ah[32] = -{ -}; - static const struct { const char *name; const char *abbr; - const char *const *strs; } leaf_info[FEATURESET_NR_ENTRIES] = { - { "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" }, }; #define COL_ALIGN "24"