From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: <x86@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<hpa@zytor.com>, Dave Hansen <dave.hansen@intel.com>
Subject: [PATCH] x86/cpufeature: explicit comments for duplicate macro
Date: Wed, 28 Aug 2019 14:11:00 +0800 [thread overview]
Message-ID: <20190828061100.27032-1-caoj.fnst@cn.fujitsu.com> (raw)
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
next reply other threads:[~2019-08-28 6:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 6:11 Cao jin [this message]
2019-08-28 6:42 ` [PATCH] x86/cpufeature: explicit comments for duplicate macro 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
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=20190828061100.27032-1-caoj.fnst@cn.fujitsu.com \
--to=caoj.fnst@cn.fujitsu.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).