1. 16 8月, 2018 2 次提交
  2. 14 8月, 2018 1 次提交
  3. 13 8月, 2018 9 次提交
  4. 11 8月, 2018 2 次提交
    • A
      lib/ubsan: remove null-pointer checks · 3ca17b1f
      Andrey Ryabinin 提交于
      With gcc-8 fsanitize=null become very noisy.  GCC started to complain
      about things like &a->b, where 'a' is NULL pointer.  There is no NULL
      dereference, we just calculate address to struct member.  It's
      technically undefined behavior so UBSAN is correct to report it.  But as
      long as there is no real NULL-dereference, I think, we should be fine.
      
      -fno-delete-null-pointer-checks compiler flag should protect us from any
      consequences.  So let's just no use -fsanitize=null as it's not useful
      for us.  If there is a real NULL-deref we will see crash.  Even if
      userspace mapped something at NULL (root can do this), with things like
      SMAP should catch the issue.
      
      Link: http://lkml.kernel.org/r/20180802153209.813-1-aryabinin@virtuozzo.comSigned-off-by: NAndrey Ryabinin <aryabinin@virtuozzo.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3ca17b1f
    • J
      x86/mm/pti: Move user W+X check into pti_finalize() · d878efce
      Joerg Roedel 提交于
      The user page-table gets the updated kernel mappings in pti_finalize(),
      which runs after the RO+X permissions got applied to the kernel page-table
      in mark_readonly().
      
      But with CONFIG_DEBUG_WX enabled, the user page-table is already checked in
      mark_readonly() for insecure mappings.  This causes false-positive
      warnings, because the user page-table did not get the updated mappings yet.
      
      Move the W+X check for the user page-table into pti_finalize() after it
      updated all required mappings.
      
      [ tglx: Folded !NX supported fix ]
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: linux-mm@kvack.org
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: David Laight <David.Laight@aculab.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Eduardo Valentin <eduval@amazon.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aliguori@amazon.com
      Cc: daniel.gruss@iaik.tugraz.at
      Cc: hughd@google.com
      Cc: keescook@google.com
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Waiman Long <llong@redhat.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
      Cc: joro@8bytes.org
      Link: https://lkml.kernel.org/r/1533727000-9172-1-git-send-email-joro@8bytes.org
      d878efce
  5. 10 8月, 2018 2 次提交
  6. 09 8月, 2018 4 次提交
    • G
      s390/mm: fix addressing exception after suspend/resume · 37a366fa
      Gerald Schaefer 提交于
      Commit c9b5ad54 "s390/mm: tag normal pages vs pages used in page tables"
      accidentally changed the logic in arch_set_page_states(), which is used by
      the suspend/resume code. set_page_stable(page, order) was changed to
      set_page_stable_dat(page, 0). After this, only the first page of higher order
      pages will be set to stable, and a write to one of the unstable pages will
      result in an addressing exception.
      
      Fix this by using "order" again, instead of "0".
      
      Fixes: c9b5ad54 ("s390/mm: tag normal pages vs pages used in page tables")
      Cc: stable@vger.kernel.org # 4.14+
      Reviewed-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NGerald Schaefer <gerald.schaefer@de.ibm.com>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      37a366fa
    • J
      parisc: Define mb() and add memory barriers to assembler unlock sequences · fedb8da9
      John David Anglin 提交于
      For years I thought all parisc machines executed loads and stores in
      order. However, Jeff Law recently indicated on gcc-patches that this is
      not correct. There are various degrees of out-of-order execution all the
      way back to the PA7xxx processor series (hit-under-miss). The PA8xxx
      series has full out-of-order execution for both integer operations, and
      loads and stores.
      
      This is described in the following article:
      http://web.archive.org/web/20040214092531/http://www.cpus.hp.com/technical_references/advperf.shtml
      
      For this reason, we need to define mb() and to insert a memory barrier
      before the store unlocking spinlocks. This ensures that all memory
      accesses are complete prior to unlocking. The ldcw instruction performs
      the same function on entry.
      Signed-off-by: NJohn David Anglin <dave.anglin@bell.net>
      Cc: stable@vger.kernel.org # 4.0+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      fedb8da9
    • H
      parisc: Enable CONFIG_MLONGCALLS by default · 66509a27
      Helge Deller 提交于
      Enable the -mlong-calls compiler option by default, because otherwise in most
      cases linking the vmlinux binary fails due to truncations of R_PARISC_PCREL22F
      relocations. This fixes building the 64-bit defconfig.
      
      Cc: stable@vger.kernel.org # 4.0+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      66509a27
    • P
      MIPS: netlogic: xlr: Remove erroneous check in nlm_fmn_send() · 02eec6c9
      Paul Burton 提交于
      In nlm_fmn_send() we have a loop which attempts to send a message
      multiple times in order to handle the transient failure condition of a
      lack of available credit. When examining the status register to detect
      the failure we check for a condition that can never be true, which falls
      foul of gcc 8's -Wtautological-compare:
      
        In file included from arch/mips/netlogic/common/irq.c:65:
        ./arch/mips/include/asm/netlogic/xlr/fmn.h: In function 'nlm_fmn_send':
        ./arch/mips/include/asm/netlogic/xlr/fmn.h:304:22: error: bitwise
          comparison always evaluates to false [-Werror=tautological-compare]
           if ((status & 0x2) == 1)
                              ^~
      
      If the path taken if this condition were true all we do is print a
      message to the kernel console. Since failures seem somewhat expected
      here (making the console message questionable anyway) and the condition
      has clearly never evaluated true we simply remove it, rather than
      attempting to fix it to check status correctly.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20174/
      Cc: Ganesan Ramalingam <ganesanr@broadcom.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Jayachandran C <jnair@caviumnetworks.com>
      Cc: John Crispin <john@phrozen.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      02eec6c9
  7. 08 8月, 2018 8 次提交
    • P
      MIPS: VDSO: Force link endianness · 2f002567
      Paul Burton 提交于
      When building the VDSO with clang it appears to invoke ld without
      specifying endianness, even though clang itself was provided with a -EB
      or -EL flag. This results in the build failing due to a mismatch between
      the objects that are the input to ld, and the output it is attempting to
      create:
      
        VDSO    arch/mips/vdso/vdso.so.dbg.raw
        mips-linux-ld: arch/mips/vdso/elf.o: compiled for a big endian system
          and target is little endian
        mips-linux-ld: arch/mips/vdso/elf.o: endianness incompatible with that
          of the selected emulation
        mips-linux-ld: failed to merge target specific data of file
          arch/mips/vdso/elf.o
        ...
      
      Work around this problem by explicitly specifying the link endianness
      using -Wl,-EB or -Wl,-EL when -EB or -EL are part of KBUILD_CFLAGS. This
      resolves the build failure when using clang, and doesn't have any
      negative effect on gcc.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      2f002567
    • P
      MIPS: Always specify -EB or -EL when using clang · c6d6f4c5
      Paul Burton 提交于
      When building using clang, always specify -EB or -EL in order to ensure
      we target the desired endianness.
      
      Since clang cross compiles using a single compiler build with multiple
      targets, our -dumpmachine tests which don't specify clang's --target
      argument check output based upon the build machine rather than the
      machine our build will target. This means our detection of whether to
      specify -EB fails miserably & we never do. Providing the endianness flag
      unconditionally for clang resolves this issue & simplifies the clang
      path somewhat.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      c6d6f4c5
    • J
      x86/mm/pti: Clone kernel-image on PTE level for 32 bit · 16a3fe63
      Joerg Roedel 提交于
      On 32 bit the kernel sections are not huge-page aligned.  When we clone
      them on PMD-level we unevitably map some areas that are normal kernel
      memory and may contain secrets to user-space. To prevent that we need to
      clone the kernel-image on PTE-level for 32 bit.
      
      Also make the page-table cloning code more general so that it can handle
      PMD and PTE level cloning. This can be generalized further in the future to
      also handle clones on the P4D-level.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: linux-mm@kvack.org
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: David Laight <David.Laight@aculab.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Eduardo Valentin <eduval@amazon.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aliguori@amazon.com
      Cc: daniel.gruss@iaik.tugraz.at
      Cc: hughd@google.com
      Cc: keescook@google.com
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Waiman Long <llong@redhat.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
      Cc: joro@8bytes.org
      Link: https://lkml.kernel.org/r/1533637471-30953-4-git-send-email-joro@8bytes.org
      16a3fe63
    • J
      x86/mm/pti: Don't clear permissions in pti_clone_pmd() · 30514eff
      Joerg Roedel 提交于
      The function sets the global-bit on cloned PMD entries, which only makes
      sense when the permissions are identical between the user and the kernel
      page-table. Further, only write-permissions are cleared for entry-text and
      kernel-text sections, which are not writeable at the end of the boot
      process.
      
      The reason why this RW clearing exists is that in the early PTI
      implementations the cloned kernel areas were set up during early boot
      before the kernel text is set to read only and not touched afterwards.
      
      This is not longer true. The cloned areas are still set up early to get the
      entry code working for interrupts and other things, but after the kernel
      text has been set RO the clone is repeated which copies the RO PMD/PTEs
      over to the user visible clone. That means the initial clearing of the
      writable bit can be avoided.
      
      [ tglx: Amended changelog ]
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NDave Hansen <dave.hansen@intel.com>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: linux-mm@kvack.org
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: David Laight <David.Laight@aculab.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Eduardo Valentin <eduval@amazon.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aliguori@amazon.com
      Cc: daniel.gruss@iaik.tugraz.at
      Cc: hughd@google.com
      Cc: keescook@google.com
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Waiman Long <llong@redhat.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
      Cc: joro@8bytes.org
      Link: https://lkml.kernel.org/r/1533637471-30953-3-git-send-email-joro@8bytes.org
      30514eff
    • P
      x86/paravirt: Fix spectre-v2 mitigations for paravirt guests · 5800dc5c
      Peter Zijlstra 提交于
      Nadav reported that on guests we're failing to rewrite the indirect
      calls to CALLEE_SAVE paravirt functions. In particular the
      pv_queued_spin_unlock() call is left unpatched and that is all over the
      place. This obviously wrecks Spectre-v2 mitigation (for paravirt
      guests) which relies on not actually having indirect calls around.
      
      The reason is an incorrect clobber test in paravirt_patch_call(); this
      function rewrites an indirect call with a direct call to the _SAME_
      function, there is no possible way the clobbers can be different
      because of this.
      
      Therefore remove this clobber check. Also put WARNs on the other patch
      failure case (not enough room for the instruction) which I've not seen
      trigger in my (limited) testing.
      
      Three live kernel image disassemblies for lock_sock_nested (as a small
      function that illustrates the problem nicely). PRE is the current
      situation for guests, POST is with this patch applied and NATIVE is with
      or without the patch for !guests.
      
      PRE:
      
      (gdb) disassemble lock_sock_nested
      Dump of assembler code for function lock_sock_nested:
         0xffffffff817be970 <+0>:     push   %rbp
         0xffffffff817be971 <+1>:     mov    %rdi,%rbp
         0xffffffff817be974 <+4>:     push   %rbx
         0xffffffff817be975 <+5>:     lea    0x88(%rbp),%rbx
         0xffffffff817be97c <+12>:    callq  0xffffffff819f7160 <_cond_resched>
         0xffffffff817be981 <+17>:    mov    %rbx,%rdi
         0xffffffff817be984 <+20>:    callq  0xffffffff819fbb00 <_raw_spin_lock_bh>
         0xffffffff817be989 <+25>:    mov    0x8c(%rbp),%eax
         0xffffffff817be98f <+31>:    test   %eax,%eax
         0xffffffff817be991 <+33>:    jne    0xffffffff817be9ba <lock_sock_nested+74>
         0xffffffff817be993 <+35>:    movl   $0x1,0x8c(%rbp)
         0xffffffff817be99d <+45>:    mov    %rbx,%rdi
         0xffffffff817be9a0 <+48>:    callq  *0xffffffff822299e8
         0xffffffff817be9a7 <+55>:    pop    %rbx
         0xffffffff817be9a8 <+56>:    pop    %rbp
         0xffffffff817be9a9 <+57>:    mov    $0x200,%esi
         0xffffffff817be9ae <+62>:    mov    $0xffffffff817be993,%rdi
         0xffffffff817be9b5 <+69>:    jmpq   0xffffffff81063ae0 <__local_bh_enable_ip>
         0xffffffff817be9ba <+74>:    mov    %rbp,%rdi
         0xffffffff817be9bd <+77>:    callq  0xffffffff817be8c0 <__lock_sock>
         0xffffffff817be9c2 <+82>:    jmp    0xffffffff817be993 <lock_sock_nested+35>
      End of assembler dump.
      
      POST:
      
      (gdb) disassemble lock_sock_nested
      Dump of assembler code for function lock_sock_nested:
         0xffffffff817be970 <+0>:     push   %rbp
         0xffffffff817be971 <+1>:     mov    %rdi,%rbp
         0xffffffff817be974 <+4>:     push   %rbx
         0xffffffff817be975 <+5>:     lea    0x88(%rbp),%rbx
         0xffffffff817be97c <+12>:    callq  0xffffffff819f7160 <_cond_resched>
         0xffffffff817be981 <+17>:    mov    %rbx,%rdi
         0xffffffff817be984 <+20>:    callq  0xffffffff819fbb00 <_raw_spin_lock_bh>
         0xffffffff817be989 <+25>:    mov    0x8c(%rbp),%eax
         0xffffffff817be98f <+31>:    test   %eax,%eax
         0xffffffff817be991 <+33>:    jne    0xffffffff817be9ba <lock_sock_nested+74>
         0xffffffff817be993 <+35>:    movl   $0x1,0x8c(%rbp)
         0xffffffff817be99d <+45>:    mov    %rbx,%rdi
         0xffffffff817be9a0 <+48>:    callq  0xffffffff810a0c20 <__raw_callee_save___pv_queued_spin_unlock>
         0xffffffff817be9a5 <+53>:    xchg   %ax,%ax
         0xffffffff817be9a7 <+55>:    pop    %rbx
         0xffffffff817be9a8 <+56>:    pop    %rbp
         0xffffffff817be9a9 <+57>:    mov    $0x200,%esi
         0xffffffff817be9ae <+62>:    mov    $0xffffffff817be993,%rdi
         0xffffffff817be9b5 <+69>:    jmpq   0xffffffff81063aa0 <__local_bh_enable_ip>
         0xffffffff817be9ba <+74>:    mov    %rbp,%rdi
         0xffffffff817be9bd <+77>:    callq  0xffffffff817be8c0 <__lock_sock>
         0xffffffff817be9c2 <+82>:    jmp    0xffffffff817be993 <lock_sock_nested+35>
      End of assembler dump.
      
      NATIVE:
      
      (gdb) disassemble lock_sock_nested
      Dump of assembler code for function lock_sock_nested:
         0xffffffff817be970 <+0>:     push   %rbp
         0xffffffff817be971 <+1>:     mov    %rdi,%rbp
         0xffffffff817be974 <+4>:     push   %rbx
         0xffffffff817be975 <+5>:     lea    0x88(%rbp),%rbx
         0xffffffff817be97c <+12>:    callq  0xffffffff819f7160 <_cond_resched>
         0xffffffff817be981 <+17>:    mov    %rbx,%rdi
         0xffffffff817be984 <+20>:    callq  0xffffffff819fbb00 <_raw_spin_lock_bh>
         0xffffffff817be989 <+25>:    mov    0x8c(%rbp),%eax
         0xffffffff817be98f <+31>:    test   %eax,%eax
         0xffffffff817be991 <+33>:    jne    0xffffffff817be9ba <lock_sock_nested+74>
         0xffffffff817be993 <+35>:    movl   $0x1,0x8c(%rbp)
         0xffffffff817be99d <+45>:    mov    %rbx,%rdi
         0xffffffff817be9a0 <+48>:    movb   $0x0,(%rdi)
         0xffffffff817be9a3 <+51>:    nopl   0x0(%rax)
         0xffffffff817be9a7 <+55>:    pop    %rbx
         0xffffffff817be9a8 <+56>:    pop    %rbp
         0xffffffff817be9a9 <+57>:    mov    $0x200,%esi
         0xffffffff817be9ae <+62>:    mov    $0xffffffff817be993,%rdi
         0xffffffff817be9b5 <+69>:    jmpq   0xffffffff81063ae0 <__local_bh_enable_ip>
         0xffffffff817be9ba <+74>:    mov    %rbp,%rdi
         0xffffffff817be9bd <+77>:    callq  0xffffffff817be8c0 <__lock_sock>
         0xffffffff817be9c2 <+82>:    jmp    0xffffffff817be993 <lock_sock_nested+35>
      End of assembler dump.
      
      
      Fixes: 63f70270 ("[PATCH] i386: PARAVIRT: add common patching machinery")
      Fixes: 3010a066 ("x86/paravirt, objtool: Annotate indirect calls")
      Reported-by: NNadav Amit <namit@vmware.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NJuergen Gross <jgross@suse.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: stable@vger.kernel.org
      5800dc5c
    • P
      MIPS: Use dins to simplify __write_64bit_c0_split() · 36dc5b20
      Paul Burton 提交于
      The code in __write_64bit_c0_split() is used by MIPS32 kernels running
      on MIPS64 CPUs to write a 64-bit value to a 64-bit coprocessor 0
      register using a single 64-bit dmtc0 instruction. It does this by
      combining the 2x 32-bit registers used to hold the 64-bit value into a
      single register, which in the existing code involves three steps:
      
        1) Zero extend register A which holds bits 31:0 of our data, since it
           may have previously held a sign-extended value.
      
        2) Shift register B which holds bits 63:32 of our data in bits 31:0
           left by 32 bits, such that the bits forming our data are in the
           position they'll be in the final 64-bit value & bits 31:0 of the
           register are zero.
      
        3) Or the two registers together to form the 64-bit value in one
           64-bit register.
      
      From MIPS r2 onwards we have a dins instruction which can effectively
      perform all 3 of those steps using a single instruction.
      
      Add a path for MIPS r2 & beyond which uses dins to take bits 31:0 from
      register B & insert them into bits 63:32 of register A, giving us our
      full 64-bit value in register A with one instruction.
      
      Since we know that MIPS r2 & above support the sel field for the dmtc0
      instruction, we don't bother special casing sel==0. Omiting the sel
      field would assemble to exactly the same instruction as when we
      explicitly specify that it equals zero.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      36dc5b20
    • P
      MIPS: Use read-write output operand in __write_64bit_c0_split() · 08eeb44b
      Paul Burton 提交于
      Commit c22c8043 ("MIPS: Fix input modify in
      __write_64bit_c0_split()") modified __write_64bit_c0_split() constraints
      such that we have both an input & an output which we hope to assign to
      the same registers, and modify the output rather than incorrectly
      clobbering an input.
      
      The way in which we use both an output & an input parameter with the
      input constrained to share the output registers is a little convoluted &
      also problematic for clang, which complains if the input & output values
      have different widths. For example:
      
        In file included from kernel/fork.c:98:
        ./arch/mips/include/asm/mmu_context.h:149:19: error: unsupported
          inline asm: input with type 'unsigned long' matching output with
          type 'unsigned long long'
                write_c0_entryhi(cpu_asid(cpu, next));
                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
        ./arch/mips/include/asm/mmu_context.h:93:2: note: expanded from macro
          'cpu_asid'
                (cpu_context((cpu), (mm)) & cpu_asid_mask(&cpu_data[cpu]))
                ^
        ./arch/mips/include/asm/mipsregs.h:1617:65: note: expanded from macro
          'write_c0_entryhi'
        #define write_c0_entryhi(val)   __write_ulong_c0_register($10, 0, val)
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
        ./arch/mips/include/asm/mipsregs.h:1430:39: note: expanded from macro
          '__write_ulong_c0_register'
                        __write_64bit_c0_register(reg, sel, val);               \
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
        ./arch/mips/include/asm/mipsregs.h:1400:41: note: expanded from macro
          '__write_64bit_c0_register'
                        __write_64bit_c0_split(register, sel, value);           \
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
        ./arch/mips/include/asm/mipsregs.h:1498:13: note: expanded from macro
          '__write_64bit_c0_split'
                                : "r,0" (val));                                 \
                                         ^~~
      
      We can both fix this build failure & simplify the code somewhat by
      assigning the __tmp variable with the input value in C prior to our
      inline assembly, and then using a single read-write output operand (ie.
      a constraint beginning with +) to provide this value to our assembly.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      08eeb44b
    • J
      x86/mm/pti: Fix 32 bit PCID check · 88c6f8a3
      Joerg Roedel 提交于
      The check uses the wrong operator and causes false positive
      warnings in the kernel log on some systems.
      
      Fixes: 5e810595 ('x86/mm/pti: Add Warning when booting on a PCID capable CPU')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: linux-mm@kvack.org
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: David Laight <David.Laight@aculab.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Eduardo Valentin <eduval@amazon.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aliguori@amazon.com
      Cc: daniel.gruss@iaik.tugraz.at
      Cc: hughd@google.com
      Cc: keescook@google.com
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Waiman Long <llong@redhat.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
      Cc: joro@8bytes.org
      Link: https://lkml.kernel.org/r/1533637471-30953-2-git-send-email-joro@8bytes.org
      88c6f8a3
  8. 07 8月, 2018 9 次提交
    • M
      s390: fix br_r1_trampoline for machines without exrl · 26f84384
      Martin Schwidefsky 提交于
      For machines without the exrl instruction the BFP jit generates
      code that uses an "br %r1" instruction located in the lowcore page.
      Unfortunately there is a cut & paste error that puts an additional
      "larl %r1,.+14" instruction in the code that clobbers the branch
      target address in %r1. Remove the larl instruction.
      
      Cc: <stable@vger.kernel.org> # v4.17+
      Fixes: de5cb6eb ("s390: use expoline thunks in the BPF JIT")
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      26f84384
    • M
      s390/lib: use expoline for all bcr instructions · 5eda25b1
      Martin Schwidefsky 提交于
      The memove, memset, memcpy, __memset16, __memset32 and __memset64
      function have an additional indirect return branch in form of a
      "bzr" instruction. These need to use expolines as well.
      
      Cc: <stable@vger.kernel.org> # v4.17+
      Fixes: 97489e06 ("s390/lib: use expoline for indirect branches")
      Reviewed-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      5eda25b1
    • O
      crypto: x86/aegis,morus - Fix and simplify CPUID checks · 877ccce7
      Ondrej Mosnacek 提交于
      It turns out I had misunderstood how the x86_match_cpu() function works.
      It evaluates a logical OR of the matching conditions, not logical AND.
      This caused the CPU feature checks for AEGIS to pass even if only SSE2
      (but not AES-NI) was supported (or vice versa), leading to potential
      crashes if something tried to use the registered algs.
      
      This patch switches the checks to a simpler method that is used e.g. in
      the Camellia x86 code.
      
      The patch also removes the MODULE_DEVICE_TABLE declarations which
      actually seem to cause the modules to be auto-loaded at boot, which is
      not desired. The crypto API on-demand module loading is sufficient.
      
      Fixes: 1d373d4e ("crypto: x86 - Add optimized AEGIS implementations")
      Fixes: 6ecc9d9f ("crypto: x86 - Add optimized MORUS implementations")
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Tested-by: NMilan Broz <gmazyland@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      877ccce7
    • A
      crypto: arm64 - revert NEON yield for fast AEAD implementations · f10dc56c
      Ard Biesheuvel 提交于
      As it turns out, checking the TIF_NEED_RESCHED flag after each
      iteration results in a significant performance regression (~10%)
      when running fast algorithms (i.e., ones that use special instructions
      and operate in the < 4 cycles per byte range) on in-order cores with
      comparatively slow memory accesses such as the Cortex-A53.
      
      Given the speed of these ciphers, and the fact that the page based
      nature of the AEAD scatterwalk API guarantees that the core NEON
      transform is never invoked with more than a single page's worth of
      input, we can estimate the worst case duration of any resulting
      scheduling blackout: on a 1 GHz Cortex-A53 running with 64k pages,
      processing a page's worth of input at 4 cycles per byte results in
      a delay of ~250 us, which is a reasonable upper bound.
      
      So let's remove the yield checks from the fused AES-CCM and AES-GCM
      routines entirely.
      
      This reverts commit 7b67ae4d and
      partially reverts commit 7c50136a.
      
      Fixes: 7c50136a ("crypto: arm64/aes-ghash - yield NEON after every ...")
      Fixes: 7b67ae4d ("crypto: arm64/aes-ccm - yield NEON after every ...")
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      f10dc56c
    • P
      MIPS: Avoid using array as parameter to write_c0_kpgd() · b023a939
      Paul Burton 提交于
      Passing an array (swapper_pg_dir) as the argument to write_c0_kpgd() in
      setup_pw() will become problematic if we modify __write_64bit_c0_split()
      to cast its val argument to unsigned long long, because for 32-bit
      kernel builds the size of a pointer will differ from the size of an
      unsigned long long. This would fall foul of gcc's pointer-to-int-cast
      diagnostic.
      
      Cast the value to a long, which should be the same width as the pointer
      that we ultimately want & will be sign extended if required to the
      unsigned long long that __write_64bit_c0_split() ultimately needs.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      b023a939
    • P
      MIPS: vdso: Allow clang's --target flag in VDSO cflags · ee67855e
      Paul Burton 提交于
      The MIPS VDSO code filters out a subset of known-good flags from
      KBUILD_CFLAGS to use when building VDSO libraries. When we build using
      clang we need to allow the --target flag through, otherwise we'll
      generally attempt to build the VDSO for the architecture of the build
      machine rather than for MIPS.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20154/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      ee67855e
    • P
      MIPS: genvdso: Remove GOT checks · 4467f7ad
      Paul Burton 提交于
      Our genvdso tool performs some rather paranoid checking that the VDSO
      library isn't attempting to make use of a GOT by constraining the number
      of entries that the GOT is allowed to contain to the minimum 2 entries
      that are always generated by binutils.
      
      Unfortunately lld prior to revision 334390 generates a third entry,
      which is unused & thus harmless but falls foul of genvdso's checks &
      causes the build to fail.
      
      Since we already check that the VDSO contains no relocations it seems
      reasonable to presume that it also doesn't contain use of a GOT, which
      would involve relocations. Thus rather than attempting to work around
      this issue by allowing 3 GOT entries when using lld, simply remove the
      GOT checks which seem overly paranoid.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20152/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      4467f7ad
    • D
      x86/mm/init: Remove freed kernel image areas from alias mapping · c40a56a7
      Dave Hansen 提交于
      The kernel image is mapped into two places in the virtual address space
      (addresses without KASLR, of course):
      
      	1. The kernel direct map (0xffff880000000000)
      	2. The "high kernel map" (0xffffffff81000000)
      
      We actually execute out of #2.  If we get the address of a kernel symbol,
      it points to #2, but almost all physical-to-virtual translations point to
      
      Parts of the "high kernel map" alias are mapped in the userspace page
      tables with the Global bit for performance reasons.  The parts that we map
      to userspace do not (er, should not) have secrets. When PTI is enabled then
      the global bit is usually not set in the high mapping and just used to
      compensate for poor performance on systems which lack PCID.
      
      This is fine, except that some areas in the kernel image that are adjacent
      to the non-secret-containing areas are unused holes.  We free these holes
      back into the normal page allocator and reuse them as normal kernel memory.
      The memory will, of course, get *used* via the normal map, but the alias
      mapping is kept.
      
      This otherwise unused alias mapping of the holes will, by default keep the
      Global bit, be mapped out to userspace, and be vulnerable to Meltdown.
      
      Remove the alias mapping of these pages entirely.  This is likely to
      fracture the 2M page mapping the kernel image near these areas, but this
      should affect a minority of the area.
      
      The pageattr code changes *all* aliases mapping the physical pages that it
      operates on (by default).  We only want to modify a single alias, so we
      need to tweak its behavior.
      
      This unmapping behavior is currently dependent on PTI being in place.
      Going forward, we should at least consider doing this for all
      configurations.  Having an extra read-write alias for memory is not exactly
      ideal for debugging things like random memory corruption and this does
      undercut features like DEBUG_PAGEALLOC or future work like eXclusive Page
      Frame Ownership (XPFO).
      
      Before this patch:
      
      current_kernel:---[ High Kernel Mapping ]---
      current_kernel-0xffffffff80000000-0xffffffff81000000          16M                               pmd
      current_kernel-0xffffffff81000000-0xffffffff81e00000          14M     ro         PSE     GLB x  pmd
      current_kernel-0xffffffff81e00000-0xffffffff81e11000          68K     ro                 GLB x  pte
      current_kernel-0xffffffff81e11000-0xffffffff82000000        1980K     RW                     NX pte
      current_kernel-0xffffffff82000000-0xffffffff82600000           6M     ro         PSE     GLB NX pmd
      current_kernel-0xffffffff82600000-0xffffffff82c00000           6M     RW         PSE         NX pmd
      current_kernel-0xffffffff82c00000-0xffffffff82e00000           2M     RW                     NX pte
      current_kernel-0xffffffff82e00000-0xffffffff83200000           4M     RW         PSE         NX pmd
      current_kernel-0xffffffff83200000-0xffffffffa0000000         462M                               pmd
      
        current_user:---[ High Kernel Mapping ]---
        current_user-0xffffffff80000000-0xffffffff81000000          16M                               pmd
        current_user-0xffffffff81000000-0xffffffff81e00000          14M     ro         PSE     GLB x  pmd
        current_user-0xffffffff81e00000-0xffffffff81e11000          68K     ro                 GLB x  pte
        current_user-0xffffffff81e11000-0xffffffff82000000        1980K     RW                     NX pte
        current_user-0xffffffff82000000-0xffffffff82600000           6M     ro         PSE     GLB NX pmd
        current_user-0xffffffff82600000-0xffffffffa0000000         474M                               pmd
      
      After this patch:
      
      current_kernel:---[ High Kernel Mapping ]---
      current_kernel-0xffffffff80000000-0xffffffff81000000          16M                               pmd
      current_kernel-0xffffffff81000000-0xffffffff81e00000          14M     ro         PSE     GLB x  pmd
      current_kernel-0xffffffff81e00000-0xffffffff81e11000          68K     ro                 GLB x  pte
      current_kernel-0xffffffff81e11000-0xffffffff82000000        1980K                               pte
      current_kernel-0xffffffff82000000-0xffffffff82400000           4M     ro         PSE     GLB NX pmd
      current_kernel-0xffffffff82400000-0xffffffff82488000         544K     ro                     NX pte
      current_kernel-0xffffffff82488000-0xffffffff82600000        1504K                               pte
      current_kernel-0xffffffff82600000-0xffffffff82c00000           6M     RW         PSE         NX pmd
      current_kernel-0xffffffff82c00000-0xffffffff82c0d000          52K     RW                     NX pte
      current_kernel-0xffffffff82c0d000-0xffffffff82dc0000        1740K                               pte
      
        current_user:---[ High Kernel Mapping ]---
        current_user-0xffffffff80000000-0xffffffff81000000          16M                               pmd
        current_user-0xffffffff81000000-0xffffffff81e00000          14M     ro         PSE     GLB x  pmd
        current_user-0xffffffff81e00000-0xffffffff81e11000          68K     ro                 GLB x  pte
        current_user-0xffffffff81e11000-0xffffffff82000000        1980K                               pte
        current_user-0xffffffff82000000-0xffffffff82400000           4M     ro         PSE     GLB NX pmd
        current_user-0xffffffff82400000-0xffffffff82488000         544K     ro                     NX pte
        current_user-0xffffffff82488000-0xffffffff82600000        1504K                               pte
        current_user-0xffffffff82600000-0xffffffffa0000000         474M                               pmd
      
      [ tglx: Do not unmap on 32bit as there is only one mapping ]
      
      Fixes: 0f561fce ("x86/pti: Enable global pages for shared areas")
      Signed-off-by: NDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@google.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Joerg Roedel <jroedel@suse.de>
      Link: https://lkml.kernel.org/r/20180802225831.5F6A2BFC@viggo.jf.intel.com
      c40a56a7
    • R
      MIPS: Remove obsolete MIPS checks for DST node "chosen@0" · 7dc084d6
      Robert P. J. Day 提交于
      As there is precious little left in any DTS files referring to the
      node "/chosen@0" as opposed to "/chosen", remove the two checks for
      the former node name.
      
      [paul.burton@mips.com:
        The modified yamon-dt code only operates on
        arch/mips/boot/dts/mti/sead3.dts right now, and that uses chosen
        rather than chosen@0 anyway, so this should have no behavioural
        effect.]
      Signed-off-by: NRobert P. J. Day <rpjday@crashcourse.ca>
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20131/
      Cc: linux-mips@linux-mips.org
      7dc084d6
  9. 06 8月, 2018 3 次提交
    • A
      x86: vdso: Use $LD instead of $CC to link · 379d98dd
      Alistair Strachan 提交于
      The vdso{32,64}.so can fail to link with CC=clang when clang tries to find
      a suitable GCC toolchain to link these libraries with.
      
      /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o:
        access beyond end of merged section (782)
      
      This happens because the host environment leaked into the cross compiler
      environment due to the way clang searches for suitable GCC toolchains.
      
      Clang is a retargetable compiler, and each invocation of it must provide
      --target=<something> --gcc-toolchain=<something> to allow it to find the
      correct binutils for cross compilation. These flags had been added to
      KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various
      reasons) which breaks clang's ability to find the correct linker when cross
      compiling.
      
      Most of the time this goes unnoticed because the host linker is new enough
      to work anyway, or is incompatible and skipped, but this cannot be reliably
      assumed.
      
      This change alters the vdso makefile to just use LD directly, which
      bypasses clang and thus the searching problem. The makefile will just use
      ${CROSS_COMPILE}ld instead, which is always what we want. This matches the
      method used to link vmlinux.
      
      This drops references to DISABLE_LTO; this option doesn't seem to be set
      anywhere, and not knowing what its possible values are, it's not clear how
      to convert it from CC to LD flag.
      Signed-off-by: NAlistair Strachan <astrachan@google.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: kernel-team@android.com
      Cc: joel@joelfernandes.org
      Cc: Andi Kleen <andi.kleen@intel.com>
      Link: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com
      379d98dd
    • N
      x86/irqflags: Provide a declaration for native_save_fl · 208cbb32
      Nick Desaulniers 提交于
      It was reported that the commit d0a8d937 is causing users of gcc < 4.9
      to observe -Werror=missing-prototypes errors.
      
      Indeed, it seems that:
      extern inline unsigned long native_save_fl(void) { return 0; }
      
      compiled with -Werror=missing-prototypes produces this warning in gcc <
      4.9, but not gcc >= 4.9.
      
      Fixes: d0a8d937 ("x86/paravirt: Make native_save_fl() extern inline").
      Reported-by: NDavid Laight <david.laight@aculab.com>
      Reported-by: NJean Delvare <jdelvare@suse.de>
      Signed-off-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: hpa@zytor.com
      Cc: jgross@suse.com
      Cc: kstewart@linuxfoundation.org
      Cc: gregkh@linuxfoundation.org
      Cc: boris.ostrovsky@oracle.com
      Cc: astrachan@google.com
      Cc: mka@chromium.org
      Cc: arnd@arndb.de
      Cc: tstellar@redhat.com
      Cc: sedat.dilek@gmail.com
      Cc: David.Laight@aculab.com
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20180803170550.164688-1-ndesaulniers@google.com
      208cbb32
    • D
      x86/mm/init: Add helper for freeing kernel image pages · 6ea2738e
      Dave Hansen 提交于
      When chunks of the kernel image are freed, free_init_pages() is used
      directly.  Consolidate the three sites that do this.  Also update the
      string to give an incrementally better description of that memory versus
      what was there before.
      Signed-off-by: NDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: keescook@google.com
      Cc: aarcange@redhat.com
      Cc: jgross@suse.com
      Cc: jpoimboe@redhat.com
      Cc: gregkh@linuxfoundation.org
      Cc: peterz@infradead.org
      Cc: hughd@google.com
      Cc: torvalds@linux-foundation.org
      Cc: bp@alien8.de
      Cc: luto@kernel.org
      Cc: ak@linux.intel.com
      Cc: Kees Cook <keescook@google.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Link: https://lkml.kernel.org/r/20180802225829.FE0E32EA@viggo.jf.intel.com
      6ea2738e