mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xin Li <xin@zytor.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	tglx@linutronix.de, mingo@redhat.com,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	will@kernel.org, peterz@infradead.org, yury.norov@gmail.com,
	akpm@linux-foundation.org, acme@kernel.org, namhyung@kernel.org,
	brgerst@gmail.com, andrew.cooper3@citrix.com,
	nik.borisov@suse.com
Subject: Re: [PATCH v5 5/5] x86/cpufeatures: Add the CPU feature bit for MSR immediate form instructions
Date: Sun, 23 Feb 2025 23:30:21 -0800	[thread overview]
Message-ID: <52bf4850-b66c-4692-8827-8995793607c3@zytor.com> (raw)
In-Reply-To: <20250222163001.GUZ7n7iRc88PTMQi9_@fat_crate.local>

On 2/22/2025 8:30 AM, Borislav Petkov wrote:
> On Sun, Jan 05, 2025 at 11:07:27PM -0800, Xin Li (Intel) wrote:
>> The immediate form of MSR access instructions are primarily motivated by
>> performance, not code size: by having the MSR number in an immediate, it
>> is available *much* earlier in the pipeline, which allows the hardware
>> much more leeway about how a particular MSR is handled.
>>
>> Add a new CPU feature word for CPUID.7.1.ECX and then the CPU feature bit
>> for MSR immediate form.
> 
> Nope, scattered.c.

Oh, neat.

>> @@ -476,6 +476,9 @@
>>   #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */
>>   #define X86_FEATURE_AMD_WORKLOAD_CLASS	(21*32 + 7) /* Workload Classification */
>>   
>> +/* Intel-defined CPU features, CPUID level 0x00000007:1 (ECX), word 22 */
>> +#define X86_FEATURE_MSR_IMM		(22*32+ 5) /* "msr_imm" MSR immediate form instructions */
> 
> Also no "msr_imm": Documentation/arch/x86/cpuinfo.rst

My bad.

> 
> In any case, this patch doesn't belong in this set.
> 

Right.

I tried to show that we don't need to make the following changes due to
NCAPINTS increased to 23 if this patch is based on this patch set.

But if this feature is added through scattered.c, NCAPINTS is not even
changed...

Thanks!
     Xin

---
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index de1ad09fe8d7..051d006cc0c6 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -95,7 +96,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
            CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 20, feature_bit) ||    \
            CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 21, feature_bit) ||    \
            REQUIRED_MASK_CHECK                                    ||    \
-          BUILD_BUG_ON_ZERO(NCAPINTS != 22))
+          BUILD_BUG_ON_ZERO(NCAPINTS != 23))

  #define DISABLED_MASK_BIT_SET(feature_bit)                             \
          ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK,  0, feature_bit) ||    \
@@ -121,7 +122,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
            CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 20, feature_bit) ||    \
            CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 21, feature_bit) ||    \
            DISABLED_MASK_CHECK                                    ||    \
-          BUILD_BUG_ON_ZERO(NCAPINTS != 22))
+          BUILD_BUG_ON_ZERO(NCAPINTS != 23))

  #define cpu_has(c, bit) 
         \
         (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 :  \
diff --git a/arch/x86/include/asm/disabled-features.h 
b/arch/x86/include/asm/disabled-features.h
index c492bdc97b05..c6a1f962185c 100644
--- a/arch/x86/include/asm/disabled-features.h
+++ b/arch/x86/include/asm/disabled-features.h
@@ -156,6 +156,6 @@
  #define DISABLED_MASK19        (DISABLE_SEV_SNP)
  #define DISABLED_MASK20        0
  #define DISABLED_MASK21        0
-#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 22)
+#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 23)

  #endif /* _ASM_X86_DISABLED_FEATURES_H */
diff --git a/arch/x86/include/asm/required-features.h 
b/arch/x86/include/asm/required-features.h
index e9187ddd3d1f..a346db1d078c 100644
--- a/arch/x86/include/asm/required-features.h
+++ b/arch/x86/include/asm/required-features.h
@@ -100,6 +100,6 @@
  #define REQUIRED_MASK19        0
  #define REQUIRED_MASK20        0
  #define REQUIRED_MASK21        0
-#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 22)
+#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 23)

  #endif /* _ASM_X86_REQUIRED_FEATURES_H */



  parent reply	other threads:[~2025-02-24  7:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  7:07 [PATCH v5 0/5] x86/cpufeatures: Automatically generate required and disabled feature masks Xin Li (Intel)
2025-01-06  7:07 ` [PATCH v5 1/5] x86/cpufeatures: Add {required,disabled} feature configs Xin Li (Intel)
2025-02-14 21:58   ` Borislav Petkov
2025-02-15 10:12     ` H. Peter Anvin
2025-02-15 14:20       ` Borislav Petkov
2025-02-15 14:27         ` H. Peter Anvin
2025-02-15 14:30           ` Borislav Petkov
2025-02-15 14:35             ` H. Peter Anvin
2025-02-15 14:44               ` Borislav Petkov
2025-01-06  7:07 ` [PATCH v5 2/5] x86/cpufeatures: Generate a feature mask header based on build config Xin Li (Intel)
2025-01-06  7:07 ` [PATCH v5 3/5] x86/cpufeatures: Remove {disabled,required}-features.h Xin Li (Intel)
2025-01-06  7:07 ` [PATCH v5 4/5] x86/cpufeatures: Use AWK to generate {REQUIRED|DISABLED}_MASK_BIT_SET Xin Li (Intel)
2025-01-06  7:07 ` [PATCH v5 5/5] x86/cpufeatures: Add the CPU feature bit for MSR immediate form instructions Xin Li (Intel)
2025-02-22 16:30   ` Borislav Petkov
2025-02-22 18:12     ` Borislav Petkov
2025-02-24  7:30     ` Xin Li [this message]
2025-02-24 17:27       ` H. Peter Anvin
2025-02-11  2:25 ` [PATCH v5 0/5] x86/cpufeatures: Automatically generate required and disabled feature masks Xin Li
2025-02-23 10:27 ` Borislav Petkov
2025-02-25 17:10   ` Xin Li
2025-02-25 17:49     ` Borislav Petkov
2025-02-25 17:54       ` Nikolay Borisov
2025-02-25 18:00         ` Borislav Petkov
2025-02-25 18:10           ` H. Peter Anvin
2025-02-25 18:15             ` Borislav Petkov
2025-02-25 18:37               ` Xin Li
2025-02-25 20:30               ` H. Peter Anvin

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=52bf4850-b66c-4692-8827-8995793607c3@zytor.com \
    --to=xin@zytor.com \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yury.norov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®