Re: dyntick-idle CPU and node's qsmask

2018-11-20 Thread Joel Fernandes
On Tue, Nov 20, 2018 at 02:28:14PM -0800, Paul E. McKenney wrote: > On Tue, Nov 20, 2018 at 12:42:43PM -0800, Joel Fernandes wrote: > > On Sun, Nov 11, 2018 at 10:36:18AM -0800, Paul E. McKenney wrote: > > > On Sun, Nov 11, 2018 at 10:09:16AM -0800, Joel Fernandes wrote: > > > > On Sat, Nov 10,

Re: dyntick-idle CPU and node's qsmask

2018-11-20 Thread Joel Fernandes
On Tue, Nov 20, 2018 at 02:28:14PM -0800, Paul E. McKenney wrote: > On Tue, Nov 20, 2018 at 12:42:43PM -0800, Joel Fernandes wrote: > > On Sun, Nov 11, 2018 at 10:36:18AM -0800, Paul E. McKenney wrote: > > > On Sun, Nov 11, 2018 at 10:09:16AM -0800, Joel Fernandes wrote: > > > > On Sat, Nov 10,

RE: [PATCH] thermal: imx: fix for dependency on cpu-freq

2018-11-20 Thread Anson Huang
Hi, Viresh Best Regards! Anson Huang > -Original Message- > From: Viresh Kumar [mailto:viresh.ku...@linaro.org] > Sent: 2018年11月20日 18:49 > To: Anson Huang > Cc: Zhang Rui ; Eduardo Valentin > ; Linux PM list ; Linux > Kernel Mailing List ; dl-linux-imx > > Subject: Re: [PATCH]

RE: [PATCH] thermal: imx: fix for dependency on cpu-freq

2018-11-20 Thread Anson Huang
Hi, Viresh Best Regards! Anson Huang > -Original Message- > From: Viresh Kumar [mailto:viresh.ku...@linaro.org] > Sent: 2018年11月20日 18:49 > To: Anson Huang > Cc: Zhang Rui ; Eduardo Valentin > ; Linux PM list ; Linux > Kernel Mailing List ; dl-linux-imx > > Subject: Re: [PATCH]

[PATCH V2] thermal: imx: fix for dependency on cpu-freq

2018-11-20 Thread Anson Huang
The thermal driver is a standalone driver for monitoring SoC temperature by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ is NOT set. So remove the dependency with CPU_THERMAL. Introduce dummy function of legacy cooling register/unregister to make thermal driver probe

Re: [PATCH v1 2/8] mm: convert PG_balloon to PG_offline

2018-11-20 Thread Michael S. Tsirkin
On Mon, Nov 19, 2018 at 11:16:10AM +0100, David Hildenbrand wrote: > PG_balloon was introduced to implement page migration/compaction for pages > inflated in virtio-balloon. Nowadays, it is only a marker that a page is > part of virtio-balloon and therefore logically offline. > > We also want to

[PATCH V2] thermal: imx: fix for dependency on cpu-freq

2018-11-20 Thread Anson Huang
The thermal driver is a standalone driver for monitoring SoC temperature by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ is NOT set. So remove the dependency with CPU_THERMAL. Introduce dummy function of legacy cooling register/unregister to make thermal driver probe

Re: [PATCH v1 2/8] mm: convert PG_balloon to PG_offline

2018-11-20 Thread Michael S. Tsirkin
On Mon, Nov 19, 2018 at 11:16:10AM +0100, David Hildenbrand wrote: > PG_balloon was introduced to implement page migration/compaction for pages > inflated in virtio-balloon. Nowadays, it is only a marker that a page is > part of virtio-balloon and therefore logically offline. > > We also want to

Re: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Michal Hocko wrote: > From: Michal Hocko > > filemap_map_pages takes a speculative reference to each page in the > range before it tries to lock that page. While this is correct it > also can influence page migration which will bail out when seeing > an elevated reference

Re: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Michal Hocko wrote: > From: Michal Hocko > > filemap_map_pages takes a speculative reference to each page in the > range before it tries to lock that page. While this is correct it > also can influence page migration which will bail out when seeing > an elevated reference

Re: [PATCH v3 2/2] proc: add /proc//arch_state

2018-11-20 Thread Li, Aubrey
On 2018/11/20 1:39, Peter Zijlstra wrote: > On Thu, Nov 15, 2018 at 07:00:07AM +0800, Aubrey Li wrote: >> Add a /proc//arch_state interface to expose per-task cpu specific >> state values. >> >> Exposing AVX-512 Hi16_ZMM registers usage is for the user space job >> scheduler to cluster AVX-512

Re: [PATCH v3 2/2] proc: add /proc//arch_state

2018-11-20 Thread Li, Aubrey
On 2018/11/20 1:39, Peter Zijlstra wrote: > On Thu, Nov 15, 2018 at 07:00:07AM +0800, Aubrey Li wrote: >> Add a /proc//arch_state interface to expose per-task cpu specific >> state values. >> >> Exposing AVX-512 Hi16_ZMM registers usage is for the user space job >> scheduler to cluster AVX-512

RE: [PATCH v3] thermal: qoriq: add multiple sensors support

2018-11-20 Thread Andy Tang
Hi all, Do you have any comments on this patch? I found for our thermal driver(qoriq_thermal.c) there are different between the following two git trees: git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git branch: next

RE: [PATCH v3] thermal: qoriq: add multiple sensors support

2018-11-20 Thread Andy Tang
Hi all, Do you have any comments on this patch? I found for our thermal driver(qoriq_thermal.c) there are different between the following two git trees: git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git branch: next

Re: [Patch v6 14/16] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Linus Torvalds
On Tue, Nov 20, 2018 at 4:33 PM Tim Chen wrote: > > Implements arch_update_spec_restriction() for x86. Use STIBP to > restrict speculative execution when running a task set to non-dumpable, > or clear the restriction if the task is set to dumpable. I don't think this necessarily makes sense.

Re: [Patch v6 14/16] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Linus Torvalds
On Tue, Nov 20, 2018 at 4:33 PM Tim Chen wrote: > > Implements arch_update_spec_restriction() for x86. Use STIBP to > restrict speculative execution when running a task set to non-dumpable, > or clear the restriction if the task is set to dumpable. I don't think this necessarily makes sense.

Re: Memory hotplug softlock issue

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Baoquan He wrote: > On 11/20/18 at 02:38pm, Vlastimil Babka wrote: > > On 11/20/18 6:44 AM, Hugh Dickins wrote: > > > [PATCH] mm: put_and_wait_on_page_locked() while page is migrated > > > > > > We have all assumed that it is essential to hold a page reference while > > >

Re: Memory hotplug softlock issue

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Baoquan He wrote: > On 11/20/18 at 02:38pm, Vlastimil Babka wrote: > > On 11/20/18 6:44 AM, Hugh Dickins wrote: > > > [PATCH] mm: put_and_wait_on_page_locked() while page is migrated > > > > > > We have all assumed that it is essential to hold a page reference while > > >

Re: Memory hotplug softlock issue

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Vlastimil Babka wrote: > On 11/20/18 6:44 AM, Hugh Dickins wrote: > > [PATCH] mm: put_and_wait_on_page_locked() while page is migrated > > > > We have all assumed that it is essential to hold a page reference while > > waiting on a page lock: partly to guarantee that there is

Re: Memory hotplug softlock issue

2018-11-20 Thread Hugh Dickins
On Tue, 20 Nov 2018, Vlastimil Babka wrote: > On 11/20/18 6:44 AM, Hugh Dickins wrote: > > [PATCH] mm: put_and_wait_on_page_locked() while page is migrated > > > > We have all assumed that it is essential to hold a page reference while > > waiting on a page lock: partly to guarantee that there is

Re: [PATCH 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver

2018-11-20 Thread Stephen Boyd
Quoting Matthias Kaehlcke (2018-11-15 16:23:37) > On Sun, Nov 11, 2018 at 06:12:29PM +0530, Taniya Das wrote: > > On 11/4/2018 9:50 AM, Stephen Boyd wrote: > > > Quoting Taniya Das (2018-11-02 20:06:00) > > > > On 10/18/2018 5:02 AM, Stephen Boyd wrote: > > > > > Quoting Taniya Das (2018-10-11

Re: [PATCH 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver

2018-11-20 Thread Stephen Boyd
Quoting Matthias Kaehlcke (2018-11-15 16:23:37) > On Sun, Nov 11, 2018 at 06:12:29PM +0530, Taniya Das wrote: > > On 11/4/2018 9:50 AM, Stephen Boyd wrote: > > > Quoting Taniya Das (2018-11-02 20:06:00) > > > > On 10/18/2018 5:02 AM, Stephen Boyd wrote: > > > > > Quoting Taniya Das (2018-10-11

Re: [Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
On 11/20/2018 04:44 PM, Jiri Kosina wrote: > On Tue, 20 Nov 2018, Tim Chen wrote: > >> diff --git a/Documentation/admin-guide/kernel-parameters.txt >> b/Documentation/admin-guide/kernel-parameters.txt >> index d2255f7..89b193c 100644 >> --- a/Documentation/admin-guide/kernel-parameters.txt >>

Re: [Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
On 11/20/2018 04:44 PM, Jiri Kosina wrote: > On Tue, 20 Nov 2018, Tim Chen wrote: > >> diff --git a/Documentation/admin-guide/kernel-parameters.txt >> b/Documentation/admin-guide/kernel-parameters.txt >> index d2255f7..89b193c 100644 >> --- a/Documentation/admin-guide/kernel-parameters.txt >>

Re: [Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Jiri Kosina
On Tue, 20 Nov 2018, Tim Chen wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index d2255f7..89b193c 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt

Re: [Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Jiri Kosina
On Tue, 20 Nov 2018, Tim Chen wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index d2255f7..89b193c 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt

Re: [Patch v6 00/16] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
On 11/20/2018 03:59 PM, Tim Chen wrote: > Fix in this version bugs causing build problems for UP configuration. > > Also merged in Jiri's change to extend STIBP for SECCOMP processes and > renaming TIF_STIBP to TIF_SPEC_INDIR_BRANCH. > > I've updated the boot options spectre_v2_app2app to > on,

Re: [Patch v6 00/16] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
On 11/20/2018 03:59 PM, Tim Chen wrote: > Fix in this version bugs causing build problems for UP configuration. > > Also merged in Jiri's change to extend STIBP for SECCOMP processes and > renaming TIF_STIBP to TIF_SPEC_INDIR_BRANCH. > > I've updated the boot options spectre_v2_app2app to > on,

[Patch v7 03/18] x86/speculation: Reorganize cpu_show_common()

2018-11-20 Thread Tim Chen
The Spectre V2 printout in cpu_show_common() handles conditionals for the various mitigation methods directly in the sprintf() argument list. That's hard to read and will become unreadable if more complex decisions need to be made for a particular method. Move the conditionals for STIBP and IBPB

[Patch v7 05/18] x86/speculation: Disable STIBP when enhanced IBRS is in use

2018-11-20 Thread Tim Chen
If enhanced IBRS is engaged, STIBP is redundant in mitigating Spectre v2 user space exploits from hyperthread sibling. Disable STIBP when enhanced IBRS is used. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 8 1 file changed, 8 insertions(+) diff --git

[Patch v7 02/18] x86/speculation: Remove unnecessary ret variable in cpu_show_common()

2018-11-20 Thread Tim Chen
Remove unnecessary ret variable in cpu_show_common() to make the code more concise. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 5ac7070..84e3579

[Patch v7 01/18] x86/speculation: Clean up spectre_v2_parse_cmdline()

2018-11-20 Thread Tim Chen
Remove unnecessary else statement in spectre_v2_parse_cmdline() to save a indentation level. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c

[Patch v7 09/18] x86/smt: Convert cpu_smt_control check to cpu_smt_enabled static key

2018-11-20 Thread Tim Chen
The checks to cpu_smt_control outside of kernel/cpu.c can be converted to use cpu_smt_enabled key to run SMT specific code. Save the export of cpu_smt_control and convert usage of cpu_smt_control to cpu_smt_enabled outside of kernel/cpu.c. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c

[Patch v7 03/18] x86/speculation: Reorganize cpu_show_common()

2018-11-20 Thread Tim Chen
The Spectre V2 printout in cpu_show_common() handles conditionals for the various mitigation methods directly in the sprintf() argument list. That's hard to read and will become unreadable if more complex decisions need to be made for a particular method. Move the conditionals for STIBP and IBPB

[Patch v7 05/18] x86/speculation: Disable STIBP when enhanced IBRS is in use

2018-11-20 Thread Tim Chen
If enhanced IBRS is engaged, STIBP is redundant in mitigating Spectre v2 user space exploits from hyperthread sibling. Disable STIBP when enhanced IBRS is used. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 8 1 file changed, 8 insertions(+) diff --git

[Patch v7 02/18] x86/speculation: Remove unnecessary ret variable in cpu_show_common()

2018-11-20 Thread Tim Chen
Remove unnecessary ret variable in cpu_show_common() to make the code more concise. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 5ac7070..84e3579

[Patch v7 01/18] x86/speculation: Clean up spectre_v2_parse_cmdline()

2018-11-20 Thread Tim Chen
Remove unnecessary else statement in spectre_v2_parse_cmdline() to save a indentation level. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c

[Patch v7 09/18] x86/smt: Convert cpu_smt_control check to cpu_smt_enabled static key

2018-11-20 Thread Tim Chen
The checks to cpu_smt_control outside of kernel/cpu.c can be converted to use cpu_smt_enabled key to run SMT specific code. Save the export of cpu_smt_control and convert usage of cpu_smt_control to cpu_smt_enabled outside of kernel/cpu.c. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c

[Patch v7 07/18] x86/speculation: Reorganize speculation control MSRs update

2018-11-20 Thread Tim Chen
The logic to detect whether there's a change in the previous and next task's flag relevant to update speculation control MSRs are spread out across multiple functions. Consolidate all checks needed for updating speculation control MSRs to __speculation_ctrl_update(). This makes it easy to pick

[Patch v7 07/18] x86/speculation: Reorganize speculation control MSRs update

2018-11-20 Thread Tim Chen
The logic to detect whether there's a change in the previous and next task's flag relevant to update speculation control MSRs are spread out across multiple functions. Consolidate all checks needed for updating speculation control MSRs to __speculation_ctrl_update(). This makes it easy to pick

[Patch v7 06/18] x86/speculation: Rename SSBD update functions

2018-11-20 Thread Tim Chen
During context switch, the SSBD bit in SPEC_CTRL MSR is updated according to changes in TIF_SSBD flag in the current and next running task. Currently, only the bit controlling speculative store in SPEC_CTRL MSR is updated and the related update functions all have "speculative_store" or "ssb" in

[Patch v7 06/18] x86/speculation: Rename SSBD update functions

2018-11-20 Thread Tim Chen
During context switch, the SSBD bit in SPEC_CTRL MSR is updated according to changes in TIF_SSBD flag in the current and next running task. Currently, only the bit controlling speculative store in SPEC_CTRL MSR is updated and the related update functions all have "speculative_store" or "ssb" in

[Patch v7 11/18] x86/speculation: Add Spectre v2 app to app protection modes

2018-11-20 Thread Tim Chen
Add new protection modes for Spectre v2 mitigations against Spectre v2 attacks on user processes. There are three modes: none mode: In this mode, no mitigations are deployed. strict mode: In this mode, IBPB and STIBP are deployed on on all tasks.

[Patch v7 13/18] x86/speculation: Enable IBPB for tasks with TIF_SPEC_BRANCH_SPECULATION

2018-11-20 Thread Tim Chen
IBPB currently is applied to all tasks. However, when spectre_v2_app2app_enabled is set to default value SPECTRE_V2_APP2APP_PRCTL, only tasks marked with TIF_SPEC_BRANCH_SPECULATION via prctl are protected against Spectre V2 sibling thread attack to minimize performance impact. It makes sense to

[Patch v7 08/18] smt: Create cpu_smt_enabled static key for SMT specific code

2018-11-20 Thread Tim Chen
In later code, STIBP will be turned on/off in the context switch code path when SMT is enabled. Checks for SMT is best avoided on such hot paths. Create cpu_smt_enabled static key to turn on such SMT specific code statically. The key is enabled by default and its scope has nothing to do with

[Patch v7 11/18] x86/speculation: Add Spectre v2 app to app protection modes

2018-11-20 Thread Tim Chen
Add new protection modes for Spectre v2 mitigations against Spectre v2 attacks on user processes. There are three modes: none mode: In this mode, no mitigations are deployed. strict mode: In this mode, IBPB and STIBP are deployed on on all tasks.

[Patch v7 13/18] x86/speculation: Enable IBPB for tasks with TIF_SPEC_BRANCH_SPECULATION

2018-11-20 Thread Tim Chen
IBPB currently is applied to all tasks. However, when spectre_v2_app2app_enabled is set to default value SPECTRE_V2_APP2APP_PRCTL, only tasks marked with TIF_SPEC_BRANCH_SPECULATION via prctl are protected against Spectre V2 sibling thread attack to minimize performance impact. It makes sense to

[Patch v7 08/18] smt: Create cpu_smt_enabled static key for SMT specific code

2018-11-20 Thread Tim Chen
In later code, STIBP will be turned on/off in the context switch code path when SMT is enabled. Checks for SMT is best avoided on such hot paths. Create cpu_smt_enabled static key to turn on such SMT specific code statically. The key is enabled by default and its scope has nothing to do with

[Patch v7 18/18] x86/smt: Allow disabling of SMT when last SMT is offlined

2018-11-20 Thread Tim Chen
Currently cpu_use_smt_and_hotplug is only set during boot time to indicate if SMT is in use. However, CPU topology may change and when the last SMT thread is offlined, the SMT code path can be skipped. The sched_smt_present key detects this condition. Export sched_smt_present and incorporate it

[Patch v7 17/18] sched/smt: Make sched_smt_present track topology

2018-11-20 Thread Tim Chen
From: Peter Zijlstra From: Peter Zijlstra (Intel) Currently the sched_smt_present static key is only enabled when we encounter SMT topology. However there is demand to also disable the key when the topology changes such that there is no SMT present anymore. Implement this by making the key

[Patch v7 18/18] x86/smt: Allow disabling of SMT when last SMT is offlined

2018-11-20 Thread Tim Chen
Currently cpu_use_smt_and_hotplug is only set during boot time to indicate if SMT is in use. However, CPU topology may change and when the last SMT thread is offlined, the SMT code path can be skipped. The sched_smt_present key detects this condition. Export sched_smt_present and incorporate it

[Patch v7 17/18] sched/smt: Make sched_smt_present track topology

2018-11-20 Thread Tim Chen
From: Peter Zijlstra From: Peter Zijlstra (Intel) Currently the sched_smt_present static key is only enabled when we encounter SMT topology. However there is demand to also disable the key when the topology changes such that there is no SMT present anymore. Implement this by making the key

[Patch v7 15/18] security: Update speculation restriction of a process when modifying its dumpability

2018-11-20 Thread Tim Chen
When a task is made non-dumpable, a higher level of security is implied implicitly as its memory is imposed with access restriction. Many daemons touching sensitive data (e.g. sshd) make theselves non-dumpable. Such tasks should have speculative execution restricted to protect them from attacks

[Patch v7 15/18] security: Update speculation restriction of a process when modifying its dumpability

2018-11-20 Thread Tim Chen
When a task is made non-dumpable, a higher level of security is implied implicitly as its memory is imposed with access restriction. Many daemons touching sensitive data (e.g. sshd) make theselves non-dumpable. Such tasks should have speculative execution restricted to protect them from attacks

[Patch v7 16/18] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Tim Chen
When a task changes its dumpability, arch_update_spec_ctrl_restriction() is called to place restriction on the task's speculative execution according to dumpability changes. Implements arch_update_spec_restriction() for x86. Use STIBP to restrict speculative execution when running a task set to

[Patch v7 00/18] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
My apology that the v6 patches are missing the first two patch in the series. Resending the patch series as v7. Fix in this version bugs causing build problems for UP configuration. Also merged in Jiri's change to extend STIBP for SECCOMP processes and renaming TIF_STIBP to

[Patch v7 10/18] x86/speculation: Turn on or off STIBP according to a task's TIF_STIBP

2018-11-20 Thread Tim Chen
If STIBP is used all the time, tasks that do not need STIBP protection will get unnecessarily slowed down by STIBP. To apply STIBP only to tasks that need it, a new task TIF_STIBP flag is created. A x86 CPU uses STIBP only for tasks labeled with TIF_STIBP. During context switch, this flag is

[Patch v7 14/18] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
From: Jiri Kosina From: Jiri Kosina If 'prctl' mode of app2app protection from spectre_v2 is selected on kernel command-line, we are currently applying STIBP protection to tasks that restrict their indirect branch speculation via prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH,

[Patch v7 04/18] x86/speculation: Add X86_FEATURE_USE_IBRS_ENHANCED

2018-11-20 Thread Tim Chen
STIBP is not needed when enhanced IBRS is used for Spectre V2 mitigation. A CPU feature flag to indicate that enhanced IBRS is used will be handy for skipping STIBP for this case. Add X86_FEATURE_USE_IBRS_ENHANCED feature bit to indicate enhanced IBRS is used for Spectre V2 mitigation.

[Patch v7 12/18] x86/speculation: Create PRCTL interface to restrict indirect branch speculation

2018-11-20 Thread Tim Chen
Create PRCTL interface to restrict an application's indirect branch speculation. This will protect the application against spectre v2 attack from another application. Invocations: Check indirect branch speculation status with - prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, 0, 0, 0);

[Patch v7 16/18] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Tim Chen
When a task changes its dumpability, arch_update_spec_ctrl_restriction() is called to place restriction on the task's speculative execution according to dumpability changes. Implements arch_update_spec_restriction() for x86. Use STIBP to restrict speculative execution when running a task set to

[Patch v7 00/18] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
My apology that the v6 patches are missing the first two patch in the series. Resending the patch series as v7. Fix in this version bugs causing build problems for UP configuration. Also merged in Jiri's change to extend STIBP for SECCOMP processes and renaming TIF_STIBP to

[Patch v7 10/18] x86/speculation: Turn on or off STIBP according to a task's TIF_STIBP

2018-11-20 Thread Tim Chen
If STIBP is used all the time, tasks that do not need STIBP protection will get unnecessarily slowed down by STIBP. To apply STIBP only to tasks that need it, a new task TIF_STIBP flag is created. A x86 CPU uses STIBP only for tasks labeled with TIF_STIBP. During context switch, this flag is

[Patch v7 14/18] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
From: Jiri Kosina From: Jiri Kosina If 'prctl' mode of app2app protection from spectre_v2 is selected on kernel command-line, we are currently applying STIBP protection to tasks that restrict their indirect branch speculation via prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH,

[Patch v7 04/18] x86/speculation: Add X86_FEATURE_USE_IBRS_ENHANCED

2018-11-20 Thread Tim Chen
STIBP is not needed when enhanced IBRS is used for Spectre V2 mitigation. A CPU feature flag to indicate that enhanced IBRS is used will be handy for skipping STIBP for this case. Add X86_FEATURE_USE_IBRS_ENHANCED feature bit to indicate enhanced IBRS is used for Spectre V2 mitigation.

[Patch v7 12/18] x86/speculation: Create PRCTL interface to restrict indirect branch speculation

2018-11-20 Thread Tim Chen
Create PRCTL interface to restrict an application's indirect branch speculation. This will protect the application against spectre v2 attack from another application. Invocations: Check indirect branch speculation status with - prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, 0, 0, 0);

Re: [LKP] dd2283f260 [ 97.263072] WARNING:at_kernel/locking/lockdep.c:#lock_downgrade

2018-11-20 Thread Yang Shi
On 11/20/18 9:42 PM, Kirill A. Shutemov wrote: On Tue, Nov 20, 2018 at 08:10:51PM +0800, Yang Shi wrote: On 11/20/18 4:57 PM, Kirill A. Shutemov wrote: On Fri, Nov 16, 2018 at 08:56:04AM -0800, Yang Shi wrote: a8dda165ec vfree: add debug might_sleep() dd2283f260 mm: mmap: zap pages with

Re: [LKP] dd2283f260 [ 97.263072] WARNING:at_kernel/locking/lockdep.c:#lock_downgrade

2018-11-20 Thread Yang Shi
On 11/20/18 9:42 PM, Kirill A. Shutemov wrote: On Tue, Nov 20, 2018 at 08:10:51PM +0800, Yang Shi wrote: On 11/20/18 4:57 PM, Kirill A. Shutemov wrote: On Fri, Nov 16, 2018 at 08:56:04AM -0800, Yang Shi wrote: a8dda165ec vfree: add debug might_sleep() dd2283f260 mm: mmap: zap pages with

[Patch v6 01/16] x86/speculation: Reorganize cpu_show_common()

2018-11-20 Thread Tim Chen
The Spectre V2 printout in cpu_show_common() handles conditionals for the various mitigation methods directly in the sprintf() argument list. That's hard to read and will become unreadable if more complex decisions need to be made for a particular method. Move the conditionals for STIBP and IBPB

[Patch v6 01/16] x86/speculation: Reorganize cpu_show_common()

2018-11-20 Thread Tim Chen
The Spectre V2 printout in cpu_show_common() handles conditionals for the various mitigation methods directly in the sprintf() argument list. That's hard to read and will become unreadable if more complex decisions need to be made for a particular method. Move the conditionals for STIBP and IBPB

[Patch v6 00/16] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
Fix in this version bugs causing build problems for UP configuration. Also merged in Jiri's change to extend STIBP for SECCOMP processes and renaming TIF_STIBP to TIF_SPEC_INDIR_BRANCH. I've updated the boot options spectre_v2_app2app to on, off, auto, prctl and seccomp. This aligns with the

[Patch v6 02/16] x86/speculation: Add X86_FEATURE_USE_IBRS_ENHANCED

2018-11-20 Thread Tim Chen
STIBP is not needed when enhanced IBRS is used for Spectre V2 mitigation. A CPU feature flag to indicate that enhanced IBRS is used will be handy for skipping STIBP for this case. Add X86_FEATURE_USE_IBRS_ENHANCED feature bit to indicate enhanced IBRS is used for Spectre V2 mitigation.

[Patch v6 00/16] Provide task property based options to enable Spectre v2 userspace-userspace protection

2018-11-20 Thread Tim Chen
Fix in this version bugs causing build problems for UP configuration. Also merged in Jiri's change to extend STIBP for SECCOMP processes and renaming TIF_STIBP to TIF_SPEC_INDIR_BRANCH. I've updated the boot options spectre_v2_app2app to on, off, auto, prctl and seccomp. This aligns with the

[Patch v6 02/16] x86/speculation: Add X86_FEATURE_USE_IBRS_ENHANCED

2018-11-20 Thread Tim Chen
STIBP is not needed when enhanced IBRS is used for Spectre V2 mitigation. A CPU feature flag to indicate that enhanced IBRS is used will be handy for skipping STIBP for this case. Add X86_FEATURE_USE_IBRS_ENHANCED feature bit to indicate enhanced IBRS is used for Spectre V2 mitigation.

[Patch v6 08/16] x86/speculation: Turn on or off STIBP according to a task's TIF_STIBP

2018-11-20 Thread Tim Chen
If STIBP is used all the time, tasks that do not need STIBP protection will get unnecessarily slowed down by STIBP. To apply STIBP only to tasks that need it, a new task TIF_STIBP flag is created. A x86 CPU uses STIBP only for tasks labeled with TIF_STIBP. During context switch, this flag is

[Patch v6 11/16] x86/speculation: Enable IBPB for tasks with TIF_SPEC_BRANCH_SPECULATION

2018-11-20 Thread Tim Chen
IBPB currently is applied to all tasks. However, when spectre_v2_app2app_enabled is set to default value SPECTRE_V2_APP2APP_PRCTL, only tasks marked with TIF_SPEC_BRANCH_SPECULATION via prctl are protected against Spectre V2 sibling thread attack to minimize performance impact. Extend this

[Patch v6 08/16] x86/speculation: Turn on or off STIBP according to a task's TIF_STIBP

2018-11-20 Thread Tim Chen
If STIBP is used all the time, tasks that do not need STIBP protection will get unnecessarily slowed down by STIBP. To apply STIBP only to tasks that need it, a new task TIF_STIBP flag is created. A x86 CPU uses STIBP only for tasks labeled with TIF_STIBP. During context switch, this flag is

[Patch v6 11/16] x86/speculation: Enable IBPB for tasks with TIF_SPEC_BRANCH_SPECULATION

2018-11-20 Thread Tim Chen
IBPB currently is applied to all tasks. However, when spectre_v2_app2app_enabled is set to default value SPECTRE_V2_APP2APP_PRCTL, only tasks marked with TIF_SPEC_BRANCH_SPECULATION via prctl are protected against Spectre V2 sibling thread attack to minimize performance impact. Extend this

[Patch v6 04/16] x86/speculation: Rename SSBD update functions

2018-11-20 Thread Tim Chen
During context switch, the SSBD bit in SPEC_CTRL MSR is updated according to changes in TIF_SSBD flag in the current and next running task. Currently, only the bit controlling speculative store in SPEC_CTRL MSR is updated and the related update functions all have "speculative_store" or "ssb" in

[Patch v6 14/16] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Tim Chen
When a task changes its dumpability, arch_update_spec_ctrl_restriction() is called to place restriction on the task's speculative execution according to dumpability changes. Implements arch_update_spec_restriction() for x86. Use STIBP to restrict speculative execution when running a task set to

[Patch v6 04/16] x86/speculation: Rename SSBD update functions

2018-11-20 Thread Tim Chen
During context switch, the SSBD bit in SPEC_CTRL MSR is updated according to changes in TIF_SSBD flag in the current and next running task. Currently, only the bit controlling speculative store in SPEC_CTRL MSR is updated and the related update functions all have "speculative_store" or "ssb" in

[Patch v6 14/16] x86/speculation: Use STIBP to restrict speculation on non-dumpable task

2018-11-20 Thread Tim Chen
When a task changes its dumpability, arch_update_spec_ctrl_restriction() is called to place restriction on the task's speculative execution according to dumpability changes. Implements arch_update_spec_restriction() for x86. Use STIBP to restrict speculative execution when running a task set to

[Patch v6 09/16] x86/speculation: Add Spectre v2 app to app protection modes

2018-11-20 Thread Tim Chen
Add new protection modes for Spectre v2 mitigations against Spectre v2 attacks on user processes. There are three modes: none mode: In this mode, no mitigations are deployed. strict mode: In this mode, IBPB and STIBP are deployed on on all tasks.

[Patch v6 07/16] x86/smt: Convert cpu_smt_control check to cpu_smt_enabled static key

2018-11-20 Thread Tim Chen
The checks to cpu_smt_control outside of kernel/cpu.c can be converted to use cpu_smt_enabled key to run SMT specific code. Save the export of cpu_smt_control and convert usage of cpu_smt_control to cpu_smt_enabled outside of kernel/cpu.c. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c

[Patch v6 06/16] smt: Create cpu_smt_enabled static key for SMT specific code

2018-11-20 Thread Tim Chen
In later code, STIBP will be turned on/off in the context switch code path when SMT is enabled. Checks for SMT is best avoided on such hot paths. Create cpu_smt_enabled static key to turn on such SMT specific code statically. The key is enabled by default and its scope has nothing to do with

[Patch v6 09/16] x86/speculation: Add Spectre v2 app to app protection modes

2018-11-20 Thread Tim Chen
Add new protection modes for Spectre v2 mitigations against Spectre v2 attacks on user processes. There are three modes: none mode: In this mode, no mitigations are deployed. strict mode: In this mode, IBPB and STIBP are deployed on on all tasks.

[Patch v6 07/16] x86/smt: Convert cpu_smt_control check to cpu_smt_enabled static key

2018-11-20 Thread Tim Chen
The checks to cpu_smt_control outside of kernel/cpu.c can be converted to use cpu_smt_enabled key to run SMT specific code. Save the export of cpu_smt_control and convert usage of cpu_smt_control to cpu_smt_enabled outside of kernel/cpu.c. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c

[Patch v6 06/16] smt: Create cpu_smt_enabled static key for SMT specific code

2018-11-20 Thread Tim Chen
In later code, STIBP will be turned on/off in the context switch code path when SMT is enabled. Checks for SMT is best avoided on such hot paths. Create cpu_smt_enabled static key to turn on such SMT specific code statically. The key is enabled by default and its scope has nothing to do with

[Patch v6 03/16] x86/speculation: Disable STIBP when enhanced IBRS is in use

2018-11-20 Thread Tim Chen
If enhanced IBRS is engaged, STIBP is redundant in mitigating Spectre v2 user space exploits from hyperthread sibling. Disable STIBP when enhanced IBRS is used. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 8 1 file changed, 8 insertions(+) diff --git

[Patch v6 15/16] sched/smt: Make sched_smt_present track topology

2018-11-20 Thread Tim Chen
From: Peter Zijlstra From: Peter Zijlstra (Intel) Currently the sched_smt_present static key is only enabled when we encounter SMT topology. However there is demand to also disable the key when the topology changes such that there is no SMT present anymore. Implement this by making the key

[Patch v6 03/16] x86/speculation: Disable STIBP when enhanced IBRS is in use

2018-11-20 Thread Tim Chen
If enhanced IBRS is engaged, STIBP is redundant in mitigating Spectre v2 user space exploits from hyperthread sibling. Disable STIBP when enhanced IBRS is used. Signed-off-by: Tim Chen --- arch/x86/kernel/cpu/bugs.c | 8 1 file changed, 8 insertions(+) diff --git

[Patch v6 15/16] sched/smt: Make sched_smt_present track topology

2018-11-20 Thread Tim Chen
From: Peter Zijlstra From: Peter Zijlstra (Intel) Currently the sched_smt_present static key is only enabled when we encounter SMT topology. However there is demand to also disable the key when the topology changes such that there is no SMT present anymore. Implement this by making the key

[Patch v6 05/16] x86/speculation: Reorganize speculation control MSRs update

2018-11-20 Thread Tim Chen
The logic to detect whether there's a change in the previous and next task's flag relevant to update speculation control MSRs are spread out across multiple functions. Consolidate all checks needed for updating speculation control MSRs to __speculation_ctrl_update(). This makes it easy to pick

[Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
From: Jiri Kosina From: Jiri Kosina If 'prctl' mode of app2app protection from spectre_v2 is selected on kernel command-line, we are currently applying STIBP protection to tasks that restrict their indirect branch speculation via prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH,

[Patch v6 05/16] x86/speculation: Reorganize speculation control MSRs update

2018-11-20 Thread Tim Chen
The logic to detect whether there's a change in the previous and next task's flag relevant to update speculation control MSRs are spread out across multiple functions. Consolidate all checks needed for updating speculation control MSRs to __speculation_ctrl_update(). This makes it easy to pick

[Patch v6 12/16] x86/speculation: Add 'seccomp' Spectre v2 app to app protection mode

2018-11-20 Thread Tim Chen
From: Jiri Kosina From: Jiri Kosina If 'prctl' mode of app2app protection from spectre_v2 is selected on kernel command-line, we are currently applying STIBP protection to tasks that restrict their indirect branch speculation via prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH,

[Patch v6 13/16] security: Update speculation restriction of a process when modifying its dumpability

2018-11-20 Thread Tim Chen
When a task is made non-dumpable, a higher level of security is implied implicitly as its memory is imposed with access restriction. Many daemons touching sensitive data (e.g. sshd) make theselves non-dumpable. Such tasks should have speculative execution restricted to protect them from attacks

[Patch v6 13/16] security: Update speculation restriction of a process when modifying its dumpability

2018-11-20 Thread Tim Chen
When a task is made non-dumpable, a higher level of security is implied implicitly as its memory is imposed with access restriction. Many daemons touching sensitive data (e.g. sshd) make theselves non-dumpable. Such tasks should have speculative execution restricted to protect them from attacks

[Patch v6 16/16] x86/smt: Allow disabling of SMT when last SMT is offlined

2018-11-20 Thread Tim Chen
Currently cpu_use_smt_and_hotplug is only set during boot time to indicate if SMT is in use. However, CPU topology may change and when the last SMT thread is offlined, the SMT code path can be skipped. The sched_smt_present key detects this condition. Export sched_smt_present and incorporate it

[Patch v6 10/16] x86/speculation: Create PRCTL interface to restrict indirect branch speculation

2018-11-20 Thread Tim Chen
Create PRCTL interface to restrict an application's indirect branch speculation. This will protect the application against spectre v2 attack from another application. Invocations: Check indirect branch speculation status with - prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, 0, 0, 0);

<    1   2   3   4   5   6   7   8   9   10   >