From: Tim Wiederhake <twiederh@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Tim Wiederhake" <twiederh@redhat.com>
Subject: [PATCH v3 5/5] target/i386: Generate feature_word_info.c.inc
Date: Tue, 6 Feb 2024 14:47:39 +0100 [thread overview]
Message-ID: <20240206134739.15345-6-twiederh@redhat.com> (raw)
In-Reply-To: <20240206134739.15345-1-twiederh@redhat.com>
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
---
target/i386/feature_word_info.c.inc | 30 ++++++++++--
target/i386/feature_word_info.py | 71 +++++++++++++++++++++++++++++
target/i386/feature_word_info.yaml | 2 +
3 files changed, 99 insertions(+), 4 deletions(-)
create mode 100755 target/i386/feature_word_info.py
diff --git a/target/i386/feature_word_info.c.inc b/target/i386/feature_word_info.c.inc
index 4beae01918..b4bece08fe 100644
--- a/target/i386/feature_word_info.c.inc
+++ b/target/i386/feature_word_info.c.inc
@@ -1,3 +1,5 @@
+/* This file is generated by feature_word_info.py. */
+
FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
[FEAT_1_EDX] = {
.type = CPUID_FEATURE_WORD,
@@ -587,9 +589,22 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
[FEAT_VMX_BASIC] = {
.type = MSR_FEATURE_WORD,
.feat_names = {
- [54] = "vmx-ins-outs",
- [55] = "vmx-true-ctls",
- [56] = "vmx-any-errcode",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, "vmx-ins-outs", "vmx-true-ctls",
+ "vmx-any-errcode", NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
},
.msr = {
.index = MSR_IA32_VMX_BASIC,
@@ -599,7 +614,14 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
[FEAT_VMX_VMFUNC] = {
.type = MSR_FEATURE_WORD,
.feat_names = {
- [0] = "vmx-eptp-switching",
+ "vmx-eptp-switching", NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
},
.msr = {
.index = MSR_IA32_VMX_VMFUNC,
diff --git a/target/i386/feature_word_info.py b/target/i386/feature_word_info.py
new file mode 100755
index 0000000000..c9aa00900c
--- /dev/null
+++ b/target/i386/feature_word_info.py
@@ -0,0 +1,71 @@
+#!/bin/env python3
+
+import os
+import yaml
+
+
+def write_feature_word(f, data):
+ f.write(" [{}] = {{\n".format(data["index"]))
+ f.write(" .type = {},\n".format(data["type"]))
+
+ if "feat_names" in data:
+ keys = data.get("feat_names").keys()
+ if not keys or max(keys) < 32:
+ highest = 32
+ else:
+ highest = 64
+
+ f.write(" .feat_names = {\n")
+ for i in range(0, highest, 4):
+ names = [data.get("feat_names").get(j) for j in range(i, i + 4)]
+ names = ["NULL" if not name else f"\"{name}\"" for name in names]
+ display = ", ".join(names)
+ if len(display) < 90:
+ f.write(" {},\n".format(display))
+ else:
+ f.write(" {}, {},\n".format(names[0], names[1]))
+ f.write(" {}, {},\n".format(names[2], names[3]))
+ f.write(" },\n")
+ if "cpuid" in data:
+ cpuid = data["cpuid"]
+ f.write(" .cpuid = {\n")
+ f.write(" .eax = {},\n".format(cpuid["eax"]))
+ if "ecx" in cpuid:
+ f.write(" .needs_ecx = true,\n")
+ f.write(" .ecx = {},\n".format(cpuid["ecx"]))
+ f.write(" .reg = {},\n".format(cpuid["reg"]))
+ f.write(" },\n")
+ if "msr" in data:
+ f.write(" .msr = {\n")
+ f.write(" .index = {},\n".format(data["msr"]))
+ f.write(" },\n")
+ if "tcg_features" in data:
+ f.write(" .tcg_features = {},\n".format(data["tcg_features"]))
+ if "unmigratable_flags" in data:
+ f.write(" .unmigratable_flags = {},\n".format(
+ data["unmigratable_flags"]))
+ if "migratable_flags" in data:
+ f.write(" .migratable_flags = {},\n".format(
+ data["migratable_flags"]))
+ if "no_autoenable_flags" in data:
+ f.write(" .no_autoenable_flags = {},\n".format(
+ data["no_autoenable_flags"]))
+ f.write(" },\n")
+
+
+def main():
+ dirname = os.path.dirname(__file__)
+
+ with open(os.path.join(dirname, "feature_word_info.yaml"), "tr") as f:
+ feature_words = yaml.safe_load(f)
+
+ with open(os.path.join(dirname, "feature_word_info.c.inc"), "tw") as f:
+ f.write("/* This file is generated by feature_word_info.py. */\n\n")
+ f.write("FeatureWordInfo feature_word_info[FEATURE_WORDS] = {\n")
+ for feature_word in feature_words:
+ write_feature_word(f, feature_word)
+ f.write("};\n")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/target/i386/feature_word_info.yaml b/target/i386/feature_word_info.yaml
index 7a8ca3f051..0e9dbcb613 100644
--- a/target/i386/feature_word_info.yaml
+++ b/target/i386/feature_word_info.yaml
@@ -1,3 +1,5 @@
+# Run feature_word_info.py if you make changes to this file!
+
- index: FEAT_1_EDX
cpuid:
eax: '1'
--
2.43.0
next prev parent reply other threads:[~2024-02-06 13:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 13:47 [PATCH v3 0/5] Generate x86 cpu features Tim Wiederhake
2024-02-06 13:47 ` [PATCH v3 1/5] target/i386: Split out feature_word_info Tim Wiederhake
2024-02-06 13:47 ` [PATCH v3 2/5] target/i386: Translate feature_word_info to yaml Tim Wiederhake
2024-02-06 13:47 ` [PATCH v3 3/5] target/i386: Remove comments from feature_word_info.c.inc Tim Wiederhake
2024-02-06 13:47 ` [PATCH v3 4/5] target/i386: Fix feature_word_info.c.inc formatting Tim Wiederhake
2024-02-06 13:47 ` Tim Wiederhake [this message]
2024-03-04 12:04 ` [PATCH v3 0/5] Generate x86 cpu features Tim Wiederhake
2024-03-05 14:17 ` Daniel P. Berrangé
2024-03-11 11:32 ` Tim Wiederhake
2024-03-11 11:58 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240206134739.15345-6-twiederh@redhat.com \
--to=twiederh@redhat.com \
--cc=berrange@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).