mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linuxfoundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>,
	David Woodhouse <dwmw@amazon.co.uk>,
	"Hansen, Dave" <dave.hansen@intel.com>
Subject: Re: [patch 1/2] sysfs/cpu: Add vulnerability folder
Date: Sun, 7 Jan 2018 22:19:51 +0100	[thread overview]
Message-ID: <20180107211951.GA26115@kroah.com> (raw)
In-Reply-To: <20180107210716.820339827@linutronix.de>

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

  reply	other threads:[~2018-01-07 21:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-07 20:57 [patch 0/2] sysfs/cpu: Implement generic vulnerabilites directory Thomas Gleixner
2018-01-07 20:57 ` [patch 1/2] sysfs/cpu: Add vulnerability folder Thomas Gleixner
2018-01-07 21:19   ` Greg Kroah-Hartman [this message]
2018-01-07 21:39     ` Thomas Gleixner
2018-01-07 20:57 ` [patch 2/2] x86/cpu: Implement CPU vulnerabilites sysfs functions Thomas Gleixner

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=20180107211951.GA26115@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linuxfoundation.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

all inboxes | Powered by JetHome®