linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Tony Luck" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@suse.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/cpu] x86/cpu: Read/save PPIN MSR during initialization
Date: Wed, 02 Feb 2022 06:31:14 -0000	[thread overview]
Message-ID: <164378347431.16921.12171659364065648377.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20220131230111.2004669-4-tony.luck@intel.com>

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

Commit-ID:     822ccfade55b6be7977b364356fcf2d78d8a373a
Gitweb:        https://git.kernel.org/tip/822ccfade55b6be7977b364356fcf2d78d8a373a
Author:        Tony Luck <tony.luck@intel.com>
AuthorDate:    Mon, 31 Jan 2022 15:01:09 -08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 01 Feb 2022 16:29:26 +01:00

x86/cpu: Read/save PPIN MSR during initialization

Currently, the PPIN (Protected Processor Inventory Number) MSR is read
by every CPU that processes a machine check, CMCI, or just polls machine
check banks from a periodic timer. This is not a "fast" MSR, so this
adds to overhead of processing errors.

Add a new "ppin" field to the cpuinfo_x86 structure. Read and save the
PPIN during initialization. Use this copy in mce_setup() instead of
reading the MSR.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220131230111.2004669-4-tony.luck@intel.com
---
 arch/x86/include/asm/processor.h | 2 ++
 arch/x86/kernel/cpu/common.c     | 4 ++++
 arch/x86/kernel/cpu/mce/core.c   | 7 +------
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 2c5f12a..a87e7c3 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -119,6 +119,8 @@ struct cpuinfo_x86 {
 	int			x86_cache_mbm_width_offset;
 	int			x86_power;
 	unsigned long		loops_per_jiffy;
+	/* protected processor identification number */
+	u64			ppin;
 	/* cpuid returned max cores value: */
 	u16			x86_max_cores;
 	u16			apicid;
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 0681c69..64deb77 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -91,14 +91,17 @@ DEFINE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id) = BAD_APICID;
 static struct ppin_info {
 	int	feature;
 	int	msr_ppin_ctl;
+	int	msr_ppin;
 } ppin_info[] = {
 	[X86_VENDOR_INTEL] = {
 		.feature = X86_FEATURE_INTEL_PPIN,
 		.msr_ppin_ctl = MSR_PPIN_CTL,
+		.msr_ppin = MSR_PPIN
 	},
 	[X86_VENDOR_AMD] = {
 		.feature = X86_FEATURE_AMD_PPIN,
 		.msr_ppin_ctl = MSR_AMD_PPIN_CTL,
+		.msr_ppin = MSR_AMD_PPIN
 	},
 };
 
@@ -153,6 +156,7 @@ static void ppin_init(struct cpuinfo_x86 *c)
 
 	/* Is the enable bit set? */
 	if (val & 2UL) {
+		c->ppin = __rdmsr(info->msr_ppin);
 		set_cpu_cap(c, info->feature);
 		return;
 	}
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 5818b83..4f1e825 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -138,12 +138,7 @@ void mce_setup(struct mce *m)
 	m->socketid = cpu_data(m->extcpu).phys_proc_id;
 	m->apicid = cpu_data(m->extcpu).initial_apicid;
 	m->mcgcap = __rdmsr(MSR_IA32_MCG_CAP);
-
-	if (this_cpu_has(X86_FEATURE_INTEL_PPIN))
-		m->ppin = __rdmsr(MSR_PPIN);
-	else if (this_cpu_has(X86_FEATURE_AMD_PPIN))
-		m->ppin = __rdmsr(MSR_AMD_PPIN);
-
+	m->ppin = cpu_data(m->extcpu).ppin;
 	m->microcode = boot_cpu_data.microcode;
 }
 

  reply	other threads:[~2022-02-02  6:53 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07 22:54 [PATCH 0/5] PPIN (Protected Processor Inventory Number) updates Tony Luck
2022-01-07 22:54 ` [PATCH 1/5] x86/ras: Merge Intel and AMD ppin_init() functions Tony Luck
2022-01-18 20:02   ` Borislav Petkov
2022-01-18 21:03     ` Luck, Tony
2022-01-18 21:15       ` Borislav Petkov
2022-01-07 22:54 ` [PATCH 2/5] x86/ras: X86_FEATURE_INTEL_PPIN finally has a CPUID bit Tony Luck
2022-01-20 13:32   ` Borislav Petkov
2022-01-07 22:54 ` [PATCH 3/5] x86/ras: Read/save PPIN MSR during initialization Tony Luck
2022-01-07 22:54 ` [PATCH 4/5] x86/sysfs: Add format parameter to macro defining "show" functions for proc Tony Luck
2022-01-20 13:32   ` Borislav Petkov
2022-01-07 22:54 ` [PATCH 5/5] x86/sysfs: Add PPIN in sysfs under cpu topology Tony Luck
2022-01-20 13:35   ` Borislav Petkov
2022-01-20 18:01     ` Luck, Tony
2022-01-20 22:48       ` Borislav Petkov
2022-01-21 17:47 ` [PATCH v2 0/6] PPIN (Protected Processor Inventory Number) updates Tony Luck
2022-01-21 17:47   ` [PATCH v2 1/6] x86/cpu: Add Xeon Icelake-D to list of CPUs that support PPIN Tony Luck
2022-01-25 17:55     ` [tip: x86/urgent] " tip-bot2 for Tony Luck
2022-01-21 17:47   ` [PATCH v2 2/6] x86/cpu: Merge Intel and AMD ppin_init() functions Tony Luck
2022-01-27 10:22     ` Borislav Petkov
2022-01-27 16:52       ` Luck, Tony
2022-01-21 17:47   ` [PATCH v2 3/6] x86/cpu: X86_FEATURE_INTEL_PPIN finally has a CPUID bit Tony Luck
2022-01-21 17:47   ` [PATCH v2 4/6] x86/cpu: Read/save PPIN MSR during initialization Tony Luck
2022-01-21 17:47   ` [PATCH v2 5/6] topology/sysfs: Add format parameter to macro defining "show" functions for proc Tony Luck
2022-01-31 11:34     ` Greg Kroah-Hartman
2022-01-21 17:47   ` [PATCH v2 6/6] topology/sysfs: Add PPIN in sysfs under cpu topology Tony Luck
2022-01-31 11:35     ` Greg Kroah-Hartman
2022-01-31 12:31   ` [PATCH v2 0/6] PPIN (Protected Processor Inventory Number) updates Borislav Petkov
2022-01-31 17:23     ` Luck, Tony
2022-01-31 18:18       ` Borislav Petkov
2022-01-31 18:49         ` Luck, Tony
2022-01-31 19:10           ` Borislav Petkov
2022-01-31 19:29             ` Luck, Tony
2022-01-31 21:58               ` Borislav Petkov
2022-01-31 22:03                 ` Luck, Tony
2022-04-06 22:01                 ` [PATCH] topology/sysfs: Hide PPIN on systems that do not support it Tony Luck
2022-04-25 22:46                   ` Andrew Morton
2022-04-25 22:56                     ` Luck, Tony
2022-01-31 23:01   ` [PATCH v3 0/5] PPIN (Protected Processor Inventory Number) updates Tony Luck
2022-01-31 23:01     ` [PATCH v3 1/5] x86/cpu: Merge Intel and AMD ppin_init() functions Tony Luck
2022-02-02  6:31       ` [tip: x86/cpu] " tip-bot2 for Tony Luck
2022-01-31 23:01     ` [PATCH v3 2/5] x86/cpu: X86_FEATURE_INTEL_PPIN finally has a CPUID bit Tony Luck
2022-02-02  6:31       ` [tip: x86/cpu] " tip-bot2 for Tony Luck
2022-01-31 23:01     ` [PATCH v3 3/5] x86/cpu: Read/save PPIN MSR during initialization Tony Luck
2022-02-02  6:31       ` tip-bot2 for Tony Luck [this message]
2022-01-31 23:01     ` [PATCH v3 4/5] topology/sysfs: Add format parameter to macro defining "show" functions for proc Tony Luck
2022-02-02  6:31       ` [tip: x86/cpu] " tip-bot2 for Tony Luck
2022-01-31 23:01     ` [PATCH v3 5/5] topology/sysfs: Add PPIN in sysfs under cpu topology Tony Luck
2022-02-02  6:31       ` [tip: x86/cpu] " tip-bot2 for Tony Luck

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=164378347431.16921.12171659364065648377.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --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).