[tip:x86/asm] x86/asm: Modernize sync_bitops.h

2019-04-10 Thread tip-bot for Jan Beulich
Commit-ID:  547571b5abe61bb33c6005d8981e86e3c61fedcc
Gitweb: https://git.kernel.org/tip/547571b5abe61bb33c6005d8981e86e3c61fedcc
Author: Jan Beulich 
AuthorDate: Wed, 27 Mar 2019 09:15:19 -0600
Committer:  Ingo Molnar 
CommitDate: Wed, 10 Apr 2019 09:53:31 +0200

x86/asm: Modernize sync_bitops.h

Add missing instruction suffixes and use rmwcc.h just like was (more or less)
recently done for bitops.h as well, see:

  22636f8c9511: x86/asm: Add instruction suffixes to bitops
  288e4521f0f6: x86/asm: 'Simplify' GEN_*_RMWcc() macros

No change in functionality intended.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5c9b9387027800222...@prv1-mh.provo.novell.com
[ Cleaned up the changelog a bit. ]
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/sync_bitops.h | 31 +--
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/sync_bitops.h 
b/arch/x86/include/asm/sync_bitops.h
index 2fe745356fb1..6d8d6bc183b7 100644
--- a/arch/x86/include/asm/sync_bitops.h
+++ b/arch/x86/include/asm/sync_bitops.h
@@ -14,6 +14,8 @@
  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  */
 
+#include 
+
 #define ADDR (*(volatile long *)addr)
 
 /**
@@ -29,7 +31,7 @@
  */
 static inline void sync_set_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("lock; bts %1,%0"
+   asm volatile("lock; " __ASM_SIZE(bts) " %1,%0"
 : "+m" (ADDR)
 : "Ir" (nr)
 : "memory");
@@ -47,7 +49,7 @@ static inline void sync_set_bit(long nr, volatile unsigned 
long *addr)
  */
 static inline void sync_clear_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("lock; btr %1,%0"
+   asm volatile("lock; " __ASM_SIZE(btr) " %1,%0"
 : "+m" (ADDR)
 : "Ir" (nr)
 : "memory");
@@ -64,7 +66,7 @@ static inline void sync_clear_bit(long nr, volatile unsigned 
long *addr)
  */
 static inline void sync_change_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("lock; btc %1,%0"
+   asm volatile("lock; " __ASM_SIZE(btc) " %1,%0"
 : "+m" (ADDR)
 : "Ir" (nr)
 : "memory");
@@ -78,14 +80,9 @@ static inline void sync_change_bit(long nr, volatile 
unsigned long *addr)
  * This operation is atomic and cannot be reordered.
  * It also implies a memory barrier.
  */
-static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr)
+static inline bool sync_test_and_set_bit(long nr, volatile unsigned long *addr)
 {
-   unsigned char oldbit;
-
-   asm volatile("lock; bts %2,%1\n\tsetc %0"
-: "=qm" (oldbit), "+m" (ADDR)
-: "Ir" (nr) : "memory");
-   return oldbit;
+   return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(bts), *addr, c, "Ir", nr);
 }
 
 /**
@@ -98,12 +95,7 @@ static inline int sync_test_and_set_bit(long nr, volatile 
unsigned long *addr)
  */
 static inline int sync_test_and_clear_bit(long nr, volatile unsigned long 
*addr)
 {
-   unsigned char oldbit;
-
-   asm volatile("lock; btr %2,%1\n\tsetc %0"
-: "=qm" (oldbit), "+m" (ADDR)
-: "Ir" (nr) : "memory");
-   return oldbit;
+   return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(btr), *addr, c, "Ir", nr);
 }
 
 /**
@@ -116,12 +108,7 @@ static inline int sync_test_and_clear_bit(long nr, 
volatile unsigned long *addr)
  */
 static inline int sync_test_and_change_bit(long nr, volatile unsigned long 
*addr)
 {
-   unsigned char oldbit;
-
-   asm volatile("lock; btc %2,%1\n\tsetc %0"
-: "=qm" (oldbit), "+m" (ADDR)
-: "Ir" (nr) : "memory");
-   return oldbit;
+   return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(btc), *addr, c, "Ir", nr);
 }
 
 #define sync_test_bit(nr, addr) test_bit(nr, addr)


[tip:x86/urgent] x86/entry/64/compat: Fix stack switching for XEN PV

2019-01-17 Thread tip-bot for Jan Beulich
Commit-ID:  fc24d75a7f91837d7918e40719575951820b2b8f
Gitweb: https://git.kernel.org/tip/fc24d75a7f91837d7918e40719575951820b2b8f
Author: Jan Beulich 
AuthorDate: Tue, 15 Jan 2019 09:58:16 -0700
Committer:  Thomas Gleixner 
CommitDate: Fri, 18 Jan 2019 00:39:33 +0100

x86/entry/64/compat: Fix stack switching for XEN PV

While in the native case entry into the kernel happens on the trampoline
stack, PV Xen kernels get entered with the current thread stack right
away. Hence source and destination stacks are identical in that case,
and special care is needed.

Other than in sync_regs() the copying done on the INT80 path isn't
NMI / #MC safe, as either of these events occurring in the middle of the
stack copying would clobber data on the (source) stack.

There is similar code in interrupt_entry() and nmi(), but there is no fixup
required because those code paths are unreachable in XEN PV guests.

[ tglx: Sanitized subject, changelog, Fixes tag and stable mail address. Sigh ]

Fixes: 7f2590a110b8 ("x86/entry/64: Use a per-CPU trampoline stack for IDT 
entries")
Signed-off-by: Jan Beulich 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Juergen Gross 
Acked-by: Andy Lutomirski 
Cc: Peter Anvin 
Cc: xen-de...@lists.xenproject.org>
Cc: Boris Ostrovsky 
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/5c3e112802780020d...@prv1-mh.provo.novell.com

---
 arch/x86/entry/entry_64_compat.S | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 8eaf8952c408..39913770a44d 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -361,7 +361,8 @@ ENTRY(entry_INT80_compat)
 
/* Need to switch before accessing the thread stack. */
SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi
-   movq%rsp, %rdi
+   /* In the Xen PV case we already run on the thread stack. */
+   ALTERNATIVE "movq %rsp, %rdi", "jmp .Lint80_keep_stack", 
X86_FEATURE_XENPV
movqPER_CPU_VAR(cpu_current_top_of_stack), %rsp
 
pushq   6*8(%rdi)   /* regs->ss */
@@ -370,8 +371,9 @@ ENTRY(entry_INT80_compat)
pushq   3*8(%rdi)   /* regs->cs */
pushq   2*8(%rdi)   /* regs->ip */
pushq   1*8(%rdi)   /* regs->orig_ax */
-
pushq   (%rdi)  /* pt_regs->di */
+.Lint80_keep_stack:
+
pushq   %rsi/* pt_regs->si */
xorl%esi, %esi  /* nospec   si */
pushq   %rdx/* pt_regs->dx */


[tip:x86/asm] x86/asm/64: Use 32-bit XOR to zero registers

2018-07-03 Thread tip-bot for Jan Beulich
Commit-ID:  a7bea8308933aaeea76dad7d42a6e51000417626
Gitweb: https://git.kernel.org/tip/a7bea8308933aaeea76dad7d42a6e51000417626
Author: Jan Beulich 
AuthorDate: Mon, 2 Jul 2018 04:31:54 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 3 Jul 2018 09:59:29 +0200

x86/asm/64: Use 32-bit XOR to zero registers

Some Intel CPUs don't recognize 64-bit XORs as zeroing idioms. Zeroing
idioms don't require execution bandwidth, as they're being taken care
of in the frontend (through register renaming). Use 32-bit XORs instead.

Signed-off-by: Jan Beulich 
Cc: Alok Kataria 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: da...@davemloft.net
Cc: herb...@gondor.apana.org.au
Cc: pa...@ucw.cz
Cc: r...@rjwysocki.net
Link: http://lkml.kernel.org/r/5b39ff1a0278001cf...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/crypto/aegis128-aesni-asm.S | 2 +-
 arch/x86/crypto/aegis128l-aesni-asm.S| 2 +-
 arch/x86/crypto/aegis256-aesni-asm.S | 2 +-
 arch/x86/crypto/aesni-intel_asm.S| 8 
 arch/x86/crypto/aesni-intel_avx-x86_64.S | 4 ++--
 arch/x86/crypto/morus1280-avx2-asm.S | 2 +-
 arch/x86/crypto/morus1280-sse2-asm.S | 2 +-
 arch/x86/crypto/morus640-sse2-asm.S  | 2 +-
 arch/x86/crypto/sha1_ssse3_asm.S | 2 +-
 arch/x86/kernel/head_64.S| 2 +-
 arch/x86/kernel/paravirt_patch_64.c  | 2 +-
 arch/x86/lib/memcpy_64.S | 2 +-
 arch/x86/power/hibernate_asm_64.S| 2 +-
 13 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/x86/crypto/aegis128-aesni-asm.S 
b/arch/x86/crypto/aegis128-aesni-asm.S
index 9254e0b6cc06..d5c5e2082ae7 100644
--- a/arch/x86/crypto/aegis128-aesni-asm.S
+++ b/arch/x86/crypto/aegis128-aesni-asm.S
@@ -75,7 +75,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG, MSG
 
mov LEN, %r8
diff --git a/arch/x86/crypto/aegis128l-aesni-asm.S 
b/arch/x86/crypto/aegis128l-aesni-asm.S
index 9263c344f2c7..0fbdf5f00bda 100644
--- a/arch/x86/crypto/aegis128l-aesni-asm.S
+++ b/arch/x86/crypto/aegis128l-aesni-asm.S
@@ -66,7 +66,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG0, MSG0
pxor MSG1, MSG1
 
diff --git a/arch/x86/crypto/aegis256-aesni-asm.S 
b/arch/x86/crypto/aegis256-aesni-asm.S
index 1d977d515bf9..a49f58e2a5dd 100644
--- a/arch/x86/crypto/aegis256-aesni-asm.S
+++ b/arch/x86/crypto/aegis256-aesni-asm.S
@@ -59,7 +59,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG, MSG
 
mov LEN, %r8
diff --git a/arch/x86/crypto/aesni-intel_asm.S 
b/arch/x86/crypto/aesni-intel_asm.S
index e762ef417562..9bd139569b41 100644
--- a/arch/x86/crypto/aesni-intel_asm.S
+++ b/arch/x86/crypto/aesni-intel_asm.S
@@ -258,7 +258,7 @@ ALL_F:  .octa 0x
 .macro GCM_INIT Iv SUBKEY AAD AADLEN
mov \AADLEN, %r11
mov %r11, AadLen(%arg2) # ctx_data.aad_length = aad_length
-   xor %r11, %r11
+   xor %r11d, %r11d
mov %r11, InLen(%arg2) # ctx_data.in_length = 0
mov %r11, PBlockLen(%arg2) # ctx_data.partial_block_length = 0
mov %r11, PBlockEncKey(%arg2) # ctx_data.partial_block_enc_key = 0
@@ -286,7 +286,7 @@ ALL_F:  .octa 0x
movdqu HashKey(%arg2), %xmm13
add %arg5, InLen(%arg2)
 
-   xor %r11, %r11 # initialise the data pointer offset as zero
+   xor %r11d, %r11d # initialise the data pointer offset as zero
PARTIAL_BLOCK %arg3 %arg4 %arg5 %r11 %xmm8 \operation
 
sub %r11, %arg5 # sub partial block data used
@@ -702,7 +702,7 @@ _no_extra_mask_1_\@:
 
# GHASH computation for the last <16 Byte block
GHASH_MUL \AAD_HASH, %xmm13, %xmm0, %xmm10, %xmm11, %xmm5, %xmm6
-   xor %rax,%rax
+   xor %eax, %eax
 
mov %rax, PBlockLen(%arg2)
jmp _dec_done_\@
@@ -737,7 +737,7 @@ _no_extra_mask_2_\@:
 
# GHASH computation for the last <16 Byte block
GHASH_MUL \AAD_HASH, %xmm13, %xmm0, %xmm10, %xmm11, %xmm5, %xmm6
-   xor %rax,%rax
+   xor %eax, %eax
 
mov %rax, PBlockLen(%arg2)
jmp _encode_done_\@
diff --git a/arch/x86/crypto/aesni-intel_avx-x86_64.S 
b/arch/x86/crypto/aesni-intel_avx-x86_64.S
index faecb1518bf8..1985ea0b551b 100644
--- a/arch/x86/crypto/aesni-intel_avx-x86_64.S
+++ b/arch/x86/crypto/aesni-intel_avx-x86_64.S
@@ -463,7 +463,7 @@ _get_AAD_rest_final\@:
 
 _get_AAD_done\@:
# initialize the data pointer offset as zero
-   xor %r11, %r11
+   xor %r11d, %r11d
 
# start AES for num_initial_blocks blocks
mov arg5, %rax # rax = *Y0
@@ -1770,7 +1770,7 @@ _get_AAD_rest_final\@:
 
 _get_AAD_done\@:
 

[tip:x86/asm] x86/entry/64: Add two more instruction suffixes

2018-07-03 Thread tip-bot for Jan Beulich
Commit-ID:  6709812f094d96543b443645c68daaa32d3d3e77
Gitweb: https://git.kernel.org/tip/6709812f094d96543b443645c68daaa32d3d3e77
Author: Jan Beulich 
AuthorDate: Mon, 2 Jul 2018 04:47:57 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 3 Jul 2018 09:59:29 +0200

x86/entry/64: Add two more instruction suffixes

Sadly, other than claimed in:

  a368d7fd2a ("x86/entry/64: Add instruction suffix")

... there are two more instances which want to be adjusted.

As said there, omitting suffixes from instructions in AT mode is bad
practice when operand size cannot be determined by the assembler from
register operands, and is likely going to be warned about by upstream
gas in the future (mine does already).

Add the other missing suffixes here as well.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5b3a02dd0278001cf...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_64.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index c6f3677e6105..65aa16d845f6 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -92,7 +92,7 @@ END(native_usergs_sysret64)
 .endm
 
 .macro TRACE_IRQS_IRETQ_DEBUG
-   bt  $9, EFLAGS(%rsp)/* interrupts off? */
+   btl $9, EFLAGS(%rsp)/* interrupts off? */
jnc 1f
TRACE_IRQS_ON_DEBUG
 1:
@@ -702,7 +702,7 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
/* Interrupts are off */
/* Check if we need preemption */
-   bt  $9, EFLAGS(%rsp)/* were interrupts off? */
+   btl $9, EFLAGS(%rsp)/* were interrupts off? */
jnc 1f
 0: cmpl$0, PER_CPU_VAR(__preempt_count)
jnz 1f


[tip:x86/asm] x86/asm/64: Use 32-bit XOR to zero registers

2018-07-03 Thread tip-bot for Jan Beulich
Commit-ID:  a7bea8308933aaeea76dad7d42a6e51000417626
Gitweb: https://git.kernel.org/tip/a7bea8308933aaeea76dad7d42a6e51000417626
Author: Jan Beulich 
AuthorDate: Mon, 2 Jul 2018 04:31:54 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 3 Jul 2018 09:59:29 +0200

x86/asm/64: Use 32-bit XOR to zero registers

Some Intel CPUs don't recognize 64-bit XORs as zeroing idioms. Zeroing
idioms don't require execution bandwidth, as they're being taken care
of in the frontend (through register renaming). Use 32-bit XORs instead.

Signed-off-by: Jan Beulich 
Cc: Alok Kataria 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: da...@davemloft.net
Cc: herb...@gondor.apana.org.au
Cc: pa...@ucw.cz
Cc: r...@rjwysocki.net
Link: http://lkml.kernel.org/r/5b39ff1a0278001cf...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/crypto/aegis128-aesni-asm.S | 2 +-
 arch/x86/crypto/aegis128l-aesni-asm.S| 2 +-
 arch/x86/crypto/aegis256-aesni-asm.S | 2 +-
 arch/x86/crypto/aesni-intel_asm.S| 8 
 arch/x86/crypto/aesni-intel_avx-x86_64.S | 4 ++--
 arch/x86/crypto/morus1280-avx2-asm.S | 2 +-
 arch/x86/crypto/morus1280-sse2-asm.S | 2 +-
 arch/x86/crypto/morus640-sse2-asm.S  | 2 +-
 arch/x86/crypto/sha1_ssse3_asm.S | 2 +-
 arch/x86/kernel/head_64.S| 2 +-
 arch/x86/kernel/paravirt_patch_64.c  | 2 +-
 arch/x86/lib/memcpy_64.S | 2 +-
 arch/x86/power/hibernate_asm_64.S| 2 +-
 13 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/x86/crypto/aegis128-aesni-asm.S 
b/arch/x86/crypto/aegis128-aesni-asm.S
index 9254e0b6cc06..d5c5e2082ae7 100644
--- a/arch/x86/crypto/aegis128-aesni-asm.S
+++ b/arch/x86/crypto/aegis128-aesni-asm.S
@@ -75,7 +75,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG, MSG
 
mov LEN, %r8
diff --git a/arch/x86/crypto/aegis128l-aesni-asm.S 
b/arch/x86/crypto/aegis128l-aesni-asm.S
index 9263c344f2c7..0fbdf5f00bda 100644
--- a/arch/x86/crypto/aegis128l-aesni-asm.S
+++ b/arch/x86/crypto/aegis128l-aesni-asm.S
@@ -66,7 +66,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG0, MSG0
pxor MSG1, MSG1
 
diff --git a/arch/x86/crypto/aegis256-aesni-asm.S 
b/arch/x86/crypto/aegis256-aesni-asm.S
index 1d977d515bf9..a49f58e2a5dd 100644
--- a/arch/x86/crypto/aegis256-aesni-asm.S
+++ b/arch/x86/crypto/aegis256-aesni-asm.S
@@ -59,7 +59,7 @@
  *   %r9
  */
 __load_partial:
-   xor %r9, %r9
+   xor %r9d, %r9d
pxor MSG, MSG
 
mov LEN, %r8
diff --git a/arch/x86/crypto/aesni-intel_asm.S 
b/arch/x86/crypto/aesni-intel_asm.S
index e762ef417562..9bd139569b41 100644
--- a/arch/x86/crypto/aesni-intel_asm.S
+++ b/arch/x86/crypto/aesni-intel_asm.S
@@ -258,7 +258,7 @@ ALL_F:  .octa 0x
 .macro GCM_INIT Iv SUBKEY AAD AADLEN
mov \AADLEN, %r11
mov %r11, AadLen(%arg2) # ctx_data.aad_length = aad_length
-   xor %r11, %r11
+   xor %r11d, %r11d
mov %r11, InLen(%arg2) # ctx_data.in_length = 0
mov %r11, PBlockLen(%arg2) # ctx_data.partial_block_length = 0
mov %r11, PBlockEncKey(%arg2) # ctx_data.partial_block_enc_key = 0
@@ -286,7 +286,7 @@ ALL_F:  .octa 0x
movdqu HashKey(%arg2), %xmm13
add %arg5, InLen(%arg2)
 
-   xor %r11, %r11 # initialise the data pointer offset as zero
+   xor %r11d, %r11d # initialise the data pointer offset as zero
PARTIAL_BLOCK %arg3 %arg4 %arg5 %r11 %xmm8 \operation
 
sub %r11, %arg5 # sub partial block data used
@@ -702,7 +702,7 @@ _no_extra_mask_1_\@:
 
# GHASH computation for the last <16 Byte block
GHASH_MUL \AAD_HASH, %xmm13, %xmm0, %xmm10, %xmm11, %xmm5, %xmm6
-   xor %rax,%rax
+   xor %eax, %eax
 
mov %rax, PBlockLen(%arg2)
jmp _dec_done_\@
@@ -737,7 +737,7 @@ _no_extra_mask_2_\@:
 
# GHASH computation for the last <16 Byte block
GHASH_MUL \AAD_HASH, %xmm13, %xmm0, %xmm10, %xmm11, %xmm5, %xmm6
-   xor %rax,%rax
+   xor %eax, %eax
 
mov %rax, PBlockLen(%arg2)
jmp _encode_done_\@
diff --git a/arch/x86/crypto/aesni-intel_avx-x86_64.S 
b/arch/x86/crypto/aesni-intel_avx-x86_64.S
index faecb1518bf8..1985ea0b551b 100644
--- a/arch/x86/crypto/aesni-intel_avx-x86_64.S
+++ b/arch/x86/crypto/aesni-intel_avx-x86_64.S
@@ -463,7 +463,7 @@ _get_AAD_rest_final\@:
 
 _get_AAD_done\@:
# initialize the data pointer offset as zero
-   xor %r11, %r11
+   xor %r11d, %r11d
 
# start AES for num_initial_blocks blocks
mov arg5, %rax # rax = *Y0
@@ -1770,7 +1770,7 @@ _get_AAD_rest_final\@:
 
 _get_AAD_done\@:
 

[tip:x86/asm] x86/entry/64: Add two more instruction suffixes

2018-07-03 Thread tip-bot for Jan Beulich
Commit-ID:  6709812f094d96543b443645c68daaa32d3d3e77
Gitweb: https://git.kernel.org/tip/6709812f094d96543b443645c68daaa32d3d3e77
Author: Jan Beulich 
AuthorDate: Mon, 2 Jul 2018 04:47:57 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 3 Jul 2018 09:59:29 +0200

x86/entry/64: Add two more instruction suffixes

Sadly, other than claimed in:

  a368d7fd2a ("x86/entry/64: Add instruction suffix")

... there are two more instances which want to be adjusted.

As said there, omitting suffixes from instructions in AT mode is bad
practice when operand size cannot be determined by the assembler from
register operands, and is likely going to be warned about by upstream
gas in the future (mine does already).

Add the other missing suffixes here as well.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5b3a02dd0278001cf...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_64.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index c6f3677e6105..65aa16d845f6 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -92,7 +92,7 @@ END(native_usergs_sysret64)
 .endm
 
 .macro TRACE_IRQS_IRETQ_DEBUG
-   bt  $9, EFLAGS(%rsp)/* interrupts off? */
+   btl $9, EFLAGS(%rsp)/* interrupts off? */
jnc 1f
TRACE_IRQS_ON_DEBUG
 1:
@@ -702,7 +702,7 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
/* Interrupts are off */
/* Check if we need preemption */
-   bt  $9, EFLAGS(%rsp)/* were interrupts off? */
+   btl $9, EFLAGS(%rsp)/* were interrupts off? */
jnc 1f
 0: cmpl$0, PER_CPU_VAR(__preempt_count)
jnz 1f


[tip:x86/urgent] x86/entry/32: Add explicit 'l' instruction suffix

2018-06-26 Thread tip-bot for Jan Beulich
Commit-ID:  236f0cd286b67291796362feeac4f342900cfa82
Gitweb: https://git.kernel.org/tip/236f0cd286b67291796362feeac4f342900cfa82
Author: Jan Beulich 
AuthorDate: Mon, 25 Jun 2018 04:21:59 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 26 Jun 2018 09:20:31 +0200

x86/entry/32: Add explicit 'l' instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream GAS in the
future (mine does already).

Add the single missing 'l' suffix here.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Andy Lutomirski 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5b30c2470278001cd...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 2582881d19ce..c371bfee137a 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -477,7 +477,7 @@ ENTRY(entry_SYSENTER_32)
 * whereas POPF does not.)
 */
addl$PT_EFLAGS-PT_DS, %esp  /* point esp at pt_regs->flags */
-   btr $X86_EFLAGS_IF_BIT, (%esp)
+   btrl$X86_EFLAGS_IF_BIT, (%esp)
popfl
 
/*


[tip:x86/urgent] x86/entry/32: Add explicit 'l' instruction suffix

2018-06-26 Thread tip-bot for Jan Beulich
Commit-ID:  236f0cd286b67291796362feeac4f342900cfa82
Gitweb: https://git.kernel.org/tip/236f0cd286b67291796362feeac4f342900cfa82
Author: Jan Beulich 
AuthorDate: Mon, 25 Jun 2018 04:21:59 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 26 Jun 2018 09:20:31 +0200

x86/entry/32: Add explicit 'l' instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream GAS in the
future (mine does already).

Add the single missing 'l' suffix here.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Andy Lutomirski 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5b30c2470278001cd...@prv1-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 2582881d19ce..c371bfee137a 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -477,7 +477,7 @@ ENTRY(entry_SYSENTER_32)
 * whereas POPF does not.)
 */
addl$PT_EFLAGS-PT_DS, %esp  /* point esp at pt_regs->flags */
-   btr $X86_EFLAGS_IF_BIT, (%esp)
+   btrl$X86_EFLAGS_IF_BIT, (%esp)
popfl
 
/*


[tip:x86/urgent] x86/asm: Add instruction suffixes to bitops

2018-02-28 Thread tip-bot for Jan Beulich
Commit-ID:  22636f8c9511245cb3c8412039f1dd95afb3aa59
Gitweb: https://git.kernel.org/tip/22636f8c9511245cb3c8412039f1dd95afb3aa59
Author: Jan Beulich 
AuthorDate: Mon, 26 Feb 2018 04:11:51 -0700
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:18:41 +0100

x86/asm: Add instruction suffixes to bitops

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream gas in the
future (mine does already). Add the missing suffixes here. Note that for
64-bit this means some operations change from being 32-bit to 64-bit.

Signed-off-by: Jan Beulich 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/5a93f9870278001ab...@prv-mh.provo.novell.com

---
 arch/x86/include/asm/bitops.h | 29 -
 arch/x86/include/asm/percpu.h |  2 +-
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 3fa039855b8f..9f645ba57dbb 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -78,7 +78,7 @@ set_bit(long nr, volatile unsigned long *addr)
: "iq" ((u8)CONST_MASK(nr))
: "memory");
} else {
-   asm volatile(LOCK_PREFIX "bts %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
: BITOP_ADDR(addr) : "Ir" (nr) : "memory");
}
 }
@@ -94,7 +94,7 @@ set_bit(long nr, volatile unsigned long *addr)
  */
 static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("bts %1,%0" : ADDR : "Ir" (nr) : "memory");
+   asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory");
 }
 
 /**
@@ -115,7 +115,7 @@ clear_bit(long nr, volatile unsigned long *addr)
: CONST_MASK_ADDR(nr, addr)
: "iq" ((u8)~CONST_MASK(nr)));
} else {
-   asm volatile(LOCK_PREFIX "btr %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
: BITOP_ADDR(addr)
: "Ir" (nr));
}
@@ -137,7 +137,7 @@ static __always_inline void clear_bit_unlock(long nr, 
volatile unsigned long *ad
 
 static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("btr %1,%0" : ADDR : "Ir" (nr));
+   asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr));
 }
 
 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, 
volatile unsigned long *addr)
@@ -182,7 +182,7 @@ static __always_inline void __clear_bit_unlock(long nr, 
volatile unsigned long *
  */
 static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("btc %1,%0" : ADDR : "Ir" (nr));
+   asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr));
 }
 
 /**
@@ -201,7 +201,7 @@ static __always_inline void change_bit(long nr, volatile 
unsigned long *addr)
: CONST_MASK_ADDR(nr, addr)
: "iq" ((u8)CONST_MASK(nr)));
} else {
-   asm volatile(LOCK_PREFIX "btc %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
: BITOP_ADDR(addr)
: "Ir" (nr));
}
@@ -217,7 +217,8 @@ static __always_inline void change_bit(long nr, volatile 
unsigned long *addr)
  */
 static __always_inline bool test_and_set_bit(long nr, volatile unsigned long 
*addr)
 {
-   GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", c);
+   GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(bts),
+*addr, "Ir", nr, "%0", c);
 }
 
 /**
@@ -246,7 +247,7 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
 {
bool oldbit;
 
-   asm("bts %2,%1"
+   asm(__ASM_SIZE(bts) " %2,%1"
CC_SET(c)
: CC_OUT(c) (oldbit), ADDR
: "Ir" (nr));
@@ -263,7 +264,8 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
  */
 static __always_inline bool test_and_clear_bit(long nr, volatile unsigned long 
*addr)
 {
-   GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", c);
+   GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(btr),
+*addr, "Ir", nr, "%0", c);
 }
 
 /**
@@ -286,7 +288,7 @@ static __always_inline bool __test_and_clear_bit(long nr, 
volatile unsigned long
 {
bool oldbit;
 
-   asm volatile("btr %2,%1"
+   asm volatile(__ASM_SIZE(btr) " %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr));
@@ -298,7 +300,7 @@ static __always_inline bool __test_and_change_bit(long nr, 
volatile unsigned lon
 {
bool oldbit;
 
-   asm 

[tip:x86/urgent] x86/asm: Add instruction suffixes to bitops

2018-02-28 Thread tip-bot for Jan Beulich
Commit-ID:  22636f8c9511245cb3c8412039f1dd95afb3aa59
Gitweb: https://git.kernel.org/tip/22636f8c9511245cb3c8412039f1dd95afb3aa59
Author: Jan Beulich 
AuthorDate: Mon, 26 Feb 2018 04:11:51 -0700
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:18:41 +0100

x86/asm: Add instruction suffixes to bitops

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream gas in the
future (mine does already). Add the missing suffixes here. Note that for
64-bit this means some operations change from being 32-bit to 64-bit.

Signed-off-by: Jan Beulich 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/5a93f9870278001ab...@prv-mh.provo.novell.com

---
 arch/x86/include/asm/bitops.h | 29 -
 arch/x86/include/asm/percpu.h |  2 +-
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 3fa039855b8f..9f645ba57dbb 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -78,7 +78,7 @@ set_bit(long nr, volatile unsigned long *addr)
: "iq" ((u8)CONST_MASK(nr))
: "memory");
} else {
-   asm volatile(LOCK_PREFIX "bts %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
: BITOP_ADDR(addr) : "Ir" (nr) : "memory");
}
 }
@@ -94,7 +94,7 @@ set_bit(long nr, volatile unsigned long *addr)
  */
 static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("bts %1,%0" : ADDR : "Ir" (nr) : "memory");
+   asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory");
 }
 
 /**
@@ -115,7 +115,7 @@ clear_bit(long nr, volatile unsigned long *addr)
: CONST_MASK_ADDR(nr, addr)
: "iq" ((u8)~CONST_MASK(nr)));
} else {
-   asm volatile(LOCK_PREFIX "btr %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
: BITOP_ADDR(addr)
: "Ir" (nr));
}
@@ -137,7 +137,7 @@ static __always_inline void clear_bit_unlock(long nr, 
volatile unsigned long *ad
 
 static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("btr %1,%0" : ADDR : "Ir" (nr));
+   asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr));
 }
 
 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, 
volatile unsigned long *addr)
@@ -182,7 +182,7 @@ static __always_inline void __clear_bit_unlock(long nr, 
volatile unsigned long *
  */
 static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
 {
-   asm volatile("btc %1,%0" : ADDR : "Ir" (nr));
+   asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr));
 }
 
 /**
@@ -201,7 +201,7 @@ static __always_inline void change_bit(long nr, volatile 
unsigned long *addr)
: CONST_MASK_ADDR(nr, addr)
: "iq" ((u8)CONST_MASK(nr)));
} else {
-   asm volatile(LOCK_PREFIX "btc %1,%0"
+   asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
: BITOP_ADDR(addr)
: "Ir" (nr));
}
@@ -217,7 +217,8 @@ static __always_inline void change_bit(long nr, volatile 
unsigned long *addr)
  */
 static __always_inline bool test_and_set_bit(long nr, volatile unsigned long 
*addr)
 {
-   GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", c);
+   GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(bts),
+*addr, "Ir", nr, "%0", c);
 }
 
 /**
@@ -246,7 +247,7 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
 {
bool oldbit;
 
-   asm("bts %2,%1"
+   asm(__ASM_SIZE(bts) " %2,%1"
CC_SET(c)
: CC_OUT(c) (oldbit), ADDR
: "Ir" (nr));
@@ -263,7 +264,8 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
  */
 static __always_inline bool test_and_clear_bit(long nr, volatile unsigned long 
*addr)
 {
-   GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", c);
+   GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(btr),
+*addr, "Ir", nr, "%0", c);
 }
 
 /**
@@ -286,7 +288,7 @@ static __always_inline bool __test_and_clear_bit(long nr, 
volatile unsigned long
 {
bool oldbit;
 
-   asm volatile("btr %2,%1"
+   asm volatile(__ASM_SIZE(btr) " %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr));
@@ -298,7 +300,7 @@ static __always_inline bool __test_and_change_bit(long nr, 
volatile unsigned lon
 {
bool oldbit;
 
-   asm volatile("btc %2,%1"
+   asm volatile(__ASM_SIZE(btc) " %2,%1"
 

[tip:x86/urgent] x86/entry/64: Add instruction suffix

2018-02-28 Thread tip-bot for Jan Beulich
Commit-ID:  a368d7fd2a3c6babb852fe974018dd97916bcd3b
Gitweb: https://git.kernel.org/tip/a368d7fd2a3c6babb852fe974018dd97916bcd3b
Author: Jan Beulich 
AuthorDate: Mon, 26 Feb 2018 04:11:21 -0700
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:18:40 +0100

x86/entry/64: Add instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream gas in the
future (mine does already). Add the single missing suffix here.

Signed-off-by: Jan Beulich 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/5a93f9690278001ab...@prv-mh.provo.novell.com

---
 arch/x86/entry/entry_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d5c7f18f79ac..805f52703ee3 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -55,7 +55,7 @@ END(native_usergs_sysret64)
 
 .macro TRACE_IRQS_FLAGS flags:req
 #ifdef CONFIG_TRACE_IRQFLAGS
-   bt  $9, \flags  /* interrupts off? */
+   btl $9, \flags  /* interrupts off? */
jnc 1f
TRACE_IRQS_ON
 1:


[tip:x86/urgent] x86/entry/64: Add instruction suffix

2018-02-28 Thread tip-bot for Jan Beulich
Commit-ID:  a368d7fd2a3c6babb852fe974018dd97916bcd3b
Gitweb: https://git.kernel.org/tip/a368d7fd2a3c6babb852fe974018dd97916bcd3b
Author: Jan Beulich 
AuthorDate: Mon, 26 Feb 2018 04:11:21 -0700
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:18:40 +0100

x86/entry/64: Add instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream gas in the
future (mine does already). Add the single missing suffix here.

Signed-off-by: Jan Beulich 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/5a93f9690278001ab...@prv-mh.provo.novell.com

---
 arch/x86/entry/entry_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d5c7f18f79ac..805f52703ee3 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -55,7 +55,7 @@ END(native_usergs_sysret64)
 
 .macro TRACE_IRQS_FLAGS flags:req
 #ifdef CONFIG_TRACE_IRQFLAGS
-   bt  $9, \flags  /* interrupts off? */
+   btl $9, \flags  /* interrupts off? */
jnc 1f
TRACE_IRQS_ON
 1:


[tip:x86/mm] x86/mm: Consider effective protection attributes in W+X check

2018-02-26 Thread tip-bot for Jan Beulich
Commit-ID:  672c0ae09b33a11d8f31fc61526632e96301164c
Gitweb: https://git.kernel.org/tip/672c0ae09b33a11d8f31fc61526632e96301164c
Author: Jan Beulich 
AuthorDate: Fri, 23 Feb 2018 01:27:37 -0700
Committer:  Ingo Molnar 
CommitDate: Mon, 26 Feb 2018 08:43:21 +0100

x86/mm: Consider effective protection attributes in W+X check

Using just the leaf page table entry flags would cause a false warning
in case _PAGE_RW is clear or _PAGE_NX is set in a higher level entry.
Hand through both the current entry's flags as well as the accumulated
effective value (the latter as pgprotval_t instead of pgprot_t, as it's
not an actual entry's value).

This in particular eliminates the false W+X warning when running under
Xen, as commit:

  2cc42bac1c ("x86-64/Xen: eliminate W+X mappings")

had to make the necessary adjustment in L2 rather than L1 (the reason is
explained there). I.e. _PAGE_RW is clear there in L1, but _PAGE_NX is
set in L2.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: Alexander Potapenko 
Cc: Andrey Ryabinin 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: Dmitry Vyukov 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5a8fde890278001aa...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/dump_pagetables.c | 94 ++-
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 0d6d67d18ad6..62a7e9f65dec 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -29,6 +29,7 @@
 struct pg_state {
int level;
pgprot_t current_prot;
+   pgprotval_t effective_prot;
unsigned long start_address;
unsigned long current_address;
const struct addr_marker *marker;
@@ -235,9 +236,9 @@ static unsigned long normalize_addr(unsigned long u)
  * print what we collected so far.
  */
 static void note_page(struct seq_file *m, struct pg_state *st,
- pgprot_t new_prot, int level)
+ pgprot_t new_prot, pgprotval_t new_eff, int level)
 {
-   pgprotval_t prot, cur;
+   pgprotval_t prot, cur, eff;
static const char units[] = "BKMGTPE";
 
/*
@@ -247,23 +248,24 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 */
prot = pgprot_val(new_prot);
cur = pgprot_val(st->current_prot);
+   eff = st->effective_prot;
 
if (!st->level) {
/* First entry */
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
st->marker = address_markers;
st->lines = 0;
pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",
   st->marker->name);
-   } else if (prot != cur || level != st->level ||
+   } else if (prot != cur || new_eff != eff || level != st->level ||
   st->current_address >= st->marker[1].start_address) {
const char *unit = units;
unsigned long delta;
int width = sizeof(unsigned long) * 2;
-   pgprotval_t pr = pgprot_val(st->current_prot);
 
-   if (st->check_wx && (pr & _PAGE_RW) && !(pr & _PAGE_NX)) {
+   if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX)) {
WARN_ONCE(1,
  "x86/mm: Found insecure W+X mapping at 
address %p/%pS\n",
  (void *)st->start_address,
@@ -317,21 +319,30 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 
st->start_address = st->current_address;
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
}
 }
 
-static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t 
addr, unsigned long P)
+static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2)
+{
+   return (prot1 & prot2 & (_PAGE_USER | _PAGE_RW)) |
+  ((prot1 | prot2) & _PAGE_NX);
+}
+
+static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
+  pgprotval_t eff_in, unsigned long P)
 {
int i;
pte_t *start;
-   pgprotval_t prot;
+   pgprotval_t prot, eff;
 
start = (pte_t *)pmd_page_vaddr(addr);
for (i = 0; i < PTRS_PER_PTE; i++) {

[tip:x86/mm] x86/mm: Consider effective protection attributes in W+X check

2018-02-26 Thread tip-bot for Jan Beulich
Commit-ID:  672c0ae09b33a11d8f31fc61526632e96301164c
Gitweb: https://git.kernel.org/tip/672c0ae09b33a11d8f31fc61526632e96301164c
Author: Jan Beulich 
AuthorDate: Fri, 23 Feb 2018 01:27:37 -0700
Committer:  Ingo Molnar 
CommitDate: Mon, 26 Feb 2018 08:43:21 +0100

x86/mm: Consider effective protection attributes in W+X check

Using just the leaf page table entry flags would cause a false warning
in case _PAGE_RW is clear or _PAGE_NX is set in a higher level entry.
Hand through both the current entry's flags as well as the accumulated
effective value (the latter as pgprotval_t instead of pgprot_t, as it's
not an actual entry's value).

This in particular eliminates the false W+X warning when running under
Xen, as commit:

  2cc42bac1c ("x86-64/Xen: eliminate W+X mappings")

had to make the necessary adjustment in L2 rather than L1 (the reason is
explained there). I.e. _PAGE_RW is clear there in L1, but _PAGE_NX is
set in L2.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: Alexander Potapenko 
Cc: Andrey Ryabinin 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: Dmitry Vyukov 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5a8fde890278001aa...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/dump_pagetables.c | 94 ++-
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 0d6d67d18ad6..62a7e9f65dec 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -29,6 +29,7 @@
 struct pg_state {
int level;
pgprot_t current_prot;
+   pgprotval_t effective_prot;
unsigned long start_address;
unsigned long current_address;
const struct addr_marker *marker;
@@ -235,9 +236,9 @@ static unsigned long normalize_addr(unsigned long u)
  * print what we collected so far.
  */
 static void note_page(struct seq_file *m, struct pg_state *st,
- pgprot_t new_prot, int level)
+ pgprot_t new_prot, pgprotval_t new_eff, int level)
 {
-   pgprotval_t prot, cur;
+   pgprotval_t prot, cur, eff;
static const char units[] = "BKMGTPE";
 
/*
@@ -247,23 +248,24 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 */
prot = pgprot_val(new_prot);
cur = pgprot_val(st->current_prot);
+   eff = st->effective_prot;
 
if (!st->level) {
/* First entry */
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
st->marker = address_markers;
st->lines = 0;
pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",
   st->marker->name);
-   } else if (prot != cur || level != st->level ||
+   } else if (prot != cur || new_eff != eff || level != st->level ||
   st->current_address >= st->marker[1].start_address) {
const char *unit = units;
unsigned long delta;
int width = sizeof(unsigned long) * 2;
-   pgprotval_t pr = pgprot_val(st->current_prot);
 
-   if (st->check_wx && (pr & _PAGE_RW) && !(pr & _PAGE_NX)) {
+   if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX)) {
WARN_ONCE(1,
  "x86/mm: Found insecure W+X mapping at 
address %p/%pS\n",
  (void *)st->start_address,
@@ -317,21 +319,30 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 
st->start_address = st->current_address;
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
}
 }
 
-static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t 
addr, unsigned long P)
+static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2)
+{
+   return (prot1 & prot2 & (_PAGE_USER | _PAGE_RW)) |
+  ((prot1 | prot2) & _PAGE_NX);
+}
+
+static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
+  pgprotval_t eff_in, unsigned long P)
 {
int i;
pte_t *start;
-   pgprotval_t prot;
+   pgprotval_t prot, eff;
 
start = (pte_t *)pmd_page_vaddr(addr);
for (i = 0; i < PTRS_PER_PTE; i++) {
prot = pte_flags(*start);
+   eff = effective_prot(eff_in, prot);
st->current_address = normalize_addr(P + i * PTE_LEVEL_MULT);
-   note_page(m, st, __pgprot(prot), 5);
+   note_page(m, st, __pgprot(prot), eff, 5);
start++;
}
 }
@@ -351,7 +362,7 @@ static inline bool 

[tip:x86/mm] x86/mm: Consider effective protection attributes in W+X check

2018-02-23 Thread tip-bot for Jan Beulich
Commit-ID:  6e558c9d10146ebe7f04917af2f8533b811f9c25
Gitweb: https://git.kernel.org/tip/6e558c9d10146ebe7f04917af2f8533b811f9c25
Author: Jan Beulich 
AuthorDate: Fri, 23 Feb 2018 01:27:37 -0700
Committer:  Ingo Molnar 
CommitDate: Fri, 23 Feb 2018 09:51:38 +0100

x86/mm: Consider effective protection attributes in W+X check

Using just the leaf page table entry flags would cause a false warning
in case _PAGE_RW is clear or _PAGE_NX is set in a higher level entry.
Hand through both the current entry's flags as well as the accumulated
effective value (the latter as pgprotval_t instead of pgprot_t, as it's
not an actual entry's value).

This in particular eliminates the false W+X warning when running under
Xen, as commit:

  2cc42bac1c ("x86-64/Xen: eliminate W+X mappings")

had to make the necessary adjustment in L2 rather than L1 (the reason is
explained there). I.e. _PAGE_RW is clear there in L1, but _PAGE_NX is
set in L2.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: Alexander Potapenko 
Cc: Andrey Ryabinin 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: Dmitry Vyukov 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5a8fde890278001aa...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/dump_pagetables.c | 94 ++-
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 0d6d67d18ad6..62a7e9f65dec 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -29,6 +29,7 @@
 struct pg_state {
int level;
pgprot_t current_prot;
+   pgprotval_t effective_prot;
unsigned long start_address;
unsigned long current_address;
const struct addr_marker *marker;
@@ -235,9 +236,9 @@ static unsigned long normalize_addr(unsigned long u)
  * print what we collected so far.
  */
 static void note_page(struct seq_file *m, struct pg_state *st,
- pgprot_t new_prot, int level)
+ pgprot_t new_prot, pgprotval_t new_eff, int level)
 {
-   pgprotval_t prot, cur;
+   pgprotval_t prot, cur, eff;
static const char units[] = "BKMGTPE";
 
/*
@@ -247,23 +248,24 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 */
prot = pgprot_val(new_prot);
cur = pgprot_val(st->current_prot);
+   eff = st->effective_prot;
 
if (!st->level) {
/* First entry */
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
st->marker = address_markers;
st->lines = 0;
pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",
   st->marker->name);
-   } else if (prot != cur || level != st->level ||
+   } else if (prot != cur || new_eff != eff || level != st->level ||
   st->current_address >= st->marker[1].start_address) {
const char *unit = units;
unsigned long delta;
int width = sizeof(unsigned long) * 2;
-   pgprotval_t pr = pgprot_val(st->current_prot);
 
-   if (st->check_wx && (pr & _PAGE_RW) && !(pr & _PAGE_NX)) {
+   if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX)) {
WARN_ONCE(1,
  "x86/mm: Found insecure W+X mapping at 
address %p/%pS\n",
  (void *)st->start_address,
@@ -317,21 +319,30 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 
st->start_address = st->current_address;
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
}
 }
 
-static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t 
addr, unsigned long P)
+static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2)
+{
+   return (prot1 & prot2 & (_PAGE_USER | _PAGE_RW)) |
+  ((prot1 | prot2) & _PAGE_NX);
+}
+
+static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
+  pgprotval_t eff_in, unsigned long P)
 {
int i;
pte_t *start;
-   pgprotval_t prot;
+   pgprotval_t prot, eff;
 
start = (pte_t *)pmd_page_vaddr(addr);
for (i = 0; i < PTRS_PER_PTE; i++) {

[tip:x86/mm] x86/mm: Consider effective protection attributes in W+X check

2018-02-23 Thread tip-bot for Jan Beulich
Commit-ID:  6e558c9d10146ebe7f04917af2f8533b811f9c25
Gitweb: https://git.kernel.org/tip/6e558c9d10146ebe7f04917af2f8533b811f9c25
Author: Jan Beulich 
AuthorDate: Fri, 23 Feb 2018 01:27:37 -0700
Committer:  Ingo Molnar 
CommitDate: Fri, 23 Feb 2018 09:51:38 +0100

x86/mm: Consider effective protection attributes in W+X check

Using just the leaf page table entry flags would cause a false warning
in case _PAGE_RW is clear or _PAGE_NX is set in a higher level entry.
Hand through both the current entry's flags as well as the accumulated
effective value (the latter as pgprotval_t instead of pgprot_t, as it's
not an actual entry's value).

This in particular eliminates the false W+X warning when running under
Xen, as commit:

  2cc42bac1c ("x86-64/Xen: eliminate W+X mappings")

had to make the necessary adjustment in L2 rather than L1 (the reason is
explained there). I.e. _PAGE_RW is clear there in L1, but _PAGE_NX is
set in L2.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: Alexander Potapenko 
Cc: Andrey Ryabinin 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: Dmitry Vyukov 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5a8fde890278001aa...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/dump_pagetables.c | 94 ++-
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 0d6d67d18ad6..62a7e9f65dec 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -29,6 +29,7 @@
 struct pg_state {
int level;
pgprot_t current_prot;
+   pgprotval_t effective_prot;
unsigned long start_address;
unsigned long current_address;
const struct addr_marker *marker;
@@ -235,9 +236,9 @@ static unsigned long normalize_addr(unsigned long u)
  * print what we collected so far.
  */
 static void note_page(struct seq_file *m, struct pg_state *st,
- pgprot_t new_prot, int level)
+ pgprot_t new_prot, pgprotval_t new_eff, int level)
 {
-   pgprotval_t prot, cur;
+   pgprotval_t prot, cur, eff;
static const char units[] = "BKMGTPE";
 
/*
@@ -247,23 +248,24 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 */
prot = pgprot_val(new_prot);
cur = pgprot_val(st->current_prot);
+   eff = st->effective_prot;
 
if (!st->level) {
/* First entry */
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
st->marker = address_markers;
st->lines = 0;
pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",
   st->marker->name);
-   } else if (prot != cur || level != st->level ||
+   } else if (prot != cur || new_eff != eff || level != st->level ||
   st->current_address >= st->marker[1].start_address) {
const char *unit = units;
unsigned long delta;
int width = sizeof(unsigned long) * 2;
-   pgprotval_t pr = pgprot_val(st->current_prot);
 
-   if (st->check_wx && (pr & _PAGE_RW) && !(pr & _PAGE_NX)) {
+   if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX)) {
WARN_ONCE(1,
  "x86/mm: Found insecure W+X mapping at 
address %p/%pS\n",
  (void *)st->start_address,
@@ -317,21 +319,30 @@ static void note_page(struct seq_file *m, struct pg_state 
*st,
 
st->start_address = st->current_address;
st->current_prot = new_prot;
+   st->effective_prot = new_eff;
st->level = level;
}
 }
 
-static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t 
addr, unsigned long P)
+static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2)
+{
+   return (prot1 & prot2 & (_PAGE_USER | _PAGE_RW)) |
+  ((prot1 | prot2) & _PAGE_NX);
+}
+
+static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
+  pgprotval_t eff_in, unsigned long P)
 {
int i;
pte_t *start;
-   pgprotval_t prot;
+   pgprotval_t prot, eff;
 
start = (pte_t *)pmd_page_vaddr(addr);
for (i = 0; i < PTRS_PER_PTE; i++) {
prot = pte_flags(*start);
+   eff = effective_prot(eff_in, prot);
st->current_address = normalize_addr(P + i * PTE_LEVEL_MULT);
-   note_page(m, st, __pgprot(prot), 5);
+   note_page(m, st, __pgprot(prot), eff, 5);
start++;
}
 }
@@ -351,7 +362,7 @@ static inline bool 

[tip:x86/pti] x86/LDT: Avoid warning in 32-bit builds with older gcc

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  f2f18b16c779978ece4a04f304a92ff9ac8fbce5
Gitweb: https://git.kernel.org/tip/f2f18b16c779978ece4a04f304a92ff9ac8fbce5
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:52:10 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:40 +0100

x86/LDT: Avoid warning in 32-bit builds with older gcc

BUG() doesn't always imply "no return", and hence should be followed by
a return statement even if that's obviously (to a human) unreachable.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af2aa0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/mmu_context.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/mmu_context.h 
b/arch/x86/include/asm/mmu_context.h
index c931b88..1de72ce 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -74,6 +74,7 @@ static inline void *ldt_slot_va(int slot)
return (void *)(LDT_BASE_ADDR + LDT_SLOT_STRIDE * slot);
 #else
BUG();
+   return (void *)fix_to_virt(FIX_HOLE);
 #endif
 }
 


[tip:x86/pti] x86/LDT: Avoid warning in 32-bit builds with older gcc

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  f2f18b16c779978ece4a04f304a92ff9ac8fbce5
Gitweb: https://git.kernel.org/tip/f2f18b16c779978ece4a04f304a92ff9ac8fbce5
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:52:10 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:40 +0100

x86/LDT: Avoid warning in 32-bit builds with older gcc

BUG() doesn't always imply "no return", and hence should be followed by
a return statement even if that's obviously (to a human) unreachable.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af2aa0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/mmu_context.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/mmu_context.h 
b/arch/x86/include/asm/mmu_context.h
index c931b88..1de72ce 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -74,6 +74,7 @@ static inline void *ldt_slot_va(int slot)
return (void *)(LDT_BASE_ADDR + LDT_SLOT_STRIDE * slot);
 #else
BUG();
+   return (void *)fix_to_virt(FIX_HOLE);
 #endif
 }
 


[tip:x86/pti] x86-64/realmode: Add instruction suffix

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  8554004a0231dedf44d4d62147fb3d6a6db489aa
Gitweb: https://git.kernel.org/tip/8554004a0231dedf44d4d62147fb3d6a6db489aa
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 08:06:14 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:41 +0100

x86-64/realmode: Add instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream GAS in the
future (mine does already). Add the single missing suffix here.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af5f60278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/realmode/rm/trampoline_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/realmode/rm/trampoline_64.S 
b/arch/x86/realmode/rm/trampoline_64.S
index de53bd1..24bb759 100644
--- a/arch/x86/realmode/rm/trampoline_64.S
+++ b/arch/x86/realmode/rm/trampoline_64.S
@@ -102,7 +102,7 @@ ENTRY(startup_32)
 * don't we'll eventually crash trying to execute encrypted
 * instructions.
 */
-   bt  $TH_FLAGS_SME_ACTIVE_BIT, pa_tr_flags
+   btl $TH_FLAGS_SME_ACTIVE_BIT, pa_tr_flags
jnc .Ldone
movl$MSR_K8_SYSCFG, %ecx
rdmsr


[tip:x86/pti] x86-64/realmode: Add instruction suffix

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  8554004a0231dedf44d4d62147fb3d6a6db489aa
Gitweb: https://git.kernel.org/tip/8554004a0231dedf44d4d62147fb3d6a6db489aa
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 08:06:14 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:41 +0100

x86-64/realmode: Add instruction suffix

Omitting suffixes from instructions in AT mode is bad practice when
operand size cannot be determined by the assembler from register
operands, and is likely going to be warned about by upstream GAS in the
future (mine does already). Add the single missing suffix here.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af5f60278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/realmode/rm/trampoline_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/realmode/rm/trampoline_64.S 
b/arch/x86/realmode/rm/trampoline_64.S
index de53bd1..24bb759 100644
--- a/arch/x86/realmode/rm/trampoline_64.S
+++ b/arch/x86/realmode/rm/trampoline_64.S
@@ -102,7 +102,7 @@ ENTRY(startup_32)
 * don't we'll eventually crash trying to execute encrypted
 * instructions.
 */
-   bt  $TH_FLAGS_SME_ACTIVE_BIT, pa_tr_flags
+   btl $TH_FLAGS_SME_ACTIVE_BIT, pa_tr_flags
jnc .Ldone
movl$MSR_K8_SYSCFG, %ecx
rdmsr


[tip:x86/pti] x86/IO-APIC: Avoid warning in 32-bit builds

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  6262b6e78ce5ba62be47774ca80f5b0a6f0eb428
Gitweb: https://git.kernel.org/tip/6262b6e78ce5ba62be47774ca80f5b0a6f0eb428
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:50:23 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:40 +0100

x86/IO-APIC: Avoid warning in 32-bit builds

Constants wider than 32 bits should be tagged with ULL.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af23f0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/io_apic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 8ad2e41..7c55387 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1603,7 +1603,7 @@ static void __init delay_with_tsc(void)
do {
rep_nop();
now = rdtsc();
-   } while ((now - start) < 400UL / HZ &&
+   } while ((now - start) < 400ULL / HZ &&
time_before_eq(jiffies, end));
 }
 


[tip:x86/pti] x86/IO-APIC: Avoid warning in 32-bit builds

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  6262b6e78ce5ba62be47774ca80f5b0a6f0eb428
Gitweb: https://git.kernel.org/tip/6262b6e78ce5ba62be47774ca80f5b0a6f0eb428
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:50:23 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:40 +0100

x86/IO-APIC: Avoid warning in 32-bit builds

Constants wider than 32 bits should be tagged with ULL.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af23f0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/io_apic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 8ad2e41..7c55387 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1603,7 +1603,7 @@ static void __init delay_with_tsc(void)
do {
rep_nop();
now = rdtsc();
-   } while ((now - start) < 400UL / HZ &&
+   } while ((now - start) < 400ULL / HZ &&
time_before_eq(jiffies, end));
 }
 


[tip:x86/pti] x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  700b7c5409c3e9da279fbea78cf28a78fbc176cd
Gitweb: https://git.kernel.org/tip/700b7c5409c3e9da279fbea78cf28a78fbc176cd
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:49:12 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:39 +0100

x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers

Commit:

  df3405245a ("x86/asm: Add suffix macro for GEN_*_RMWcc()")

... introduced "suffix" RMWcc operations, adding bogus clobber specifiers:
For one, on x86 there's no point explicitly clobbering "cc".

In fact, with GCC properly fixed, this results in an overlap being detected by
the compiler between outputs and clobbers.

Furthermore it seems bad practice to me to have clobber specification
and use of the clobbered register(s) disconnected - it should rather be
at the invocation place of that GEN_{UN,BIN}ARY_SUFFIXED_RMWcc() macros
that the clobber is specified which this particular invocation needs.

Drop the "cc" clobber altogether and move the "cx" one to refcount.h.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Kees Cook 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af1f80278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/refcount.h |  4 ++--
 arch/x86/include/asm/rmwcc.h| 16 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h
index 4e44250..d651711 100644
--- a/arch/x86/include/asm/refcount.h
+++ b/arch/x86/include/asm/refcount.h
@@ -67,13 +67,13 @@ static __always_inline __must_check
 bool refcount_sub_and_test(unsigned int i, refcount_t *r)
 {
GEN_BINARY_SUFFIXED_RMWcc(LOCK_PREFIX "subl", REFCOUNT_CHECK_LT_ZERO,
- r->refs.counter, "er", i, "%0", e);
+ r->refs.counter, "er", i, "%0", e, "cx");
 }
 
 static __always_inline __must_check bool refcount_dec_and_test(refcount_t *r)
 {
GEN_UNARY_SUFFIXED_RMWcc(LOCK_PREFIX "decl", REFCOUNT_CHECK_LT_ZERO,
-r->refs.counter, "%0", e);
+r->refs.counter, "%0", e, "cx");
 }
 
 static __always_inline __must_check
diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index f91c365..4914a3e 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -2,8 +2,7 @@
 #ifndef _ASM_X86_RMWcc
 #define _ASM_X86_RMWcc
 
-#define __CLOBBERS_MEM "memory"
-#define __CLOBBERS_MEM_CC_CX   "memory", "cc", "cx"
+#define __CLOBBERS_MEM(clb...) "memory", ## clb
 
 #if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
 
@@ -40,18 +39,19 @@ do {
\
 #endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
 
 #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
-   __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM)
+   __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())
 
-#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc)\
+#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc, clobbers...)\
__GEN_RMWcc(op " " arg0 "\n\t" suffix, var, cc, \
-   __CLOBBERS_MEM_CC_CX)
+   __CLOBBERS_MEM(clobbers))
 
 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0, var, cc,\
-   __CLOBBERS_MEM, vcon (val))
+   __CLOBBERS_MEM(), vcon (val))
 
-#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc)
\
+#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc,
\
+ clobbers...)  \
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0 "\n\t" suffix, var, cc,  \
-   __CLOBBERS_MEM_CC_CX, vcon (val))
+   __CLOBBERS_MEM(clobbers), vcon (val))
 
 #endif /* _ASM_X86_RMWcc */


[tip:x86/pti] x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  700b7c5409c3e9da279fbea78cf28a78fbc176cd
Gitweb: https://git.kernel.org/tip/700b7c5409c3e9da279fbea78cf28a78fbc176cd
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:49:12 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:39 +0100

x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers

Commit:

  df3405245a ("x86/asm: Add suffix macro for GEN_*_RMWcc()")

... introduced "suffix" RMWcc operations, adding bogus clobber specifiers:
For one, on x86 there's no point explicitly clobbering "cc".

In fact, with GCC properly fixed, this results in an overlap being detected by
the compiler between outputs and clobbers.

Furthermore it seems bad practice to me to have clobber specification
and use of the clobbered register(s) disconnected - it should rather be
at the invocation place of that GEN_{UN,BIN}ARY_SUFFIXED_RMWcc() macros
that the clobber is specified which this particular invocation needs.

Drop the "cc" clobber altogether and move the "cx" one to refcount.h.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Kees Cook 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5a8af1f80278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/refcount.h |  4 ++--
 arch/x86/include/asm/rmwcc.h| 16 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h
index 4e44250..d651711 100644
--- a/arch/x86/include/asm/refcount.h
+++ b/arch/x86/include/asm/refcount.h
@@ -67,13 +67,13 @@ static __always_inline __must_check
 bool refcount_sub_and_test(unsigned int i, refcount_t *r)
 {
GEN_BINARY_SUFFIXED_RMWcc(LOCK_PREFIX "subl", REFCOUNT_CHECK_LT_ZERO,
- r->refs.counter, "er", i, "%0", e);
+ r->refs.counter, "er", i, "%0", e, "cx");
 }
 
 static __always_inline __must_check bool refcount_dec_and_test(refcount_t *r)
 {
GEN_UNARY_SUFFIXED_RMWcc(LOCK_PREFIX "decl", REFCOUNT_CHECK_LT_ZERO,
-r->refs.counter, "%0", e);
+r->refs.counter, "%0", e, "cx");
 }
 
 static __always_inline __must_check
diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index f91c365..4914a3e 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -2,8 +2,7 @@
 #ifndef _ASM_X86_RMWcc
 #define _ASM_X86_RMWcc
 
-#define __CLOBBERS_MEM "memory"
-#define __CLOBBERS_MEM_CC_CX   "memory", "cc", "cx"
+#define __CLOBBERS_MEM(clb...) "memory", ## clb
 
 #if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
 
@@ -40,18 +39,19 @@ do {
\
 #endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
 
 #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
-   __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM)
+   __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())
 
-#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc)\
+#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc, clobbers...)\
__GEN_RMWcc(op " " arg0 "\n\t" suffix, var, cc, \
-   __CLOBBERS_MEM_CC_CX)
+   __CLOBBERS_MEM(clobbers))
 
 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0, var, cc,\
-   __CLOBBERS_MEM, vcon (val))
+   __CLOBBERS_MEM(), vcon (val))
 
-#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc)
\
+#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc,
\
+ clobbers...)  \
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0 "\n\t" suffix, var, cc,  \
-   __CLOBBERS_MEM_CC_CX, vcon (val))
+   __CLOBBERS_MEM(clobbers), vcon (val))
 
 #endif /* _ASM_X86_RMWcc */


[tip:x86/pti] x86/mm: Fix {pmd,pud}_{set,clear}_flags()

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  842cef9113c2120f74f645111ded1e020193d84c
Gitweb: https://git.kernel.org/tip/842cef9113c2120f74f645111ded1e020193d84c
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:48:11 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:39 +0100

x86/mm: Fix {pmd,pud}_{set,clear}_flags()

Just like pte_{set,clear}_flags() their PMD and PUD counterparts should
not do any address translation. This was outright wrong under Xen
(causing a dead boot with no useful output on "suitable" systems), and
produced needlessly more complicated code (even if just slightly) when
paravirt was enabled.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/5a8af1bb0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/pgtable.h   |  8 
 arch/x86/include/asm/pgtable_types.h | 10 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 63c2552..b444d83 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -350,14 +350,14 @@ static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
 {
pmdval_t v = native_pmd_val(pmd);
 
-   return __pmd(v | set);
+   return native_make_pmd(v | set);
 }
 
 static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
 {
pmdval_t v = native_pmd_val(pmd);
 
-   return __pmd(v & ~clear);
+   return native_make_pmd(v & ~clear);
 }
 
 static inline pmd_t pmd_mkold(pmd_t pmd)
@@ -409,14 +409,14 @@ static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
 {
pudval_t v = native_pud_val(pud);
 
-   return __pud(v | set);
+   return native_make_pud(v | set);
 }
 
 static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
 {
pudval_t v = native_pud_val(pud);
 
-   return __pud(v & ~clear);
+   return native_make_pud(v & ~clear);
 }
 
 static inline pud_t pud_mkold(pud_t pud)
diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index 3696398..246f15b 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -323,6 +323,11 @@ static inline pudval_t native_pud_val(pud_t pud)
 #else
 #include 
 
+static inline pud_t native_make_pud(pudval_t val)
+{
+   return (pud_t) { .p4d.pgd = native_make_pgd(val) };
+}
+
 static inline pudval_t native_pud_val(pud_t pud)
 {
return native_pgd_val(pud.p4d.pgd);
@@ -344,6 +349,11 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
 #else
 #include 
 
+static inline pmd_t native_make_pmd(pmdval_t val)
+{
+   return (pmd_t) { .pud.p4d.pgd = native_make_pgd(val) };
+}
+
 static inline pmdval_t native_pmd_val(pmd_t pmd)
 {
return native_pgd_val(pmd.pud.p4d.pgd);


[tip:x86/pti] x86/mm: Fix {pmd,pud}_{set,clear}_flags()

2018-02-20 Thread tip-bot for Jan Beulich
Commit-ID:  842cef9113c2120f74f645111ded1e020193d84c
Gitweb: https://git.kernel.org/tip/842cef9113c2120f74f645111ded1e020193d84c
Author: Jan Beulich 
AuthorDate: Mon, 19 Feb 2018 07:48:11 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Feb 2018 09:33:39 +0100

x86/mm: Fix {pmd,pud}_{set,clear}_flags()

Just like pte_{set,clear}_flags() their PMD and PUD counterparts should
not do any address translation. This was outright wrong under Xen
(causing a dead boot with no useful output on "suitable" systems), and
produced needlessly more complicated code (even if just slightly) when
paravirt was enabled.

Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Acked-by: Thomas Gleixner 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/5a8af1bb0278001a9...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/pgtable.h   |  8 
 arch/x86/include/asm/pgtable_types.h | 10 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 63c2552..b444d83 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -350,14 +350,14 @@ static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
 {
pmdval_t v = native_pmd_val(pmd);
 
-   return __pmd(v | set);
+   return native_make_pmd(v | set);
 }
 
 static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
 {
pmdval_t v = native_pmd_val(pmd);
 
-   return __pmd(v & ~clear);
+   return native_make_pmd(v & ~clear);
 }
 
 static inline pmd_t pmd_mkold(pmd_t pmd)
@@ -409,14 +409,14 @@ static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
 {
pudval_t v = native_pud_val(pud);
 
-   return __pud(v | set);
+   return native_make_pud(v | set);
 }
 
 static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
 {
pudval_t v = native_pud_val(pud);
 
-   return __pud(v & ~clear);
+   return native_make_pud(v & ~clear);
 }
 
 static inline pud_t pud_mkold(pud_t pud)
diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index 3696398..246f15b 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -323,6 +323,11 @@ static inline pudval_t native_pud_val(pud_t pud)
 #else
 #include 
 
+static inline pud_t native_make_pud(pudval_t val)
+{
+   return (pud_t) { .p4d.pgd = native_make_pgd(val) };
+}
+
 static inline pudval_t native_pud_val(pud_t pud)
 {
return native_pgd_val(pud.p4d.pgd);
@@ -344,6 +349,11 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
 #else
 #include 
 
+static inline pmd_t native_make_pmd(pmdval_t val)
+{
+   return (pmd_t) { .pud.p4d.pgd = native_make_pgd(val) };
+}
+
 static inline pmdval_t native_pmd_val(pmd_t pmd)
 {
return native_pgd_val(pmd.pud.p4d.pgd);


[tip:x86/mm] x86/mm: Use pr_cont() in dump_pagetable()

2017-08-31 Thread tip-bot for Jan Beulich
Commit-ID:  39e48d9b128abbd2ea9b8403bb1e2693323db2f4
Gitweb: http://git.kernel.org/tip/39e48d9b128abbd2ea9b8403bb1e2693323db2f4
Author: Jan Beulich 
AuthorDate: Thu, 31 Aug 2017 01:30:19 -0600
Committer:  Ingo Molnar 
CommitDate: Thu, 31 Aug 2017 11:01:58 +0200

x86/mm: Use pr_cont() in dump_pagetable()

The lack of newlines in preceding format strings is a clear indication
that these were meant to be continuations of one another, and indeed
output ends up quite a bit more compact (and readable) that way.

Switch other plain printk()-s in the function instances to pr_info(),
as requested.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/59a7d72b027800175...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/fault.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 2a1fa10c..0cdf14c 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -396,14 +396,18 @@ static void dump_pagetable(unsigned long address)
pte_t *pte;
 
 #ifdef CONFIG_X86_PAE
-   printk("*pdpt = %016Lx ", pgd_val(*pgd));
+   pr_info("*pdpt = %016Lx ", pgd_val(*pgd));
if (!low_pfn(pgd_val(*pgd) >> PAGE_SHIFT) || !pgd_present(*pgd))
goto out;
+#define pr_pde pr_cont
+#else
+#define pr_pde pr_info
 #endif
p4d = p4d_offset(pgd, address);
pud = pud_offset(p4d, address);
pmd = pmd_offset(pud, address);
-   printk(KERN_CONT "*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd));
+   pr_pde("*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd));
+#undef pr_pde
 
/*
 * We must not directly access the pte in the highpte
@@ -415,9 +419,9 @@ static void dump_pagetable(unsigned long address)
goto out;
 
pte = pte_offset_kernel(pmd, address);
-   printk("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte));
+   pr_cont("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte));
 out:
-   printk("\n");
+   pr_cont("\n");
 }
 
 #else /* CONFIG_X86_64: */
@@ -565,7 +569,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pgd))
goto bad;
 
-   printk("PGD %lx ", pgd_val(*pgd));
+   pr_info("PGD %lx ", pgd_val(*pgd));
 
if (!pgd_present(*pgd))
goto out;
@@ -574,7 +578,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(p4d))
goto bad;
 
-   printk("P4D %lx ", p4d_val(*p4d));
+   pr_cont("P4D %lx ", p4d_val(*p4d));
if (!p4d_present(*p4d) || p4d_large(*p4d))
goto out;
 
@@ -582,7 +586,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pud))
goto bad;
 
-   printk("PUD %lx ", pud_val(*pud));
+   pr_cont("PUD %lx ", pud_val(*pud));
if (!pud_present(*pud) || pud_large(*pud))
goto out;
 
@@ -590,7 +594,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pmd))
goto bad;
 
-   printk("PMD %lx ", pmd_val(*pmd));
+   pr_cont("PMD %lx ", pmd_val(*pmd));
if (!pmd_present(*pmd) || pmd_large(*pmd))
goto out;
 
@@ -598,12 +602,12 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pte))
goto bad;
 
-   printk("PTE %lx", pte_val(*pte));
+   pr_cont("PTE %lx", pte_val(*pte));
 out:
-   printk("\n");
+   pr_cont("\n");
return;
 bad:
-   printk("BAD\n");
+   pr_info("BAD\n");
 }
 
 #endif /* CONFIG_X86_64 */


[tip:x86/mm] x86/mm: Use pr_cont() in dump_pagetable()

2017-08-31 Thread tip-bot for Jan Beulich
Commit-ID:  39e48d9b128abbd2ea9b8403bb1e2693323db2f4
Gitweb: http://git.kernel.org/tip/39e48d9b128abbd2ea9b8403bb1e2693323db2f4
Author: Jan Beulich 
AuthorDate: Thu, 31 Aug 2017 01:30:19 -0600
Committer:  Ingo Molnar 
CommitDate: Thu, 31 Aug 2017 11:01:58 +0200

x86/mm: Use pr_cont() in dump_pagetable()

The lack of newlines in preceding format strings is a clear indication
that these were meant to be continuations of one another, and indeed
output ends up quite a bit more compact (and readable) that way.

Switch other plain printk()-s in the function instances to pr_info(),
as requested.

Signed-off-by: Jan Beulich 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/59a7d72b027800175...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/fault.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 2a1fa10c..0cdf14c 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -396,14 +396,18 @@ static void dump_pagetable(unsigned long address)
pte_t *pte;
 
 #ifdef CONFIG_X86_PAE
-   printk("*pdpt = %016Lx ", pgd_val(*pgd));
+   pr_info("*pdpt = %016Lx ", pgd_val(*pgd));
if (!low_pfn(pgd_val(*pgd) >> PAGE_SHIFT) || !pgd_present(*pgd))
goto out;
+#define pr_pde pr_cont
+#else
+#define pr_pde pr_info
 #endif
p4d = p4d_offset(pgd, address);
pud = pud_offset(p4d, address);
pmd = pmd_offset(pud, address);
-   printk(KERN_CONT "*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd));
+   pr_pde("*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd));
+#undef pr_pde
 
/*
 * We must not directly access the pte in the highpte
@@ -415,9 +419,9 @@ static void dump_pagetable(unsigned long address)
goto out;
 
pte = pte_offset_kernel(pmd, address);
-   printk("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte));
+   pr_cont("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte));
 out:
-   printk("\n");
+   pr_cont("\n");
 }
 
 #else /* CONFIG_X86_64: */
@@ -565,7 +569,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pgd))
goto bad;
 
-   printk("PGD %lx ", pgd_val(*pgd));
+   pr_info("PGD %lx ", pgd_val(*pgd));
 
if (!pgd_present(*pgd))
goto out;
@@ -574,7 +578,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(p4d))
goto bad;
 
-   printk("P4D %lx ", p4d_val(*p4d));
+   pr_cont("P4D %lx ", p4d_val(*p4d));
if (!p4d_present(*p4d) || p4d_large(*p4d))
goto out;
 
@@ -582,7 +586,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pud))
goto bad;
 
-   printk("PUD %lx ", pud_val(*pud));
+   pr_cont("PUD %lx ", pud_val(*pud));
if (!pud_present(*pud) || pud_large(*pud))
goto out;
 
@@ -590,7 +594,7 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pmd))
goto bad;
 
-   printk("PMD %lx ", pmd_val(*pmd));
+   pr_cont("PMD %lx ", pmd_val(*pmd));
if (!pmd_present(*pmd) || pmd_large(*pmd))
goto out;
 
@@ -598,12 +602,12 @@ static void dump_pagetable(unsigned long address)
if (bad_address(pte))
goto bad;
 
-   printk("PTE %lx", pte_val(*pte));
+   pr_cont("PTE %lx", pte_val(*pte));
 out:
-   printk("\n");
+   pr_cont("\n");
return;
 bad:
-   printk("BAD\n");
+   pr_info("BAD\n");
 }
 
 #endif /* CONFIG_X86_64 */


[tip:efi/core] efi: Move efi_mem_type() to common code

2017-08-26 Thread tip-bot for Jan Beulich
Commit-ID:  23f0571c9fd184504f7a2f27011750e0ad99bb73
Gitweb: http://git.kernel.org/tip/23f0571c9fd184504f7a2f27011750e0ad99bb73
Author: Jan Beulich 
AuthorDate: Fri, 25 Aug 2017 16:50:18 +0100
Committer:  Ingo Molnar 
CommitDate: Sat, 26 Aug 2017 09:20:33 +0200

efi: Move efi_mem_type() to common code

This follows efi_mem_attributes(), as it's similarly generic. Drop
__weak from that one though (and don't introduce it for efi_mem_type()
in the first place) to make clear that other overrides to these
functions are really not intended.

Signed-off-by: Jan Beulich 
Signed-off-by: Ard Biesheuvel 
Cc: Jan Beulich 
Cc: Linus Torvalds 
Cc: Matt Fleming 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20170825155019.6740-5-ard.biesheu...@linaro.org
[ Resolved conflict with: f99afd08a45f: (efi: Update efi_mem_type() to return 
an error rather than 0) ]
Signed-off-by: Ingo Molnar 
---
 arch/x86/platform/efi/efi.c | 19 ---
 drivers/firmware/efi/efi.c  | 37 +++--
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 6217b23..928b6dc 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1032,25 +1032,6 @@ void __init efi_enter_virtual_mode(void)
efi_dump_pagetable();
 }
 
-/*
- * Convenience functions to obtain memory types and attributes
- */
-int efi_mem_type(unsigned long phys_addr)
-{
-   efi_memory_desc_t *md;
-
-   if (!efi_enabled(EFI_MEMMAP))
-   return -ENOTSUPP;
-
-   for_each_efi_memory_desc(md) {
-   if ((md->phys_addr <= phys_addr) &&
-   (phys_addr < (md->phys_addr +
- (md->num_pages << EFI_PAGE_SHIFT
-   return md->type;
-   }
-   return -EINVAL;
-}
-
 static int __init arch_parse_efi_cmdline(char *str)
 {
if (!str) {
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index c8a27a2..f70febf 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -811,19 +811,19 @@ char * __init efi_md_typeattr_format(char *buf, size_t 
size,
 }
 
 /*
+ * IA64 has a funky EFI memory map that doesn't work the same way as
+ * other architectures.
+ */
+#ifndef CONFIG_IA64
+/*
  * efi_mem_attributes - lookup memmap attributes for physical address
  * @phys_addr: the physical address to lookup
  *
  * Search in the EFI memory map for the region covering
  * @phys_addr. Returns the EFI memory attributes if the region
  * was found in the memory map, 0 otherwise.
- *
- * Despite being marked __weak, most architectures should *not*
- * override this function. It is __weak solely for the benefit
- * of ia64 which has a funky EFI memory map that doesn't work
- * the same way as other architectures.
  */
-u64 __weak efi_mem_attributes(unsigned long phys_addr)
+u64 efi_mem_attributes(unsigned long phys_addr)
 {
efi_memory_desc_t *md;
 
@@ -839,6 +839,31 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr)
return 0;
 }
 
+/*
+ * efi_mem_type - lookup memmap type for physical address
+ * @phys_addr: the physical address to lookup
+ *
+ * Search in the EFI memory map for the region covering @phys_addr.
+ * Returns the EFI memory type if the region was found in the memory
+ * map, EFI_RESERVED_TYPE (zero) otherwise.
+ */
+int efi_mem_type(unsigned long phys_addr)
+{
+   const efi_memory_desc_t *md;
+
+   if (!efi_enabled(EFI_MEMMAP))
+   return -ENOTSUPP;
+
+   for_each_efi_memory_desc(md) {
+   if ((md->phys_addr <= phys_addr) &&
+   (phys_addr < (md->phys_addr +
+ (md->num_pages << EFI_PAGE_SHIFT
+   return md->type;
+   }
+   return -EINVAL;
+}
+#endif
+
 int efi_status_to_err(efi_status_t status)
 {
int err;


[tip:efi/core] efi: Move efi_mem_type() to common code

2017-08-26 Thread tip-bot for Jan Beulich
Commit-ID:  23f0571c9fd184504f7a2f27011750e0ad99bb73
Gitweb: http://git.kernel.org/tip/23f0571c9fd184504f7a2f27011750e0ad99bb73
Author: Jan Beulich 
AuthorDate: Fri, 25 Aug 2017 16:50:18 +0100
Committer:  Ingo Molnar 
CommitDate: Sat, 26 Aug 2017 09:20:33 +0200

efi: Move efi_mem_type() to common code

This follows efi_mem_attributes(), as it's similarly generic. Drop
__weak from that one though (and don't introduce it for efi_mem_type()
in the first place) to make clear that other overrides to these
functions are really not intended.

Signed-off-by: Jan Beulich 
Signed-off-by: Ard Biesheuvel 
Cc: Jan Beulich 
Cc: Linus Torvalds 
Cc: Matt Fleming 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20170825155019.6740-5-ard.biesheu...@linaro.org
[ Resolved conflict with: f99afd08a45f: (efi: Update efi_mem_type() to return 
an error rather than 0) ]
Signed-off-by: Ingo Molnar 
---
 arch/x86/platform/efi/efi.c | 19 ---
 drivers/firmware/efi/efi.c  | 37 +++--
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 6217b23..928b6dc 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1032,25 +1032,6 @@ void __init efi_enter_virtual_mode(void)
efi_dump_pagetable();
 }
 
-/*
- * Convenience functions to obtain memory types and attributes
- */
-int efi_mem_type(unsigned long phys_addr)
-{
-   efi_memory_desc_t *md;
-
-   if (!efi_enabled(EFI_MEMMAP))
-   return -ENOTSUPP;
-
-   for_each_efi_memory_desc(md) {
-   if ((md->phys_addr <= phys_addr) &&
-   (phys_addr < (md->phys_addr +
- (md->num_pages << EFI_PAGE_SHIFT
-   return md->type;
-   }
-   return -EINVAL;
-}
-
 static int __init arch_parse_efi_cmdline(char *str)
 {
if (!str) {
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index c8a27a2..f70febf 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -811,19 +811,19 @@ char * __init efi_md_typeattr_format(char *buf, size_t 
size,
 }
 
 /*
+ * IA64 has a funky EFI memory map that doesn't work the same way as
+ * other architectures.
+ */
+#ifndef CONFIG_IA64
+/*
  * efi_mem_attributes - lookup memmap attributes for physical address
  * @phys_addr: the physical address to lookup
  *
  * Search in the EFI memory map for the region covering
  * @phys_addr. Returns the EFI memory attributes if the region
  * was found in the memory map, 0 otherwise.
- *
- * Despite being marked __weak, most architectures should *not*
- * override this function. It is __weak solely for the benefit
- * of ia64 which has a funky EFI memory map that doesn't work
- * the same way as other architectures.
  */
-u64 __weak efi_mem_attributes(unsigned long phys_addr)
+u64 efi_mem_attributes(unsigned long phys_addr)
 {
efi_memory_desc_t *md;
 
@@ -839,6 +839,31 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr)
return 0;
 }
 
+/*
+ * efi_mem_type - lookup memmap type for physical address
+ * @phys_addr: the physical address to lookup
+ *
+ * Search in the EFI memory map for the region covering @phys_addr.
+ * Returns the EFI memory type if the region was found in the memory
+ * map, EFI_RESERVED_TYPE (zero) otherwise.
+ */
+int efi_mem_type(unsigned long phys_addr)
+{
+   const efi_memory_desc_t *md;
+
+   if (!efi_enabled(EFI_MEMMAP))
+   return -ENOTSUPP;
+
+   for_each_efi_memory_desc(md) {
+   if ((md->phys_addr <= phys_addr) &&
+   (phys_addr < (md->phys_addr +
+ (md->num_pages << EFI_PAGE_SHIFT
+   return md->type;
+   }
+   return -EINVAL;
+}
+#endif
+
 int efi_status_to_err(efi_status_t status)
 {
int err;


[tip:efi/core] efi/bgrt: Use efi_mem_type()

2017-08-26 Thread tip-bot for Jan Beulich
Commit-ID:  6de47a5e371f75f80544986e6c9636211a2ae8af
Gitweb: http://git.kernel.org/tip/6de47a5e371f75f80544986e6c9636211a2ae8af
Author: Jan Beulich 
AuthorDate: Fri, 25 Aug 2017 16:50:19 +0100
Committer:  Ingo Molnar 
CommitDate: Sat, 26 Aug 2017 09:20:33 +0200

efi/bgrt: Use efi_mem_type()

Avoid effectively open-coding the function.

Signed-off-by: Jan Beulich 
Signed-off-by: Ard Biesheuvel 
Cc: Jan Beulich 
Cc: Linus Torvalds 
Cc: Matt Fleming 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20170825155019.6740-6-ard.biesheu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 drivers/firmware/efi/efi-bgrt.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b58233e..50793fd 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -27,26 +27,6 @@ struct bmp_header {
u32 size;
 } __packed;
 
-static bool efi_bgrt_addr_valid(u64 addr)
-{
-   efi_memory_desc_t *md;
-
-   for_each_efi_memory_desc(md) {
-   u64 size;
-   u64 end;
-
-   if (md->type != EFI_BOOT_SERVICES_DATA)
-   continue;
-
-   size = md->num_pages << EFI_PAGE_SHIFT;
-   end = md->phys_addr + size;
-   if (addr >= md->phys_addr && addr < end)
-   return true;
-   }
-
-   return false;
-}
-
 void __init efi_bgrt_init(struct acpi_table_header *table)
 {
void *image;
@@ -85,7 +65,7 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
goto out;
}
 
-   if (!efi_bgrt_addr_valid(bgrt->image_address)) {
+   if (efi_mem_type(bgrt->image_address) != EFI_BOOT_SERVICES_DATA) {
pr_notice("Ignoring BGRT: invalid image address\n");
goto out;
}


[tip:efi/core] efi/bgrt: Use efi_mem_type()

2017-08-26 Thread tip-bot for Jan Beulich
Commit-ID:  6de47a5e371f75f80544986e6c9636211a2ae8af
Gitweb: http://git.kernel.org/tip/6de47a5e371f75f80544986e6c9636211a2ae8af
Author: Jan Beulich 
AuthorDate: Fri, 25 Aug 2017 16:50:19 +0100
Committer:  Ingo Molnar 
CommitDate: Sat, 26 Aug 2017 09:20:33 +0200

efi/bgrt: Use efi_mem_type()

Avoid effectively open-coding the function.

Signed-off-by: Jan Beulich 
Signed-off-by: Ard Biesheuvel 
Cc: Jan Beulich 
Cc: Linus Torvalds 
Cc: Matt Fleming 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20170825155019.6740-6-ard.biesheu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 drivers/firmware/efi/efi-bgrt.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b58233e..50793fd 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -27,26 +27,6 @@ struct bmp_header {
u32 size;
 } __packed;
 
-static bool efi_bgrt_addr_valid(u64 addr)
-{
-   efi_memory_desc_t *md;
-
-   for_each_efi_memory_desc(md) {
-   u64 size;
-   u64 end;
-
-   if (md->type != EFI_BOOT_SERVICES_DATA)
-   continue;
-
-   size = md->num_pages << EFI_PAGE_SHIFT;
-   end = md->phys_addr + size;
-   if (addr >= md->phys_addr && addr < end)
-   return true;
-   }
-
-   return false;
-}
-
 void __init efi_bgrt_init(struct acpi_table_header *table)
 {
void *image;
@@ -85,7 +65,7 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
goto out;
}
 
-   if (!efi_bgrt_addr_valid(bgrt->image_address)) {
+   if (efi_mem_type(bgrt->image_address) != EFI_BOOT_SERVICES_DATA) {
pr_notice("Ignoring BGRT: invalid image address\n");
goto out;
}


[tip:x86/asm] x86/entry/64: Relax pvops stub clobber specifications

2017-03-01 Thread tip-bot for Jan Beulich
Commit-ID:  2140a9942b84dd4bf559dd1215b8f43c36ece5b5
Gitweb: http://git.kernel.org/tip/2140a9942b84dd4bf559dd1215b8f43c36ece5b5
Author: Jan Beulich 
AuthorDate: Fri, 3 Feb 2017 02:03:25 -0700
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:16:35 +0100

x86/entry/64: Relax pvops stub clobber specifications

Except for the error_exit case, none of the code paths following the
{DIS,EN}ABLE_INTERRUPTS() invocations being modified here make any
assumptions on register values, so all registers can be clobbered
there. In the error_exit case a minor adjustment to register usage
(at once eliminating an instruction) also allows for this to be true.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5894556d027800136...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_64.S | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 044d18e..d2b2a2948 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -212,7 +212,7 @@ entry_SYSCALL_64_fastpath:
 * If we see that no exit work is required (which we are required
 * to check with IRQs off), then we can go straight to SYSRET64.
 */
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
movqPER_CPU_VAR(current_task), %r11
testl   $_TIF_ALLWORK_MASK, TASK_TI_flags(%r11)
@@ -233,7 +233,7 @@ entry_SYSCALL_64_fastpath:
 * raise(3) will trigger this, for example.  IRQs are off.
 */
TRACE_IRQS_ON
-   ENABLE_INTERRUPTS(CLBR_NONE)
+   ENABLE_INTERRUPTS(CLBR_ANY)
SAVE_EXTRA_REGS
movq%rsp, %rdi
callsyscall_return_slowpath /* returns with IRQs disabled */
@@ -343,7 +343,7 @@ ENTRY(stub_ptregs_64)
 * Called from fast path -- disable IRQs again, pop return address
 * and jump to slow path
 */
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
popq%rax
jmp entry_SYSCALL64_slow_path
@@ -518,7 +518,7 @@ common_interrupt:
interrupt do_IRQ
/* 0(%rsp): old RSP */
 ret_from_intr:
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
declPER_CPU_VAR(irq_count)
 
@@ -1051,7 +1051,7 @@ END(paranoid_entry)
  * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
  */
 ENTRY(paranoid_exit)
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF_DEBUG
testl   %ebx, %ebx  /* swapgs needed? */
jnz paranoid_exit_no_swapgs
@@ -1156,10 +1156,9 @@ END(error_entry)
  *   0: user gsbase is loaded, we need SWAPGS and standard preparation for 
return to usermode
  */
 ENTRY(error_exit)
-   movl%ebx, %eax
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
-   testl   %eax, %eax
+   testl   %ebx, %ebx
jnz retint_kernel
jmp retint_user
 END(error_exit)


[tip:x86/asm] x86/entry/64: Relax pvops stub clobber specifications

2017-03-01 Thread tip-bot for Jan Beulich
Commit-ID:  2140a9942b84dd4bf559dd1215b8f43c36ece5b5
Gitweb: http://git.kernel.org/tip/2140a9942b84dd4bf559dd1215b8f43c36ece5b5
Author: Jan Beulich 
AuthorDate: Fri, 3 Feb 2017 02:03:25 -0700
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:16:35 +0100

x86/entry/64: Relax pvops stub clobber specifications

Except for the error_exit case, none of the code paths following the
{DIS,EN}ABLE_INTERRUPTS() invocations being modified here make any
assumptions on register values, so all registers can be clobbered
there. In the error_exit case a minor adjustment to register usage
(at once eliminating an instruction) also allows for this to be true.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5894556d027800136...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_64.S | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 044d18e..d2b2a2948 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -212,7 +212,7 @@ entry_SYSCALL_64_fastpath:
 * If we see that no exit work is required (which we are required
 * to check with IRQs off), then we can go straight to SYSRET64.
 */
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
movqPER_CPU_VAR(current_task), %r11
testl   $_TIF_ALLWORK_MASK, TASK_TI_flags(%r11)
@@ -233,7 +233,7 @@ entry_SYSCALL_64_fastpath:
 * raise(3) will trigger this, for example.  IRQs are off.
 */
TRACE_IRQS_ON
-   ENABLE_INTERRUPTS(CLBR_NONE)
+   ENABLE_INTERRUPTS(CLBR_ANY)
SAVE_EXTRA_REGS
movq%rsp, %rdi
callsyscall_return_slowpath /* returns with IRQs disabled */
@@ -343,7 +343,7 @@ ENTRY(stub_ptregs_64)
 * Called from fast path -- disable IRQs again, pop return address
 * and jump to slow path
 */
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
popq%rax
jmp entry_SYSCALL64_slow_path
@@ -518,7 +518,7 @@ common_interrupt:
interrupt do_IRQ
/* 0(%rsp): old RSP */
 ret_from_intr:
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
declPER_CPU_VAR(irq_count)
 
@@ -1051,7 +1051,7 @@ END(paranoid_entry)
  * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
  */
 ENTRY(paranoid_exit)
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF_DEBUG
testl   %ebx, %ebx  /* swapgs needed? */
jnz paranoid_exit_no_swapgs
@@ -1156,10 +1156,9 @@ END(error_entry)
  *   0: user gsbase is loaded, we need SWAPGS and standard preparation for 
return to usermode
  */
 ENTRY(error_exit)
-   movl%ebx, %eax
-   DISABLE_INTERRUPTS(CLBR_NONE)
+   DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
-   testl   %eax, %eax
+   testl   %ebx, %ebx
jnz retint_kernel
jmp retint_user
 END(error_exit)


[tip:x86/asm] x86/entry/32: Relax a pvops stub clobber specification

2017-03-01 Thread tip-bot for Jan Beulich
Commit-ID:  fdbd518adfaf2c10903250dffe70c61ed90b7dd7
Gitweb: http://git.kernel.org/tip/fdbd518adfaf2c10903250dffe70c61ed90b7dd7
Author: Jan Beulich 
AuthorDate: Fri, 3 Feb 2017 01:58:03 -0700
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:16:30 +0100

x86/entry/32: Relax a pvops stub clobber specification

The code at .Lrestore_nocheck does not make any assumptions on register
values, so all registers can be clobbered on code paths leading there.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5894542b027800136...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 57f7ec3..5553475 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -585,7 +585,7 @@ ENTRY(iret_exc  )
 * will soon execute iret and the tracer was already set to
 * the irqstate after the IRET:
 */
-   DISABLE_INTERRUPTS(CLBR_EAX)
+   DISABLE_INTERRUPTS(CLBR_ANY)
lss (%esp), %esp/* switch to espfix segment */
jmp .Lrestore_nocheck
 #endif


[tip:x86/asm] x86/entry/32: Relax a pvops stub clobber specification

2017-03-01 Thread tip-bot for Jan Beulich
Commit-ID:  fdbd518adfaf2c10903250dffe70c61ed90b7dd7
Gitweb: http://git.kernel.org/tip/fdbd518adfaf2c10903250dffe70c61ed90b7dd7
Author: Jan Beulich 
AuthorDate: Fri, 3 Feb 2017 01:58:03 -0700
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:16:30 +0100

x86/entry/32: Relax a pvops stub clobber specification

The code at .Lrestore_nocheck does not make any assumptions on register
values, so all registers can be clobbered on code paths leading there.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5894542b027800136...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/entry_32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 57f7ec3..5553475 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -585,7 +585,7 @@ ENTRY(iret_exc  )
 * will soon execute iret and the tracer was already set to
 * the irqstate after the IRET:
 */
-   DISABLE_INTERRUPTS(CLBR_EAX)
+   DISABLE_INTERRUPTS(CLBR_ANY)
lss (%esp), %esp/* switch to espfix segment */
jmp .Lrestore_nocheck
 #endif


[tip:x86/urgent] x86/build: Fix build with older GCC versions

2016-10-25 Thread tip-bot for Jan Beulich
Commit-ID:  a2209b742e6cf978b85d4f31a25a269c3d3b062b
Gitweb: http://git.kernel.org/tip/a2209b742e6cf978b85d4f31a25a269c3d3b062b
Author: Jan Beulich 
AuthorDate: Mon, 24 Oct 2016 09:00:12 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 25 Oct 2016 11:44:25 +0200

x86/build: Fix build with older GCC versions

Older GCC (observed with 4.1.x) doesn't support -Wno-override-init and
also doesn't ignore unknown -Wno-* options.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Valdis Kletnieks 
Cc: valdis.kletni...@vt.edu
Fixes: 5e44258d16 "x86/build: Reduce the W=1 warnings noise when compiling x86 
syscall tables"
Link: http://lkml.kernel.org/r/580e3e1c027800119...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile
index 77f28ce..9976fce 100644
--- a/arch/x86/entry/Makefile
+++ b/arch/x86/entry/Makefile
@@ -5,8 +5,8 @@
 OBJECT_FILES_NON_STANDARD_entry_$(BITS).o   := y
 OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y
 
-CFLAGS_syscall_64.o+= -Wno-override-init
-CFLAGS_syscall_32.o+= -Wno-override-init
+CFLAGS_syscall_64.o+= $(call cc-option,-Wno-override-init,)
+CFLAGS_syscall_32.o+= $(call cc-option,-Wno-override-init,)
 obj-y  := entry_$(BITS).o thunk_$(BITS).o 
syscall_$(BITS).o
 obj-y  += common.o
 


[tip:x86/urgent] x86/build: Fix build with older GCC versions

2016-10-25 Thread tip-bot for Jan Beulich
Commit-ID:  a2209b742e6cf978b85d4f31a25a269c3d3b062b
Gitweb: http://git.kernel.org/tip/a2209b742e6cf978b85d4f31a25a269c3d3b062b
Author: Jan Beulich 
AuthorDate: Mon, 24 Oct 2016 09:00:12 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 25 Oct 2016 11:44:25 +0200

x86/build: Fix build with older GCC versions

Older GCC (observed with 4.1.x) doesn't support -Wno-override-init and
also doesn't ignore unknown -Wno-* options.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Valdis Kletnieks 
Cc: valdis.kletni...@vt.edu
Fixes: 5e44258d16 "x86/build: Reduce the W=1 warnings noise when compiling x86 
syscall tables"
Link: http://lkml.kernel.org/r/580e3e1c027800119...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/entry/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile
index 77f28ce..9976fce 100644
--- a/arch/x86/entry/Makefile
+++ b/arch/x86/entry/Makefile
@@ -5,8 +5,8 @@
 OBJECT_FILES_NON_STANDARD_entry_$(BITS).o   := y
 OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y
 
-CFLAGS_syscall_64.o+= -Wno-override-init
-CFLAGS_syscall_32.o+= -Wno-override-init
+CFLAGS_syscall_64.o+= $(call cc-option,-Wno-override-init,)
+CFLAGS_syscall_32.o+= $(call cc-option,-Wno-override-init,)
 obj-y  := entry_$(BITS).o thunk_$(BITS).o 
syscall_$(BITS).o
 obj-y  += common.o
 


[tip:locking/core] locking/rwsem, x86: Drop a bogus cc clobber

2016-09-20 Thread tip-bot for Jan Beulich
Commit-ID:  c907420fdaec78b17f59a6011cb5f9d6051c6a35
Gitweb: http://git.kernel.org/tip/c907420fdaec78b17f59a6011cb5f9d6051c6a35
Author: Jan Beulich 
AuthorDate: Mon, 19 Sep 2016 07:27:08 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Sep 2016 08:26:41 +0200

locking/rwsem, x86: Drop a bogus cc clobber

With the addition of uses of GCC's condition code outputs in commit:

  35ccfb7114 ("x86, asm: Use CC_SET()/CC_OUT() in ")

... there's now an overlap of outputs and clobbers in __down_write_trylock().

Such overlaps are generally getting tagged with an error (occasionally
even with an ICE). I can't really tell why plain GCC 6.2 doesn't detect
this (judging by the code it is meant to), while the slightly modified
one I use does. Since condition code clobbers are never necessary on x86
(other than perhaps for documentation purposes, which doesn't really
get done consistently), remove it altogether rather than inventing
something like CC_CLOBBER (to accompany CC_SET/CC_OUT).

Signed-off-by: Jan Beulich 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Paul E. McKenney 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/57e003cc027800110...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/rwsem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
index 8dbc762..3d33a71 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -154,7 +154,7 @@ static inline bool __down_write_trylock(struct rw_semaphore 
*sem)
 : "+m" (sem->count), "=" (tmp0), "=" (tmp1),
   CC_OUT(e) (result)
 : "er" (RWSEM_ACTIVE_WRITE_BIAS)
-: "memory", "cc");
+: "memory");
return result;
 }
 


[tip:locking/core] locking/rwsem, x86: Drop a bogus cc clobber

2016-09-20 Thread tip-bot for Jan Beulich
Commit-ID:  c907420fdaec78b17f59a6011cb5f9d6051c6a35
Gitweb: http://git.kernel.org/tip/c907420fdaec78b17f59a6011cb5f9d6051c6a35
Author: Jan Beulich 
AuthorDate: Mon, 19 Sep 2016 07:27:08 -0600
Committer:  Ingo Molnar 
CommitDate: Tue, 20 Sep 2016 08:26:41 +0200

locking/rwsem, x86: Drop a bogus cc clobber

With the addition of uses of GCC's condition code outputs in commit:

  35ccfb7114 ("x86, asm: Use CC_SET()/CC_OUT() in ")

... there's now an overlap of outputs and clobbers in __down_write_trylock().

Such overlaps are generally getting tagged with an error (occasionally
even with an ICE). I can't really tell why plain GCC 6.2 doesn't detect
this (judging by the code it is meant to), while the slightly modified
one I use does. Since condition code clobbers are never necessary on x86
(other than perhaps for documentation purposes, which doesn't really
get done consistently), remove it altogether rather than inventing
something like CC_CLOBBER (to accompany CC_SET/CC_OUT).

Signed-off-by: Jan Beulich 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Paul E. McKenney 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/57e003cc027800110...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/rwsem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
index 8dbc762..3d33a71 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -154,7 +154,7 @@ static inline bool __down_write_trylock(struct rw_semaphore 
*sem)
 : "+m" (sem->count), "=" (tmp0), "=" (tmp1),
   CC_OUT(e) (result)
 : "er" (RWSEM_ACTIVE_WRITE_BIAS)
-: "memory", "cc");
+: "memory");
return result;
 }
 


[tip:core/urgent] objtool: Allow building with older libelf

2016-05-17 Thread tip-bot for Jan Beulich
Commit-ID:  2e51f26245701cb28f154552836b7807159088a8
Gitweb: http://git.kernel.org/tip/2e51f26245701cb28f154552836b7807159088a8
Author: Jan Beulich 
AuthorDate: Mon, 16 May 2016 15:31:07 -0500
Committer:  Ingo Molnar 
CommitDate: Tue, 17 May 2016 10:42:46 +0200

objtool: Allow building with older libelf

The switch to elf_getshdr{num,strndx} post-dates the oldest tool chain
the kernel is supposed to be able to build with, so try to cope with
such an environment.

Signed-off-by: Jan Beulich 
Signed-off-by: Josh Poimboeuf 
Cc:  # for v4.6
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jan Beulich 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: 
http://lkml.kernel.org/r/732dae6872b7ff187d94f22bb699a12849d3fe04.1463430618.git.jpoim...@redhat.com
Signed-off-by: Ingo Molnar 
---
 tools/objtool/Makefile | 4 
 tools/objtool/elf.h| 5 +
 2 files changed, 9 insertions(+)

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 6765c7e..f094f3c 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -30,6 +30,10 @@ INCLUDES := -I$(srctree)/tools/include
 CFLAGS   += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g 
$(INCLUDES)
 LDFLAGS  += -lelf $(LIBSUBCMD)
 
+# Allow old libelf to be used:
+elfshdr := $(shell echo '\#include ' | $(CC) $(CFLAGS) -x c -E - | 
grep elf_getshdr)
+CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
+
 AWK = awk
 export srctree OUTPUT CFLAGS ARCH AWK
 include $(srctree)/tools/build/Makefile.include
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 7f3e00a..aa1ff65 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -23,6 +23,11 @@
 #include 
 #include 
 
+#ifdef LIBELF_USE_DEPRECATED
+# define elf_getshdrnumelf_getshnum
+# define elf_getshdrstrndx elf_getshstrndx
+#endif
+
 struct section {
struct list_head list;
GElf_Shdr sh;


[tip:core/urgent] objtool: Allow building with older libelf

2016-05-17 Thread tip-bot for Jan Beulich
Commit-ID:  2e51f26245701cb28f154552836b7807159088a8
Gitweb: http://git.kernel.org/tip/2e51f26245701cb28f154552836b7807159088a8
Author: Jan Beulich 
AuthorDate: Mon, 16 May 2016 15:31:07 -0500
Committer:  Ingo Molnar 
CommitDate: Tue, 17 May 2016 10:42:46 +0200

objtool: Allow building with older libelf

The switch to elf_getshdr{num,strndx} post-dates the oldest tool chain
the kernel is supposed to be able to build with, so try to cope with
such an environment.

Signed-off-by: Jan Beulich 
Signed-off-by: Josh Poimboeuf 
Cc:  # for v4.6
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jan Beulich 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: 
http://lkml.kernel.org/r/732dae6872b7ff187d94f22bb699a12849d3fe04.1463430618.git.jpoim...@redhat.com
Signed-off-by: Ingo Molnar 
---
 tools/objtool/Makefile | 4 
 tools/objtool/elf.h| 5 +
 2 files changed, 9 insertions(+)

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 6765c7e..f094f3c 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -30,6 +30,10 @@ INCLUDES := -I$(srctree)/tools/include
 CFLAGS   += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g 
$(INCLUDES)
 LDFLAGS  += -lelf $(LIBSUBCMD)
 
+# Allow old libelf to be used:
+elfshdr := $(shell echo '\#include ' | $(CC) $(CFLAGS) -x c -E - | 
grep elf_getshdr)
+CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
+
 AWK = awk
 export srctree OUTPUT CFLAGS ARCH AWK
 include $(srctree)/tools/build/Makefile.include
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 7f3e00a..aa1ff65 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -23,6 +23,11 @@
 #include 
 #include 
 
+#ifdef LIBELF_USE_DEPRECATED
+# define elf_getshdrnumelf_getshnum
+# define elf_getshdrstrndx elf_getshstrndx
+#endif
+
 struct section {
struct list_head list;
GElf_Shdr sh;


[tip:x86/asm] x86/mm/xen: Suppress hugetlbfs in PV guests

2016-04-22 Thread tip-bot for Jan Beulich
Commit-ID:  103f6112f253017d7062cd74d17f4a514ed4485c
Gitweb: http://git.kernel.org/tip/103f6112f253017d7062cd74d17f4a514ed4485c
Author: Jan Beulich 
AuthorDate: Thu, 21 Apr 2016 00:27:04 -0600
Committer:  Ingo Molnar 
CommitDate: Fri, 22 Apr 2016 10:05:00 +0200

x86/mm/xen: Suppress hugetlbfs in PV guests

Huge pages are not normally available to PV guests. Not suppressing
hugetlbfs use results in an endless loop of page faults when user mode
code tries to access a hugetlbfs mapped area (since the hypervisor
denies such PTEs to be created, but error indications can't be
propagated out of xen_set_pte_at(), just like for various of its
siblings), and - once killed in an oops like this:

  kernel BUG at .../fs/hugetlbfs/inode.c:428!
  invalid opcode:  [#1] SMP
  ...
  RIP: e030:[]  [] 
remove_inode_hugepages+0x25b/0x320
  ...
  Call Trace:
   [] hugetlbfs_evict_inode+0x15/0x40
   [] evict+0xbd/0x1b0
   [] __dentry_kill+0x19a/0x1f0
   [] dput+0x1fe/0x220
   [] __fput+0x155/0x200
   [] task_work_run+0x60/0xa0
   [] do_exit+0x160/0x400
   [] do_group_exit+0x3b/0xa0
   [] get_signal+0x1ed/0x470
   [] do_signal+0x14/0x110
   [] prepare_exit_to_usermode+0xe9/0xf0
   [] retint_user+0x8/0x13

This is CVE-2016-3961 / XSA-174.

Reported-by: Vitaly Kuznetsov 
Signed-off-by: Jan Beulich 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: David Vrabel 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Luis R. Rodriguez 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Toshi Kani 
Cc: sta...@vger.kernel.org
Cc: xen-devel 
Link: http://lkml.kernel.org/r/57188ed80278000e4...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/hugetlb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index f8a29d2..e6a8613 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -4,6 +4,7 @@
 #include 
 #include 
 
+#define hugepages_supported() cpu_has_pse
 
 static inline int is_hugepage_only_range(struct mm_struct *mm,
 unsigned long addr,


[tip:x86/asm] x86/mm/xen: Suppress hugetlbfs in PV guests

2016-04-22 Thread tip-bot for Jan Beulich
Commit-ID:  103f6112f253017d7062cd74d17f4a514ed4485c
Gitweb: http://git.kernel.org/tip/103f6112f253017d7062cd74d17f4a514ed4485c
Author: Jan Beulich 
AuthorDate: Thu, 21 Apr 2016 00:27:04 -0600
Committer:  Ingo Molnar 
CommitDate: Fri, 22 Apr 2016 10:05:00 +0200

x86/mm/xen: Suppress hugetlbfs in PV guests

Huge pages are not normally available to PV guests. Not suppressing
hugetlbfs use results in an endless loop of page faults when user mode
code tries to access a hugetlbfs mapped area (since the hypervisor
denies such PTEs to be created, but error indications can't be
propagated out of xen_set_pte_at(), just like for various of its
siblings), and - once killed in an oops like this:

  kernel BUG at .../fs/hugetlbfs/inode.c:428!
  invalid opcode:  [#1] SMP
  ...
  RIP: e030:[]  [] 
remove_inode_hugepages+0x25b/0x320
  ...
  Call Trace:
   [] hugetlbfs_evict_inode+0x15/0x40
   [] evict+0xbd/0x1b0
   [] __dentry_kill+0x19a/0x1f0
   [] dput+0x1fe/0x220
   [] __fput+0x155/0x200
   [] task_work_run+0x60/0xa0
   [] do_exit+0x160/0x400
   [] do_group_exit+0x3b/0xa0
   [] get_signal+0x1ed/0x470
   [] do_signal+0x14/0x110
   [] prepare_exit_to_usermode+0xe9/0xf0
   [] retint_user+0x8/0x13

This is CVE-2016-3961 / XSA-174.

Reported-by: Vitaly Kuznetsov 
Signed-off-by: Jan Beulich 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: David Vrabel 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Luis R. Rodriguez 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Toshi Kani 
Cc: sta...@vger.kernel.org
Cc: xen-devel 
Link: http://lkml.kernel.org/r/57188ed80278000e4...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/hugetlb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index f8a29d2..e6a8613 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -4,6 +4,7 @@
 #include 
 #include 
 
+#define hugepages_supported() cpu_has_pse
 
 static inline int is_hugepage_only_range(struct mm_struct *mm,
 unsigned long addr,


[tip:x86/mm] x86/mm: Avoid premature success when changing page attributes

2016-02-25 Thread tip-bot for Jan Beulich
Commit-ID:  405e1133d00e0271cedef75c17ecb773ff3e2732
Gitweb: http://git.kernel.org/tip/405e1133d00e0271cedef75c17ecb773ff3e2732
Author: Jan Beulich 
AuthorDate: Wed, 10 Feb 2016 02:03:00 -0700
Committer:  Thomas Gleixner 
CommitDate: Thu, 25 Feb 2016 10:41:43 +0100

x86/mm: Avoid premature success when changing page attributes

set_memory_nx() (and set_memory_x()) currently differ in behavior from
all other set_memory_*() functions when encountering a virtual address
space hole within the kernel address range: They stop processing at the
hole, but nevertheless report success (making the caller believe the
operation was carried out on the entire range). While observed to be a
problem - triggering the CONFIG_DEBUG_WX warning - only with out of
tree code, I suspect (but didn't check) that on x86-64 the
CONFIG_DEBUG_PAGEALLOC logic in free_init_pages() would, when called
from free_initmem(), have the same effect on the set_memory_nx() called
from mark_rodata_ro().

This unexpected behavior is a result of change_page_attr_set_clr()
special casing changes to only the NX bit, in that it passes "false" as
the "checkalias" argument to __change_page_attr_set_clr(). Since this
flag becomes the "primary" argument of both __change_page_attr() and
__cpa_process_fault(), the latter would so far return success without
adjusting cpa->numpages. Success to the higher level callers, however,
means that whatever cpa->numpages currently holds is the count of
successfully processed pages. The cases when __change_page_attr() calls
__cpa_process_fault(), otoh, don't generally mean the entire range got
processed (as can be seen from one of the two success return paths in
__cpa_process_fault() already adjusting ->numpages).

Signed-off-by: Jan Beulich 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/56bb0ad40278000d0...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/mm/pageattr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 2440814..3dd6afd 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1122,8 +1122,10 @@ static int __cpa_process_fault(struct cpa_data *cpa, 
unsigned long vaddr,
/*
 * Ignore all non primary paths.
 */
-   if (!primary)
+   if (!primary) {
+   cpa->numpages = 1;
return 0;
+   }
 
/*
 * Ignore the NULL PTE for kernel identity mapping, as it is expected


[tip:x86/mm] x86/mm: Avoid premature success when changing page attributes

2016-02-25 Thread tip-bot for Jan Beulich
Commit-ID:  405e1133d00e0271cedef75c17ecb773ff3e2732
Gitweb: http://git.kernel.org/tip/405e1133d00e0271cedef75c17ecb773ff3e2732
Author: Jan Beulich 
AuthorDate: Wed, 10 Feb 2016 02:03:00 -0700
Committer:  Thomas Gleixner 
CommitDate: Thu, 25 Feb 2016 10:41:43 +0100

x86/mm: Avoid premature success when changing page attributes

set_memory_nx() (and set_memory_x()) currently differ in behavior from
all other set_memory_*() functions when encountering a virtual address
space hole within the kernel address range: They stop processing at the
hole, but nevertheless report success (making the caller believe the
operation was carried out on the entire range). While observed to be a
problem - triggering the CONFIG_DEBUG_WX warning - only with out of
tree code, I suspect (but didn't check) that on x86-64 the
CONFIG_DEBUG_PAGEALLOC logic in free_init_pages() would, when called
from free_initmem(), have the same effect on the set_memory_nx() called
from mark_rodata_ro().

This unexpected behavior is a result of change_page_attr_set_clr()
special casing changes to only the NX bit, in that it passes "false" as
the "checkalias" argument to __change_page_attr_set_clr(). Since this
flag becomes the "primary" argument of both __change_page_attr() and
__cpa_process_fault(), the latter would so far return success without
adjusting cpa->numpages. Success to the higher level callers, however,
means that whatever cpa->numpages currently holds is the count of
successfully processed pages. The cases when __change_page_attr() calls
__cpa_process_fault(), otoh, don't generally mean the entire range got
processed (as can be seen from one of the two success return paths in
__cpa_process_fault() already adjusting ->numpages).

Signed-off-by: Jan Beulich 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/56bb0ad40278000d0...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/mm/pageattr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 2440814..3dd6afd 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1122,8 +1122,10 @@ static int __cpa_process_fault(struct cpa_data *cpa, 
unsigned long vaddr,
/*
 * Ignore all non primary paths.
 */
-   if (!primary)
+   if (!primary) {
+   cpa->numpages = 1;
return 0;
+   }
 
/*
 * Ignore the NULL PTE for kernel identity mapping, as it is expected


[tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability flags translations

2016-01-26 Thread tip-bot for Jan Beulich
Commit-ID:  3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Gitweb: http://git.kernel.org/tip/3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Author: Jan Beulich 
AuthorDate: Tue, 26 Jan 2016 04:15:18 -0700
Committer:  Thomas Gleixner 
CommitDate: Tue, 26 Jan 2016 21:05:36 +0100

x86/mm: Fix types used in pgprot cacheability flags translations

For PAE kernels "unsigned long" is not suitable to hold page protection
flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
few W+X pages getting reported as insecure during boot (observed namely
for the entire initrd range).

Fixes: 281d4078be ("x86: Make page cache mode a real type")
Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/56a763560278000ca...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/pgtable_types.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index a471cad..79c9185 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -363,20 +363,18 @@ static inline enum page_cache_mode 
pgprot2cachemode(pgprot_t pgprot)
 }
 static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
 {
+   pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
-   unsigned long val;
 
-   val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
return new;
 }
 static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
 {
+   pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
-   unsigned long val;
 
-   val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
  ((val & _PAGE_PAT_LARGE) >>
   (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));


[tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability flags translations

2016-01-26 Thread tip-bot for Jan Beulich
Commit-ID:  3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Gitweb: http://git.kernel.org/tip/3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Author: Jan Beulich 
AuthorDate: Tue, 26 Jan 2016 04:15:18 -0700
Committer:  Thomas Gleixner 
CommitDate: Tue, 26 Jan 2016 21:05:36 +0100

x86/mm: Fix types used in pgprot cacheability flags translations

For PAE kernels "unsigned long" is not suitable to hold page protection
flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
few W+X pages getting reported as insecure during boot (observed namely
for the entire initrd range).

Fixes: 281d4078be ("x86: Make page cache mode a real type")
Signed-off-by: Jan Beulich 
Reviewed-by: Juergen Gross 
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/56a763560278000ca...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/pgtable_types.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index a471cad..79c9185 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -363,20 +363,18 @@ static inline enum page_cache_mode 
pgprot2cachemode(pgprot_t pgprot)
 }
 static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
 {
+   pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
-   unsigned long val;
 
-   val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
return new;
 }
 static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
 {
+   pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
-   unsigned long val;
 
-   val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
  ((val & _PAGE_PAT_LARGE) >>
   (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));


[tip:x86/mm] x86/LDT: Print the real LDT base address

2015-12-29 Thread tip-bot for Jan Beulich
Commit-ID:  0d430e3fb3f7cdc13c0d22078b820f682821b45a
Gitweb: http://git.kernel.org/tip/0d430e3fb3f7cdc13c0d22078b820f682821b45a
Author: Jan Beulich 
AuthorDate: Tue, 22 Dec 2015 08:42:44 -0700
Committer:  Thomas Gleixner 
CommitDate: Tue, 29 Dec 2015 12:34:38 +0100

x86/LDT: Print the real LDT base address

This was meant to print base address and entry count; make it do so
again.

Fixes: 37868fe113ff "x86/ldt: Make modify_ldt synchronous"
Signed-off-by: Jan Beulich 
Acked-by: Andy Lutomirski 
Link: http://lkml.kernel.org/r/56797d840278000c2...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/process_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e835d26..b9d99e0 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -125,7 +125,7 @@ void release_thread(struct task_struct *dead_task)
if (dead_task->mm->context.ldt) {
pr_warn("WARNING: dead process %s still has LDT? 
<%p/%d>\n",
dead_task->comm,
-   dead_task->mm->context.ldt,
+   dead_task->mm->context.ldt->entries,
dead_task->mm->context.ldt->size);
BUG();
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/mm] x86/LDT: Print the real LDT base address

2015-12-29 Thread tip-bot for Jan Beulich
Commit-ID:  0d430e3fb3f7cdc13c0d22078b820f682821b45a
Gitweb: http://git.kernel.org/tip/0d430e3fb3f7cdc13c0d22078b820f682821b45a
Author: Jan Beulich 
AuthorDate: Tue, 22 Dec 2015 08:42:44 -0700
Committer:  Thomas Gleixner 
CommitDate: Tue, 29 Dec 2015 12:34:38 +0100

x86/LDT: Print the real LDT base address

This was meant to print base address and entry count; make it do so
again.

Fixes: 37868fe113ff "x86/ldt: Make modify_ldt synchronous"
Signed-off-by: Jan Beulich 
Acked-by: Andy Lutomirski 
Link: http://lkml.kernel.org/r/56797d840278000c2...@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/process_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e835d26..b9d99e0 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -125,7 +125,7 @@ void release_thread(struct task_struct *dead_task)
if (dead_task->mm->context.ldt) {
pr_warn("WARNING: dead process %s still has LDT? 
<%p/%d>\n",
dead_task->comm,
-   dead_task->mm->context.ldt,
+   dead_task->mm->context.ldt->entries,
dead_task->mm->context.ldt->size);
BUG();
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timers/x86/hpet: Type adjustments

2015-10-21 Thread tip-bot for Jan Beulich
Commit-ID:  3d45ac4b35cbdf942f2a45b2b927f2ef6a8bda48
Gitweb: http://git.kernel.org/tip/3d45ac4b35cbdf942f2a45b2b927f2ef6a8bda48
Author: Jan Beulich 
AuthorDate: Mon, 19 Oct 2015 04:35:44 -0600
Committer:  Ingo Molnar 
CommitDate: Wed, 21 Oct 2015 11:17:32 +0200

timers/x86/hpet: Type adjustments

Standardize on bool instead of an inconsistent mixture of u8 and plain 'int'.

Also use u32 or 'unsigned int' instead of 'unsigned long' when a 32-bit type
suffices, generating slightly better code on x86-64.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5624e3a00278000ac...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/hpet.h|  6 +++---
 arch/x86/kernel/early-quirks.c |  2 +-
 arch/x86/kernel/hpet.c | 29 ++---
 arch/x86/kernel/quirks.c   |  2 +-
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index 5fa9fb0..cc285ec 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -63,10 +63,10 @@
 /* hpet memory map physical address */
 extern unsigned long hpet_address;
 extern unsigned long force_hpet_address;
-extern int boot_hpet_disable;
+extern bool boot_hpet_disable;
 extern u8 hpet_blockid;
-extern int hpet_force_user;
-extern u8 hpet_msi_disable;
+extern bool hpet_force_user;
+extern bool hpet_msi_disable;
 extern int is_hpet_enabled(void);
 extern int hpet_enable(void);
 extern void hpet_disable(void);
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 9f9cc68..db9a675 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -584,7 +584,7 @@ static void __init intel_graphics_stolen(int num, int slot, 
int func)
 static void __init force_disable_hpet(int num, int slot, int func)
 {
 #ifdef CONFIG_HPET_TIMER
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
pr_info("x86/hpet: Will disable the HPET for this platform because it's 
not reliable\n");
 #endif
 }
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 88b4da3..b8e6ff5 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -37,10 +37,10 @@
  */
 unsigned long  hpet_address;
 u8 hpet_blockid; /* OS timer block num */
-u8 hpet_msi_disable;
+bool   hpet_msi_disable;
 
 #ifdef CONFIG_PCI_MSI
-static unsigned long   hpet_num_timers;
+static unsigned inthpet_num_timers;
 #endif
 static void __iomem*hpet_virt_address;
 
@@ -86,9 +86,9 @@ static inline void hpet_clear_mapping(void)
 /*
  * HPET command line enable / disable
  */
-int boot_hpet_disable;
-int hpet_force_user;
-static int hpet_verbose;
+bool boot_hpet_disable;
+bool hpet_force_user;
+static bool hpet_verbose;
 
 static int __init hpet_setup(char *str)
 {
@@ -98,11 +98,11 @@ static int __init hpet_setup(char *str)
if (next)
*next++ = 0;
if (!strncmp("disable", str, 7))
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
if (!strncmp("force", str, 5))
-   hpet_force_user = 1;
+   hpet_force_user = true;
if (!strncmp("verbose", str, 7))
-   hpet_verbose = 1;
+   hpet_verbose = true;
str = next;
}
return 1;
@@ -111,7 +111,7 @@ __setup("hpet=", hpet_setup);
 
 static int __init disable_hpet(char *str)
 {
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
return 1;
 }
 __setup("nohpet", disable_hpet);
@@ -124,7 +124,7 @@ static inline int is_hpet_capable(void)
 /*
  * HPET timer interrupt enable / disable
  */
-static int hpet_legacy_int_enabled;
+static bool hpet_legacy_int_enabled;
 
 /**
  * is_hpet_enabled - check whether the hpet timer interrupt is enabled
@@ -230,7 +230,7 @@ static struct clock_event_device hpet_clockevent;
 
 static void hpet_stop_counter(void)
 {
-   unsigned long cfg = hpet_readl(HPET_CFG);
+   u32 cfg = hpet_readl(HPET_CFG);
cfg &= ~HPET_CFG_ENABLE;
hpet_writel(cfg, HPET_CFG);
 }
@@ -272,7 +272,7 @@ static void hpet_enable_legacy_int(void)
 
cfg |= HPET_CFG_LEGACY;
hpet_writel(cfg, HPET_CFG);
-   hpet_legacy_int_enabled = 1;
+   hpet_legacy_int_enabled = true;
 }
 
 static void hpet_legacy_clockevent_register(void)
@@ -983,7 +983,7 @@ void hpet_disable(void)
cfg = *hpet_boot_cfg;
else if (hpet_legacy_int_enabled) {
cfg &= ~HPET_CFG_LEGACY;
-   

[tip:timers/core] timers/x86/hpet: Type adjustments

2015-10-21 Thread tip-bot for Jan Beulich
Commit-ID:  3d45ac4b35cbdf942f2a45b2b927f2ef6a8bda48
Gitweb: http://git.kernel.org/tip/3d45ac4b35cbdf942f2a45b2b927f2ef6a8bda48
Author: Jan Beulich 
AuthorDate: Mon, 19 Oct 2015 04:35:44 -0600
Committer:  Ingo Molnar 
CommitDate: Wed, 21 Oct 2015 11:17:32 +0200

timers/x86/hpet: Type adjustments

Standardize on bool instead of an inconsistent mixture of u8 and plain 'int'.

Also use u32 or 'unsigned int' instead of 'unsigned long' when a 32-bit type
suffices, generating slightly better code on x86-64.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5624e3a00278000ac...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/hpet.h|  6 +++---
 arch/x86/kernel/early-quirks.c |  2 +-
 arch/x86/kernel/hpet.c | 29 ++---
 arch/x86/kernel/quirks.c   |  2 +-
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index 5fa9fb0..cc285ec 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -63,10 +63,10 @@
 /* hpet memory map physical address */
 extern unsigned long hpet_address;
 extern unsigned long force_hpet_address;
-extern int boot_hpet_disable;
+extern bool boot_hpet_disable;
 extern u8 hpet_blockid;
-extern int hpet_force_user;
-extern u8 hpet_msi_disable;
+extern bool hpet_force_user;
+extern bool hpet_msi_disable;
 extern int is_hpet_enabled(void);
 extern int hpet_enable(void);
 extern void hpet_disable(void);
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 9f9cc68..db9a675 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -584,7 +584,7 @@ static void __init intel_graphics_stolen(int num, int slot, 
int func)
 static void __init force_disable_hpet(int num, int slot, int func)
 {
 #ifdef CONFIG_HPET_TIMER
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
pr_info("x86/hpet: Will disable the HPET for this platform because it's 
not reliable\n");
 #endif
 }
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 88b4da3..b8e6ff5 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -37,10 +37,10 @@
  */
 unsigned long  hpet_address;
 u8 hpet_blockid; /* OS timer block num */
-u8 hpet_msi_disable;
+bool   hpet_msi_disable;
 
 #ifdef CONFIG_PCI_MSI
-static unsigned long   hpet_num_timers;
+static unsigned inthpet_num_timers;
 #endif
 static void __iomem*hpet_virt_address;
 
@@ -86,9 +86,9 @@ static inline void hpet_clear_mapping(void)
 /*
  * HPET command line enable / disable
  */
-int boot_hpet_disable;
-int hpet_force_user;
-static int hpet_verbose;
+bool boot_hpet_disable;
+bool hpet_force_user;
+static bool hpet_verbose;
 
 static int __init hpet_setup(char *str)
 {
@@ -98,11 +98,11 @@ static int __init hpet_setup(char *str)
if (next)
*next++ = 0;
if (!strncmp("disable", str, 7))
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
if (!strncmp("force", str, 5))
-   hpet_force_user = 1;
+   hpet_force_user = true;
if (!strncmp("verbose", str, 7))
-   hpet_verbose = 1;
+   hpet_verbose = true;
str = next;
}
return 1;
@@ -111,7 +111,7 @@ __setup("hpet=", hpet_setup);
 
 static int __init disable_hpet(char *str)
 {
-   boot_hpet_disable = 1;
+   boot_hpet_disable = true;
return 1;
 }
 __setup("nohpet", disable_hpet);
@@ -124,7 +124,7 @@ static inline int is_hpet_capable(void)
 /*
  * HPET timer interrupt enable / disable
  */
-static int hpet_legacy_int_enabled;
+static bool hpet_legacy_int_enabled;
 
 /**
  * is_hpet_enabled - check whether the hpet timer interrupt is enabled
@@ -230,7 +230,7 @@ static struct clock_event_device hpet_clockevent;
 
 static void hpet_stop_counter(void)
 {
-   unsigned long cfg = hpet_readl(HPET_CFG);
+   u32 cfg = hpet_readl(HPET_CFG);
cfg &= ~HPET_CFG_ENABLE;
hpet_writel(cfg, HPET_CFG);
 }
@@ -272,7 +272,7 @@ static void hpet_enable_legacy_int(void)
 
cfg |= HPET_CFG_LEGACY;
hpet_writel(cfg, HPET_CFG);
-   hpet_legacy_int_enabled = 1;
+   hpet_legacy_int_enabled = true;
 }
 
 static void 

[tip:x86/urgent] x86/ldt: Fix small LDT allocation for Xen

2015-09-14 Thread tip-bot for Jan Beulich
Commit-ID:  f454b478861325f067fd58ba7ee9f1b5c4a9d6a0
Gitweb: http://git.kernel.org/tip/f454b478861325f067fd58ba7ee9f1b5c4a9d6a0
Author: Jan Beulich 
AuthorDate: Wed, 2 Sep 2015 09:45:58 -0600
Committer:  Ingo Molnar 
CommitDate: Mon, 14 Sep 2015 12:10:50 +0200

x86/ldt: Fix small LDT allocation for Xen

While the following commit:

  37868fe113 ("x86/ldt: Make modify_ldt synchronous")

added a nice comment explaining that Xen needs page-aligned
whole page chunks for guest descriptor tables, it then
nevertheless used kzalloc() on the small size path.

As I'm unaware of guarantees for kmalloc(PAGE_SIZE, ) to return
page-aligned memory blocks, I believe this needs to be switched
back to __get_free_page() (or better get_zeroed_page()).

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: David Vrabel 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Konrad Rzeszutek Wilk 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/55e735d602780009f...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/ldt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 2bcc052..6acc9dd 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -58,7 +58,7 @@ static struct ldt_struct *alloc_ldt_struct(int size)
if (alloc_size > PAGE_SIZE)
new_ldt->entries = vzalloc(alloc_size);
else
-   new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL);
 
if (!new_ldt->entries) {
kfree(new_ldt);
@@ -95,7 +95,7 @@ static void free_ldt_struct(struct ldt_struct *ldt)
if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE)
vfree(ldt->entries);
else
-   kfree(ldt->entries);
+   free_page((unsigned long)ldt->entries);
kfree(ldt);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/ldt: Fix small LDT allocation for Xen

2015-09-14 Thread tip-bot for Jan Beulich
Commit-ID:  f454b478861325f067fd58ba7ee9f1b5c4a9d6a0
Gitweb: http://git.kernel.org/tip/f454b478861325f067fd58ba7ee9f1b5c4a9d6a0
Author: Jan Beulich 
AuthorDate: Wed, 2 Sep 2015 09:45:58 -0600
Committer:  Ingo Molnar 
CommitDate: Mon, 14 Sep 2015 12:10:50 +0200

x86/ldt: Fix small LDT allocation for Xen

While the following commit:

  37868fe113 ("x86/ldt: Make modify_ldt synchronous")

added a nice comment explaining that Xen needs page-aligned
whole page chunks for guest descriptor tables, it then
nevertheless used kzalloc() on the small size path.

As I'm unaware of guarantees for kmalloc(PAGE_SIZE, ) to return
page-aligned memory blocks, I believe this needs to be switched
back to __get_free_page() (or better get_zeroed_page()).

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Boris Ostrovsky 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: David Vrabel 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Konrad Rzeszutek Wilk 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/55e735d602780009f...@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/ldt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 2bcc052..6acc9dd 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -58,7 +58,7 @@ static struct ldt_struct *alloc_ldt_struct(int size)
if (alloc_size > PAGE_SIZE)
new_ldt->entries = vzalloc(alloc_size);
else
-   new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL);
 
if (!new_ldt->entries) {
kfree(new_ldt);
@@ -95,7 +95,7 @@ static void free_ldt_struct(struct ldt_struct *ldt)
if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE)
vfree(ldt->entries);
else
-   kfree(ldt->entries);
+   free_page((unsigned long)ldt->entries);
kfree(ldt);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/mm/pat: Adjust default caching mode translation tables

2015-07-21 Thread tip-bot for Jan Beulich
Commit-ID:  ca1fec58bc6a90be96a59b4769e951156846c6ca
Gitweb: http://git.kernel.org/tip/ca1fec58bc6a90be96a59b4769e951156846c6ca
Author: Jan Beulich 
AuthorDate: Mon, 20 Jul 2015 08:46:14 +0100
Committer:  Ingo Molnar 
CommitDate: Tue, 21 Jul 2015 08:23:06 +0200

x86/mm/pat: Adjust default caching mode translation tables

Make WT really mean WT (rather than UC).

I can't see why commit 9cd25aac1f ("x86/mm/pat: Emulate PAT when
it is disabled") didn't make this to match its changes to
pat_init().

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Toshi Kani 
Link: http://lkml.kernel.org/r/55acc366027800092...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 8533b46..7a45322 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -43,18 +43,18 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
[_PAGE_CACHE_MODE_WC  ] = 0 | _PAGE_PCD,
[_PAGE_CACHE_MODE_UC_MINUS] = 0 | _PAGE_PCD,
[_PAGE_CACHE_MODE_UC  ] = _PAGE_PWT | _PAGE_PCD,
-   [_PAGE_CACHE_MODE_WT  ] = 0 | _PAGE_PCD,
+   [_PAGE_CACHE_MODE_WT  ] = _PAGE_PWT | 0,
[_PAGE_CACHE_MODE_WP  ] = 0 | _PAGE_PCD,
 };
 EXPORT_SYMBOL(__cachemode2pte_tbl);
 
 uint8_t __pte2cachemode_tbl[8] = {
[__pte2cm_idx( 0| 0 | 0)] = _PAGE_CACHE_MODE_WB,
-   [__pte2cm_idx(_PAGE_PWT | 0 | 0)] = 
_PAGE_CACHE_MODE_UC_MINUS,
+   [__pte2cm_idx(_PAGE_PWT | 0 | 0)] = _PAGE_CACHE_MODE_WT,
[__pte2cm_idx( 0| _PAGE_PCD | 0)] = 
_PAGE_CACHE_MODE_UC_MINUS,
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | 0)] = _PAGE_CACHE_MODE_UC,
[__pte2cm_idx( 0| 0 | _PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
-   [__pte2cm_idx(_PAGE_PWT | 0 | _PAGE_PAT)] = 
_PAGE_CACHE_MODE_UC_MINUS,
+   [__pte2cm_idx(_PAGE_PWT | 0 | _PAGE_PAT)] = _PAGE_CACHE_MODE_WT,
[__pte2cm_idx(0 | _PAGE_PCD | _PAGE_PAT)] = 
_PAGE_CACHE_MODE_UC_MINUS,
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
 };
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/fpu: Disable dependent CPU features on " noxsave"

2015-07-21 Thread tip-bot for Jan Beulich
Commit-ID:  5bc016f1abaa1c5ac0e3af23aa79faec4634a074
Gitweb: http://git.kernel.org/tip/5bc016f1abaa1c5ac0e3af23aa79faec4634a074
Author: Jan Beulich 
AuthorDate: Mon, 20 Jul 2015 08:49:01 +0100
Committer:  Ingo Molnar 
CommitDate: Tue, 21 Jul 2015 08:20:42 +0200

x86/fpu: Disable dependent CPU features on "noxsave"

Complete the set of dependent features that need disabling at
once: XSAVEC, AVX-512 and all currently known to the kernel
extensions to it, as well as MPX need to be disabled too.

Signed-off-by: Jan Beulich 
Cc: Dave Hansen 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/55acc40d027800092...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/init.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 0b39173..1e173f6 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -351,9 +351,15 @@ static int __init x86_noxsave_setup(char *s)
 
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
+   setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
setup_clear_cpu_cap(X86_FEATURE_XSAVES);
setup_clear_cpu_cap(X86_FEATURE_AVX);
setup_clear_cpu_cap(X86_FEATURE_AVX2);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512F);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
+   setup_clear_cpu_cap(X86_FEATURE_MPX);
 
return 1;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/mm/pat: Adjust default caching mode translation tables

2015-07-21 Thread tip-bot for Jan Beulich
Commit-ID:  ca1fec58bc6a90be96a59b4769e951156846c6ca
Gitweb: http://git.kernel.org/tip/ca1fec58bc6a90be96a59b4769e951156846c6ca
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 20 Jul 2015 08:46:14 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 21 Jul 2015 08:23:06 +0200

x86/mm/pat: Adjust default caching mode translation tables

Make WT really mean WT (rather than UC).

I can't see why commit 9cd25aac1f (x86/mm/pat: Emulate PAT when
it is disabled) didn't make this to match its changes to
pat_init().

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: Borislav Petkov b...@suse.de
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Cc: Toshi Kani toshi.k...@hp.com
Link: http://lkml.kernel.org/r/55acc366027800092...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 8533b46..7a45322 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -43,18 +43,18 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
[_PAGE_CACHE_MODE_WC  ] = 0 | _PAGE_PCD,
[_PAGE_CACHE_MODE_UC_MINUS] = 0 | _PAGE_PCD,
[_PAGE_CACHE_MODE_UC  ] = _PAGE_PWT | _PAGE_PCD,
-   [_PAGE_CACHE_MODE_WT  ] = 0 | _PAGE_PCD,
+   [_PAGE_CACHE_MODE_WT  ] = _PAGE_PWT | 0,
[_PAGE_CACHE_MODE_WP  ] = 0 | _PAGE_PCD,
 };
 EXPORT_SYMBOL(__cachemode2pte_tbl);
 
 uint8_t __pte2cachemode_tbl[8] = {
[__pte2cm_idx( 0| 0 | 0)] = _PAGE_CACHE_MODE_WB,
-   [__pte2cm_idx(_PAGE_PWT | 0 | 0)] = 
_PAGE_CACHE_MODE_UC_MINUS,
+   [__pte2cm_idx(_PAGE_PWT | 0 | 0)] = _PAGE_CACHE_MODE_WT,
[__pte2cm_idx( 0| _PAGE_PCD | 0)] = 
_PAGE_CACHE_MODE_UC_MINUS,
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | 0)] = _PAGE_CACHE_MODE_UC,
[__pte2cm_idx( 0| 0 | _PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
-   [__pte2cm_idx(_PAGE_PWT | 0 | _PAGE_PAT)] = 
_PAGE_CACHE_MODE_UC_MINUS,
+   [__pte2cm_idx(_PAGE_PWT | 0 | _PAGE_PAT)] = _PAGE_CACHE_MODE_WT,
[__pte2cm_idx(0 | _PAGE_PCD | _PAGE_PAT)] = 
_PAGE_CACHE_MODE_UC_MINUS,
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
 };
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/fpu: Disable dependent CPU features on noxsave

2015-07-21 Thread tip-bot for Jan Beulich
Commit-ID:  5bc016f1abaa1c5ac0e3af23aa79faec4634a074
Gitweb: http://git.kernel.org/tip/5bc016f1abaa1c5ac0e3af23aa79faec4634a074
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 20 Jul 2015 08:49:01 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 21 Jul 2015 08:20:42 +0200

x86/fpu: Disable dependent CPU features on noxsave

Complete the set of dependent features that need disabling at
once: XSAVEC, AVX-512 and all currently known to the kernel
extensions to it, as well as MPX need to be disabled too.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Dave Hansen dave.han...@linux.intel.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/55acc40d027800092...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/fpu/init.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 0b39173..1e173f6 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -351,9 +351,15 @@ static int __init x86_noxsave_setup(char *s)
 
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
+   setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
setup_clear_cpu_cap(X86_FEATURE_XSAVES);
setup_clear_cpu_cap(X86_FEATURE_AVX);
setup_clear_cpu_cap(X86_FEATURE_AVX2);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512F);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
+   setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
+   setup_clear_cpu_cap(X86_FEATURE_MPX);
 
return 1;
 }
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86/asm/entry/64: Fold identical code paths

2015-06-02 Thread tip-bot for Jan Beulich
Commit-ID:  2f63b9db7260beba3c19d66d6c11b0b78ea84a8c
Gitweb: http://git.kernel.org/tip/2f63b9db7260beba3c19d66d6c11b0b78ea84a8c
Author: Jan Beulich 
AuthorDate: Mon, 1 Jun 2015 13:03:59 +0100
Committer:  Ingo Molnar 
CommitDate: Tue, 2 Jun 2015 10:10:09 +0200

x86/asm/entry/64: Fold identical code paths

retint_kernel doesn't require %rcx to be pointing to thread info
(anymore?), and the code on the two alternative paths is - not
really surprisingly - identical.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/556c664f02780007f...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/entry_64.S | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b84cec5..4ad79e9 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -615,7 +615,7 @@ ret_from_intr:
testb   $3, CS(%rsp)
jz  retint_kernel
/* Interrupt came from user space */
-
+retint_user:
GET_THREAD_INFO(%rcx)
/*
 * %rcx: thread info. Interrupts off.
@@ -1194,15 +1194,9 @@ ENTRY(error_exit)
RESTORE_EXTRA_REGS
DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF
-   GET_THREAD_INFO(%rcx)
testl %eax,%eax
jnz retint_kernel
-   LOCKDEP_SYS_EXIT_IRQ
-   movl TI_flags(%rcx),%edx
-   movl $_TIF_WORK_MASK,%edi
-   andl %edi,%edx
-   jnz retint_careful
-   jmp retint_swapgs
+   jmp retint_user
 END(error_exit)
 
 /* Runs on exception stack */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86/asm/entry/64: Use negative immediates for stack adjustments

2015-06-02 Thread tip-bot for Jan Beulich
Commit-ID:  2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Gitweb: http://git.kernel.org/tip/2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Author: Jan Beulich 
AuthorDate: Mon, 1 Jun 2015 13:02:55 +0100
Committer:  Ingo Molnar 
CommitDate: Tue, 2 Jun 2015 10:10:09 +0200

x86/asm/entry/64: Use negative immediates for stack adjustments

Doing so allows adjustments by 128 bytes (occurring for
REMOVE_PT_GPREGS_FROM_STACK 8 uses) to be expressed with a
single byte immediate.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/556c660f02780007f...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/calling.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 0d76acc..f4e6308 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -89,7 +89,7 @@ For 32-bit we have the following conventions - kernel is 
built with
 #define SIZEOF_PTREGS  21*8
 
.macro ALLOC_PT_GPREGS_ON_STACK addskip=0
-   subq$15*8+\addskip, %rsp
+   addq$-(15*8+\addskip), %rsp
.endm
 
.macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
@@ -201,7 +201,7 @@ For 32-bit we have the following conventions - kernel is 
built with
.endm
 
.macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
-   addq $15*8+\addskip, %rsp
+   subq $-(15*8+\addskip), %rsp
.endm
 
.macro icebp
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86/asm/entry/64: Use negative immediates for stack adjustments

2015-06-02 Thread tip-bot for Jan Beulich
Commit-ID:  2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Gitweb: http://git.kernel.org/tip/2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 1 Jun 2015 13:02:55 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 2 Jun 2015 10:10:09 +0200

x86/asm/entry/64: Use negative immediates for stack adjustments

Doing so allows adjustments by 128 bytes (occurring for
REMOVE_PT_GPREGS_FROM_STACK 8 uses) to be expressed with a
single byte immediate.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: Borislav Petkov b...@alien8.de
Cc: Brian Gerst brge...@gmail.com
Cc: Denys Vlasenko dvlas...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/556c660f02780007f...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/calling.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 0d76acc..f4e6308 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -89,7 +89,7 @@ For 32-bit we have the following conventions - kernel is 
built with
 #define SIZEOF_PTREGS  21*8
 
.macro ALLOC_PT_GPREGS_ON_STACK addskip=0
-   subq$15*8+\addskip, %rsp
+   addq$-(15*8+\addskip), %rsp
.endm
 
.macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
@@ -201,7 +201,7 @@ For 32-bit we have the following conventions - kernel is 
built with
.endm
 
.macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
-   addq $15*8+\addskip, %rsp
+   subq $-(15*8+\addskip), %rsp
.endm
 
.macro icebp
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86/asm/entry/64: Fold identical code paths

2015-06-02 Thread tip-bot for Jan Beulich
Commit-ID:  2f63b9db7260beba3c19d66d6c11b0b78ea84a8c
Gitweb: http://git.kernel.org/tip/2f63b9db7260beba3c19d66d6c11b0b78ea84a8c
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 1 Jun 2015 13:03:59 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 2 Jun 2015 10:10:09 +0200

x86/asm/entry/64: Fold identical code paths

retint_kernel doesn't require %rcx to be pointing to thread info
(anymore?), and the code on the two alternative paths is - not
really surprisingly - identical.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: Andy Lutomirski l...@kernel.org
Cc: Borislav Petkov b...@alien8.de
Cc: Brian Gerst brge...@gmail.com
Cc: Denys Vlasenko dvlas...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/556c664f02780007f...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/entry_64.S | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b84cec5..4ad79e9 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -615,7 +615,7 @@ ret_from_intr:
testb   $3, CS(%rsp)
jz  retint_kernel
/* Interrupt came from user space */
-
+retint_user:
GET_THREAD_INFO(%rcx)
/*
 * %rcx: thread info. Interrupts off.
@@ -1194,15 +1194,9 @@ ENTRY(error_exit)
RESTORE_EXTRA_REGS
DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF
-   GET_THREAD_INFO(%rcx)
testl %eax,%eax
jnz retint_kernel
-   LOCKDEP_SYS_EXIT_IRQ
-   movl TI_flags(%rcx),%edx
-   movl $_TIF_WORK_MASK,%edi
-   andl %edi,%edx
-   jnz retint_careful
-   jmp retint_swapgs
+   jmp retint_user
 END(error_exit)
 
 /* Runs on exception stack */
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

2015-05-29 Thread tip-bot for Jan Beulich
Commit-ID:  7ba554b5ac69e5f3edac9ce3233beb5acd480878
Gitweb: http://git.kernel.org/tip/7ba554b5ac69e5f3edac9ce3233beb5acd480878
Author: Jan Beulich 
AuthorDate: Thu, 28 May 2015 09:16:45 +0100
Committer:  Ingo Molnar 
CommitDate: Fri, 29 May 2015 09:46:40 +0200

x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

While commit efa7045103 ("x86/asm/entry: Make user_mode() work
correctly if regs came from VM86 mode") claims that "user_mode()
is now identical to user_mode_vm()", this wasn't actually the
case - no prior commit made it so.

Signed-off-by: Jan Beulich 
Acked-by: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5566eb0d02780007e...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/ptrace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 19507ff..5fabf13 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -107,7 +107,7 @@ static inline unsigned long regs_return_value(struct 
pt_regs *regs)
 static inline int user_mode(struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
-   return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
+   return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >= 
USER_RPL;
 #else
return !!(regs->cs & 3);
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

2015-05-29 Thread tip-bot for Jan Beulich
Commit-ID:  7ba554b5ac69e5f3edac9ce3233beb5acd480878
Gitweb: http://git.kernel.org/tip/7ba554b5ac69e5f3edac9ce3233beb5acd480878
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Thu, 28 May 2015 09:16:45 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Fri, 29 May 2015 09:46:40 +0200

x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

While commit efa7045103 (x86/asm/entry: Make user_mode() work
correctly if regs came from VM86 mode) claims that user_mode()
is now identical to user_mode_vm(), this wasn't actually the
case - no prior commit made it so.

Signed-off-by: Jan Beulich jbeul...@suse.com
Acked-by: Andy Lutomirski l...@kernel.org
Cc: Andy Lutomirski l...@amacapital.net
Cc: Borislav Petkov b...@alien8.de
Cc: Brian Gerst brge...@gmail.com
Cc: Denys Vlasenko dvlas...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/5566eb0d02780007e...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/ptrace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 19507ff..5fabf13 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -107,7 +107,7 @@ static inline unsigned long regs_return_value(struct 
pt_regs *regs)
 static inline int user_mode(struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
-   return (regs-cs  SEGMENT_RPL_MASK) == USER_RPL;
+   return ((regs-cs  SEGMENT_RPL_MASK) | (regs-flags  X86_VM_MASK)) = 
USER_RPL;
 #else
return !!(regs-cs  3);
 #endif
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/mm] x86/mm: Mark arch_ioremap_p{m,u}d_supported() __init

2015-05-28 Thread tip-bot for Jan Beulich
Commit-ID:  1e6277de3a23373b89e0affc3d179f2173b857a4
Gitweb: http://git.kernel.org/tip/1e6277de3a23373b89e0affc3d179f2173b857a4
Author: Jan Beulich 
AuthorDate: Thu, 28 May 2015 09:29:27 +0100
Committer:  Ingo Molnar 
CommitDate: Thu, 28 May 2015 11:08:38 +0200

x86/mm: Mark arch_ioremap_p{m,u}d_supported() __init

... as their only caller is.

Signed-off-by: Jan Beulich 
Cc: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/5566ee0702780007e...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/ioremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 82d63ed..b0da358 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -365,7 +365,7 @@ void iounmap(volatile void __iomem *addr)
 }
 EXPORT_SYMBOL(iounmap);
 
-int arch_ioremap_pud_supported(void)
+int __init arch_ioremap_pud_supported(void)
 {
 #ifdef CONFIG_X86_64
return cpu_has_gbpages;
@@ -374,7 +374,7 @@ int arch_ioremap_pud_supported(void)
 #endif
 }
 
-int arch_ioremap_pmd_supported(void)
+int __init arch_ioremap_pmd_supported(void)
 {
return cpu_has_pse;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/mm] x86/mm: Mark arch_ioremap_p{m,u}d_supported() __init

2015-05-28 Thread tip-bot for Jan Beulich
Commit-ID:  1e6277de3a23373b89e0affc3d179f2173b857a4
Gitweb: http://git.kernel.org/tip/1e6277de3a23373b89e0affc3d179f2173b857a4
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Thu, 28 May 2015 09:29:27 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 28 May 2015 11:08:38 +0200

x86/mm: Mark arch_ioremap_p{m,u}d_supported() __init

... as their only caller is.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Borislav Petkov b...@alien8.de
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/5566ee0702780007e...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/ioremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 82d63ed..b0da358 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -365,7 +365,7 @@ void iounmap(volatile void __iomem *addr)
 }
 EXPORT_SYMBOL(iounmap);
 
-int arch_ioremap_pud_supported(void)
+int __init arch_ioremap_pud_supported(void)
 {
 #ifdef CONFIG_X86_64
return cpu_has_gbpages;
@@ -374,7 +374,7 @@ int arch_ioremap_pud_supported(void)
 #endif
 }
 
-int arch_ioremap_pmd_supported(void)
+int __init arch_ioremap_pmd_supported(void)
 {
return cpu_has_pse;
 }
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  0cdb81bef20b1d9e12111fa6cd81f748ebd87778
Gitweb: http://git.kernel.org/tip/0cdb81bef20b1d9e12111fa6cd81f748ebd87778
Author: Jan Beulich 
AuthorDate: Fri, 23 Jan 2015 08:35:13 +
Committer:  Ingo Molnar 
CommitDate: Thu, 19 Feb 2015 02:18:26 +0100

x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

Not just setting it when the feature is available is for
consistency, and may allow Xen to drop its custom clearing of
the flag (unless it needs it cleared earlier than this code
executes). Note that the change is benign to ix86, as the flag
starts out clear there.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/54c215d1027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 079c3b6..090499a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -179,7 +179,8 @@ static void __init probe_page_size_mask(void)
if (cpu_has_pge) {
set_in_cr4(X86_CR4_PGE);
__supported_pte_mask |= _PAGE_GLOBAL;
-   }
+   } else
+   __supported_pte_mask &= ~_PAGE_GLOBAL;
 }
 
 #ifdef CONFIG_X86_32
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:irq/core] irqflags: Fix (at least latent) code generation issue

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  db2dcb4f91d5fec5c346a82c309187ee821e2495
Gitweb: http://git.kernel.org/tip/db2dcb4f91d5fec5c346a82c309187ee821e2495
Author: Jan Beulich 
AuthorDate: Tue, 20 Jan 2015 13:00:46 +
Committer:  Ingo Molnar 
CommitDate: Thu, 19 Feb 2015 01:08:42 +0100

irqflags: Fix (at least latent) code generation issue

The conditional in local_irq_restore() otherwise can cause code
bloat (the if and else blocks may get translated into separate
code paths despite the generated code being identical, dependent
on compiler internal heuristics). Note that this adjustment gets
the code in sync with the comment preceding it (which was
slightly wrong from at least from 2.6.37 onwards).

The code bloat was observed in reality with an experimental x86
patch.

Signed-off-by: Jan Beulich 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/54be5f8e027800057...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 include/linux/irqflags.h | 43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index d176d65..5dd1272 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -85,7 +85,7 @@
  * The local_irq_*() APIs are equal to the raw_local_irq*()
  * if !TRACE_IRQFLAGS.
  */
-#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+#ifdef CONFIG_TRACE_IRQFLAGS
 #define local_irq_enable() \
do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
 #define local_irq_disable() \
@@ -107,22 +107,6 @@
raw_local_irq_restore(flags);   \
}   \
} while (0)
-#define local_save_flags(flags)\
-   do {\
-   raw_local_save_flags(flags);\
-   } while (0)
-
-#define irqs_disabled_flags(flags) \
-   ({  \
-   raw_irqs_disabled_flags(flags); \
-   })
-
-#define irqs_disabled()\
-   ({  \
-   unsigned long _flags;   \
-   raw_local_save_flags(_flags);   \
-   raw_irqs_disabled_flags(_flags);\
-   })
 
 #define safe_halt()\
do {\
@@ -131,7 +115,7 @@
} while (0)
 
 
-#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
+#else /* !CONFIG_TRACE_IRQFLAGS */
 
 #define local_irq_enable() do { raw_local_irq_enable(); } while (0)
 #define local_irq_disable()do { raw_local_irq_disable(); } while (0)
@@ -140,11 +124,28 @@
raw_local_irq_save(flags);  \
} while (0)
 #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
-#define local_save_flags(flags)do { raw_local_save_flags(flags); } 
while (0)
-#define irqs_disabled()(raw_irqs_disabled())
-#define irqs_disabled_flags(flags) (raw_irqs_disabled_flags(flags))
 #define safe_halt()do { raw_safe_halt(); } while (0)
 
+#endif /* CONFIG_TRACE_IRQFLAGS */
+
+#define local_save_flags(flags)raw_local_save_flags(flags)
+
+/*
+ * Some architectures don't define arch_irqs_disabled(), so even if either
+ * definition would be fine we need to use different ones for the time being
+ * to avoid build issues.
+ */
+#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+#define irqs_disabled()\
+   ({  \
+   unsigned long _flags;   \
+   raw_local_save_flags(_flags);   \
+   raw_irqs_disabled_flags(_flags);\
+   })
+#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
+#define irqs_disabled()raw_irqs_disabled()
 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
 
+#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
+
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  3ebfaff2bbd1d2ef882e475245d9f0276f21fe83
Gitweb: http://git.kernel.org/tip/3ebfaff2bbd1d2ef882e475245d9f0276f21fe83
Author: Jan Beulich 
AuthorDate: Fri, 23 Jan 2015 08:35:13 +
Committer:  Ingo Molnar 
CommitDate: Thu, 19 Feb 2015 00:44:46 +0100

x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

Not just setting it when the feature is available is for
consistency, and may allow Xen to drop its custom clearing of
the flag (unless it needs it cleared earlier than this code
executes). Note that the change is benign to ix86, as the flag
starts out clear there.

Signed-off-by: Jan Beulich 
Cc: Andy Lutomirski 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/54c215d1027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 079c3b6..090499a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -179,7 +179,8 @@ static void __init probe_page_size_mask(void)
if (cpu_has_pge) {
set_in_cr4(X86_CR4_PGE);
__supported_pte_mask |= _PAGE_GLOBAL;
-   }
+   } else
+   __supported_pte_mask &= ~_PAGE_GLOBAL;
 }
 
 #ifdef CONFIG_X86_32
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Simplify X86_UP_APIC handling

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  50849eefea3ba8aa6e540e0cbdc9533098f25656
Gitweb: http://git.kernel.org/tip/50849eefea3ba8aa6e540e0cbdc9533098f25656
Author: Jan Beulich 
AuthorDate: Thu, 5 Feb 2015 15:31:56 +
Committer:  Ingo Molnar 
CommitDate: Wed, 18 Feb 2015 22:10:54 +0100

x86/Kconfig: Simplify X86_UP_APIC handling

We don't really need a helper symbol for that. For one, it's
pointlessly getting set to Y for all configurations (even 64-bit
ones). And then the purpose can be fulfilled by suitably
adjusting X86_UP_APIC: Hide its prompt when PCI_MSI, and default
it to PCI_MSI.

Tested-by: Bryan O'Donoghue 
Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/54d39afc02780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index afb75f5..c226c2b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -859,7 +859,8 @@ config UP_LATE_INIT
depends on !SMP && X86_LOCAL_APIC
 
 config X86_UP_APIC
-   bool "Local APIC support on uniprocessors"
+   bool "Local APIC support on uniprocessors" if !PCI_MSI
+   default PCI_MSI
depends on X86_32 && !SMP && !X86_32_NON_STANDARD
---help---
  A local APIC (Advanced Programmable Interrupt Controller) is an
@@ -871,10 +872,6 @@ config X86_UP_APIC
  performance counters), and the NMI watchdog which detects hard
  lockups.
 
-config X86_UP_APIC_MSI
-   def_bool y
-   select X86_UP_APIC if X86_32 && !SMP && !X86_32_NON_STANDARD && PCI_MSI
-
 config X86_UP_IOAPIC
bool "IO-APIC support on uniprocessors"
depends on X86_UP_APIC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Avoid issuing pointless turned off entries to .config

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  e0fd24a3b4ad7b4084b41944835952eedec53f98
Gitweb: http://git.kernel.org/tip/e0fd24a3b4ad7b4084b41944835952eedec53f98
Author: Jan Beulich 
AuthorDate: Thu, 5 Feb 2015 15:39:34 +
Committer:  Ingo Molnar 
CommitDate: Wed, 18 Feb 2015 22:08:46 +0100

x86/Kconfig: Avoid issuing pointless turned off entries to .config

Settings without prompts shouldn't normally have defaults other
than Y, as otherwise they (a) needlessly enlarge the resulting
.config and (b) if they ever get a prompt added later, the
tracked setting of off will prevent the devloper from then being
prompted for his/her choice when doing an incremental update of
the configuration (make oldconfig).

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/54d39cc602780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5e28e2b..463d883 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -233,12 +233,10 @@ config ARCH_WANT_GENERAL_HUGETLB
def_bool y
 
 config ZONE_DMA32
-   bool
-   default X86_64
+   def_bool y if X86_64
 
 config AUDIT_ARCH
-   bool
-   default X86_64
+   def_bool y if X86_64
 
 config ARCH_SUPPORTS_OPTIMIZED_INLINING
def_bool y
@@ -1115,10 +1113,10 @@ config MICROCODE_OLD_INTERFACE
depends on MICROCODE
 
 config MICROCODE_INTEL_EARLY
-   def_bool n
+   bool
 
 config MICROCODE_AMD_EARLY
-   def_bool n
+   bool
 
 config MICROCODE_EARLY
bool "Early load microcode"
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Simplify X86_IO_APIC dependencies

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  b1da1e715d4faf01468b7f45f7098922bc85ea8e
Gitweb: http://git.kernel.org/tip/b1da1e715d4faf01468b7f45f7098922bc85ea8e
Author: Jan Beulich 
AuthorDate: Thu, 5 Feb 2015 15:35:21 +
Committer:  Ingo Molnar 
CommitDate: Wed, 18 Feb 2015 22:09:33 +0100

x86/Kconfig: Simplify X86_IO_APIC dependencies

Since dependencies are transitive, we don't really need to
repeat those of X86_UP_IOAPIC.

Furthermore avoid the symbol getting entered into .config when
it is off by having the default simply Y and the dependencies
solely handled via the intended for that purpose "depends on".

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/54d39bc902780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 463d883..afb75f5 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -893,8 +893,8 @@ config X86_LOCAL_APIC
select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 
 config X86_IO_APIC
-   def_bool X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC
-   depends on X86_LOCAL_APIC
+   def_bool y
+   depends on X86_LOCAL_APIC || X86_UP_IOAPIC
select IRQ_DOMAIN
 
 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/numa: Avoid some pointless iterations

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  890a5409f9d0c84d75a1e16eebdfe91d8a57ef1e
Gitweb: http://git.kernel.org/tip/890a5409f9d0c84d75a1e16eebdfe91d8a57ef1e
Author: Jan Beulich 
AuthorDate: Mon, 9 Feb 2015 12:30:00 +0100
Committer:  Ingo Molnar 
CommitDate: Wed, 18 Feb 2015 16:18:02 +0100

sched/numa: Avoid some pointless iterations

Commit 81907478c431 ("sched/fair: Avoid using uninitialized variable
in preferred_group_nid()") unconditionally initializes max_group with
NODE_MASK_NONE, this means that when !max_faults (max_group didn't get
set), we'll now continue the iteration with an empty mask.

Which in turn makes the actual body of the loop go away, so we'll just
iterate until completion; short circuit this by breaking out of the
loop as soon as this would happen.

Signed-off-by: Jan Beulich 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Link: 
http://lkml.kernel.org/r/20150209113727.gs5...@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 28cbaca..ee595ef 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1774,6 +1774,8 @@ static int preferred_group_nid(struct task_struct *p, int 
nid)
}
}
/* Next round, evaluate the nodes within max_group. */
+   if (!max_faults)
+   break;
nodes = max_group;
}
return nid;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/numa: Avoid some pointless iterations

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  890a5409f9d0c84d75a1e16eebdfe91d8a57ef1e
Gitweb: http://git.kernel.org/tip/890a5409f9d0c84d75a1e16eebdfe91d8a57ef1e
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 9 Feb 2015 12:30:00 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 18 Feb 2015 16:18:02 +0100

sched/numa: Avoid some pointless iterations

Commit 81907478c431 (sched/fair: Avoid using uninitialized variable
in preferred_group_nid()) unconditionally initializes max_group with
NODE_MASK_NONE, this means that when !max_faults (max_group didn't get
set), we'll now continue the iteration with an empty mask.

Which in turn makes the actual body of the loop go away, so we'll just
iterate until completion; short circuit this by breaking out of the
loop as soon as this would happen.

Signed-off-by: Jan Beulich jbeul...@suse.com
Signed-off-by: Peter Zijlstra (Intel) pet...@infradead.org
Cc: Linus Torvalds torva...@linux-foundation.org
Link: 
http://lkml.kernel.org/r/20150209113727.gs5...@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 28cbaca..ee595ef 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1774,6 +1774,8 @@ static int preferred_group_nid(struct task_struct *p, int 
nid)
}
}
/* Next round, evaluate the nodes within max_group. */
+   if (!max_faults)
+   break;
nodes = max_group;
}
return nid;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:irq/core] irqflags: Fix (at least latent) code generation issue

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  db2dcb4f91d5fec5c346a82c309187ee821e2495
Gitweb: http://git.kernel.org/tip/db2dcb4f91d5fec5c346a82c309187ee821e2495
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Tue, 20 Jan 2015 13:00:46 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 19 Feb 2015 01:08:42 +0100

irqflags: Fix (at least latent) code generation issue

The conditional in local_irq_restore() otherwise can cause code
bloat (the if and else blocks may get translated into separate
code paths despite the generated code being identical, dependent
on compiler internal heuristics). Note that this adjustment gets
the code in sync with the comment preceding it (which was
slightly wrong from at least from 2.6.37 onwards).

The code bloat was observed in reality with an experimental x86
patch.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Steven Rostedt rost...@goodmis.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/54be5f8e027800057...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 include/linux/irqflags.h | 43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index d176d65..5dd1272 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -85,7 +85,7 @@
  * The local_irq_*() APIs are equal to the raw_local_irq*()
  * if !TRACE_IRQFLAGS.
  */
-#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+#ifdef CONFIG_TRACE_IRQFLAGS
 #define local_irq_enable() \
do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
 #define local_irq_disable() \
@@ -107,22 +107,6 @@
raw_local_irq_restore(flags);   \
}   \
} while (0)
-#define local_save_flags(flags)\
-   do {\
-   raw_local_save_flags(flags);\
-   } while (0)
-
-#define irqs_disabled_flags(flags) \
-   ({  \
-   raw_irqs_disabled_flags(flags); \
-   })
-
-#define irqs_disabled()\
-   ({  \
-   unsigned long _flags;   \
-   raw_local_save_flags(_flags);   \
-   raw_irqs_disabled_flags(_flags);\
-   })
 
 #define safe_halt()\
do {\
@@ -131,7 +115,7 @@
} while (0)
 
 
-#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
+#else /* !CONFIG_TRACE_IRQFLAGS */
 
 #define local_irq_enable() do { raw_local_irq_enable(); } while (0)
 #define local_irq_disable()do { raw_local_irq_disable(); } while (0)
@@ -140,11 +124,28 @@
raw_local_irq_save(flags);  \
} while (0)
 #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
-#define local_save_flags(flags)do { raw_local_save_flags(flags); } 
while (0)
-#define irqs_disabled()(raw_irqs_disabled())
-#define irqs_disabled_flags(flags) (raw_irqs_disabled_flags(flags))
 #define safe_halt()do { raw_safe_halt(); } while (0)
 
+#endif /* CONFIG_TRACE_IRQFLAGS */
+
+#define local_save_flags(flags)raw_local_save_flags(flags)
+
+/*
+ * Some architectures don't define arch_irqs_disabled(), so even if either
+ * definition would be fine we need to use different ones for the time being
+ * to avoid build issues.
+ */
+#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+#define irqs_disabled()\
+   ({  \
+   unsigned long _flags;   \
+   raw_local_save_flags(_flags);   \
+   raw_irqs_disabled_flags(_flags);\
+   })
+#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
+#define irqs_disabled()raw_irqs_disabled()
 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
 
+#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
+
 #endif
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  3ebfaff2bbd1d2ef882e475245d9f0276f21fe83
Gitweb: http://git.kernel.org/tip/3ebfaff2bbd1d2ef882e475245d9f0276f21fe83
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Fri, 23 Jan 2015 08:35:13 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 19 Feb 2015 00:44:46 +0100

x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

Not just setting it when the feature is available is for
consistency, and may allow Xen to drop its custom clearing of
the flag (unless it needs it cleared earlier than this code
executes). Note that the change is benign to ix86, as the flag
starts out clear there.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: H. Peter Anvin h...@zytor.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/54c215d1027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 079c3b6..090499a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -179,7 +179,8 @@ static void __init probe_page_size_mask(void)
if (cpu_has_pge) {
set_in_cr4(X86_CR4_PGE);
__supported_pte_mask |= _PAGE_GLOBAL;
-   }
+   } else
+   __supported_pte_mask = ~_PAGE_GLOBAL;
 }
 
 #ifdef CONFIG_X86_32
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Simplify X86_IO_APIC dependencies

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  b1da1e715d4faf01468b7f45f7098922bc85ea8e
Gitweb: http://git.kernel.org/tip/b1da1e715d4faf01468b7f45f7098922bc85ea8e
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Thu, 5 Feb 2015 15:35:21 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 18 Feb 2015 22:09:33 +0100

x86/Kconfig: Simplify X86_IO_APIC dependencies

Since dependencies are transitive, we don't really need to
repeat those of X86_UP_IOAPIC.

Furthermore avoid the symbol getting entered into .config when
it is off by having the default simply Y and the dependencies
solely handled via the intended for that purpose depends on.

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/54d39bc902780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 463d883..afb75f5 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -893,8 +893,8 @@ config X86_LOCAL_APIC
select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 
 config X86_IO_APIC
-   def_bool X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC
-   depends on X86_LOCAL_APIC
+   def_bool y
+   depends on X86_LOCAL_APIC || X86_UP_IOAPIC
select IRQ_DOMAIN
 
 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/asm] x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  0cdb81bef20b1d9e12111fa6cd81f748ebd87778
Gitweb: http://git.kernel.org/tip/0cdb81bef20b1d9e12111fa6cd81f748ebd87778
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Fri, 23 Jan 2015 08:35:13 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 19 Feb 2015 02:18:26 +0100

x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge

Not just setting it when the feature is available is for
consistency, and may allow Xen to drop its custom clearing of
the flag (unless it needs it cleared earlier than this code
executes). Note that the change is benign to ix86, as the flag
starts out clear there.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: H. Peter Anvin h...@zytor.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/54c215d1027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 079c3b6..090499a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -179,7 +179,8 @@ static void __init probe_page_size_mask(void)
if (cpu_has_pge) {
set_in_cr4(X86_CR4_PGE);
__supported_pte_mask |= _PAGE_GLOBAL;
-   }
+   } else
+   __supported_pte_mask = ~_PAGE_GLOBAL;
 }
 
 #ifdef CONFIG_X86_32
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Simplify X86_UP_APIC handling

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  50849eefea3ba8aa6e540e0cbdc9533098f25656
Gitweb: http://git.kernel.org/tip/50849eefea3ba8aa6e540e0cbdc9533098f25656
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Thu, 5 Feb 2015 15:31:56 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 18 Feb 2015 22:10:54 +0100

x86/Kconfig: Simplify X86_UP_APIC handling

We don't really need a helper symbol for that. For one, it's
pointlessly getting set to Y for all configurations (even 64-bit
ones). And then the purpose can be fulfilled by suitably
adjusting X86_UP_APIC: Hide its prompt when PCI_MSI, and default
it to PCI_MSI.

Tested-by: Bryan O'Donoghue pure.lo...@nexus-software.ie
Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/54d39afc02780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Kconfig | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index afb75f5..c226c2b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -859,7 +859,8 @@ config UP_LATE_INIT
depends on !SMP  X86_LOCAL_APIC
 
 config X86_UP_APIC
-   bool Local APIC support on uniprocessors
+   bool Local APIC support on uniprocessors if !PCI_MSI
+   default PCI_MSI
depends on X86_32  !SMP  !X86_32_NON_STANDARD
---help---
  A local APIC (Advanced Programmable Interrupt Controller) is an
@@ -871,10 +872,6 @@ config X86_UP_APIC
  performance counters), and the NMI watchdog which detects hard
  lockups.
 
-config X86_UP_APIC_MSI
-   def_bool y
-   select X86_UP_APIC if X86_32  !SMP  !X86_32_NON_STANDARD  PCI_MSI
-
 config X86_UP_IOAPIC
bool IO-APIC support on uniprocessors
depends on X86_UP_APIC
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/build] x86/Kconfig: Avoid issuing pointless turned off entries to .config

2015-02-18 Thread tip-bot for Jan Beulich
Commit-ID:  e0fd24a3b4ad7b4084b41944835952eedec53f98
Gitweb: http://git.kernel.org/tip/e0fd24a3b4ad7b4084b41944835952eedec53f98
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Thu, 5 Feb 2015 15:39:34 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 18 Feb 2015 22:08:46 +0100

x86/Kconfig: Avoid issuing pointless turned off entries to .config

Settings without prompts shouldn't normally have defaults other
than Y, as otherwise they (a) needlessly enlarge the resulting
.config and (b) if they ever get a prompt added later, the
tracked setting of off will prevent the devloper from then being
prompted for his/her choice when doing an incremental update of
the configuration (make oldconfig).

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/54d39cc602780005d...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Kconfig | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5e28e2b..463d883 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -233,12 +233,10 @@ config ARCH_WANT_GENERAL_HUGETLB
def_bool y
 
 config ZONE_DMA32
-   bool
-   default X86_64
+   def_bool y if X86_64
 
 config AUDIT_ARCH
-   bool
-   default X86_64
+   def_bool y if X86_64
 
 config ARCH_SUPPORTS_OPTIMIZED_INLINING
def_bool y
@@ -1115,10 +1113,10 @@ config MICROCODE_OLD_INTERFACE
depends on MICROCODE
 
 config MICROCODE_INTEL_EARLY
-   def_bool n
+   bool
 
 config MICROCODE_AMD_EARLY
-   def_bool n
+   bool
 
 config MICROCODE_EARLY
bool Early load microcode
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/urgent] sched/fair: Avoid using uninitialized variable in preferred_group_nid()

2015-01-28 Thread tip-bot for Jan Beulich
Commit-ID:  81907478c4311a679849216abf723999184ab984
Gitweb: http://git.kernel.org/tip/81907478c4311a679849216abf723999184ab984
Author: Jan Beulich 
AuthorDate: Fri, 23 Jan 2015 08:25:38 +
Committer:  Ingo Molnar 
CommitDate: Wed, 28 Jan 2015 13:14:12 +0100

sched/fair: Avoid using uninitialized variable in preferred_group_nid()

At least some gcc versions - validly afaict - warn about potentially
using max_group uninitialized: There's no way the compiler can prove
that the body of the conditional where it and max_faults get set/
updated gets executed; in fact, without knowing all the details of
other scheduler code, I can't prove this either.

Generally the necessary change would appear to be to clear max_group
prior to entering the inner loop, and break out of the outer loop when
it ends up being all clear after the inner one. This, however, seems
inefficient, and afaict the same effect can be achieved by exiting the
outer loop when max_faults is still zero after the inner loop.

[ mingo: changed the solution to zero initialization: uninitialized_var()
  needs to die, as it's an actively dangerous construct: if in the future
  a known-proven-good piece of code is changed to have a true, buggy
  uninitialized variable, the compiler warning is then supressed...

  The better long term solution is to clean up the code flow, so that
  even simple minded compilers (and humans!) are able to read it without
  getting a headache.  ]

Signed-off-by: Jan Beulich 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Rik van Riel 
Cc: Linus Torvalds 
Link: http://lkml.kernel.org/r/54c21392027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 40667cb..fe331fc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1730,7 +1730,7 @@ static int preferred_group_nid(struct task_struct *p, int 
nid)
nodes = node_online_map;
for (dist = sched_max_numa_distance; dist > LOCAL_DISTANCE; dist--) {
unsigned long max_faults = 0;
-   nodemask_t max_group;
+   nodemask_t max_group = NODE_MASK_NONE;
int a, b;
 
/* Are there nodes at this distance from each other? */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/urgent] sched/fair: Avoid using uninitialized variable in preferred_group_nid()

2015-01-28 Thread tip-bot for Jan Beulich
Commit-ID:  81907478c4311a679849216abf723999184ab984
Gitweb: http://git.kernel.org/tip/81907478c4311a679849216abf723999184ab984
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Fri, 23 Jan 2015 08:25:38 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 28 Jan 2015 13:14:12 +0100

sched/fair: Avoid using uninitialized variable in preferred_group_nid()

At least some gcc versions - validly afaict - warn about potentially
using max_group uninitialized: There's no way the compiler can prove
that the body of the conditional where it and max_faults get set/
updated gets executed; in fact, without knowing all the details of
other scheduler code, I can't prove this either.

Generally the necessary change would appear to be to clear max_group
prior to entering the inner loop, and break out of the outer loop when
it ends up being all clear after the inner one. This, however, seems
inefficient, and afaict the same effect can be achieved by exiting the
outer loop when max_faults is still zero after the inner loop.

[ mingo: changed the solution to zero initialization: uninitialized_var()
  needs to die, as it's an actively dangerous construct: if in the future
  a known-proven-good piece of code is changed to have a true, buggy
  uninitialized variable, the compiler warning is then supressed...

  The better long term solution is to clean up the code flow, so that
  even simple minded compilers (and humans!) are able to read it without
  getting a headache.  ]

Signed-off-by: Jan Beulich jbeul...@suse.com
Signed-off-by: Peter Zijlstra (Intel) pet...@infradead.org
Cc: Rik van Riel r...@redhat.com
Cc: Linus Torvalds torva...@linux-foundation.org
Link: http://lkml.kernel.org/r/54c21392027800058...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 40667cb..fe331fc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1730,7 +1730,7 @@ static int preferred_group_nid(struct task_struct *p, int 
nid)
nodes = node_online_map;
for (dist = sched_max_numa_distance; dist  LOCAL_DISTANCE; dist--) {
unsigned long max_faults = 0;
-   nodemask_t max_group;
+   nodemask_t max_group = NODE_MASK_NONE;
int a, b;
 
/* Are there nodes at this distance from each other? */
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86, irq: Properly tag virtualization entry in / proc/interrupts

2015-01-20 Thread tip-bot for Jan Beulich
Commit-ID:  4a0d3107d6b19125f21172c2b7d95f9c30ecaf6f
Gitweb: http://git.kernel.org/tip/4a0d3107d6b19125f21172c2b7d95f9c30ecaf6f
Author: Jan Beulich 
AuthorDate: Fri, 16 Jan 2015 15:47:07 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 20 Jan 2015 12:37:23 +0100

x86, irq: Properly tag virtualization entry in /proc/interrupts

The mis-naming likely was a copy-and-paste effect.

Signed-off-by: Jan Beulich 
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/54b9408b027800055...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 6307a0f..705ef8d 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -127,7 +127,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
seq_puts(p, "  Machine check polls\n");
 #endif
 #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
-   seq_printf(p, "%*s: ", prec, "THR");
+   seq_printf(p, "%*s: ", prec, "HYP");
for_each_online_cpu(j)
seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
seq_puts(p, "  Hypervisor callback interrupts\n");
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86, irq: Properly tag virtualization entry in / proc/interrupts

2015-01-20 Thread tip-bot for Jan Beulich
Commit-ID:  4a0d3107d6b19125f21172c2b7d95f9c30ecaf6f
Gitweb: http://git.kernel.org/tip/4a0d3107d6b19125f21172c2b7d95f9c30ecaf6f
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Fri, 16 Jan 2015 15:47:07 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 20 Jan 2015 12:37:23 +0100

x86, irq: Properly tag virtualization entry in /proc/interrupts

The mis-naming likely was a copy-and-paste effect.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/54b9408b027800055...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/kernel/irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 6307a0f..705ef8d 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -127,7 +127,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
seq_puts(p,   Machine check polls\n);
 #endif
 #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
-   seq_printf(p, %*s: , prec, THR);
+   seq_printf(p, %*s: , prec, HYP);
for_each_online_cpu(j)
seq_printf(p, %10u , irq_stats(j)-irq_hv_callback_count);
seq_puts(p,   Hypervisor callback interrupts\n);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/urgent] x86: Fix step size adjustment during initial memory mapping

2014-12-23 Thread tip-bot for Jan Beulich
Commit-ID:  132978b94e66f8ad7d20790f8332f0e9c1426029
Gitweb: http://git.kernel.org/tip/132978b94e66f8ad7d20790f8332f0e9c1426029
Author: Jan Beulich 
AuthorDate: Fri, 19 Dec 2014 16:10:54 +
Committer:  Ingo Molnar 
CommitDate: Tue, 23 Dec 2014 11:39:34 +0100

x86: Fix step size adjustment during initial memory mapping

The old scheme can lead to failure in certain cases - the
problem is that after bumping step_size the next (non-final)
iteration is only guaranteed to make available a memory block
the size of what step_size was before. E.g. for a memory block
[0,300460) we'd have:

 iter   start   end stepamount
 1  300440  30045f   2M   2M
 2  300400  30043f  64M   4M
 3  30  3003ff   2G  64M
 4  20  2f  64G  64G

Yet to map 64G with 4k pages (as happens e.g. under PV Xen) we
need slightly over 128M, but the first three iterations made
only about 70M available.

The condition (new_mapped_ram_size > mapped_ram_size) for
bumping step_size is just not suitable. Instead we want to bump
it when we know we have enough memory available to cover a block
of the new step_size. And rather than making that condition more
complicated than needed, simply adjust step_size by the largest
possible factor we know we can cover at that point - which is
shifting it left by one less than the difference between page
table level shifts. (Interestingly the original STEP_SIZE_SHIFT
definition had a comment hinting at that having been the
intention, just that it should have been PUD_SHIFT-PMD_SHIFT-1
instead of (PUD_SHIFT-PMD_SHIFT)/2, and of course for non-PAE
32-bit we can't really use these two constants as they're equal
there.)

Furthermore the comment in get_new_step_size() didn't get
updated when the bottom-down mapping logic got added. Yet while
an overflow (flushing step_size to zero) of the shift doesn't
matter for the top-down method, it does for bottom-up because
round_up(x, 0) = 0, and an upper range boundary of zero can't
really work well.

Signed-off-by: Jan Beulich 
Acked-by: Yinghai Lu 
Link: http://lkml.kernel.org/r/54945c1e027800051...@mail.emea.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/init.c | 37 +
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index a97ee08..08a7d31 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -438,20 +438,20 @@ static unsigned long __init init_range_memory_mapping(
 static unsigned long __init get_new_step_size(unsigned long step_size)
 {
/*
-* Explain why we shift by 5 and why we don't have to worry about
-* 'step_size << 5' overflowing:
-*
-* initial mapped size is PMD_SIZE (2M).
+* Initial mapped size is PMD_SIZE (2M).
 * We can not set step_size to be PUD_SIZE (1G) yet.
 * In worse case, when we cross the 1G boundary, and
 * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k)
-* to map 1G range with PTE. Use 5 as shift for now.
+* to map 1G range with PTE. Hence we use one less than the
+* difference of page table level shifts.
 *
-* Don't need to worry about overflow, on 32bit, when step_size
-* is 0, round_down() returns 0 for start, and that turns it
-* into 0x1ULL.
+* Don't need to worry about overflow in the top-down case, on 32bit,
+* when step_size is 0, round_down() returns 0 for start, and that
+* turns it into 0x1ULL.
+* In the bottom-up case, round_up(x, 0) returns 0 though too, which
+* needs to be taken into consideration by the code below.
 */
-   return step_size << 5;
+   return step_size << (PMD_SHIFT - PAGE_SHIFT - 1);
 }
 
 /**
@@ -471,7 +471,6 @@ static void __init memory_map_top_down(unsigned long 
map_start,
unsigned long step_size;
unsigned long addr;
unsigned long mapped_ram_size = 0;
-   unsigned long new_mapped_ram_size;
 
/* xen has big range in reserved near end of ram, skip it at first.*/
addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE);
@@ -496,14 +495,12 @@ static void __init memory_map_top_down(unsigned long 
map_start,
start = map_start;
} else
start = map_start;
-   new_mapped_ram_size = init_range_memory_mapping(start,
+   mapped_ram_size += init_range_memory_mapping(start,
last_start);
last_start = start;
min_pfn_mapped = last_start >> PAGE_SHIFT;
-   /* only increase step_size after big range get mapped */
-   if (new_mapped_ram_size > mapped_ram_size)
+   if 

[tip:x86/urgent] x86: Fix step size adjustment during initial memory mapping

2014-12-23 Thread tip-bot for Jan Beulich
Commit-ID:  132978b94e66f8ad7d20790f8332f0e9c1426029
Gitweb: http://git.kernel.org/tip/132978b94e66f8ad7d20790f8332f0e9c1426029
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Fri, 19 Dec 2014 16:10:54 +
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 23 Dec 2014 11:39:34 +0100

x86: Fix step size adjustment during initial memory mapping

The old scheme can lead to failure in certain cases - the
problem is that after bumping step_size the next (non-final)
iteration is only guaranteed to make available a memory block
the size of what step_size was before. E.g. for a memory block
[0,300460) we'd have:

 iter   start   end stepamount
 1  300440  30045f   2M   2M
 2  300400  30043f  64M   4M
 3  30  3003ff   2G  64M
 4  20  2f  64G  64G

Yet to map 64G with 4k pages (as happens e.g. under PV Xen) we
need slightly over 128M, but the first three iterations made
only about 70M available.

The condition (new_mapped_ram_size  mapped_ram_size) for
bumping step_size is just not suitable. Instead we want to bump
it when we know we have enough memory available to cover a block
of the new step_size. And rather than making that condition more
complicated than needed, simply adjust step_size by the largest
possible factor we know we can cover at that point - which is
shifting it left by one less than the difference between page
table level shifts. (Interestingly the original STEP_SIZE_SHIFT
definition had a comment hinting at that having been the
intention, just that it should have been PUD_SHIFT-PMD_SHIFT-1
instead of (PUD_SHIFT-PMD_SHIFT)/2, and of course for non-PAE
32-bit we can't really use these two constants as they're equal
there.)

Furthermore the comment in get_new_step_size() didn't get
updated when the bottom-down mapping logic got added. Yet while
an overflow (flushing step_size to zero) of the shift doesn't
matter for the top-down method, it does for bottom-up because
round_up(x, 0) = 0, and an upper range boundary of zero can't
really work well.

Signed-off-by: Jan Beulich jbeul...@suse.com
Acked-by: Yinghai Lu ying...@kernel.org
Link: http://lkml.kernel.org/r/54945c1e027800051...@mail.emea.novell.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/init.c | 37 +
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index a97ee08..08a7d31 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -438,20 +438,20 @@ static unsigned long __init init_range_memory_mapping(
 static unsigned long __init get_new_step_size(unsigned long step_size)
 {
/*
-* Explain why we shift by 5 and why we don't have to worry about
-* 'step_size  5' overflowing:
-*
-* initial mapped size is PMD_SIZE (2M).
+* Initial mapped size is PMD_SIZE (2M).
 * We can not set step_size to be PUD_SIZE (1G) yet.
 * In worse case, when we cross the 1G boundary, and
 * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k)
-* to map 1G range with PTE. Use 5 as shift for now.
+* to map 1G range with PTE. Hence we use one less than the
+* difference of page table level shifts.
 *
-* Don't need to worry about overflow, on 32bit, when step_size
-* is 0, round_down() returns 0 for start, and that turns it
-* into 0x1ULL.
+* Don't need to worry about overflow in the top-down case, on 32bit,
+* when step_size is 0, round_down() returns 0 for start, and that
+* turns it into 0x1ULL.
+* In the bottom-up case, round_up(x, 0) returns 0 though too, which
+* needs to be taken into consideration by the code below.
 */
-   return step_size  5;
+   return step_size  (PMD_SHIFT - PAGE_SHIFT - 1);
 }
 
 /**
@@ -471,7 +471,6 @@ static void __init memory_map_top_down(unsigned long 
map_start,
unsigned long step_size;
unsigned long addr;
unsigned long mapped_ram_size = 0;
-   unsigned long new_mapped_ram_size;
 
/* xen has big range in reserved near end of ram, skip it at first.*/
addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE);
@@ -496,14 +495,12 @@ static void __init memory_map_top_down(unsigned long 
map_start,
start = map_start;
} else
start = map_start;
-   new_mapped_ram_size = init_range_memory_mapping(start,
+   mapped_ram_size += init_range_memory_mapping(start,
last_start);
last_start = start;
min_pfn_mapped = last_start  PAGE_SHIFT;
-   /* only increase step_size after big range get mapped */
-

[tip:x86/apic] x86: Avoid building unused IRQ entry stubs

2014-12-19 Thread tip-bot for Jan Beulich
Commit-ID:  2414e021ac8d588f1b09f64891f69a3e26feadf1
Gitweb: http://git.kernel.org/tip/2414e021ac8d588f1b09f64891f69a3e26feadf1
Author: Jan Beulich 
AuthorDate: Mon, 3 Nov 2014 08:39:43 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 16 Dec 2014 14:08:14 +0100

x86: Avoid building unused IRQ entry stubs

When X86_LOCAL_APIC (i.e. unconditionally on x86-64),
first_system_vector will never end up being higher than
LOCAL_TIMER_VECTOR (0xef), and hence building stubs for vectors
0xef...0xff is pointlessly reducing code density. Deal with this at
build time already.

Taking into consideration that X86_64 implies X86_LOCAL_APIC, also
simplify (and hence make easier to read and more consistent with the
change done here) some #if-s in arch/x86/kernel/irqinit.c.

While we could further improve the packing of the IRQ entry stubs (the
four ones now left in the last set could be fit into the four padding
bytes each of the final four sets have) this doesn't seem to provide
any real benefit: Both irq_entries_start and common_interrupt getting
cache line aligned, eliminating the 30th set would just produce 32
bytes of padding between the 29th and common_interrupt.

[ tglx: Folded lguest fix from Dan Carpenter ]

Signed-off-by: Jan Beulich 
Cc: Dan Carpenter 
Cc: Andi Kleen 
Cc: lgu...@lists.ozlabs.org
Cc: Rusty Russell 
Link: http://lkml.kernel.org/r/54574d5f027800044...@mail.emea.novell.com
Link: http://lkml.kernel.org/r/20141115185718.GB6530@mwanda
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/hw_irq.h  |  3 ++-
 arch/x86/include/asm/irq_vectors.h |  6 ++
 arch/x86/kernel/apic/apic.c| 22 --
 arch/x86/kernel/entry_32.S |  4 ++--
 arch/x86/kernel/entry_64.S |  4 ++--
 arch/x86/kernel/irqinit.c  | 13 +
 arch/x86/lguest/boot.c |  2 +-
 7 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index fa5d1e7..8dbe237 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -189,7 +189,8 @@ extern __visible void 
smp_call_function_single_interrupt(struct pt_regs *);
 extern __visible void smp_invalidate_interrupt(struct pt_regs *);
 #endif
 
-extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
+extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
+   - FIRST_EXTERNAL_VECTOR])(void);
 #ifdef CONFIG_TRACING
 #define trace_interrupt interrupt
 #endif
diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 5702d7e..666c89e 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -126,6 +126,12 @@
 
 #define NR_VECTORS  256
 
+#ifdef CONFIG_X86_LOCAL_APIC
+#define FIRST_SYSTEM_VECTORLOCAL_TIMER_VECTOR
+#else
+#define FIRST_SYSTEM_VECTORNR_VECTORS
+#endif
+
 #define FPU_IRQ  13
 
 #defineFIRST_VM86_IRQ 3
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ba6cc04..29b5b18 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata;
 int local_apic_timer_c2_ok;
 EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
 
-int first_system_vector = 0xfe;
+int first_system_vector = FIRST_SYSTEM_VECTOR;
 
 /*
  * Debug level, exported for io_apic.c
@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void)
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
-static inline void __smp_spurious_interrupt(void)
+static inline void __smp_spurious_interrupt(u8 vector)
 {
u32 v;
 
@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void)
 * if it is a vectored one.  Just in case...
 * Spurious interrupts should not be ACKed.
 */
-   v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
-   if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
+   v = apic_read(APIC_ISR + ((vector & ~0x1f) >> 1));
+   if (v & (1 << (vector & 0x1f)))
ack_APIC_irq();
 
inc_irq_stat(irq_spurious_count);
 
/* see sw-dev-man vol 3, chapter 7.4.13.5 */
-   pr_info("spurious APIC interrupt on CPU#%d, "
-   "should never happen.\n", smp_processor_id());
+   pr_info("spurious APIC interrupt through vector %02x on CPU#%d, "
+   "should never happen.\n", vector, smp_processor_id());
 }
 
 __visible void smp_spurious_interrupt(struct pt_regs *regs)
 {
entering_irq();
-   __smp_spurious_interrupt();
+   __smp_spurious_interrupt(~regs->orig_ax);
exiting_irq();
 }
 
 __visible void smp_trace_spurious_interrupt(struct pt_regs *regs)
 {
+   u8 vector = ~regs->orig_ax;
+
entering_irq();
-   trace_spurious_apic_entry(SPURIOUS_APIC_VECTOR);
-   

[tip:x86/apic] x86: irq: Fix placement of mp_should_keep_irq()

2014-12-19 Thread tip-bot for Jan Beulich
Commit-ID:  e10679825924580845c4825deaaddf5331ff627c
Gitweb: http://git.kernel.org/tip/e10679825924580845c4825deaaddf5331ff627c
Author: Jan Beulich 
AuthorDate: Mon, 3 Nov 2014 08:15:42 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 16 Dec 2014 14:08:14 +0100

x86: irq: Fix placement of mp_should_keep_irq()

While f3761db164 ("x86, irq: Fix build error caused by
9eabc99a635a77cbf09") addressed the original build problem,
declaration, inline stub, and definition still seem misplaced: It isn't
really IO-APIC related, and it's being used solely in arch/x86/pci/.
This also means stubbing it out when !CONFIG_X86_IO_APIC was at least
questionable.

Signed-off-by: Jan Beulich 
Cc: Jiang Liu 
Link: http://lkml.kernel.org/r/545747be027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/io_apic.h |  3 ---
 arch/x86/include/asm/pci_x86.h |  2 ++
 arch/x86/kernel/apic/io_apic.c | 12 
 arch/x86/pci/irq.c | 12 
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 1733ab4..0aeed5c 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -227,8 +227,6 @@ static inline void io_apic_modify(unsigned int apic, 
unsigned int reg, unsigned
 
 extern void io_apic_eoi(unsigned int apic, unsigned int vector);
 
-extern bool mp_should_keep_irq(struct device *dev);
-
 #else  /* !CONFIG_X86_IO_APIC */
 
 #define io_apic_assign_pci_irqs 0
@@ -239,7 +237,6 @@ static inline int mp_find_ioapic(u32 gsi) { return 0; }
 static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; }
 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; 
}
 static inline void mp_unmap_irq(int irq) { }
-static inline bool mp_should_keep_irq(struct device *dev) { return 1; }
 
 static inline int save_ioapic_entries(void)
 {
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index fa1195d..164e3f8 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
+extern bool mp_should_keep_irq(struct device *dev);
+
 struct pci_raw_ops {
int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 7ffe0a2..a157b66 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3964,18 +3964,6 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, 
int node)
return ret;
 }
 
-bool mp_should_keep_irq(struct device *dev)
-{
-   if (dev->power.is_prepared)
-   return true;
-#ifdef CONFIG_PM_RUNTIME
-   if (dev->power.runtime_status == RPM_SUSPENDING)
-   return true;
-#endif
-
-   return false;
-}
-
 /* Enable IOAPIC early just for system timer */
 void __init pre_init_apic_IRQ0(void)
 {
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index eb500c2..cb50e28 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1254,6 +1254,18 @@ static int pirq_enable_irq(struct pci_dev *dev)
return 0;
 }
 
+bool mp_should_keep_irq(struct device *dev)
+{
+   if (dev->power.is_prepared)
+   return true;
+#ifdef CONFIG_PM_RUNTIME
+   if (dev->power.runtime_status == RPM_SUSPENDING)
+   return true;
+#endif
+
+   return false;
+}
+
 static void pirq_disable_irq(struct pci_dev *dev)
 {
if (io_apic_assign_pci_irqs && !mp_should_keep_irq(>dev) &&
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86: irq: Fix placement of mp_should_keep_irq()

2014-12-19 Thread tip-bot for Jan Beulich
Commit-ID:  e10679825924580845c4825deaaddf5331ff627c
Gitweb: http://git.kernel.org/tip/e10679825924580845c4825deaaddf5331ff627c
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 3 Nov 2014 08:15:42 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 16 Dec 2014 14:08:14 +0100

x86: irq: Fix placement of mp_should_keep_irq()

While f3761db164 (x86, irq: Fix build error caused by
9eabc99a635a77cbf09) addressed the original build problem,
declaration, inline stub, and definition still seem misplaced: It isn't
really IO-APIC related, and it's being used solely in arch/x86/pci/.
This also means stubbing it out when !CONFIG_X86_IO_APIC was at least
questionable.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Jiang Liu jiang@linux.intel.com
Link: http://lkml.kernel.org/r/545747be027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de

---
 arch/x86/include/asm/io_apic.h |  3 ---
 arch/x86/include/asm/pci_x86.h |  2 ++
 arch/x86/kernel/apic/io_apic.c | 12 
 arch/x86/pci/irq.c | 12 
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 1733ab4..0aeed5c 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -227,8 +227,6 @@ static inline void io_apic_modify(unsigned int apic, 
unsigned int reg, unsigned
 
 extern void io_apic_eoi(unsigned int apic, unsigned int vector);
 
-extern bool mp_should_keep_irq(struct device *dev);
-
 #else  /* !CONFIG_X86_IO_APIC */
 
 #define io_apic_assign_pci_irqs 0
@@ -239,7 +237,6 @@ static inline int mp_find_ioapic(u32 gsi) { return 0; }
 static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; }
 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; 
}
 static inline void mp_unmap_irq(int irq) { }
-static inline bool mp_should_keep_irq(struct device *dev) { return 1; }
 
 static inline int save_ioapic_entries(void)
 {
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index fa1195d..164e3f8 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
+extern bool mp_should_keep_irq(struct device *dev);
+
 struct pci_raw_ops {
int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 7ffe0a2..a157b66 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3964,18 +3964,6 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, 
int node)
return ret;
 }
 
-bool mp_should_keep_irq(struct device *dev)
-{
-   if (dev-power.is_prepared)
-   return true;
-#ifdef CONFIG_PM_RUNTIME
-   if (dev-power.runtime_status == RPM_SUSPENDING)
-   return true;
-#endif
-
-   return false;
-}
-
 /* Enable IOAPIC early just for system timer */
 void __init pre_init_apic_IRQ0(void)
 {
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index eb500c2..cb50e28 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1254,6 +1254,18 @@ static int pirq_enable_irq(struct pci_dev *dev)
return 0;
 }
 
+bool mp_should_keep_irq(struct device *dev)
+{
+   if (dev-power.is_prepared)
+   return true;
+#ifdef CONFIG_PM_RUNTIME
+   if (dev-power.runtime_status == RPM_SUSPENDING)
+   return true;
+#endif
+
+   return false;
+}
+
 static void pirq_disable_irq(struct pci_dev *dev)
 {
if (io_apic_assign_pci_irqs  !mp_should_keep_irq(dev-dev) 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86: Avoid building unused IRQ entry stubs

2014-12-19 Thread tip-bot for Jan Beulich
Commit-ID:  2414e021ac8d588f1b09f64891f69a3e26feadf1
Gitweb: http://git.kernel.org/tip/2414e021ac8d588f1b09f64891f69a3e26feadf1
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 3 Nov 2014 08:39:43 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 16 Dec 2014 14:08:14 +0100

x86: Avoid building unused IRQ entry stubs

When X86_LOCAL_APIC (i.e. unconditionally on x86-64),
first_system_vector will never end up being higher than
LOCAL_TIMER_VECTOR (0xef), and hence building stubs for vectors
0xef...0xff is pointlessly reducing code density. Deal with this at
build time already.

Taking into consideration that X86_64 implies X86_LOCAL_APIC, also
simplify (and hence make easier to read and more consistent with the
change done here) some #if-s in arch/x86/kernel/irqinit.c.

While we could further improve the packing of the IRQ entry stubs (the
four ones now left in the last set could be fit into the four padding
bytes each of the final four sets have) this doesn't seem to provide
any real benefit: Both irq_entries_start and common_interrupt getting
cache line aligned, eliminating the 30th set would just produce 32
bytes of padding between the 29th and common_interrupt.

[ tglx: Folded lguest fix from Dan Carpenter ]

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Dan Carpenter dan.carpen...@oracle.com
Cc: Andi Kleen a...@linux.intel.com
Cc: lgu...@lists.ozlabs.org
Cc: Rusty Russell ru...@rustcorp.com.au
Link: http://lkml.kernel.org/r/54574d5f027800044...@mail.emea.novell.com
Link: http://lkml.kernel.org/r/20141115185718.GB6530@mwanda
Signed-off-by: Thomas Gleixner t...@linutronix.de

---
 arch/x86/include/asm/hw_irq.h  |  3 ++-
 arch/x86/include/asm/irq_vectors.h |  6 ++
 arch/x86/kernel/apic/apic.c| 22 --
 arch/x86/kernel/entry_32.S |  4 ++--
 arch/x86/kernel/entry_64.S |  4 ++--
 arch/x86/kernel/irqinit.c  | 13 +
 arch/x86/lguest/boot.c |  2 +-
 7 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index fa5d1e7..8dbe237 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -189,7 +189,8 @@ extern __visible void 
smp_call_function_single_interrupt(struct pt_regs *);
 extern __visible void smp_invalidate_interrupt(struct pt_regs *);
 #endif
 
-extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
+extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
+   - FIRST_EXTERNAL_VECTOR])(void);
 #ifdef CONFIG_TRACING
 #define trace_interrupt interrupt
 #endif
diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 5702d7e..666c89e 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -126,6 +126,12 @@
 
 #define NR_VECTORS  256
 
+#ifdef CONFIG_X86_LOCAL_APIC
+#define FIRST_SYSTEM_VECTORLOCAL_TIMER_VECTOR
+#else
+#define FIRST_SYSTEM_VECTORNR_VECTORS
+#endif
+
 #define FPU_IRQ  13
 
 #defineFIRST_VM86_IRQ 3
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ba6cc04..29b5b18 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata;
 int local_apic_timer_c2_ok;
 EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
 
-int first_system_vector = 0xfe;
+int first_system_vector = FIRST_SYSTEM_VECTOR;
 
 /*
  * Debug level, exported for io_apic.c
@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void)
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
-static inline void __smp_spurious_interrupt(void)
+static inline void __smp_spurious_interrupt(u8 vector)
 {
u32 v;
 
@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void)
 * if it is a vectored one.  Just in case...
 * Spurious interrupts should not be ACKed.
 */
-   v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR  ~0x1f)  1));
-   if (v  (1  (SPURIOUS_APIC_VECTOR  0x1f)))
+   v = apic_read(APIC_ISR + ((vector  ~0x1f)  1));
+   if (v  (1  (vector  0x1f)))
ack_APIC_irq();
 
inc_irq_stat(irq_spurious_count);
 
/* see sw-dev-man vol 3, chapter 7.4.13.5 */
-   pr_info(spurious APIC interrupt on CPU#%d, 
-   should never happen.\n, smp_processor_id());
+   pr_info(spurious APIC interrupt through vector %02x on CPU#%d, 
+   should never happen.\n, vector, smp_processor_id());
 }
 
 __visible void smp_spurious_interrupt(struct pt_regs *regs)
 {
entering_irq();
-   __smp_spurious_interrupt();
+   __smp_spurious_interrupt(~regs-orig_ax);
exiting_irq();
 }
 
 __visible void smp_trace_spurious_interrupt(struct pt_regs *regs)
 {
+   u8 vector = 

[tip:x86/boot] x86-64: Use RIP-relative addressing for most per-CPU accesses

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  97b67ae559947f1e208439a1bf6a734da3087006
Gitweb: http://git.kernel.org/tip/97b67ae559947f1e208439a1bf6a734da3087006
Author: Jan Beulich 
AuthorDate: Tue, 4 Nov 2014 08:50:48 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Nov 2014 20:43:14 +0100

x86-64: Use RIP-relative addressing for most per-CPU accesses

Observing that per-CPU data (in the SMP case) is reachable by
exploiting 64-bit address wraparound (building on the default kernel
load address being at 16Mb), the one byte shorter RIP-relative
addressing form can be used for most per-CPU accesses. The one
exception are the "stable" reads, where the use of the "P" operand
modifier prevents the compiler from using RIP-relative addressing, but
is unavoidable due to the use of the "p" constraint (side note: with
gcc 4.9.x the intended effect of this isn't being achieved anymore,
see gcc bug 63637).

With the dependency on the minimum kernel load address, arbitrarily
low values for CONFIG_PHYSICAL_START are now no longer possible. A
link time assertion is being added, directing to the need to increase
that value when it triggers.

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/5458a178027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/percpu.h | 59 ---
 arch/x86/kernel/vmlinux.lds.S |  2 ++
 2 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 74da317..e0ba66c 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -64,7 +64,7 @@
 #define __percpu_prefix""
 #endif
 
-#define __percpu_arg(x)__percpu_prefix "%P" #x
+#define __percpu_arg(x)__percpu_prefix "%" #x
 
 /*
  * Initialized pointers to per-cpu variables needed for the boot
@@ -179,29 +179,58 @@ do {  
\
}   \
 } while (0)
 
-#define percpu_from_op(op, var, constraint)\
+#define percpu_from_op(op, var)\
 ({ \
typeof(var) pfo_ret__;  \
switch (sizeof(var)) {  \
case 1: \
asm(op "b "__percpu_arg(1)",%0" \
: "=q" (pfo_ret__)  \
-   : constraint);  \
+   : "m" (var));   \
break;  \
case 2: \
asm(op "w "__percpu_arg(1)",%0" \
: "=r" (pfo_ret__)  \
-   : constraint);  \
+   : "m" (var));   \
break;  \
case 4: \
asm(op "l "__percpu_arg(1)",%0" \
: "=r" (pfo_ret__)  \
-   : constraint);  \
+   : "m" (var));   \
break;  \
case 8: \
asm(op "q "__percpu_arg(1)",%0" \
: "=r" (pfo_ret__)  \
-   : constraint);  \
+   : "m" (var));   \
+   break;  \
+   default: __bad_percpu_size();   \
+   }   \
+   pfo_ret__;  \
+})
+
+#define percpu_stable_op(op, var)  \
+({ \
+   typeof(var) pfo_ret__;  \
+   switch (sizeof(var)) {  \
+   case 1: \
+   asm(op "b "__percpu_arg(P1)",%0"\
+   : "=q" (pfo_ret__)  \
+   : "p" (&(var)));\
+   break;  \
+   case 2: \
+   asm(op "w "__percpu_arg(P1)",%0"\
+   : "=r" (pfo_ret__)  \
+   : "p" (&(var)));\
+   break;  \
+   case 4: \
+   asm(op "l "__percpu_arg(P1)",%0"\
+   : "=r" (pfo_ret__)  \
+   : "p" (&(var)));\
+

[tip:x86/boot] x86-64: Handle PC-relative relocations on per-CPU data

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba
Gitweb: http://git.kernel.org/tip/6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba
Author: Jan Beulich 
AuthorDate: Tue, 4 Nov 2014 08:50:18 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Nov 2014 20:43:14 +0100

x86-64: Handle PC-relative relocations on per-CPU data

This is in preparation of using RIP-relative addressing in many of the
per-CPU accesses.

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/5458a15a027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/boot/compressed/misc.c | 14 +-
 arch/x86/tools/relocs.c | 36 +++-
 2 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 57ab74d..644abd7 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -260,7 +260,7 @@ static void handle_relocations(void *output, unsigned long 
output_len)
 
/*
 * Process relocations: 32 bit relocations first then 64 bit after.
-* Two sets of binary relocations are added to the end of the kernel
+* Three sets of binary relocations are added to the end of the kernel
 * before compression. Each relocation table entry is the kernel
 * address of the location which needs to be updated stored as a
 * 32-bit value which is sign extended to 64 bits.
@@ -270,6 +270,8 @@ static void handle_relocations(void *output, unsigned long 
output_len)
 * kernel bits...
 * 0 - zero terminator for 64 bit relocations
 * 64 bit relocation repeated
+* 0 - zero terminator for inverse 32 bit relocations
+* 32 bit inverse relocation repeated
 * 0 - zero terminator for 32 bit relocations
 * 32 bit relocation repeated
 *
@@ -286,6 +288,16 @@ static void handle_relocations(void *output, unsigned long 
output_len)
*(uint32_t *)ptr += delta;
}
 #ifdef CONFIG_X86_64
+   while (*--reloc) {
+   long extended = *reloc;
+   extended += map;
+
+   ptr = (unsigned long)extended;
+   if (ptr < min_addr || ptr > max_addr)
+   error("inverse 32-bit relocation outside of kernel!\n");
+
+   *(int32_t *)ptr -= delta;
+   }
for (reloc--; *reloc; reloc--) {
long extended = *reloc;
extended += map;
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index a5efb21..0c2fae8 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -20,7 +20,10 @@ struct relocs {
 
 static struct relocs relocs16;
 static struct relocs relocs32;
+#if ELF_BITS == 64
+static struct relocs relocs32neg;
 static struct relocs relocs64;
+#endif
 
 struct section {
Elf_Shdr   shdr;
@@ -762,11 +765,16 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, 
ElfW(Sym) *sym,
 
switch (r_type) {
case R_X86_64_NONE:
+   /* NONE can be ignored. */
+   break;
+
case R_X86_64_PC32:
/*
-* NONE can be ignored and PC relative relocations don't
-* need to be adjusted.
+* PC relative relocations don't need to be adjusted unless
+* referencing a percpu symbol.
 */
+   if (is_percpu_sym(sym, symname))
+   add_reloc(, offset);
break;
 
case R_X86_64_32:
@@ -986,7 +994,10 @@ static void emit_relocs(int as_text, int use_real_mode)
/* Order the relocations for more efficient processing */
sort_relocs();
sort_relocs();
+#if ELF_BITS == 64
+   sort_relocs();
sort_relocs();
+#endif
 
/* Print the relocations */
if (as_text) {
@@ -1007,14 +1018,21 @@ static void emit_relocs(int as_text, int use_real_mode)
for (i = 0; i < relocs32.count; i++)
write_reloc(relocs32.offset[i], stdout);
} else {
-   if (ELF_BITS == 64) {
-   /* Print a stop */
-   write_reloc(0, stdout);
+#if ELF_BITS == 64
+   /* Print a stop */
+   write_reloc(0, stdout);
 
-   /* Now print each relocation */
-   for (i = 0; i < relocs64.count; i++)
-   write_reloc(relocs64.offset[i], stdout);
-   }
+   /* Now print each relocation */
+   for (i = 0; i < relocs64.count; i++)
+   write_reloc(relocs64.offset[i], stdout);
+
+   /* Print a stop */
+   write_reloc(0, stdout);
+
+   /* Now print each inverse 32-bit relocation */
+   for (i = 0; i < relocs32neg.count; i++)
+   write_reloc(relocs32neg.offset[i], stdout);
+#endif
 

[tip:x86/boot] x86: Convert a few more per-CPU items to read-mostly ones

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  2c773dd31fbacbbb6425f8a9d3f97e0010272368
Gitweb: http://git.kernel.org/tip/2c773dd31fbacbbb6425f8a9d3f97e0010272368
Author: Jan Beulich 
AuthorDate: Tue, 4 Nov 2014 08:26:42 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Nov 2014 20:13:28 +0100

x86: Convert a few more per-CPU items to read-mostly ones

Both this_cpu_off and cpu_info aren't getting modified post boot, yet
are being accessed on enough code paths that grouping them with other
frequently read items seems desirable. For cpu_info this at the same
time implies removing the cache line alignment (which afaict became
pointless when it got converted to per-CPU data years ago).

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/54589bd2027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/percpu.h| 2 +-
 arch/x86/include/asm/processor.h | 4 ++--
 arch/x86/kernel/setup_percpu.c   | 2 +-
 arch/x86/kernel/smpboot.c| 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index fd47218..74da317 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -522,7 +522,7 @@ static inline int x86_this_cpu_variable_test_bit(int nr,
 #include 
 
 /* We can use this directly for local CPU (faster). */
-DECLARE_PER_CPU(unsigned long, this_cpu_off);
+DECLARE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off);
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index eb71ec7..3aeb31c 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -127,7 +127,7 @@ struct cpuinfo_x86 {
/* Index into per_cpu list: */
u16 cpu_index;
u32 microcode;
-} __attribute__((__aligned__(SMP_CACHE_BYTES)));
+};
 
 #define X86_VENDOR_INTEL   0
 #define X86_VENDOR_CYRIX   1
@@ -151,7 +151,7 @@ extern __u32
cpu_caps_cleared[NCAPINTS];
 extern __u32   cpu_caps_set[NCAPINTS];
 
 #ifdef CONFIG_SMP
-DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
+DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
 #define cpu_data(cpu)  per_cpu(cpu_info, cpu)
 #else
 #define cpu_info   boot_cpu_data
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 5cdff03..e4fcb87 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -30,7 +30,7 @@ EXPORT_PER_CPU_SYMBOL(cpu_number);
 #define BOOT_PERCPU_OFFSET 0
 #endif
 
-DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
+DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
 
 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 4d2128a..a03ec604 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -99,7 +99,7 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
 
 /* Per CPU bogomips and other parameters */
-DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
+DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
 
 atomic_t init_deasserted;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86: Avoid building unused IRQ entry stubs

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  8c66877ee65ec4e6974e9aa69bc53abe4a603f10
Gitweb: http://git.kernel.org/tip/8c66877ee65ec4e6974e9aa69bc53abe4a603f10
Author: Jan Beulich 
AuthorDate: Mon, 3 Nov 2014 08:39:43 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Nov 2014 20:11:59 +0100

x86: Avoid building unused IRQ entry stubs

When X86_LOCAL_APIC (i.e. unconditionally on x86-64),
first_system_vector will never end up being higher than
LOCAL_TIMER_VECTOR (0xef), and hence building stubs for vectors
0xef...0xff is pointlessly reducing code density. Deal with this at
build time already.

Taking into consideration that X86_64 implies X86_LOCAL_APIC, also
simplify (and hence make easier to read and more consistent with the
change done here) some #if-s in arch/x86/kernel/irqinit.c.

While we could further improve the packing of the IRQ entry stubs (the
four ones now left in the last set could be fit into the four padding
bytes each of the final four sets have) this doesn't seem to provide
any real benefit: Both irq_entries_start and common_interrupt getting
cache line aligned, eliminating the 30th set would just produce 32
bytes of padding between the 29th and common_interrupt.

Signed-off-by: Jan Beulich 
Link: http://lkml.kernel.org/r/54574d5f027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/hw_irq.h  |  3 ++-
 arch/x86/include/asm/irq_vectors.h |  6 ++
 arch/x86/kernel/apic/apic.c| 22 --
 arch/x86/kernel/entry_32.S |  4 ++--
 arch/x86/kernel/entry_64.S |  4 ++--
 arch/x86/kernel/irqinit.c  | 13 +
 6 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index 4615906..cb7917f 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -185,7 +185,8 @@ extern __visible void 
smp_call_function_single_interrupt(struct pt_regs *);
 extern __visible void smp_invalidate_interrupt(struct pt_regs *);
 #endif
 
-extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
+extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
+   - FIRST_EXTERNAL_VECTOR])(void);
 #ifdef CONFIG_TRACING
 #define trace_interrupt interrupt
 #endif
diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 5702d7e..666c89e 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -126,6 +126,12 @@
 
 #define NR_VECTORS  256
 
+#ifdef CONFIG_X86_LOCAL_APIC
+#define FIRST_SYSTEM_VECTORLOCAL_TIMER_VECTOR
+#else
+#define FIRST_SYSTEM_VECTORNR_VECTORS
+#endif
+
 #define FPU_IRQ  13
 
 #defineFIRST_VM86_IRQ 3
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ba6cc04..29b5b18 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata;
 int local_apic_timer_c2_ok;
 EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
 
-int first_system_vector = 0xfe;
+int first_system_vector = FIRST_SYSTEM_VECTOR;
 
 /*
  * Debug level, exported for io_apic.c
@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void)
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
-static inline void __smp_spurious_interrupt(void)
+static inline void __smp_spurious_interrupt(u8 vector)
 {
u32 v;
 
@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void)
 * if it is a vectored one.  Just in case...
 * Spurious interrupts should not be ACKed.
 */
-   v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
-   if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
+   v = apic_read(APIC_ISR + ((vector & ~0x1f) >> 1));
+   if (v & (1 << (vector & 0x1f)))
ack_APIC_irq();
 
inc_irq_stat(irq_spurious_count);
 
/* see sw-dev-man vol 3, chapter 7.4.13.5 */
-   pr_info("spurious APIC interrupt on CPU#%d, "
-   "should never happen.\n", smp_processor_id());
+   pr_info("spurious APIC interrupt through vector %02x on CPU#%d, "
+   "should never happen.\n", vector, smp_processor_id());
 }
 
 __visible void smp_spurious_interrupt(struct pt_regs *regs)
 {
entering_irq();
-   __smp_spurious_interrupt();
+   __smp_spurious_interrupt(~regs->orig_ax);
exiting_irq();
 }
 
 __visible void smp_trace_spurious_interrupt(struct pt_regs *regs)
 {
+   u8 vector = ~regs->orig_ax;
+
entering_irq();
-   trace_spurious_apic_entry(SPURIOUS_APIC_VECTOR);
-   __smp_spurious_interrupt();
-   trace_spurious_apic_exit(SPURIOUS_APIC_VECTOR);
+   trace_spurious_apic_entry(vector);
+   __smp_spurious_interrupt(vector);
+   trace_spurious_apic_exit(vector);
exiting_irq();
 }
 
diff 

[tip:x86/apic] x86: irq: Fix placement of mp_should_keep_irq()

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  3b67bdc6599e25b082f12dbde6b0ce91dd235549
Gitweb: http://git.kernel.org/tip/3b67bdc6599e25b082f12dbde6b0ce91dd235549
Author: Jan Beulich 
AuthorDate: Mon, 3 Nov 2014 08:15:42 +
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Nov 2014 19:12:41 +0100

x86: irq: Fix placement of mp_should_keep_irq()

While f3761db164 ("x86, irq: Fix build error caused by
9eabc99a635a77cbf09") addressed the original build problem,
declaration, inline stub, and definition still seem misplaced: It isn't
really IO-APIC related, and it's being used solely in arch/x86/pci/.
This also means stubbing it out when !CONFIG_X86_IO_APIC was at least
questionable.

Signed-off-by: Jan Beulich 
Cc: Jiang Liu 
Link: http://lkml.kernel.org/r/545747be027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/io_apic.h |  3 ---
 arch/x86/include/asm/pci_x86.h |  2 ++
 arch/x86/kernel/apic/io_apic.c | 12 
 arch/x86/pci/irq.c | 12 
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index ca742d5..0db2b70 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -229,8 +229,6 @@ static inline void io_apic_modify(unsigned int apic, 
unsigned int reg, unsigned
 
 extern void io_apic_eoi(unsigned int apic, unsigned int vector);
 
-extern bool mp_should_keep_irq(struct device *dev);
-
 #else  /* !CONFIG_X86_IO_APIC */
 
 #define io_apic_assign_pci_irqs 0
@@ -241,7 +239,6 @@ static inline int mp_find_ioapic(u32 gsi) { return 0; }
 static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; }
 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; 
}
 static inline void mp_unmap_irq(int irq) { }
-static inline bool mp_should_keep_irq(struct device *dev) { return 1; }
 
 static inline int save_ioapic_entries(void)
 {
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index fa1195d..164e3f8 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
+extern bool mp_should_keep_irq(struct device *dev);
+
 struct pci_raw_ops {
int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index ff2709e..1b7de4c 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -4116,18 +4116,6 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, 
int node)
return ret;
 }
 
-bool mp_should_keep_irq(struct device *dev)
-{
-   if (dev->power.is_prepared)
-   return true;
-#ifdef CONFIG_PM_RUNTIME
-   if (dev->power.runtime_status == RPM_SUSPENDING)
-   return true;
-#endif
-
-   return false;
-}
-
 /* Enable IOAPIC early just for system timer */
 void __init pre_init_apic_IRQ0(void)
 {
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index a47e2de..9988458 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1258,6 +1258,18 @@ static int pirq_enable_irq(struct pci_dev *dev)
return 0;
 }
 
+bool mp_should_keep_irq(struct device *dev)
+{
+   if (dev->power.is_prepared)
+   return true;
+#ifdef CONFIG_PM_RUNTIME
+   if (dev->power.runtime_status == RPM_SUSPENDING)
+   return true;
+#endif
+
+   return false;
+}
+
 static void pirq_disable_irq(struct pci_dev *dev)
 {
if (io_apic_assign_pci_irqs && !mp_should_keep_irq(>dev) &&
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86: irq: Fix placement of mp_should_keep_irq()

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  3b67bdc6599e25b082f12dbde6b0ce91dd235549
Gitweb: http://git.kernel.org/tip/3b67bdc6599e25b082f12dbde6b0ce91dd235549
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 3 Nov 2014 08:15:42 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 4 Nov 2014 19:12:41 +0100

x86: irq: Fix placement of mp_should_keep_irq()

While f3761db164 (x86, irq: Fix build error caused by
9eabc99a635a77cbf09) addressed the original build problem,
declaration, inline stub, and definition still seem misplaced: It isn't
really IO-APIC related, and it's being used solely in arch/x86/pci/.
This also means stubbing it out when !CONFIG_X86_IO_APIC was at least
questionable.

Signed-off-by: Jan Beulich jbeul...@suse.com
Cc: Jiang Liu jiang@linux.intel.com
Link: http://lkml.kernel.org/r/545747be027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/include/asm/io_apic.h |  3 ---
 arch/x86/include/asm/pci_x86.h |  2 ++
 arch/x86/kernel/apic/io_apic.c | 12 
 arch/x86/pci/irq.c | 12 
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index ca742d5..0db2b70 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -229,8 +229,6 @@ static inline void io_apic_modify(unsigned int apic, 
unsigned int reg, unsigned
 
 extern void io_apic_eoi(unsigned int apic, unsigned int vector);
 
-extern bool mp_should_keep_irq(struct device *dev);
-
 #else  /* !CONFIG_X86_IO_APIC */
 
 #define io_apic_assign_pci_irqs 0
@@ -241,7 +239,6 @@ static inline int mp_find_ioapic(u32 gsi) { return 0; }
 static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; }
 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; 
}
 static inline void mp_unmap_irq(int irq) { }
-static inline bool mp_should_keep_irq(struct device *dev) { return 1; }
 
 static inline int save_ioapic_entries(void)
 {
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index fa1195d..164e3f8 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
+extern bool mp_should_keep_irq(struct device *dev);
+
 struct pci_raw_ops {
int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index ff2709e..1b7de4c 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -4116,18 +4116,6 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, 
int node)
return ret;
 }
 
-bool mp_should_keep_irq(struct device *dev)
-{
-   if (dev-power.is_prepared)
-   return true;
-#ifdef CONFIG_PM_RUNTIME
-   if (dev-power.runtime_status == RPM_SUSPENDING)
-   return true;
-#endif
-
-   return false;
-}
-
 /* Enable IOAPIC early just for system timer */
 void __init pre_init_apic_IRQ0(void)
 {
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index a47e2de..9988458 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1258,6 +1258,18 @@ static int pirq_enable_irq(struct pci_dev *dev)
return 0;
 }
 
+bool mp_should_keep_irq(struct device *dev)
+{
+   if (dev-power.is_prepared)
+   return true;
+#ifdef CONFIG_PM_RUNTIME
+   if (dev-power.runtime_status == RPM_SUSPENDING)
+   return true;
+#endif
+
+   return false;
+}
+
 static void pirq_disable_irq(struct pci_dev *dev)
 {
if (io_apic_assign_pci_irqs  !mp_should_keep_irq(dev-dev) 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86: Avoid building unused IRQ entry stubs

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  8c66877ee65ec4e6974e9aa69bc53abe4a603f10
Gitweb: http://git.kernel.org/tip/8c66877ee65ec4e6974e9aa69bc53abe4a603f10
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Mon, 3 Nov 2014 08:39:43 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 4 Nov 2014 20:11:59 +0100

x86: Avoid building unused IRQ entry stubs

When X86_LOCAL_APIC (i.e. unconditionally on x86-64),
first_system_vector will never end up being higher than
LOCAL_TIMER_VECTOR (0xef), and hence building stubs for vectors
0xef...0xff is pointlessly reducing code density. Deal with this at
build time already.

Taking into consideration that X86_64 implies X86_LOCAL_APIC, also
simplify (and hence make easier to read and more consistent with the
change done here) some #if-s in arch/x86/kernel/irqinit.c.

While we could further improve the packing of the IRQ entry stubs (the
four ones now left in the last set could be fit into the four padding
bytes each of the final four sets have) this doesn't seem to provide
any real benefit: Both irq_entries_start and common_interrupt getting
cache line aligned, eliminating the 30th set would just produce 32
bytes of padding between the 29th and common_interrupt.

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/54574d5f027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/include/asm/hw_irq.h  |  3 ++-
 arch/x86/include/asm/irq_vectors.h |  6 ++
 arch/x86/kernel/apic/apic.c| 22 --
 arch/x86/kernel/entry_32.S |  4 ++--
 arch/x86/kernel/entry_64.S |  4 ++--
 arch/x86/kernel/irqinit.c  | 13 +
 6 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index 4615906..cb7917f 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -185,7 +185,8 @@ extern __visible void 
smp_call_function_single_interrupt(struct pt_regs *);
 extern __visible void smp_invalidate_interrupt(struct pt_regs *);
 #endif
 
-extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
+extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
+   - FIRST_EXTERNAL_VECTOR])(void);
 #ifdef CONFIG_TRACING
 #define trace_interrupt interrupt
 #endif
diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 5702d7e..666c89e 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -126,6 +126,12 @@
 
 #define NR_VECTORS  256
 
+#ifdef CONFIG_X86_LOCAL_APIC
+#define FIRST_SYSTEM_VECTORLOCAL_TIMER_VECTOR
+#else
+#define FIRST_SYSTEM_VECTORNR_VECTORS
+#endif
+
 #define FPU_IRQ  13
 
 #defineFIRST_VM86_IRQ 3
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ba6cc04..29b5b18 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata;
 int local_apic_timer_c2_ok;
 EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
 
-int first_system_vector = 0xfe;
+int first_system_vector = FIRST_SYSTEM_VECTOR;
 
 /*
  * Debug level, exported for io_apic.c
@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void)
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
-static inline void __smp_spurious_interrupt(void)
+static inline void __smp_spurious_interrupt(u8 vector)
 {
u32 v;
 
@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void)
 * if it is a vectored one.  Just in case...
 * Spurious interrupts should not be ACKed.
 */
-   v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR  ~0x1f)  1));
-   if (v  (1  (SPURIOUS_APIC_VECTOR  0x1f)))
+   v = apic_read(APIC_ISR + ((vector  ~0x1f)  1));
+   if (v  (1  (vector  0x1f)))
ack_APIC_irq();
 
inc_irq_stat(irq_spurious_count);
 
/* see sw-dev-man vol 3, chapter 7.4.13.5 */
-   pr_info(spurious APIC interrupt on CPU#%d, 
-   should never happen.\n, smp_processor_id());
+   pr_info(spurious APIC interrupt through vector %02x on CPU#%d, 
+   should never happen.\n, vector, smp_processor_id());
 }
 
 __visible void smp_spurious_interrupt(struct pt_regs *regs)
 {
entering_irq();
-   __smp_spurious_interrupt();
+   __smp_spurious_interrupt(~regs-orig_ax);
exiting_irq();
 }
 
 __visible void smp_trace_spurious_interrupt(struct pt_regs *regs)
 {
+   u8 vector = ~regs-orig_ax;
+
entering_irq();
-   trace_spurious_apic_entry(SPURIOUS_APIC_VECTOR);
-   __smp_spurious_interrupt();
-   trace_spurious_apic_exit(SPURIOUS_APIC_VECTOR);
+   trace_spurious_apic_entry(vector);
+   __smp_spurious_interrupt(vector);
+   

[tip:x86/boot] x86: Convert a few more per-CPU items to read-mostly ones

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  2c773dd31fbacbbb6425f8a9d3f97e0010272368
Gitweb: http://git.kernel.org/tip/2c773dd31fbacbbb6425f8a9d3f97e0010272368
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Tue, 4 Nov 2014 08:26:42 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 4 Nov 2014 20:13:28 +0100

x86: Convert a few more per-CPU items to read-mostly ones

Both this_cpu_off and cpu_info aren't getting modified post boot, yet
are being accessed on enough code paths that grouping them with other
frequently read items seems desirable. For cpu_info this at the same
time implies removing the cache line alignment (which afaict became
pointless when it got converted to per-CPU data years ago).

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/54589bd2027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/include/asm/percpu.h| 2 +-
 arch/x86/include/asm/processor.h | 4 ++--
 arch/x86/kernel/setup_percpu.c   | 2 +-
 arch/x86/kernel/smpboot.c| 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index fd47218..74da317 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -522,7 +522,7 @@ static inline int x86_this_cpu_variable_test_bit(int nr,
 #include asm-generic/percpu.h
 
 /* We can use this directly for local CPU (faster). */
-DECLARE_PER_CPU(unsigned long, this_cpu_off);
+DECLARE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off);
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index eb71ec7..3aeb31c 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -127,7 +127,7 @@ struct cpuinfo_x86 {
/* Index into per_cpu list: */
u16 cpu_index;
u32 microcode;
-} __attribute__((__aligned__(SMP_CACHE_BYTES)));
+};
 
 #define X86_VENDOR_INTEL   0
 #define X86_VENDOR_CYRIX   1
@@ -151,7 +151,7 @@ extern __u32
cpu_caps_cleared[NCAPINTS];
 extern __u32   cpu_caps_set[NCAPINTS];
 
 #ifdef CONFIG_SMP
-DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
+DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
 #define cpu_data(cpu)  per_cpu(cpu_info, cpu)
 #else
 #define cpu_info   boot_cpu_data
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 5cdff03..e4fcb87 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -30,7 +30,7 @@ EXPORT_PER_CPU_SYMBOL(cpu_number);
 #define BOOT_PERCPU_OFFSET 0
 #endif
 
-DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
+DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
 
 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 4d2128a..a03ec604 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -99,7 +99,7 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
 
 /* Per CPU bogomips and other parameters */
-DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
+DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
 
 atomic_t init_deasserted;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/boot] x86-64: Handle PC-relative relocations on per-CPU data

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba
Gitweb: http://git.kernel.org/tip/6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Tue, 4 Nov 2014 08:50:18 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 4 Nov 2014 20:43:14 +0100

x86-64: Handle PC-relative relocations on per-CPU data

This is in preparation of using RIP-relative addressing in many of the
per-CPU accesses.

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/5458a15a027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/boot/compressed/misc.c | 14 +-
 arch/x86/tools/relocs.c | 36 +++-
 2 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 57ab74d..644abd7 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -260,7 +260,7 @@ static void handle_relocations(void *output, unsigned long 
output_len)
 
/*
 * Process relocations: 32 bit relocations first then 64 bit after.
-* Two sets of binary relocations are added to the end of the kernel
+* Three sets of binary relocations are added to the end of the kernel
 * before compression. Each relocation table entry is the kernel
 * address of the location which needs to be updated stored as a
 * 32-bit value which is sign extended to 64 bits.
@@ -270,6 +270,8 @@ static void handle_relocations(void *output, unsigned long 
output_len)
 * kernel bits...
 * 0 - zero terminator for 64 bit relocations
 * 64 bit relocation repeated
+* 0 - zero terminator for inverse 32 bit relocations
+* 32 bit inverse relocation repeated
 * 0 - zero terminator for 32 bit relocations
 * 32 bit relocation repeated
 *
@@ -286,6 +288,16 @@ static void handle_relocations(void *output, unsigned long 
output_len)
*(uint32_t *)ptr += delta;
}
 #ifdef CONFIG_X86_64
+   while (*--reloc) {
+   long extended = *reloc;
+   extended += map;
+
+   ptr = (unsigned long)extended;
+   if (ptr  min_addr || ptr  max_addr)
+   error(inverse 32-bit relocation outside of kernel!\n);
+
+   *(int32_t *)ptr -= delta;
+   }
for (reloc--; *reloc; reloc--) {
long extended = *reloc;
extended += map;
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index a5efb21..0c2fae8 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -20,7 +20,10 @@ struct relocs {
 
 static struct relocs relocs16;
 static struct relocs relocs32;
+#if ELF_BITS == 64
+static struct relocs relocs32neg;
 static struct relocs relocs64;
+#endif
 
 struct section {
Elf_Shdr   shdr;
@@ -762,11 +765,16 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, 
ElfW(Sym) *sym,
 
switch (r_type) {
case R_X86_64_NONE:
+   /* NONE can be ignored. */
+   break;
+
case R_X86_64_PC32:
/*
-* NONE can be ignored and PC relative relocations don't
-* need to be adjusted.
+* PC relative relocations don't need to be adjusted unless
+* referencing a percpu symbol.
 */
+   if (is_percpu_sym(sym, symname))
+   add_reloc(relocs32neg, offset);
break;
 
case R_X86_64_32:
@@ -986,7 +994,10 @@ static void emit_relocs(int as_text, int use_real_mode)
/* Order the relocations for more efficient processing */
sort_relocs(relocs16);
sort_relocs(relocs32);
+#if ELF_BITS == 64
+   sort_relocs(relocs32neg);
sort_relocs(relocs64);
+#endif
 
/* Print the relocations */
if (as_text) {
@@ -1007,14 +1018,21 @@ static void emit_relocs(int as_text, int use_real_mode)
for (i = 0; i  relocs32.count; i++)
write_reloc(relocs32.offset[i], stdout);
} else {
-   if (ELF_BITS == 64) {
-   /* Print a stop */
-   write_reloc(0, stdout);
+#if ELF_BITS == 64
+   /* Print a stop */
+   write_reloc(0, stdout);
 
-   /* Now print each relocation */
-   for (i = 0; i  relocs64.count; i++)
-   write_reloc(relocs64.offset[i], stdout);
-   }
+   /* Now print each relocation */
+   for (i = 0; i  relocs64.count; i++)
+   write_reloc(relocs64.offset[i], stdout);
+
+   /* Print a stop */
+   write_reloc(0, stdout);
+
+   /* Now print each inverse 32-bit relocation */
+   for (i = 0; i  

[tip:x86/boot] x86-64: Use RIP-relative addressing for most per-CPU accesses

2014-11-04 Thread tip-bot for Jan Beulich
Commit-ID:  97b67ae559947f1e208439a1bf6a734da3087006
Gitweb: http://git.kernel.org/tip/97b67ae559947f1e208439a1bf6a734da3087006
Author: Jan Beulich jbeul...@suse.com
AuthorDate: Tue, 4 Nov 2014 08:50:48 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Tue, 4 Nov 2014 20:43:14 +0100

x86-64: Use RIP-relative addressing for most per-CPU accesses

Observing that per-CPU data (in the SMP case) is reachable by
exploiting 64-bit address wraparound (building on the default kernel
load address being at 16Mb), the one byte shorter RIP-relative
addressing form can be used for most per-CPU accesses. The one
exception are the stable reads, where the use of the P operand
modifier prevents the compiler from using RIP-relative addressing, but
is unavoidable due to the use of the p constraint (side note: with
gcc 4.9.x the intended effect of this isn't being achieved anymore,
see gcc bug 63637).

With the dependency on the minimum kernel load address, arbitrarily
low values for CONFIG_PHYSICAL_START are now no longer possible. A
link time assertion is being added, directing to the need to increase
that value when it triggers.

Signed-off-by: Jan Beulich jbeul...@suse.com
Link: http://lkml.kernel.org/r/5458a178027800044...@mail.emea.novell.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 arch/x86/include/asm/percpu.h | 59 ---
 arch/x86/kernel/vmlinux.lds.S |  2 ++
 2 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 74da317..e0ba66c 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -64,7 +64,7 @@
 #define __percpu_prefix
 #endif
 
-#define __percpu_arg(x)__percpu_prefix %P #x
+#define __percpu_arg(x)__percpu_prefix % #x
 
 /*
  * Initialized pointers to per-cpu variables needed for the boot
@@ -179,29 +179,58 @@ do {  
\
}   \
 } while (0)
 
-#define percpu_from_op(op, var, constraint)\
+#define percpu_from_op(op, var)\
 ({ \
typeof(var) pfo_ret__;  \
switch (sizeof(var)) {  \
case 1: \
asm(op b __percpu_arg(1),%0 \
: =q (pfo_ret__)  \
-   : constraint);  \
+   : m (var));   \
break;  \
case 2: \
asm(op w __percpu_arg(1),%0 \
: =r (pfo_ret__)  \
-   : constraint);  \
+   : m (var));   \
break;  \
case 4: \
asm(op l __percpu_arg(1),%0 \
: =r (pfo_ret__)  \
-   : constraint);  \
+   : m (var));   \
break;  \
case 8: \
asm(op q __percpu_arg(1),%0 \
: =r (pfo_ret__)  \
-   : constraint);  \
+   : m (var));   \
+   break;  \
+   default: __bad_percpu_size();   \
+   }   \
+   pfo_ret__;  \
+})
+
+#define percpu_stable_op(op, var)  \
+({ \
+   typeof(var) pfo_ret__;  \
+   switch (sizeof(var)) {  \
+   case 1: \
+   asm(op b __percpu_arg(P1),%0\
+   : =q (pfo_ret__)  \
+   : p ((var)));\
+   break;  \
+   case 2: \
+   asm(op w __percpu_arg(P1),%0\
+   : =r (pfo_ret__)  \
+   : p ((var)));\
+   break;  \
+   case 4: \
+   asm(op l __percpu_arg(P1),%0\
+   : =r (pfo_ret__)  \
+   : p ((var)));\
+ 

  1   2   >