From: Tim Chen <tim.c.chen@linux.intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Greg KH <gregkh@linuxfoundation.org>,
Dave Hansen <dave.hansen@intel.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Andi Kleen <ak@linux.intel.com>,
Arjan Van De Ven <arjan.van.de.ven@intel.com>,
David Woodhouse <dwmw@amazon.co.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/8] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature
Date: Tue, 9 Jan 2018 10:05:57 -0800 [thread overview]
Message-ID: <6a9ff9c1-4d62-579b-9764-aa9d37260273@linux.intel.com> (raw)
In-Reply-To: <20180109002943.vdcjeubkflnccmup@pd.tnic>
On 01/08/2018 04:29 PM, Borislav Petkov wrote:
> On Fri, Jan 05, 2018 at 06:12:19PM -0800, Tim Chen wrote:
>> From: Tim Chen <tim.c.chen@linux.intel.com>
>> From: Andrea Arcangeli <aarcange@redhat.com>
>
> There's Co-Developed-by for this:
>
> - Co-Developed-by: states that the patch was also created by another developer
> along with the original author. This is useful at times when multiple
> people work on a single patch. Note, this person also needs to have a
> Signed-off-by: line in the patch as well.
>
Thanks. Will do.
>> .Lskip_\@:
>> + lfence
>> +.Ldone_\@:
>> .endm
>
> Why not put all macros in spec_ctrl.h ?
There were a previous discussion thread in v1 patch with Peter Z and Dave.
Peter and Dave prefer that all these entrance macros be consolidated
in calling.h
>
>> diff --git a/arch/x86/include/asm/spec_ctrl.h b/arch/x86/include/asm/spec_ctrl.h
>> new file mode 100644
>> index 0000000..4fda38b
>> --- /dev/null
>> +++ b/arch/x86/include/asm/spec_ctrl.h
>> @@ -0,0 +1,15 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +
>> +#ifndef _ASM_X86_SPEC_CTRL_H
>> +#define _ASM_X86_SPEC_CTRL_H
>> +
>> +#include <asm/msr-index.h>
>> +#include <asm/cpufeatures.h>
>> +#include <asm/microcode.h>
>
> Left over include from a previous version.
>
> Instead, you need
>
> #include <linux/cpu.h>
>
> in spec_ctrl.c for get/put_online_cpus().
>
>> +void scan_spec_ctrl_feature(struct cpuinfo_x86 *c);
>> +bool ibrs_inuse(void);
>> +
>> +extern unsigned int dynamic_ibrs;
>> +
>> +#endif /* _ASM_X86_SPEC_CTRL_H */
>> diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
>> index 570e8bb..3ffbd24 100644
>> --- a/arch/x86/kernel/cpu/Makefile
>> +++ b/arch/x86/kernel/cpu/Makefile
>> @@ -24,6 +24,7 @@ obj-y += match.o
>> obj-y += bugs.o
>> obj-y += aperfmperf.o
>> obj-y += cpuid-deps.o
>> +obj-y += spec_ctrl.o
>>
>> obj-$(CONFIG_PROC_FS) += proc.o
>> obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o
>> diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
>> index bc50c40..5756d14 100644
>> --- a/arch/x86/kernel/cpu/scattered.c
>> +++ b/arch/x86/kernel/cpu/scattered.c
>> @@ -8,6 +8,7 @@
>> #include <asm/processor.h>
>>
>> #include <asm/apic.h>
>> +#include <asm/spec_ctrl.h>
>>
>> struct cpuid_bit {
>> u16 feature;
>> @@ -57,6 +58,7 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
>> if (regs[cb->reg] & (1 << cb->bit))
>> set_cpu_cap(c, cb->feature);
>> }
>> + scan_spec_ctrl_feature(c);
>
> Hell no!
>
> This function is only for setting the feature bits.
>
>> u32 get_scattered_cpuid_leaf(unsigned int level, unsigned int sub_leaf,
>> diff --git a/arch/x86/kernel/cpu/spec_ctrl.c b/arch/x86/kernel/cpu/spec_ctrl.c
>> new file mode 100644
>> index 0000000..1641bec
>> --- /dev/null
>> +++ b/arch/x86/kernel/cpu/spec_ctrl.c
>> @@ -0,0 +1,160 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +
>> +#include <linux/mutex.h>
>> +#include <linux/debugfs.h>
>> +#include <linux/uaccess.h>
>> +
>> +#include <asm/spec_ctrl.h>
>> +#include <asm/cpufeature.h>
>> +
>> +unsigned int dynamic_ibrs __read_mostly;
>
> WTH is dynamic_ibrs?
Dynamic ibrs because we enable the IBRS in MSR 0x48
entering the kernel and disable it when we exit the
kernel.
>
>> +EXPORT_SYMBOL_GPL(dynamic_ibrs);
>> +
>> +enum {
>> + IBRS_DISABLED,
>> + /* in host kernel, disabled in guest and userland */
>> + IBRS_ENABLED,
>> + /* in host kernel and host userland, disabled in guest */
>> + IBRS_ENABLED_USER,
>> + IBRS_MAX = IBRS_ENABLED_USER,
>> +};
>> +static unsigned int ibrs_enabled;
>> +static bool ibrs_admin_disabled;
>
> Srsly?!
>
> That's *three* variables controlling IBRS. This needs simplification.
>
>> +
>> +/* mutex to serialize IBRS control changes */
>> +DEFINE_MUTEX(spec_ctrl_mutex);
>
> static
>
>> +void scan_spec_ctrl_feature(struct cpuinfo_x86 *c)
>> +{
>> + if ((!c->cpu_index) && (boot_cpu_has(X86_FEATURE_SPEC_CTRL))) {
>
> What is !c->cpu_index? Checking whether this is the BSP? What for?
This is to ensure that we only do the operation once during boot.
Thanks.
Tim
next prev parent reply other threads:[~2018-01-09 18:06 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-06 2:12 [PATCH v2 0/8] IBRS patch series Tim Chen
2018-01-06 2:12 ` [PATCH v2 1/8] x86/feature: Detect the x86 IBRS feature to control Speculation Tim Chen
2018-01-06 12:56 ` Borislav Petkov
2018-01-07 17:14 ` Tim Chen
2018-01-07 18:31 ` Borislav Petkov
2018-01-09 18:13 ` Dave Hansen
2018-01-09 18:55 ` Borislav Petkov
2018-01-08 16:14 ` Paolo Bonzini
2018-01-09 10:39 ` Paolo Bonzini
2018-01-09 17:53 ` Tim Chen
2018-01-09 17:58 ` Paolo Bonzini
2018-01-09 22:59 ` Tim Chen
2018-01-18 23:28 ` Andy Lutomirski
2018-01-06 2:12 ` [PATCH v2 2/8] x86/enter: MACROS to set/clear IBRS Tim Chen
2018-01-07 12:03 ` Borislav Petkov
2018-01-07 17:12 ` Tim Chen
2018-01-07 18:44 ` Borislav Petkov
2018-01-08 22:24 ` Tim Chen
2018-01-06 2:12 ` [PATCH v2 3/8] x86/enter: Use IBRS on syscall and interrupts Tim Chen
2018-01-07 19:27 ` Borislav Petkov
2018-01-06 2:12 ` [PATCH v2 4/8] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature Tim Chen
2018-01-06 3:12 ` Dave Hansen
2018-01-08 12:47 ` Peter Zijlstra
2018-01-08 16:14 ` Peter Zijlstra
2018-01-08 17:28 ` Tim Chen
2018-01-08 17:42 ` Peter Zijlstra
2018-01-08 19:34 ` Woodhouse, David
2018-01-08 19:52 ` Lu, Hongjiu
2018-01-09 10:40 ` Thomas Gleixner
2018-01-09 17:55 ` Tim Chen
2018-01-09 18:13 ` David Woodhouse
2018-01-09 20:31 ` Tim Chen
2018-01-27 13:59 ` Konrad Rzeszutek Wilk
2018-01-27 14:26 ` David Woodhouse
2018-01-06 8:54 ` Greg KH
2018-01-06 18:10 ` Tim Chen
2018-01-06 21:25 ` Konrad Rzeszutek Wilk
2018-01-07 8:20 ` Greg KH
2018-01-06 14:41 ` Konrad Rzeszutek Wilk
2018-01-06 17:33 ` Dave Hansen
2018-01-06 17:41 ` Van De Ven, Arjan
2018-01-06 19:22 ` Dave Hansen
2018-01-06 19:47 ` Thomas Gleixner
2018-01-06 21:32 ` Konrad Rzeszutek Wilk
2018-01-06 21:34 ` Van De Ven, Arjan
2018-01-06 21:41 ` Konrad Rzeszutek Wilk
2018-01-06 21:44 ` Van De Ven, Arjan
2018-01-06 21:39 ` Thomas Gleixner
2018-01-06 21:46 ` Is: Linus, name for 'spectre' variable. Was:Re: " Konrad Rzeszutek Wilk
2018-01-06 18:23 ` Tim Chen
2018-01-06 18:20 ` Tim Chen
2018-01-08 15:08 ` Peter Zijlstra
2018-01-08 15:29 ` Van De Ven, Arjan
2018-01-08 17:02 ` Tim Chen
2018-01-08 15:11 ` Peter Zijlstra
2018-01-08 15:15 ` Peter Zijlstra
2018-01-08 15:53 ` Peter Zijlstra
2018-01-09 0:29 ` Borislav Petkov
2018-01-09 18:05 ` Tim Chen [this message]
2018-01-06 2:12 ` [PATCH v2 5/8] x86/idle: Disable IBRS entering idle and enable it on wakeup Tim Chen
2018-01-06 2:12 ` [PATCH v2 6/8] x86/microcode: Recheck IBRS features on microcode reload Tim Chen
2018-01-06 12:09 ` Woodhouse, David
2018-01-09 0:34 ` Borislav Petkov
2018-01-06 2:12 ` [PATCH v2 7/8] x86: Do not use dynamic IBRS if retpoline is enabled Tim Chen
2018-01-06 2:12 ` [PATCH v2 8/8] x86: Use IBRS for firmware update path Tim Chen
2018-01-06 8:55 ` Greg KH
2018-01-06 8:57 ` Greg KH
2018-01-06 6:43 ` [PATCH v2 0/8] IBRS patch series Tim Chen
2018-01-06 12:00 ` Woodhouse, David
2018-01-06 12:11 ` Woodhouse, David
2018-01-08 17:43 [PATCH v2 4/8] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature Alexey Dobriyan
2018-01-08 18:30 ` Andrea Arcangeli
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=6a9ff9c1-4d62-579b-9764-aa9d37260273@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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®