Re: [PATCH 6/7] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature

Borislav Petkov
2018-01-04T18:33:49Z

On Thu, Jan 04, 2018 at 09:56:47AM -0800, Tim Chen wrote:
> There are 2 ways to control IBRS
>
> 1. At boot time
> noibrs kernel boot parameter will disable IBRS usage
>
> Otherwise if the above parameters are not specified, the system
> will enable ibrs and ibpb usage if the cpu supports it.
>
> 2. At run time
> echo 0 > /sys/kernel/debug/ibrs_enabled will turn off IBRS
> echo 1 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in kernel
> echo 2 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in both userspace and kernel

I am not sure that tristate is really needed. What's wrong with on/off
only?

Also, stuff like that:

+/* mutex to serialize IBRS control changes */
+DEFINE_MUTEX(spec_ctrl_mutex);
+EXPORT_SYMBOL(spec_ctrl_mutex);

looks ugly.

Wrapper functions which everything calls and they hide internals are
much more preferrable.

And then, if at all, this needs to be connected to the retpolines fun,
methinks, so that it can be decided at boot what to use.

Thx.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.