All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is" failed to apply to 4.4-stable tree
@ 2021-05-10  7:42 gregkh
  2021-05-12 10:08 ` [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2021-05-10  7:42 UTC (permalink / raw)
  To: seanjc, tglx; +Cc: stable


The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From b6b4fbd90b155a0025223df2c137af8a701d53b3 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc@google.com>
Date: Tue, 4 May 2021 15:56:31 -0700
Subject: [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is
 supported

Initialize MSR_TSC_AUX with CPU node information if RDTSCP or RDPID is
supported.  This fixes a bug where vdso_read_cpunode() will read garbage
via RDPID if RDPID is supported but RDTSCP is not.  While no known CPU
supports RDPID but not RDTSCP, both Intel's SDM and AMD's APM allow for
RDPID to exist without RDTSCP, e.g. it's technically a legal CPU model
for a virtual machine.

Note, technically MSR_TSC_AUX could be initialized if and only if RDPID
is supported since RDTSCP is currently not used to retrieve the CPU node.
But, the cost of the superfluous WRMSR is negigible, whereas leaving
MSR_TSC_AUX uninitialized is just asking for future breakage if someone
decides to utilize RDTSCP.

Fixes: a582c540ac1b ("x86/vdso: Use RDPID in preference to LSL when available")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210504225632.1532621-2-seanjc@google.com

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 6bdb69a9a7dc..490bed07fe35 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1851,7 +1851,7 @@ static inline void setup_getcpu(int cpu)
 	unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
 	struct desc_struct d = { };
 
-	if (boot_cpu_has(X86_FEATURE_RDTSCP))
+	if (boot_cpu_has(X86_FEATURE_RDTSCP) || boot_cpu_has(X86_FEATURE_RDPID))
 		write_rdtscp_aux(cpudata);
 
 	/* Store CPU and node number in limit. */


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

* [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported
  2021-05-10  7:42 FAILED: patch "[PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is" failed to apply to 4.4-stable tree gregkh
@ 2021-05-12 10:08 ` Thomas Gleixner
  2021-05-12 10:10   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2021-05-12 10:08 UTC (permalink / raw)
  To: gregkh, seanjc; +Cc: stable

From: Sean Christopherson <seanjc@google.com>

commit b6b4fbd90b155a0025223df2c137af8a701d53b3 upstream

Initialize MSR_TSC_AUX with CPU node information if RDTSCP or RDPID is
supported.  This fixes a bug where vdso_read_cpunode() will read garbage
via RDPID if RDPID is supported but RDTSCP is not.  While no known CPU
supports RDPID but not RDTSCP, both Intel's SDM and AMD's APM allow for
RDPID to exist without RDTSCP, e.g. it's technically a legal CPU model
for a virtual machine.

Note, technically MSR_TSC_AUX could be initialized if and only if RDPID
is supported since RDTSCP is currently not used to retrieve the CPU node.
But, the cost of the superfluous WRMSR is negigible, whereas leaving
MSR_TSC_AUX uninitialized is just asking for future breakage if someone
decides to utilize RDTSCP.

[ tglx: Backport for 4.14/4.19 ]

Fixes: a582c540ac1b ("x86/vdso: Use RDPID in preference to LSL when available")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210504225632.1532621-2-seanjc@google.com
---
 arch/x86/entry/vdso/vma.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -342,7 +342,7 @@ static void vgetcpu_cpu_init(void *arg)
 #ifdef CONFIG_NUMA
 	node = cpu_to_node(cpu);
 #endif
-	if (static_cpu_has(X86_FEATURE_RDTSCP))
+	if (boot_cpu_has(X86_FEATURE_RDTSCP) || boot_cpu_has(X86_FEATURE_RDPID))
 		write_rdtscp_aux((node << 12) | cpu);
 
 	/*

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

* Re: [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported
  2021-05-12 10:08 ` [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Thomas Gleixner
@ 2021-05-12 10:10   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2021-05-12 10:10 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: seanjc, stable

On Wed, May 12, 2021 at 12:08:00PM +0200, Thomas Gleixner wrote:
> From: Sean Christopherson <seanjc@google.com>
> 
> commit b6b4fbd90b155a0025223df2c137af8a701d53b3 upstream
> 
> Initialize MSR_TSC_AUX with CPU node information if RDTSCP or RDPID is
> supported.  This fixes a bug where vdso_read_cpunode() will read garbage
> via RDPID if RDPID is supported but RDTSCP is not.  While no known CPU
> supports RDPID but not RDTSCP, both Intel's SDM and AMD's APM allow for
> RDPID to exist without RDTSCP, e.g. it's technically a legal CPU model
> for a virtual machine.
> 
> Note, technically MSR_TSC_AUX could be initialized if and only if RDPID
> is supported since RDTSCP is currently not used to retrieve the CPU node.
> But, the cost of the superfluous WRMSR is negigible, whereas leaving
> MSR_TSC_AUX uninitialized is just asking for future breakage if someone
> decides to utilize RDTSCP.
> 
> [ tglx: Backport for 4.14/4.19 ]

Now queued up, thanks!

greg k-h

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

end of thread, other threads:[~2021-05-12 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  7:42 FAILED: patch "[PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is" failed to apply to 4.4-stable tree gregkh
2021-05-12 10:08 ` [PATCH] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Thomas Gleixner
2021-05-12 10:10   ` Greg KH

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.