2023-08-09 12:05:59

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH 0/3] x86/bugs: Some SRSO fixes

From: "Borislav Petkov (AMD)" <[email protected]>

Hi all,

those are the leftover smaller fixes which can go after the release
date. I'll queue them next week.

Thx.

Borislav Petkov (AMD) (3):
Documentation/hw-vuln: Unify filename specification in index
driver core: cpu: Unify redundant silly stubs
Documentation/srso: Document IBPB aspect and fix formatting

Documentation/admin-guide/hw-vuln/index.rst | 12 +--
Documentation/admin-guide/hw-vuln/srso.rst | 71 ++++++++++-------
drivers/base/cpu.c | 86 +++++----------------
3 files changed, 68 insertions(+), 101 deletions(-)

--
2.41.0



2023-08-09 12:07:15

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs

From: "Borislav Petkov (AMD)" <[email protected]>

Make them all a weak function, aliasing to a single function which
issues the "Not affected" string.

No functional changes.

Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
---
drivers/base/cpu.c | 86 ++++++++++------------------------------------
1 file changed, 18 insertions(+), 68 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 52df435eecf8..971771347aa6 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -509,79 +509,29 @@ static void __init cpu_dev_register_generic(void)
}

#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
-
-ssize_t __weak cpu_show_meltdown(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v1(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v2(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_l1tf(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_mds(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_srbds(struct device *dev,
+ssize_t cpu_show_not_affected(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "Not affected\n");
}

-ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_retbleed(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
+#define CPU_VULN_FALLBACK(func) \
+ ssize_t cpu_show_##func(struct device *, \
+ struct device_attribute *, char *) \
+ __attribute__((weak, alias("cpu_show_not_affected")))
+
+CPU_VULN_FALLBACK(meltdown);
+CPU_VULN_FALLBACK(spectre_v1);
+CPU_VULN_FALLBACK(spectre_v2);
+CPU_VULN_FALLBACK(spec_store_bypass);
+CPU_VULN_FALLBACK(l1tf);
+CPU_VULN_FALLBACK(mds);
+CPU_VULN_FALLBACK(tsx_async_abort);
+CPU_VULN_FALLBACK(itlb_multihit);
+CPU_VULN_FALLBACK(srbds);
+CPU_VULN_FALLBACK(mmio_stale_data);
+CPU_VULN_FALLBACK(retbleed);
+CPU_VULN_FALLBACK(spec_rstack_overflow);

ssize_t __weak cpu_show_gds(struct device *dev,
struct device_attribute *attr, char *buf)
--
2.41.0


2023-08-09 12:19:48

by Nikolay Borisov

[permalink] [raw]
Subject: Re: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs



On 9.08.23 г. 13:26 ч., Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <[email protected]>
>
> Make them all a weak function, aliasing to a single function which
> issues the "Not affected" string.
>
> No functional changes.
>
> Suggested-by: Linus Torvalds <[email protected]>
> Signed-off-by: Borislav Petkov (AMD) <[email protected]>


Reviewed-by: Nikolay Borisov <[email protected]>

2023-08-09 13:03:09

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/3] x86/bugs: Some SRSO fixes

On Wed, Aug 09, 2023 at 12:26:57PM +0200, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <[email protected]>
>
> Hi all,
>
> those are the leftover smaller fixes which can go after the release
> date. I'll queue them next week.
>
> Thx.
>
> Borislav Petkov (AMD) (3):
> Documentation/hw-vuln: Unify filename specification in index
> driver core: cpu: Unify redundant silly stubs
> Documentation/srso: Document IBPB aspect and fix formatting
>
> Documentation/admin-guide/hw-vuln/index.rst | 12 +--
> Documentation/admin-guide/hw-vuln/srso.rst | 71 ++++++++++-------
> drivers/base/cpu.c | 86 +++++----------------
> 3 files changed, 68 insertions(+), 101 deletions(-)
>
> --
> 2.41.0
>

Reviewed-by: Greg Kroah-Hartman <[email protected]>

2023-08-09 22:05:15

by Pawan Gupta

[permalink] [raw]
Subject: Re: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs

On Wed, Aug 09, 2023 at 12:26:59PM +0200, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <[email protected]>
>
> Make them all a weak function, aliasing to a single function which
> issues the "Not affected" string.
>
> No functional changes.
>
> Suggested-by: Linus Torvalds <[email protected]>
> Signed-off-by: Borislav Petkov (AMD) <[email protected]>
> ---
> drivers/base/cpu.c | 86 ++++++++++------------------------------------
> 1 file changed, 18 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 52df435eecf8..971771347aa6 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -509,79 +509,29 @@ static void __init cpu_dev_register_generic(void)
> }
>
> #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
> -
> -ssize_t __weak cpu_show_meltdown(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spectre_v1(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spectre_v2(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_l1tf(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_mds(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_srbds(struct device *dev,
> +ssize_t cpu_show_not_affected(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> return sysfs_emit(buf, "Not affected\n");
> }
>
> -ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_retbleed(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - return sysfs_emit(buf, "Not affected\n");
> -}
> +#define CPU_VULN_FALLBACK(func) \

Nit, its not actually a vulnerability fallback, does
CPU_SHOW_VULN_FALLBACK() sound better?

> + ssize_t cpu_show_##func(struct device *, \
> + struct device_attribute *, char *) \
> + __attribute__((weak, alias("cpu_show_not_affected")))
> +
> +CPU_VULN_FALLBACK(meltdown);
> +CPU_VULN_FALLBACK(spectre_v1);
> +CPU_VULN_FALLBACK(spectre_v2);
> +CPU_VULN_FALLBACK(spec_store_bypass);
> +CPU_VULN_FALLBACK(l1tf);
> +CPU_VULN_FALLBACK(mds);
> +CPU_VULN_FALLBACK(tsx_async_abort);
> +CPU_VULN_FALLBACK(itlb_multihit);
> +CPU_VULN_FALLBACK(srbds);
> +CPU_VULN_FALLBACK(mmio_stale_data);
> +CPU_VULN_FALLBACK(retbleed);
> +CPU_VULN_FALLBACK(spec_rstack_overflow);
>
> ssize_t __weak cpu_show_gds(struct device *dev,
> struct device_attribute *attr, char *buf)

Do you want me to send a separate patch for this?

2023-08-09 23:19:06

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs

On Wed, Aug 09, 2023 at 02:47:41PM -0700, Pawan Gupta wrote:
> Do you want me to send a separate patch for this?

No need - I'll fix it up.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Subject: [tip: x86/bugs] driver core: cpu: Unify redundant silly stubs

The following commit has been merged into the x86/bugs branch of tip:

Commit-ID: 0fddfe338210aa018137c03030c581f5ea4be282
Gitweb: https://git.kernel.org/tip/0fddfe338210aa018137c03030c581f5ea4be282
Author: Borislav Petkov (AMD) <[email protected]>
AuthorDate: Sat, 29 Jul 2023 17:20:33 +02:00
Committer: Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 10 Aug 2023 11:03:04 +02:00

driver core: cpu: Unify redundant silly stubs

Make them all a weak function, aliasing to a single function which
issues the "Not affected" string.

No functional changes.

Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Nikolay Borisov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
drivers/base/cpu.c | 87 +++++++++------------------------------------
1 file changed, 19 insertions(+), 68 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 52df435..054c81b 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -509,79 +509,30 @@ static void __init cpu_dev_register_generic(void)
}

#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
-
-ssize_t __weak cpu_show_meltdown(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v1(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v2(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_l1tf(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_mds(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_srbds(struct device *dev,
+ssize_t cpu_show_not_affected(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "Not affected\n");
}

-ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_retbleed(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
+#define CPU_SHOW_VULN_FALLBACK(func) \
+ ssize_t cpu_show_##func(struct device *, \
+ struct device_attribute *, char *) \
+ __attribute__((weak, alias("cpu_show_not_affected")))
+
+CPU_SHOW_VULN_FALLBACK(meltdown);
+CPU_SHOW_VULN_FALLBACK(spectre_v1);
+CPU_SHOW_VULN_FALLBACK(spectre_v2);
+CPU_SHOW_VULN_FALLBACK(spec_store_bypass);
+CPU_SHOW_VULN_FALLBACK(l1tf);
+CPU_SHOW_VULN_FALLBACK(mds);
+CPU_SHOW_VULN_FALLBACK(tsx_async_abort);
+CPU_SHOW_VULN_FALLBACK(itlb_multihit);
+CPU_SHOW_VULN_FALLBACK(srbds);
+CPU_SHOW_VULN_FALLBACK(mmio_stale_data);
+CPU_SHOW_VULN_FALLBACK(retbleed);
+CPU_SHOW_VULN_FALLBACK(spec_rstack_overflow);
+CPU_SHOW_VULN_FALLBACK(gather_data_sampling);

ssize_t __weak cpu_show_gds(struct device *dev,
struct device_attribute *attr, char *buf)