Re: [RFC PATCH 53/56] drivers/cpu: Re-patch mitigations through sysfs

Nikolay Borisov
2025-10-27T12:25:17Z

On 10/13/25 17:34, David Kaplan wrote:
> Create a new file at /sys/devices/system/cpu/mitigations that prints the
> current set of mitigation options and can be written to in order to
> re-select mitigations.
>
> Only options related to mitigations are handled, with the file initially
> returning the relevant options from the command line. When the file is
> written, any existing selections are discarded and the new options are
> evaluated.
>
> Signed-off-by: David Kaplan <david.kaplan@amd.com>
> ---
> .../ABI/testing/sysfs-devices-system-cpu | 8 ++
> drivers/base/cpu.c | 113 ++++++++++++++++++
> include/linux/cpu.h | 3 +
> 3 files changed, 124 insertions(+)
>

<snip>

> +
> +ssize_t cpu_show_mitigation_options(struct device *dev, struct device_attribute *attr, char *buf);
> +ssize_t cpu_show_mitigation_options(struct device *dev, struct device_attribute *attr, char *buf)

Make it static

> +{
> + return sysfs_emit(buf, saved_opts);
> +}
> +
> +ssize_t cpu_write_mitigation_options(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count);
> +
> +void __weak cpu_prepare_repatch_alternatives(void)
> +{
> +}
> +
> +void __weak cpu_update_alternatives(void)
> +{
> +}
> +
> +void __weak cpu_select_mitigations(void)
> +{
> +}
> +
> +ssize_t cpu_write_mitigation_options(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
Ditto

<snip>