[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 09/40] i386/tdx: Update tdx_fixed0/1 bits by tdx_caps.cpuid_co
From: |
Xiaoyao Li |
Subject: |
[PATCH v1 09/40] i386/tdx: Update tdx_fixed0/1 bits by tdx_caps.cpuid_config[] |
Date: |
Tue, 2 Aug 2022 15:47:19 +0800 |
tdx_cpuid_lookup[].tdx_fixed0/1 is the QEMU maintained data which
reflects TDX restrictions regrading how some CPUID is virtualized by
TDX. It's retrieved from TDX spec. However, TDX may 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 | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index e3e9a424512e..d12b03fa05c9 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -369,6 +369,34 @@ static void get_tdx_capabilities(void)
tdx_caps = caps;
}
+static void update_tdx_cpuid_lookup_by_tdx_caps(void)
+{
+ KvmTdxCpuidLookup *entry;
+ FeatureWordInfo *fi;
+ uint32_t config;
+ FeatureWord w;
+
+ /*
+ * Patch tdx_fixed0/1 by tdx_caps that what TDX module reports as
+ * configurable is not fixed.
+ */
+ 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);
+
+ entry->tdx_fixed0 &= ~config;
+ entry->tdx_fixed1 &= ~config;
+ }
+}
+
int tdx_kvm_init(MachineState *ms, Error **errp)
{
TdxGuest *tdx = (TdxGuest *)object_dynamic_cast(OBJECT(ms->cgs),
@@ -378,6 +406,8 @@ int tdx_kvm_init(MachineState *ms, Error **errp)
get_tdx_capabilities();
}
+ update_tdx_cpuid_lookup_by_tdx_caps();
+
tdx_guest = tdx;
return 0;
--
2.27.0
- Re: [PATCH v1 06/40] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES, (continued)
- [PATCH v1 07/40] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, Xiaoyao Li, 2022/08/02
- [PATCH v1 08/40] i386/tdx: Adjust the supported CPUID based on TDX restrictions, Xiaoyao Li, 2022/08/02
- [PATCH v1 09/40] i386/tdx: Update tdx_fixed0/1 bits by tdx_caps.cpuid_config[],
Xiaoyao Li <=
- [PATCH v1 12/40] i386/kvm: Move architectural CPUID leaf generation to separate helper, Xiaoyao Li, 2022/08/02
- [PATCH v1 10/40] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup, Xiaoyao Li, 2022/08/02
- [PATCH v1 11/40] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup, Xiaoyao Li, 2022/08/02
- [PATCH v1 13/40] KVM: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2022/08/02
- [PATCH v1 14/40] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2022/08/02
- [PATCH v1 15/40] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2022/08/02