integ/kernel-rt/centos/patches/cpuidle-menu-Avoid-taking-spinlock-for-accessing-QoS.patch
Jim Somerville 50a9ff6df4 Kernel Upgrades for Meltdown and Spectre
The kernel is moved ahead to version 3.10.0-693.21.1.el7

To summarize:

CVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'
This is fixed by load fences and is "baked in" and cannot
be turned off.

CVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'
This is fixed by a combination of retpolines and IBPB, or
IBRS+IBPB if on skylake.  This requires a microcode change in
the processors.  This feature, if on, has a significant performance
impact.  It is assumed on unless turned off via the
"nospectre_v2" bootarg.

CVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'
This is fixed by page table isolation using the Kaiser patches.
This feature is assumed on unless turned off via the
"nopti" bootarg.

As of the commit date, we have changed the installer kickstarts
to issue both "nopti nospectre_v2" bootargs to minimize realtime
impacts by default.  The customer will be able to optionally
sacrifice performance for extra security at datafill time.

Change-Id: Id7c99923f2ee2ee91f77c7bd9940e684eff8b476
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
2018-06-22 12:53:11 -04:00

93 lines
3.6 KiB
Diff

From 52a9e3d1424fb24f3a5683919fc8a1d98d10e869 Mon Sep 17 00:00:00 2001
Message-Id: <52a9e3d1424fb24f3a5683919fc8a1d98d10e869.1522795098.git.Jim.Somerville@windriver.com>
In-Reply-To: <21c11de06542297206c798b405b54a3ec9052aa4.1522795097.git.Jim.Somerville@windriver.com>
References: <21c11de06542297206c798b405b54a3ec9052aa4.1522795097.git.Jim.Somerville@windriver.com>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Date: Fri, 24 Feb 2017 13:25:14 +0100
Subject: [PATCH 25/33] cpuidle: menu: Avoid taking spinlock for accessing QoS
values
[commit 6dbf5cea05a7098a69f294c96b6d76f08562cae5 from linux-stable ]
After commit 9908859acaa9 (cpuidle/menu: add per CPU PM QoS resume
latency consideration) the cpuidle menu governor calls
dev_pm_qos_read_value() on CPU devices to read the current resume latency QoS
constraint values for them. That function takes a spinlock to prevent the
device's power.qos pointer from becoming NULL during the access which is a
problem for the RT patchset where spinlocks are converted into mutexes and
the idle loop stops working.
However, it is not even necessary for the menu governor to take
that spinlock, because the power.qos pointer accessed under it
cannot be modified during the access anyway.
For this reason, introduce a "raw" routine for accessing device
QoS resume latency constraints without locking and use it in the
menu governor.
Fixes: 9908859acaa9 (cpuidle/menu: add per CPU PM QoS resume latency consideration)
Acked-by: Alex Shi <alex.shi@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Alex Kozyrev <alex.kozyrev@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
---
drivers/base/power/qos.c | 3 +--
drivers/cpuidle/governors/menu.c | 2 +-
include/linux/pm_qos.h | 6 ++++++
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 2f8ac59..08a4cec 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -104,8 +104,7 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_flags);
*/
s32 __dev_pm_qos_read_value(struct device *dev)
{
- return IS_ERR_OR_NULL(dev->power.qos) ?
- 0 : pm_qos_read_value(&dev->power.qos->latency);
+ return dev_pm_qos_raw_read_value(dev);
}
/**
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index fe2dcb8..f9861fd 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -265,7 +265,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
int i;
int multiplier;
struct timespec t;
- int resume_latency = dev_pm_qos_read_value(device);
+ int resume_latency = dev_pm_qos_raw_read_value(device);
if (data->needs_update) {
menu_update(drv, dev);
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 5281e7f..1d8b629 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -217,6 +217,11 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev)
{
return dev->power.qos->flags_req->data.flr.flags;
}
+static inline s32 dev_pm_qos_raw_read_value(struct device *dev)
+{
+ return IS_ERR_OR_NULL(dev->power.qos) ?
+ 0 : pm_qos_read_value(&dev->power.qos->latency);
+}
#else
static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
{ return 0; }
@@ -236,6 +241,7 @@ static inline void dev_pm_qos_hide_latency_tolerance(struct device *dev) {}
static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return 0; }
static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; }
+static inline s32 dev_pm_qos_raw_read_value(struct device *dev) { return 0; }
#endif
#endif
--
1.8.3.1