[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 19/66] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx
From: |
Xiaoyao Li |
Subject: |
[PATCH v4 19/66] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[] |
Date: |
Wed, 24 Jan 2024 22:22:41 -0500 |
tdx_cpuid_lookup[].tdx_fixed0/1 is QEMU maintained data which reflects
TDX restrictions regrading what bits are fixed by TDX module.
It's retrieved from TDX spec and static. However, TDX may evolve and
change some fixed fields to configurable in the future. Update
tdx_cpuid.lookup[].tdx_fixed0/1 fields by removing the bits that
reported from TDX module as configurable. This can adapt with the
updated TDX (module) automatically.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
target/i386/kvm/tdx.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index 2703e97f991d..5dfea0378f26 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -377,6 +377,38 @@ static int get_tdx_capabilities(Error **errp)
return 0;
}
+static void update_tdx_cpuid_lookup_by_tdx_caps(void)
+{
+ KvmTdxCpuidLookup *entry;
+ FeatureWordInfo *fi;
+ uint32_t config;
+ FeatureWord w;
+
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ fi = &feature_word_info[w];
+ entry = &tdx_cpuid_lookup[w];
+
+ if (fi->type != CPUID_FEATURE_WORD) {
+ continue;
+ }
+
+ config = tdx_cap_cpuid_config(fi->cpuid.eax,
+ fi->cpuid.needs_ecx ? fi->cpuid.ecx :
~0u,
+ fi->cpuid.reg);
+
+ if (!config) {
+ continue;
+ }
+
+ /*
+ * Remove the configurable bits from tdx_fixed0/1 in case QEMU
+ * maintained fixed0/1 values is outdated to TDX module.
+ */
+ entry->tdx_fixed0 &= ~config;
+ entry->tdx_fixed1 &= ~config;
+ }
+}
+
int tdx_kvm_init(MachineState *ms, Error **errp)
{
TdxGuest *tdx = TDX_GUEST(OBJECT(ms->cgs));
@@ -391,6 +423,8 @@ int tdx_kvm_init(MachineState *ms, Error **errp)
}
}
+ update_tdx_cpuid_lookup_by_tdx_caps();
+
tdx_guest = tdx;
return 0;
}
--
2.34.1
- [PATCH v4 10/66] *** HACK *** linux-headers: Update headers to pull in TDX API changes, (continued)
- [PATCH v4 10/66] *** HACK *** linux-headers: Update headers to pull in TDX API changes, Xiaoyao Li, 2024/01/24
- [PATCH v4 09/66] trace/kvm: Add trace for page convertion between shared and private, Xiaoyao Li, 2024/01/24
- [PATCH v4 12/66] target/i386: Implement mc->kvm_type() to get VM type, Xiaoyao Li, 2024/01/24
- [PATCH v4 11/66] i386: Introduce tdx-guest object, Xiaoyao Li, 2024/01/24
- [PATCH v4 13/66] target/i386: Introduce kvm_confidential_guest_init(), Xiaoyao Li, 2024/01/24
- [PATCH v4 15/66] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES, Xiaoyao Li, 2024/01/24
- [PATCH v4 14/66] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context, Xiaoyao Li, 2024/01/24
- [PATCH v4 16/66] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, Xiaoyao Li, 2024/01/24
- [PATCH v4 18/66] i386/tdx: Make Intel-PT unsupported for TD guest, Xiaoyao Li, 2024/01/24
- [PATCH v4 17/66] i386/tdx: Adjust the supported CPUID based on TDX restrictions, Xiaoyao Li, 2024/01/24
- [PATCH v4 19/66] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[],
Xiaoyao Li <=
- [PATCH v4 20/66] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup, Xiaoyao Li, 2024/01/24
- [PATCH v4 21/66] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup, Xiaoyao Li, 2024/01/24
- [PATCH v4 22/66] i386/kvm: Move architectural CPUID leaf generation to separate helper, Xiaoyao Li, 2024/01/24
- [PATCH v4 23/66] kvm: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2024/01/24
- [PATCH v4 24/66] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2024/01/24
- [PATCH v4 25/66] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2024/01/24
- [PATCH v4 27/66] i386/tdx: Wire CPU features up with attributes of TD guest, Xiaoyao Li, 2024/01/24
- [PATCH v4 28/66] i386/tdx: Validate TD attributes, Xiaoyao Li, 2024/01/24
- [PATCH v4 26/66] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2024/01/24
- [PATCH v4 29/66] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig, Xiaoyao Li, 2024/01/24