Re: [PATCH v7 48/52] i386/tdx: Fetch and validate CPUID of TD guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Xiaoyao Li <xiaoyao.li@xxxxxxxxx> writes:

> Use KVM_TDX_GET_CPUID to get the CPUIDs that are managed and enfored
> by TDX module for TD guest. Check QEMU's configuration against the
> fetched data.
>
> Print wanring  message when 1. a feature is not supported but requested
> by QEMU or 2. QEMU doesn't want to expose a feature while it is enforced
> enabled.
>
> - If cpu->enforced_cpuid is not set, prints the warning message of both
> 1) and 2) and tweak QEMU's configuration.
>
> - If cpu->enforced_cpuid is set, quit if any case of 1) or 2).
>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
> ---
>  target/i386/cpu.c     | 33 ++++++++++++++-
>  target/i386/cpu.h     |  7 +++
>  target/i386/kvm/tdx.c | 99 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 137 insertions(+), 2 deletions(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index f1330627adbb..a948fd0bd674 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -5482,8 +5482,8 @@ static bool x86_cpu_have_filtered_features(X86CPU *cpu)
>      return false;
>  }
>  
> -static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
> -                                      const char *verbose_prefix)
> +void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
> +                               const char *verbose_prefix)
>  {
>      CPUX86State *env = &cpu->env;
>      FeatureWordInfo *f = &feature_word_info[w];
> @@ -5510,6 +5510,35 @@ static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
>      }
>  }
>  
> +void mark_forced_on_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
> +                             const char *verbose_prefix)
> +{
> +    CPUX86State *env = &cpu->env;
> +    FeatureWordInfo *f = &feature_word_info[w];
> +    int i;
> +
> +    if (!cpu->force_features) {
> +        env->features[w] |= mask;
> +    }
> +
> +    cpu->forced_on_features[w] |= mask;
> +
> +    if (!verbose_prefix) {
> +        return;
> +    }
> +
> +    for (i = 0; i < 64; ++i) {
> +        if ((1ULL << i) & mask) {
> +            g_autofree char *feat_word_str = feature_word_description(f);

Does not compile for me:

    ../target/i386/cpu.c: In function ‘mark_forced_on_features’:
    ../target/i386/cpu.c:5531:46: error: too few arguments to function ‘feature_word_description’
     5531 |             g_autofree char *feat_word_str = feature_word_description(f);
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~
    ../target/i386/cpu.c:5451:14: note: declared here
     5451 | static char *feature_word_description(FeatureWordInfo *f, uint32_t bit)
          |              ^~~~~~~~~~~~~~~~~~~~~~~~

> +            warn_report("%s: %s%s%s [bit %d]",
> +                        verbose_prefix,
> +                        feat_word_str,
> +                        f->feat_names[i] ? "." : "",
> +                        f->feat_names[i] ? f->feat_names[i] : "", i);
> +        }
> +    }
> +}
> +
>  static void x86_cpuid_version_get_family(Object *obj, Visitor *v,
>                                           const char *name, void *opaque,
>                                           Error **errp)

[...]






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux