lkml.org 
[lkml]   [2018]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 1/2] sysfs/cpu: Add vulnerability folder
On Sun, Jan 07, 2018 at 09:57:50PM +0100, Thomas Gleixner wrote:
> As the meltdown/spectre problem affects several CPU architectures, it makes
> sense to have common way to express whether a system is affected by a
> particular vulnerability or not. If affected the way to express the
> mitigation should be common as well.
>
> Create /sys/devices/system/cpu/vulnerabilities folder and files for
> meltdown, spectre_v1 and spectre_v2.

I like this, minor nits below:

>
> Allow architextures to override the show function.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> drivers/base/Kconfig | 3 +++
> drivers/base/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/cpu.h | 7 +++++++
> 3 files changed, 58 insertions(+)

A Documentation/ABI/ update is needed for the new sysfs files.

> +#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
> +
> +ssize_t __weak cpu_show_meltdown(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return snprintf(buf, PAGE_SIZE - 2, "Not affected\n");

sysfs is one-value-per-file, so you never need to care about the page
size, a simple sprintf() is fine. No need to change if you don't want
to, your call.

> +}
> +
> +ssize_t __weak cpu_show_spectre_v1(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return snprintf(buf, PAGE_SIZE - 2, "Not affected\n");
> +}
> +
> +ssize_t __weak cpu_show_spectre_v2(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return snprintf(buf, PAGE_SIZE - 2, "Not affected\n");
> +}
> +
> +static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
> +static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
> +static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);

DEVICE_ATTR_RO() please.

Yeah, that does make the global symbols a bit different, meltdown_show()
and the like. Hm, I guess this is ok, given that it's ment to be
overridden.

Oh, nevermind. So, just a documentation update please, that can always
be an add-on patch if you promise to do it :)

thanks,

greg k-h

\
 
 \ /
  Last update: 2018-01-14 23:16    [W:0.057 / U:1.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site