All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: babu.moger@amd.com, "Borislav Petkov (AMD)" <bp@alien8.de>,
	qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PATCH] target/i386: Add TSA feature flags
Date: Thu, 10 Jul 2025 10:57:49 +0800	[thread overview]
Message-ID: <de97d1cc-69c9-4fcf-aa7d-3989475549d5@intel.com> (raw)
In-Reply-To: <8ba851bc-e7b3-461b-9bfb-4d7018771f0c@amd.com>

On 7/9/2025 11:02 PM, Moger, Babu wrote:
> Hi Boris,
> 
> On 7/9/25 05:49, Borislav Petkov (AMD) wrote:
>> Hi,
>>
>> I *think* this is how it should be done but I might be forgetting something.
>> It seems to work in my testing here.
>>
>> Babu, double-check me pls.
>>
>> Thx.
> 
> 
> Patch looks good. Few comments.
> 
> Is KVM aware of these bits? I didn’t notice any patches adding support for
> them in the kernel.

Hi Boris,

Besides KVM patch, would you please provide the public doc that 
describes the new bits?

> I recommend splitting this into two separate patches:
> a. One patch to introduce the new bit 0021_EAX_VERW_CLEAR.

It also needs to be a separate patch to add it to "EPYC-Genoa" as v3, so 
please make it 3 patches.

> b. Another patch to add the new feature leaf FEAT_8000_0021_ECX.
> Also, don’t forget to define tsa-sq-no and tsa-l1-no in target/i386/cpu.h.
> 
> 
>>
>> ---
>>
>> Add CPUID leaf 0x8000_0021.ECX support and add the TSA CPUID flags.
>>
>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>> ---
>>   target/i386/cpu.c | 20 +++++++++++++++++++-
>>   target/i386/cpu.h |  3 +++
>>   2 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>> index 0d35e95430fe..b889de61ed9d 100644
>> --- a/target/i386/cpu.c
>> +++ b/target/i386/cpu.c
>> @@ -1274,7 +1274,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
>>           .type = CPUID_FEATURE_WORD,
>>           .feat_names = {
>>               "no-nested-data-bp", "fs-gs-base-ns", "lfence-always-serializing", NULL,
>> -            NULL, NULL, "null-sel-clr-base", NULL,
>> +            NULL, "verw-clear", "null-sel-clr-base", NULL,
>>               "auto-ibrs", NULL, NULL, NULL,
>>               NULL, NULL, NULL, NULL,
>>               NULL, NULL, NULL, NULL,
>> @@ -1308,6 +1308,22 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
>>           .tcg_features = 0,
>>           .unmigratable_flags = 0,
>>       },
>> +    [FEAT_8000_0021_ECX] = {
>> +        .type = CPUID_FEATURE_WORD,
>> +        .feat_names = {
>> +            NULL, "tsa-sq-no", "tsa-l1-no", 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,
>> +        },
>> +        .cpuid = { .eax = 0x80000021, .reg = R_ECX, },
>> +        .tcg_features = 0,
>> +        .unmigratable_flags = 0,
>> +    },
>>       [FEAT_XSAVE] = {
>>           .type = CPUID_FEATURE_WORD,
>>           .feat_names = {
>> @@ -5835,6 +5851,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
>>           .features[FEAT_8000_0021_EAX] =
>>               CPUID_8000_0021_EAX_NO_NESTED_DATA_BP |
>>               CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING |
>> +            CPUID_8000_0021_EAX_VERW_CLEAR |
>>               CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE |
>>               CPUID_8000_0021_EAX_AUTO_IBRS,
>>           .features[FEAT_7_0_EBX] =
>> @@ -7934,6 +7951,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
>>           *eax = *ebx = *ecx = *edx = 0;
>>           *eax = env->features[FEAT_8000_0021_EAX];
>>           *ebx = env->features[FEAT_8000_0021_EBX];
>> +        *ecx = env->features[FEAT_8000_0021_ECX];
>>           break;
>>       default:
>>           /* reserved values: zero */
>> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
>> index 51e10139dfdf..8b2703f41b73 100644
>> --- a/target/i386/cpu.h
>> +++ b/target/i386/cpu.h
>> @@ -641,6 +641,7 @@ typedef enum FeatureWord {
>>       FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */
>>       FEAT_8000_0021_EAX, /* CPUID[8000_0021].EAX */
>>       FEAT_8000_0021_EBX, /* CPUID[8000_0021].EBX */
>> +    FEAT_8000_0021_ECX, /* CPUID[8000_0021].ECX */
>>       FEAT_8000_0022_EAX, /* CPUID[8000_0022].EAX */
>>       FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */
>>       FEAT_KVM,           /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */
>> @@ -1101,6 +1102,8 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);
>>   #define CPUID_8000_0021_EAX_FS_GS_BASE_NS                (1U << 1)
>>   /* LFENCE is always serializing */
>>   #define CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING    (1U << 2)
>> +/* Memory form of VERW mitigates TSA */
>> +#define CPUID_8000_0021_EAX_VERW_CLEAR                   (1U << 5)
>>   /* Null Selector Clears Base */
>>   #define CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE            (1U << 6)
>>   /* Automatic IBRS */
> 
> We need to define tsa-sq-no and tsa-l1-no here.
> These definitions can be used later when adding a new CPU model.

Add them later along with the patch introduces the new CPU model is also OK.



  reply	other threads:[~2025-07-10  2:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 10:49 [PATCH] target/i386: Add TSA feature flags Borislav Petkov (AMD)
2025-07-09 15:02 ` Moger, Babu
2025-07-10  2:57   ` Xiaoyao Li [this message]
2025-07-10  9:11     ` Zhao Liu
2025-07-10 16:18     ` Moger, Babu

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=de97d1cc-69c9-4fcf-aa7d-3989475549d5@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.