[PATCH v3 7/9] x86: extable: use macros instead of inline assembly

2018-06-10 Thread Nadav Amit
: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 61 +- arch/x86/kernel/macros.S | 1 + 2 files changed, 28 insertions(+), 34 deletions(-) di

[PATCH v3 8/9] x86: cpufeature: use macros instead of inline assembly

2018-06-10 Thread Nadav Amit
Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Signed-off-by: Nadav Amit --- arch/x86/include/asm/cpufeature.h | 82 ++- arch/x86/kernel/macros.S | 1 + 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/cpufeature

Re: [PATCH] mremap: Increase LATENCY_LIMIT of mremap to reduce the number of TLB shootdowns

2018-06-06 Thread Nadav Amit
Mel Gorman wrote: > On Wed, Jun 06, 2018 at 08:55:15AM -0700, Nadav Amit wrote: >>> -#define LATENCY_LIMIT (64 * PAGE_SIZE) >>> +#define LATENCY_LIMIT (PMD_SIZE) >>> >>> unsigned long move_page_tables(struct vm_area_struct *vma, >>

Re: [PATCH] mremap: Increase LATENCY_LIMIT of mremap to reduce the number of TLB shootdowns

2018-06-06 Thread Nadav Amit
Mel Gorman wrote: > Commit 5d1904204c99 ("mremap: fix race between mremap() and page cleanning") > fixed races between mremap and other operations for both file-backed and > anonymous mappings. The file-backed was the most critical as it allowed the > possibility that data could be changed on a p

Re: [PATCH] mremap: Avoid TLB flushing anonymous pages that are not in swap cache

2018-06-05 Thread Nadav Amit
Mel Gorman wrote: > On Tue, Jun 05, 2018 at 12:53:57PM -0700, Nadav Amit wrote: >> While I do not have a specific reservation regarding the logic, I find the >> current TLB invalidation scheme hard to follow and inconsistent. I guess >> should_force_flush() can be extended a

Re: [PATCH] mremap: Avoid TLB flushing anonymous pages that are not in swap cache

2018-06-05 Thread Nadav Amit
Mel Gorman wrote: > Commit 5d1904204c99 ("mremap: fix race between mremap() and page cleanning") > fixed races between mremap and other operations for both file-backed and > anonymous mappings. The file-backed was the most critical as it allowed the > possibility that data could be changed on a p

Re: [PATCH v2 3/9] x86: refcount: prevent gcc distortions

2018-06-04 Thread Nadav Amit
Kees Cook wrote: > On Mon, Jun 4, 2018 at 4:21 AM, Nadav Amit wrote: >> GCC considers the number of statements in inlined assembly blocks, >> according to new-lines and semicolons, as an indication to the cost of >> the block in time and space. This data is distort

[PATCH] gpio: Fix wrong rounding in gpio-menz127

2018-06-04 Thread Nadav Amit
;) Signed-off-by: Nadav Amit --- drivers/gpio/gpio-menz127.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c index e1037582e34d..b2635326546e 100644 --- a/drivers/gpio/gpio-menz127.c +++ b/drivers/gpio/gpio-menz127.

[PATCH v2 3/9] x86: refcount: prevent gcc distortions

2018-06-04 Thread Nadav Amit
) Functions such as kref_get(), free_user(), fuse_file_get() now get inlined. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Kees Cook Cc: Jan Beulich Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/refco

[PATCH v2 8/9] x86: cpufeature: use macros instead of inline assembly

2018-06-04 Thread Nadav Amit
Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Signed-off-by: Nadav Amit --- arch/x86/include/asm/cpufeature.h | 82 ++- arch/x86/kernel/macros.S | 1 + 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/cpufeature

[PATCH v2 1/9] Makefile: Prepare for using macros for inline asm

2018-06-04 Thread Nadav Amit
Using macros for inline assembly improves both readability and compilation decisions that are distorted by big assembly blocks that use alternative sections. Compile macros.S and use it to assemble all C files. Currently, only x86 will use it. Signed-off-by: Nadav Amit --- Makefile

[PATCH v2 6/9] x86: prevent inline distortion by paravirt ops

2018-06-04 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: virtualizat...@lists.linux-foundation.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/paravirt_types.h | 54 +++ arch/x86/kernel/macros.S | 1 + 2 files changed, 31 inserti

[PATCH v2 2/9] x86: objtool: use asm macro for better compiler decisions

2018-06-04 Thread Nadav Amit
: 40302 (-19) Cc: Christopher Li Cc: linux-spa...@vger.kernel.org Signed-off-by: Nadav Amit --- arch/x86/kernel/macros.S | 2 ++ include/linux/compiler.h | 60 +++- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/macros.S b/arch

[PATCH v2 7/9] x86: extable: use macros instead of inline assembly

2018-06-04 Thread Nadav Amit
: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 61 +- arch/x86/kernel/macros.S | 1 + 2 files changed, 28 insertions(+), 34 deletions(-) di

[PATCH v2 4/9] x86: alternatives: macrofy locks for better inlining

2018-06-04 Thread Nadav Amit
nel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/alternative-asm.h | 20 ++-- arch/x86/include/asm/alternative.h | 16 ++-- arch/x86/kernel/macros.S | 1 + 3 files changed, 17 insertions(+), 20 deletions(-) diff --git

[PATCH v2 9/9] x86: jump-labels: use macros instead of inline assembly

2018-06-04 Thread Nadav Amit
: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Greg Kroah-Hartman Cc: Kate Stewart Cc: Philippe Ombredanne Signed-off-by: Nadav Amit --- arch/x86/include/asm/jump_label.h | 65 ++- arch/x86/kernel/macros.S | 1

[PATCH v2 5/9] x86: bug: prevent gcc distortions

2018-06-04 Thread Nadav Amit
(-165) Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/bug.h | 98 ++ arch/x86/kernel/macros.S | 1 + 2 files changed, 57

[PATCH v3 RESEND] vmw_balloon: fixing double free when batching mode is off

2018-06-01 Thread Nadav Amit
.org Reported-by: Oleksandr Natalenko Signed-off-by: Gil Kupfer Signed-off-by: Nadav Amit Reviewed-by: Xavier Deguillard Tested-by: Oleksandr Natalenko --- drivers/misc/vmw_balloon.c | 23 +++ 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/misc

Re: [PATCH v3] vmw_balloon: fixing double free when batching mode is off

2018-06-01 Thread Nadav Amit
Greg Kroah-Hartman wrote: > On Thu, May 31, 2018 at 08:56:52PM +0000, Nadav Amit wrote: >> Nadav Amit wrote: >> >>> Nadav Amit wrote: >>> >>>> Ping. Please consider it for inclusion for rc4. >>>> >>>> Nadav Amit wrote:

Re: Can kfree() sleep at runtime?

2018-05-31 Thread Nadav Amit
Jia-Ju Bai wrote: > > > On 2018/5/31 22:30, Christopher Lameter wrote: >> On Thu, 31 May 2018, Matthew Wilcox wrote: >> Freeing a page in the page allocator also was traditionally not sleeping. That has changed? >>> No. "Your bug" being "The bug in your static analysis tool". It pr

Re: [PATCH v3] vmw_balloon: fixing double free when batching mode is off

2018-05-31 Thread Nadav Amit
Nadav Amit wrote: > Nadav Amit wrote: > >> Ping. Please consider it for inclusion for rc4. >> >> Nadav Amit wrote: >> >>> From: Gil Kupfer >>> >>> The balloon.page field is used for two different purposes if batching is >>&g

Re: [PATCH v3] vmw_balloon: fixing double free when batching mode is off

2018-05-29 Thread Nadav Amit
Nadav Amit wrote: > Ping. Please consider it for inclusion for rc4. > > Nadav Amit wrote: > >> From: Gil Kupfer >> >> The balloon.page field is used for two different purposes if batching is >> on or off. If batching is on, the field point to the page

Re: [PATCH] mm: Add new vma flag VM_LOCAL_CPU

2018-05-23 Thread Nadav Amit
Dave Hansen wrote: > On 05/22/2018 10:51 AM, Matthew Wilcox wrote: >> But CR3 is a per-CPU register. So it'd be *possible* to allocate one >> PGD per CPU (per process). Have them be identical in all but one of >> the PUD entries. Then you've reserved 1/512 of your address space for >> per-CPU

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 12:21:00 PM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: >> >>> Gnu ASM manual says: "Each time you run as it assembles exactly one >> source >>> program. The

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:02 PM Nadav Amit wrote: > >> I can add a -Wa,[filename.s] switch. It works, but sort of undocumented. > > Oh, if it assembles things together, then that sounds optimal. > > And yes, like hpa says, we should ma

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 11:50:12 AM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 11:34 AM wrote: >> >>> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >> torva...@linux-foundation.org> wrote: >> >>> Unfortunately gcc doesn't guarantee that global assembly inlines

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:59 AM Peter Zijlstra > wrote: > >> This is an awesome hack, but is there really nothing we can do to make >> it more readable? Esp, that global asm doing the macro definition is a >> pain to read. > > I actually find that macro to be *more* le

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 03:46:33PM +0000, Nadav Amit wrote: >> In case you didn’t read the cover-letter: the patch-set does give a 2% >> performance improvement for #PF-MADV_DONTNEED microbenchmark loop. > > I saw it but *micro*-benchmark doesn'

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 02:36:21PM +0000, Nadav Amit wrote: >> I didn’t try too hard to find more affected (micro)benchmarks, but I am >> pretty sure there are: > > So you being pretty sure there are, doesn't make me go, oh, ok, then, > this

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 10:13:54AM +0200, Ingo Molnar wrote: >> Yes, that's my main worry too about all these inlining changes: >> the very, very marked reduction in the readability of assembly code. > > Same reaction here: the small improvements this brings is simply no

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Ingo Molnar wrote: > > * Peter Zijlstra wrote: > >> On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >>> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >>> +"1:\t \\ins\n\t" >>> +&q

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Peter Zijlstra wrote: > On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >> +"1:\t \\ins\n\t" >> +".pushsection __bug_table,\"aw\"\n" >&

Re: [PATCH 0/6] Macrofying inline assembly for better compilation

2018-05-18 Thread Nadav Amit
David Laight wrote: > From: Nadav Amit >> Sent: 17 May 2018 17:14 >> This patch-set deals with an interesting yet stupid problem: kernel code >> that does not get inlined despite its simplicity. There are several >> causes for this behavior: "cold" at

[PATCH 0/6] Macrofying inline assembly for better compilation

2018-05-17 Thread Nadav Amit
er Cc: virtualizat...@lists.linux-foundation.org Cc: x...@kernel.org Nadav Amit (6): x86: objtool: use asm macro for better compiler decisions x86: bug: prevent gcc distortions x86: alternative: macrofy locks for better inlining x86: prevent inline distortion by paravirt ops x86: refcoun

[PATCH 5/6] x86: refcount: prevent gcc distortions

2018-05-17 Thread Nadav Amit
: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Kees Cook Cc: Jan Beulich Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/refcount.h | 62 + 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/arch/x86/i

[PATCH 1/6] x86: objtool: use asm macro for better compiler decisions

2018-05-17 Thread Nadav Amit
text symbols: Before: 40033 After: 40015 (-18) Cc: Christopher Li Cc: linux-spa...@vger.kernel.org Signed-off-by: Nadav Amit --- include/linux/compiler.h | 37 + 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/include/linux/compiler.h b/include

[PATCH 3/6] x86: alternative: macrofy locks for better inlining

2018-05-17 Thread Nadav Amit
nel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/alternative.h | 34 +++--- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 4cd6a3b71824..1dc47c9fd480 10

[PATCH 4/6] x86: prevent inline distortion by paravirt ops

2018-05-17 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: virtualizat...@lists.linux-foundation.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/paravirt_types.h | 63 +-- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/arch/x86/i

[PATCH 6/6] x86: removing unneeded new-lines

2018-05-17 Thread Nadav Amit
kernel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 4 ++-- arch/x86/include/asm/cmpxchg.h | 10 +- arch/x86/include/asm/special_insns.h | 12 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/i

[PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-17 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/bug.h | 56 +- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/arch/x86/i

Re: [RFC 5/8] x86: refcount: prevent gcc distortions

2018-05-16 Thread Nadav Amit
Jan Beulich wrote: On 15.05.18 at 16:11, wrote: >> --- a/arch/x86/include/asm/refcount.h >> +++ b/arch/x86/include/asm/refcount.h >> @@ -14,34 +14,43 @@ >> * central refcount exception. The fixup address for the exception points >> * back to the regular execution flow in .text. >> */ >>

Re: [RFC 5/8] x86: refcount: prevent gcc distortions

2018-05-16 Thread Nadav Amit
Kees Cook wrote: > On Tue, May 15, 2018 at 7:11 AM, Nadav Amit wrote: >> GCC considers the number of statements in inlined assembly blocks, >> according to new-lines and semicolons, as an indication to the cost of >> the block in time and space. This data is distort

Re: [RFC 0/8] Improving compiler inlining decisions

2018-05-15 Thread Nadav Amit
Josh Poimboeuf wrote: > On Tue, May 15, 2018 at 07:11:07AM -0700, Nadav Amit wrote: >> This patch-set deals with an interesting yet stupid problem: code that >> does not get inlined despite its simplicity. > > I got the 0/8 patch twice, and didn't get the 1/8 patch.

Re: [RFC 0/8] Improving compiler inlining decisions

2018-05-15 Thread Nadav Amit
Nadav Amit wrote: > This patch-set deals with an interesting yet stupid problem: code that > does not get inlined despite its simplicity. > > I find 5 classes of causes: > > 1. Inline assembly blocks in which code and data are added to > alternative sections. The compile

Re: [RFC 1/8] x86: objtool: use asm macro for better compiler decisions

2018-05-15 Thread Nadav Amit
Josh Triplett wrote: > On Tue, May 15, 2018 at 07:11:08AM -0700, Nadav Amit wrote: >> GCC considers the number of statements in inlined assembly blocks, >> according to new-lines and semicolons, as an indication to the cost of >> the block in time and space. This data is di

[RFC 4/8] x86: prevent inline distortion by paravirt ops

2018-05-15 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: virtualizat...@lists.linux-foundation.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/paravirt_types.h | 53 +++ 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/arch/x86/i

[RFC 0/8] Improving compiler inlining decisions

2018-05-15 Thread Nadav Amit
...@lists.linux-foundation.org Cc: x...@kernel.org Nadav Amit (8): x86: objtool: use asm macro for better compiler decisions x86: bug: prevent gcc distortions x86: alternative: macrofy locks for better inlining x86: prevent inline distortion by paravirt ops x86: refcount: prevent gcc dist

[RFC 2/8] x86: bug: prevent gcc distortions

2018-05-15 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/bug.h | 48 +++--- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/arch/x86/i

[RFC 6/8] x86: removing unneeded new-lines

2018-05-15 Thread Nadav Amit
kernel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 4 ++-- arch/x86/include/asm/cmpxchg.h | 10 +- arch/x86/include/asm/special_insns.h | 12 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/i

[RFC 7/8] ilog2: preventing compiler distortion due to big condition

2018-05-15 Thread Nadav Amit
5 10064176 2936832 31150173 1db505d ./vmlinux after (+437) Static text symbols: Before: 39650 After: 39643 (-7) Cc: Randy Dunlap Cc: Jonathan Corbet Signed-off-by: Nadav Amit --- include/linux/log2.h | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linu

[RFC 8/8] bitops: prevent compiler inline decision distortion

2018-05-15 Thread Nadav Amit
73 1db505d ./vmlinux before 18149210 10064048 2936832 31150090 1db500a ./vmlinux after (-83) Static text symbols: Before: 39643 After: 39632 (-11) Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/bito

[RFC 3/8] x86: alternative: macrofy locks for better inlining

2018-05-15 Thread Nadav Amit
nel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/alternative.h | 28 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 4cd6a3b71824..daa68ad51665 10

[RFC 5/8] x86: refcount: prevent gcc distortions

2018-05-15 Thread Nadav Amit
: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Kees Cook Cc: Jan Beulich Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/refcount.h | 55 - 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/arch/x86/i

[RFC 2/8] x86: bug: prevent gcc distortions

2018-05-15 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Peter Zijlstra Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/bug.h | 48 +++--- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/arch/x86/i

[RFC 1/8] x86: objtool: use asm macro for better compiler decisions

2018-05-15 Thread Nadav Amit
text symbols: Before: 40033 After: 40015 (-18) Cc: Christopher Li Cc: linux-spa...@vger.kernel.org Signed-off-by: Nadav Amit --- include/linux/compiler.h | 29 + 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/include/linux/compiler.h b/include/linux

[RFC 1/8] x86: objtool: use asm macro for better compiler decisions

2018-05-15 Thread Nadav Amit
text symbols: Before: 40033 After: 40015 (-18) Cc: Christopher Li Cc: linux-spa...@vger.kernel.org Signed-off-by: Nadav Amit --- include/linux/compiler.h | 29 + 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/include/linux/compiler.h b/include/linux

[RFC 4/8] x86: prevent inline distortion by paravirt ops

2018-05-15 Thread Nadav Amit
Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: virtualizat...@lists.linux-foundation.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/paravirt_types.h | 53 +++ 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/arch/x86/i

[RFC 0/8] Improving compiler inlining decisions

2018-05-15 Thread Nadav Amit
...@lists.linux-foundation.org Cc: x...@kernel.org Nadav Amit (8): x86: objtool: use asm macro for better compiler decisions x86: bug: prevent gcc distortions x86: alternative: macrofy locks for better inlining x86: prevent inline distortion by paravirt ops x86: refcount: prevent gcc dist

[RFC 5/8] x86: refcount: prevent gcc distortions

2018-05-15 Thread Nadav Amit
: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Kees Cook Cc: Jan Beulich Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/refcount.h | 55 - 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/arch/x86/i

[RFC 8/8] bitops: prevent compiler inline decision distortion

2018-05-15 Thread Nadav Amit
73 1db505d ./vmlinux before 18149210 10064048 2936832 31150090 1db500a ./vmlinux after (-83) Static text symbols: Before: 39643 After: 39632 (-11) Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org Signed-off-by: Nadav Amit --- arch/x86/include/asm/bito

[RFC 7/8] ilog2: preventing compiler distortion due to big condition

2018-05-15 Thread Nadav Amit
5 10064176 2936832 31150173 1db505d ./vmlinux after (+437) Static text symbols: Before: 39650 After: 39643 (-7) Cc: Randy Dunlap Cc: Jonathan Corbet Signed-off-by: Nadav Amit --- include/linux/log2.h | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linu

[RFC 6/8] x86: removing unneeded new-lines

2018-05-15 Thread Nadav Amit
kernel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 4 ++-- arch/x86/include/asm/cmpxchg.h | 10 +- arch/x86/include/asm/special_insns.h | 12 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/i

[RFC 3/8] x86: alternative: macrofy locks for better inlining

2018-05-15 Thread Nadav Amit
nel.org Cc: Josh Poimboeuf Signed-off-by: Nadav Amit --- arch/x86/include/asm/alternative.h | 28 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 4cd6a3b71824..daa68ad51665 10

Re: [PATCH] compiler-gcc: disable -ftracer for __noclone functions

2018-05-08 Thread Nadav Amit
Paolo Bonzini wrote: > On 05/05/2018 19:22, Nadav Amit wrote: >> Paolo Bonzini wrote: >> >>> -ftracer can duplicate asm blocks causing compilation to fail in >>> noclone functions. For example, KVM declares a global variable >>> in an asm like >>

Re: [PATCH] compiler-gcc: disable -ftracer for __noclone functions

2018-05-05 Thread Nadav Amit
Paolo Bonzini wrote: > -ftracer can duplicate asm blocks causing compilation to fail in > noclone functions. For example, KVM declares a global variable > in an asm like > >asm("2: ... \n > .pushsection data \n > .global vmx_return \n > vmx_return: .long 2b"); > > a

Re: [RFC/RFT] Add noats flag to boot parameters

2018-05-03 Thread Nadav Amit
Sinan Kaya wrote: > +Bjorn, > > On 5/3/2018 9:59 AM, Joerg Roedel wrote: >> On Thu, May 03, 2018 at 09:46:34AM -0400, Sinan Kaya wrote: >>> I also like the idea in general. >>> Minor nit.. >>> >>> Shouldn't this be an iommu parameter rather than a PCI kernel command line >>> parameter? >>> We

Re: Suboptimal inline heuristics due to non-code sections

2018-05-01 Thread Nadav Amit
Linus Torvalds wrote: > On Tue, May 1, 2018 at 9:46 AM Nadav Amit wrote: > >> My bad. It’s not the new-line. Let me do some more digging. > > From the gcc docs: > > Some targets require that GCC track the size of each instruction used > in order to generate

Re: Suboptimal inline heuristics due to non-code sections

2018-05-01 Thread Nadav Amit
Nadav Amit wrote: > Linus Torvalds wrote: > >> On Tue, May 1, 2018 at 6:40 AM Josh Poimboeuf wrote: >> >>> But if I remove the section completely by removing the >>> pushsection/popsection, then copy_overflow() gets inlined. >> >>> So GCC

Re: Suboptimal inline heuristics due to non-code sections

2018-05-01 Thread Nadav Amit
Linus Torvalds wrote: > On Tue, May 1, 2018 at 6:40 AM Josh Poimboeuf wrote: > >> But if I remove the section completely by removing the >> pushsection/popsection, then copy_overflow() gets inlined. > >> So GCC's inlining decisions are somehow influenced by the existence of >> some random empt

Suboptimal inline heuristics due to non-code sections

2018-04-30 Thread Nadav Amit
When gcc considers the size of a function for inlining decisions, it apparently considers *all* sections. Since the kernel extensively uses sections for things other than code (e.g., exception-table, bug-table), the optimality of these decisions seem questionable to me. The objtool’s sections may

Re: [PATCH v3] vmw_balloon: fixing double free when batching mode is off

2018-04-30 Thread Nadav Amit
Ping. Please consider it for inclusion for rc4. Nadav Amit wrote: > From: Gil Kupfer > > The balloon.page field is used for two different purposes if batching is > on or off. If batching is on, the field point to the page which is used > to communicate with with the hyperviso

Re: [PATCH 5/5] x86, pti: filter at vma->vm_page_prot population

2018-04-20 Thread Nadav Amit
Cc: Andy Lutomirski > Cc: Arjan van de Ven > Cc: Borislav Petkov > Cc: Dan Williams > Cc: David Woodhouse > Cc: Greg Kroah-Hartman > Cc: Hugh Dickins > Cc: Josh Poimboeuf > Cc: Juergen Gross > Cc: Kees Cook > Cc: Linus Torvalds > Cc: Nadav Amit > Cc:

[PATCH v3] vmw_balloon: fixing double free when batching mode is off

2018-04-19 Thread Nadav Amit
.org Reported-by: Oleksandr Natalenko Signed-off-by: Gil Kupfer Signed-off-by: Nadav Amit Reviewed-by: Xavier Deguillard --- drivers/misc/vmw_balloon.c | 23 +++ 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw

Re: [PATCH v2] vmw_balloon: fixing double free when batching mode is off

2018-04-18 Thread Nadav Amit
Oleksandr Natalenko wrote: > Hello. > > On Fri, Mar 23, 2018 at 9:42 AM, Oleksandr Natalenko > wrote: >>> Actually, rechecking the bug description, I might have rushed. The bug that >>> I encountered is related to the vunmap() but it is only caused when batching >>> is off, while the bug you re

Re: [PATCH 09/11] x86/pti: enable global pages for shared areas

2018-04-04 Thread Nadav Amit
Dave Hansen wrote: > On 04/03/2018 09:45 PM, Nadav Amit wrote: >> Dave Hansen wrote: >> >>> From: Dave Hansen >>> >>> The entry/exit text and cpu_entry_area are mapped into userspace and >>> the kernel. But, they are not _PAGE_GLOBAL. Th

Re: [PATCH 09/11] x86/pti: enable global pages for shared areas

2018-04-03 Thread Nadav Amit
gned-off-by: Dave Hansen > Cc: Andrea Arcangeli > Cc: Andy Lutomirski > Cc: Linus Torvalds > Cc: Kees Cook > Cc: Hugh Dickins > Cc: Juergen Gross > Cc: x...@kernel.org > Cc: Nadav Amit > --- > > b/arch/x86/mm/cpu_entry_area.c | 10 +- > b/arch/x

Re: [PATCH 05/11] x86/mm: do not auto-massage page protections

2018-03-23 Thread Nadav Amit
Dave Hansen wrote: > On 03/23/2018 12:15 PM, Nadav Amit wrote: >>> A PTE is constructed from a physical address and a pgprotval_t. >>> __PAGE_KERNEL, for instance, is a pgprot_t and must be converted >>> into a pgprotval_t before it can be used to create a PTE

Re: [PATCH 05/11] x86/mm: do not auto-massage page protections

2018-03-23 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > A PTE is constructed from a physical address and a pgprotval_t. > __PAGE_KERNEL, for instance, is a pgprot_t and must be converted > into a pgprotval_t before it can be used to create a PTE. This is > done implicitly within functions like set_pte()

Re: [PATCH 09/11] x86/pti: enable global pages for shared areas

2018-03-23 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > The entry/exit text and cpu_entry_area are mapped into userspace and > the kernel. But, they are not _PAGE_GLOBAL. This creates unnecessary > TLB misses. > > Add the _PAGE_GLOBAL flag for these areas. > > static void __init > diff -puN arch/x86/

Re: [PATCH v2] vmw_balloon: fixing double free when batching mode is off

2018-03-22 Thread Nadav Amit
Oleksandr Natalenko wrote: > Hi. > > On Mon, Mar 19, 2018 at 7:52 PM, Nadav Amit wrote: >>> Oleksandr, if you can confirm that it fixes the bug you encountered, it >>> would be great. >>> >>> Greg, Arnd, on your free time, please let me know

Re: [PATCH v2] vmw_balloon: fixing double free when batching mode is off

2018-03-19 Thread Nadav Amit
Nadav Amit wrote: > Nadav Amit wrote: > >> From: Gil Kupfer >> >> The balloon.page field is used for two different purposes if batching is >> on or off. If batching is on, the field point to the page which is used >> to communicate with with the hy

Re: [PATCH v2] vmw_balloon: fixing double free when batching mode is off

2018-03-13 Thread Nadav Amit
Nadav Amit wrote: > From: Gil Kupfer > > The balloon.page field is used for two different purposes if batching is > on or off. If batching is on, the field point to the page which is used > to communicate with with the hypervisor. If it is off, balloon.page > points to the

[PATCH v2] vmw_balloon: fixing double free when batching mode is off

2018-03-12 Thread Nadav Amit
.org Reported-by: Oleksandr Natalenko Signed-off-by: Gil Kupfer Signed-off-by: Nadav Amit Reviewed-by: Xavier Deguillard --- v2: Fixing commit message drivers/misc/vmw_balloon.c | 23 +++ 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/misc/vmw_bal

[PATCH] vmw_balloon: fixing double free when batching mode is off

2018-03-12 Thread Nadav Amit
63be98 [ 42.325735] ---[ end trace 872e008e33f81508 ]--- To solve the bug, we eliminate the dual purpose of balloon.page. Fixes: 220a80f0c2e7 ("VMware balloon: add batching to the vmw_balloon.") Cc: sta...@vger.kernel.org Reported-by: Oleksandr Natalenko Signed-off-by: Gil Kupfer Sign

Re: [PATCH v3] KVM: X86: Allow userspace to define the microcode version

2018-02-26 Thread Nadav Amit
Wanpeng Li wrote: > 2018-02-27 9:30 GMT+08:00 Nadav Amit : >> Wanpeng Li wrote: >> >>> From: Wanpeng Li >>> >>> Linux (among the others) has checks to make sure that certain features >>> aren't enabled on a certain family/model/ste

Re: [PATCH v3] KVM: X86: Allow userspace to define the microcode version

2018-02-26 Thread Nadav Amit
Wanpeng Li wrote: > From: Wanpeng Li > > Linux (among the others) has checks to make sure that certain features > aren't enabled on a certain family/model/stepping if the microcode version > isn't greater than or equal to a known good version. > > By exposing the real microcode version, we'r

Re: [RFC][PATCH 03/10] x86/mm: introduce "default" kernel PTE mask

2018-02-22 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > The __PAGE_KERNEL_* page permissions are "raw". They contain bits > that may or may not be supported on the current processor. They > need to be filtered by a mask (currently __supported_pte_mask) to > turn them into a value that we can actually s

Re: [RFC][PATCH 05/10] x86/mm: do not auto-massage page protections

2018-02-22 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > > +static inline pgprotval_t check_pgprot(pgprot_t pgprot) > +{ > + pgprotval_t massaged_val = massage_pgprot(pgprot); > + > + WARN_ONCE(pgprot_val(pgprot) != massaged_val, > + "attempted to set unsupported pgprot: %016lx " >

Re: [RFC][PATCH 04/10] x86/espfix: use kernel-default PTE mask

2018-02-22 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > In creating its page tables, the espfix code masks its PGTABLE_PROT > value with the supported mask: __supported_pte_mask. This ensures > that unsupported bits are not set in the final PTE. But, it also > sets _PAGE_GLOBAL which we do not want for

Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode

2018-02-16 Thread Nadav Amit
Dmitry Safonov <0x7f454...@gmail.com> wrote: > 2018-02-16 7:11 GMT+00:00 Cyrill Gorcunov : >> On Thu, Feb 15, 2018 at 11:29:42PM +, Andy Lutomirski wrote: >> ... >> +bool pti_handle_segment_not_present(long error_code) >> +{ >> + if (!static_cpu_has(X86_FEATURE_PTI)) >> +

Re: [PATCH 2/3] x86/mm: introduce __PAGE_KERNEL_GLOBAL

2018-02-16 Thread Nadav Amit
Dave Hansen wrote: > On 02/16/2018 10:25 AM, Nadav Amit wrote: >>> +#ifdef CONFIG_PAGE_TABLE_ISOLATION >>> +#define __PAGE_KERNEL_GLOBAL 0 >>> +#else >>> +#define __PAGE_KERNEL_GLOBAL _PAGE_GLOBAL >>> +#endif >> .

Re: [PATCH 2/3] x86/mm: introduce __PAGE_KERNEL_GLOBAL

2018-02-16 Thread Nadav Amit
Dave Hansen wrote: > On 02/16/2018 09:47 AM, Nadav Amit wrote: >>> But, this also means that we now get *no* opportunity to use >>> global pages with PTI, even for data which is shared such as the >>> cpu_entry_area and entry/exit text. >> >> Doesn’t

Re: [PATCH 2/3] x86/mm: introduce __PAGE_KERNEL_GLOBAL

2018-02-16 Thread Nadav Amit
Dave Hansen wrote: > > From: Dave Hansen > > Kernel mappings are historically _PAGE_GLOBAL. But, with PTI, we do not > want them to be _PAGE_GLOBAL. We currently accomplish this by simply > clearing _PAGE_GLOBAL from the suppotred mask which ensures it is > cleansed from many of our PTE cons

Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode

2018-02-15 Thread Nadav Amit
Andy Lutomirski wrote: > On Fri, Feb 16, 2018 at 12:42 AM, Linus Torvalds > wrote: >> On Thu, Feb 15, 2018 at 4:22 PM, Nadav Amit wrote: >>> It is not too pretty, I agree, but it should do the work. There is only one >>> problematic descriptor that can be used to

Re: [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode

2018-02-15 Thread Nadav Amit
Andrew Cooper wrote: > On 16/02/2018 00:25, Nadav Amit wrote: >> Dave Hansen wrote: >> >>> On 02/15/2018 08:35 AM, Nadav Amit wrote: >>>> I removed the PTI disabling while SMEP is unsupported, although I >>>> must admit I did not fully understa

Re: [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode

2018-02-15 Thread Nadav Amit
Dave Hansen wrote: > On 02/15/2018 04:25 PM, Nadav Amit wrote: >> Dave Hansen wrote: >> >>> On 02/15/2018 08:35 AM, Nadav Amit wrote: >>>> I removed the PTI disabling while SMEP is unsupported, although I >>>> must admit I did not fully underst

Re: [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode

2018-02-15 Thread Nadav Amit
Dave Hansen wrote: > On 02/15/2018 08:35 AM, Nadav Amit wrote: >> I removed the PTI disabling while SMEP is unsupported, although I >> must admit I did not fully understand why it is required. > > Do you mean you don't fully understand how PTI gives SMEP-like behav

Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode

2018-02-15 Thread Nadav Amit
Linus Torvalds wrote: > On Thu, Feb 15, 2018 at 3:29 PM, Andy Lutomirski wrote: >> It's possible we could get away with adding the prctl but making the >> default be that only the bitness that matches the program being run is >> allowed. After all, it's possible that CRIU is literally the only

Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode

2018-02-15 Thread Nadav Amit
Andy Lutomirski wrote: > On Thu, Feb 15, 2018 at 4:36 PM, Nadav Amit wrote: >> Based on the understanding that there should be no way for userspace to >> address the kernel-space from compatibility mode, disable it while >> running in compatibility mode as long as the 64-bi

Re: [PATCH RFC v2 1/6] x86: Skip PTI when disable indication is set

2018-02-15 Thread Nadav Amit
Andy Lutomirski wrote: > On Thu, Feb 15, 2018 at 4:35 PM, Nadav Amit wrote: >> If PTI is disabled, we do not want to switch page-tables. On entry to >> the kernel, this is done based on CR3 value. On return, do it according >> to per core indication. >> >&

<    6   7   8   9   10   11   12   13   14   >