integ/kernel-std/centos/patches/Fix-cacheinfo-compilation-issues-for-3.10.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

115 lines
3.3 KiB
Diff

From 265367764432161b5d72d0024167e7eb7302bfd8 Mon Sep 17 00:00:00 2001
Message-Id: <265367764432161b5d72d0024167e7eb7302bfd8.1522097754.git.Jim.Somerville@windriver.com>
In-Reply-To: <f4706beaf86081b0890ea616082913f8f51823ff.1522097754.git.Jim.Somerville@windriver.com>
References: <f4706beaf86081b0890ea616082913f8f51823ff.1522097754.git.Jim.Somerville@windriver.com>
From: Alex Kozyrev <alex.kozyrev@windriver.com>
Date: Wed, 19 Jul 2017 02:25:15 -0500
Subject: [PATCH 18/27] Fix cacheinfo compilation issues for 3.10
Had to revert commit 7cc277b489b4fe91f42eb596b282879c2d13152e:
"Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs. No functional change."
There is no hotplug state machine in 3.10 kernel.
Also implemented cpumap_print_to_pagebuf() function in place.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
---
drivers/base/cacheinfo.c | 65 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index eb3af27..c924f7e 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -383,7 +383,12 @@ static ssize_t shared_cpumap_show_func(struct device *dev, bool list, char *buf)
struct cacheinfo *this_leaf = dev_get_drvdata(dev);
const struct cpumask *mask = &this_leaf->shared_cpu_map;
- return cpumap_print_to_pagebuf(list, buf, mask);
+ int len = list?
+ cpulist_scnprintf(buf, PAGE_SIZE-2, mask) :
+ cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
+ buf[len++] = '\n';
+ buf[len] = '\0';
+ return len;
}
static ssize_t shared_cpu_map_show(struct device *dev,
@@ -633,30 +638,58 @@ err:
return rc;
}
-static int cacheinfo_cpu_online(unsigned int cpu)
+static void cache_remove_dev(unsigned int cpu)
{
- int rc = detect_cache_attributes(cpu);
+ if (!cpumask_test_cpu(cpu, &cache_dev_map))
+ return;
+ cpumask_clear_cpu(cpu, &cache_dev_map);
- if (rc)
- return rc;
- rc = cache_add_dev(cpu);
- if (rc)
- free_cache_attributes(cpu);
- return rc;
+ cpu_cache_sysfs_exit(cpu);
}
-static int cacheinfo_cpu_pre_down(unsigned int cpu)
+static int cacheinfo_cpu_callback(struct notifier_block *nfb,
+ unsigned long action, void *hcpu)
{
- if (cpumask_test_and_clear_cpu(cpu, &cache_dev_map))
- cpu_cache_sysfs_exit(cpu);
+ unsigned int cpu = (unsigned long)hcpu;
+ int rc = 0;
- free_cache_attributes(cpu);
- return 0;
+ switch (action & ~CPU_TASKS_FROZEN) {
+ case CPU_ONLINE:
+ rc = detect_cache_attributes(cpu);
+ if (!rc)
+ rc = cache_add_dev(cpu);
+ break;
+ case CPU_DEAD:
+ cache_remove_dev(cpu);
+ if (per_cpu_cacheinfo(cpu))
+ free_cache_attributes(cpu);
+ break;
+ }
+ return notifier_from_errno(rc);
}
static int __init cacheinfo_sysfs_init(void)
{
- return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "base/cacheinfo:online",
- cacheinfo_cpu_online, cacheinfo_cpu_pre_down);
+ int cpu, rc = 0;
+
+ cpu_notifier_register_begin();
+
+ for_each_online_cpu(cpu) {
+ rc = detect_cache_attributes(cpu);
+ if (rc)
+ goto out;
+ rc = cache_add_dev(cpu);
+ if (rc) {
+ free_cache_attributes(cpu);
+ pr_err("error populating cacheinfo..cpu%d\n", cpu);
+ goto out;
+ }
+ }
+ __hotcpu_notifier(cacheinfo_cpu_callback, 0);
+
+out:
+ cpu_notifier_register_done();
+ return rc;
}
+
device_initcall(cacheinfo_sysfs_init);
--
1.8.3.1