linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/cpufeature: explicit comments for duplicate macro
@ 2019-08-28  6:11 Cao jin
  2019-08-28  6:42 ` Borislav Petkov
  2019-08-28  6:49 ` [tip: x86/cleanups] x86/cpufeature: Explain the macro duplication tip-bot2 for Cao Jin
  0 siblings, 2 replies; 4+ messages in thread
From: Cao jin @ 2019-08-28  6:11 UTC (permalink / raw)
  To: x86, linux-kernel; +Cc: tglx, mingo, bp, hpa, Dave Hansen

Help people to understand the author's intent of apparent duplication of
BUILD_BUG_ON_ZERO(NCAPINTS != n), which is hard to detect by eyes.

CC: Dave Hansen <dave.hansen@intel.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
Tried my best to describe it accurately, in case of any inaccuracy, feel
free to rephrase.

 arch/x86/include/asm/cpufeature.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 58acda503817..e943174abf1e 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -61,6 +61,17 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 #define CHECK_BIT_IN_MASK_WORD(maskname, word, bit)	\
 	(((bit)>>5)==(word) && (1UL<<((bit)&31) & maskname##word ))
 
+/*
+ * REQUIRED_MASK_CHECK may seems duplicate, but actually has its reason to
+ * live here.
+ * New CPUID leaf added or feature bit adjustment would/may result in increase
+ * in NCAPINTS. When it does, two required-features.h and here need to be
+ * modified correspondingly. BUILD_BUG_ON_ZERO assures the modification to be
+ * carried out, checking NCAPINTS also reminds the additional lines for new
+ * word. But, required-features.h as a single header file, can't be compiled
+ * directly, that is why a wrapper is defined there and called here.
+ * Totally the same case for DISABLED_MASK_BIT_SET.
+ */
 #define REQUIRED_MASK_BIT_SET(feature_bit)		\
 	 ( CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK,  0, feature_bit) ||	\
 	   CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK,  1, feature_bit) ||	\
-- 
2.17.0




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/cpufeature: explicit comments for duplicate macro
  2019-08-28  6:11 [PATCH] x86/cpufeature: explicit comments for duplicate macro Cao jin
@ 2019-08-28  6:42 ` Borislav Petkov
  2019-08-28  8:16   ` Cao jin
  2019-08-28  6:49 ` [tip: x86/cleanups] x86/cpufeature: Explain the macro duplication tip-bot2 for Cao Jin
  1 sibling, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2019-08-28  6:42 UTC (permalink / raw)
  To: Cao jin; +Cc: x86, linux-kernel, tglx, mingo, hpa, Dave Hansen

On Wed, Aug 28, 2019 at 02:11:00PM +0800, Cao jin wrote:

For the future:

> Subject: Re: [PATCH] x86/cpufeature: explicit comments for duplicate macro

your subject needs to have a verb and start with a capital letter after
the subsystem/path prefix. In this case, something like this, for
example:

Subject: [PATCH] x86/cpufeature: Explain the macro duplication

> Help people to understand the author's intent of apparent duplication of
> BUILD_BUG_ON_ZERO(NCAPINTS != n), which is hard to detect by eyes.
> 
> CC: Dave Hansen <dave.hansen@intel.com>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> Tried my best to describe it accurately, in case of any inaccuracy, feel
> free to rephrase.

Yap, I fixed it up.

Thanks!

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: x86/cleanups] x86/cpufeature: Explain the macro duplication
  2019-08-28  6:11 [PATCH] x86/cpufeature: explicit comments for duplicate macro Cao jin
  2019-08-28  6:42 ` Borislav Petkov
@ 2019-08-28  6:49 ` tip-bot2 for Cao Jin
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Cao Jin @ 2019-08-28  6:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Borislav Petkov, Cao Jin, Borislav Petkov, Dave Hansen,
	Fenghua Yu, H. Peter Anvin, Ingo Molnar, Jann Horn,
	Masahiro Yamada, Michael Ellerman, Nadav Amit, Thomas Gleixner,
	x86-ml, Ingo Molnar, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     cbb1133b563a63901cf778220eb17e3ff1425aed
Gitweb:        https://git.kernel.org/tip/cbb1133b563a63901cf778220eb17e3ff1425aed
Author:        Cao Jin <caoj.fnst@cn.fujitsu.com>
AuthorDate:    Wed, 28 Aug 2019 14:11:00 +08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Wed, 28 Aug 2019 08:38:39 +02:00

x86/cpufeature: Explain the macro duplication

Explain the intent behind the duplication of the

  BUILD_BUG_ON_ZERO(NCAPINTS != n)

check in *_MASK_CHECK and its immediate use in the *MASK_BIT_SET macros
too.

 [ bp: Massage. ]

Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Cao Jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nadav Amit <namit@vmware.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190828061100.27032-1-caoj.fnst@cn.fujitsu.com
---
 arch/x86/include/asm/cpufeature.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 58acda5..59bf91c 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -61,6 +61,13 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 #define CHECK_BIT_IN_MASK_WORD(maskname, word, bit)	\
 	(((bit)>>5)==(word) && (1UL<<((bit)&31) & maskname##word ))
 
+/*
+ * {REQUIRED,DISABLED}_MASK_CHECK below may seem duplicated with the
+ * following BUILD_BUG_ON_ZERO() check but when NCAPINTS gets changed, all
+ * header macros which use NCAPINTS need to be changed. The duplicated macro
+ * use causes the compiler to issue errors for all headers so that all usage
+ * sites can be corrected.
+ */
 #define REQUIRED_MASK_BIT_SET(feature_bit)		\
 	 ( CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK,  0, feature_bit) ||	\
 	   CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK,  1, feature_bit) ||	\

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/cpufeature: explicit comments for duplicate macro
  2019-08-28  6:42 ` Borislav Petkov
@ 2019-08-28  8:16   ` Cao jin
  0 siblings, 0 replies; 4+ messages in thread
From: Cao jin @ 2019-08-28  8:16 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: x86, linux-kernel, tglx, mingo, hpa, Dave Hansen

On 8/28/19 2:42 PM, Borislav Petkov wrote:
> On Wed, Aug 28, 2019 at 02:11:00PM +0800, Cao jin wrote:
> 
> For the future:
> 
>> Subject: Re: [PATCH] x86/cpufeature: explicit comments for duplicate macro
> 
> your subject needs to have a verb and start with a capital letter after
> the subsystem/path prefix. In this case, something like this, for
> example:
> 
> Subject: [PATCH] x86/cpufeature: Explain the macro duplication
> 

Kept that in mind. Thanks very much!

-- 
Sincerely,
Cao jin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-28  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28  6:11 [PATCH] x86/cpufeature: explicit comments for duplicate macro Cao jin
2019-08-28  6:42 ` Borislav Petkov
2019-08-28  8:16   ` Cao jin
2019-08-28  6:49 ` [tip: x86/cleanups] x86/cpufeature: Explain the macro duplication tip-bot2 for Cao Jin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).