On Tue, Apr 01, 2025 at 09:01:54AM -0400, Xiaoyao Li wrote: > Date: Tue, 1 Apr 2025 09:01:54 -0400 > From: Xiaoyao Li <xiaoyao...@intel.com> > Subject: [PATCH v8 44/55] i386/tdx: Implement adjust_cpuid_features() for > TDX > X-Mailer: git-send-email 2.34.1 > > Maintain a TDX specific supported CPUID set, and use it to mask the > common supported CPUID value of KVM. It can avoid newly added supported > features (reported via KVM_GET_SUPPORTED_CPUID) for common VMs being > falsely reported as supported for TDX. > > As the first step, initialize the TDX supported CPUID set with all the > configurable CPUID bits. It's not complete because there are other CPUID > bits are supported for TDX but not reported as directly configurable. > E.g. the XFAM related bits, attribute related bits and fixed-1 bits. > They will be handled in the future. > > Also, what matters are the CPUID bits related to QEMU's feature word. > Only mask the CPUID leafs which are feature word leaf. > > Signed-off-by: Xiaoyao Li <xiaoyao...@intel.com> > --- > target/i386/cpu.c | 18 ++++++++++++++++++ > target/i386/cpu.h | 1 + > target/i386/kvm/kvm.c | 2 +- > target/i386/kvm/kvm_i386.h | 1 + > target/i386/kvm/tdx.c | 34 ++++++++++++++++++++++++++++++++++ > 5 files changed, 55 insertions(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1....@intel.com> > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index f219961b62cd..4061d38d3fbe 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -1655,6 +1655,24 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { > }, > }; > > +bool is_feature_word_cpuid(uint32_t feature, uint32_t index, int reg) > +{ > + FeatureWordInfo *wi; > + FeatureWord w; > + > + for (w = 0; w < FEATURE_WORDS; w++) > + { (style nit?) "{" should be at the end of the previous line? > + wi = &feature_word_info[w]; > + if (wi->type == CPUID_FEATURE_WORD && wi->cpuid.eax == feature && > + (!wi->cpuid.needs_ecx || wi->cpuid.ecx == index) && > + wi->cpuid.reg == reg) > + { ditto. > + return true; > + } > + } > + return false; > +} > +