Skip to content
Snippets Groups Projects
  1. Mar 01, 2019
    • Paul Burton's avatar
      MIPS: eBPF: Fix icache flush end address · d1a2930d
      Paul Burton authored
      
      The MIPS eBPF JIT calls flush_icache_range() in order to ensure the
      icache observes the code that we just wrote. Unfortunately it gets the
      end address calculation wrong due to some bad pointer arithmetic.
      
      The struct jit_ctx target field is of type pointer to u32, and as such
      adding one to it will increment the address being pointed to by 4 bytes.
      Therefore in order to find the address of the end of the code we simply
      need to add the number of 4 byte instructions emitted, but we mistakenly
      add the number of instructions multiplied by 4. This results in the call
      to flush_icache_range() operating on a memory region 4x larger than
      intended, which is always wasteful and can cause crashes if we overrun
      into an unmapped page.
      
      Fix this by correcting the pointer arithmetic to remove the bogus
      multiplication, and use braces to remove the need for a set of brackets
      whilst also making it obvious that the target field is a pointer.
      
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: b6bd53f9 ("MIPS: Add missing file for eBPF JIT.")
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: netdev@vger.kernel.org
      Cc: bpf@vger.kernel.org
      Cc: linux-mips@vger.kernel.org
      Cc: stable@vger.kernel.org # v4.13+
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      d1a2930d
  2. Feb 28, 2019
  3. Feb 27, 2019
  4. Feb 25, 2019
    • Jonas Gorski's avatar
      MIPS: BCM63XX: provide DMA masks for ethernet devices · 18836b48
      Jonas Gorski authored
      
      The switch to the generic dma ops made dma masks mandatory, breaking
      devices having them not set. In case of bcm63xx, it broke ethernet with
      the following warning when trying to up the device:
      
      [    2.633123] ------------[ cut here ]------------
      [    2.637949] WARNING: CPU: 0 PID: 325 at ./include/linux/dma-mapping.h:516 bcm_enetsw_open+0x160/0xbbc
      [    2.647423] Modules linked in: gpio_button_hotplug
      [    2.652361] CPU: 0 PID: 325 Comm: ip Not tainted 4.19.16 #0
      [    2.658080] Stack : 80520000 804cd3ec 00000000 00000000 804ccc00 87085bdc 87d3f9d4 804f9a17
      [    2.666707]         8049cf18 00000145 80a942a0 00000204 80ac0000 10008400 87085b90 eb3d5ab7
      [    2.675325]         00000000 00000000 80ac0000 000022b0 00000000 00000000 00000007 00000000
      [    2.683954]         0000007a 80500000 0013b381 00000000 80000000 00000000 804a1664 80289878
      [    2.692572]         00000009 00000204 80ac0000 00000200 00000002 00000000 00000000 80a90000
      [    2.701191]         ...
      [    2.703701] Call Trace:
      [    2.706244] [<8001f3c8>] show_stack+0x58/0x100
      [    2.710840] [<800336e4>] __warn+0xe4/0x118
      [    2.715049] [<800337d4>] warn_slowpath_null+0x48/0x64
      [    2.720237] [<80289878>] bcm_enetsw_open+0x160/0xbbc
      [    2.725347] [<802d1d4c>] __dev_open+0xf8/0x16c
      [    2.729913] [<802d20cc>] __dev_change_flags+0x100/0x1c4
      [    2.735290] [<802d21b8>] dev_change_flags+0x28/0x70
      [    2.740326] [<803539e0>] devinet_ioctl+0x310/0x7b0
      [    2.745250] [<80355fd8>] inet_ioctl+0x1f8/0x224
      [    2.749939] [<802af290>] sock_ioctl+0x30c/0x488
      [    2.754632] [<80112b34>] do_vfs_ioctl+0x740/0x7dc
      [    2.759459] [<80112c20>] ksys_ioctl+0x50/0x94
      [    2.763955] [<800240b8>] syscall_common+0x34/0x58
      [    2.768782] ---[ end trace fb1a6b14d74e28b6 ]---
      [    2.773544] bcm63xx_enetsw bcm63xx_enetsw.0: cannot allocate rx ring 512
      
      Fix this by adding appropriate DMA masks for the platform devices.
      
      Fixes: f8c55dc6 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
      Signed-off-by: default avatarJonas Gorski <jonas.gorski@gmail.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: stable@vger.kernel.org # v4.19+
      18836b48
    • Andy Lutomirski's avatar
      x86/uaccess: Don't leak the AC flag into __put_user() value evaluation · 2a418cf3
      Andy Lutomirski authored
      
      When calling __put_user(foo(), ptr), the __put_user() macro would call
      foo() in between __uaccess_begin() and __uaccess_end().  If that code
      were buggy, then those bugs would be run without SMAP protection.
      
      Fortunately, there seem to be few instances of the problem in the
      kernel. Nevertheless, __put_user() should be fixed to avoid doing this.
      Therefore, evaluate __put_user()'s argument before setting AC.
      
      This issue was noticed when an objtool hack by Peter Zijlstra complained
      about genregs_get() and I compared the assembly output to the C source.
      
       [ bp: Massage commit message and fixed up whitespace. ]
      
      Fixes: 11f1a4b9 ("x86: reorganize SMAP handling in user space accesses")
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190225125231.845656645@infradead.org
      2a418cf3
    • Linus Torvalds's avatar
      Revert "x86/fault: BUG() when uaccess helpers fault on kernel addresses" · 53a41cb7
      Linus Torvalds authored
      
      This reverts commit 9da3f2b7.
      
      It was well-intentioned, but wrong.  Overriding the exception tables for
      instructions for random reasons is just wrong, and that is what the new
      code did.
      
      It caused problems for tracing, and it caused problems for strncpy_from_user(),
      because the new checks made perfectly valid use cases break, rather than
      catch things that did bad things.
      
      Unchecked user space accesses are a problem, but that's not a reason to
      add invalid checks that then people have to work around with silly flags
      (in this case, that 'kernel_uaccess_faults_ok' flag, which is just an
      odd way to say "this commit was wrong" and was sprinked into random
      places to hide the wrongness).
      
      The real fix to unchecked user space accesses is to get rid of the
      special "let's not check __get_user() and __put_user() at all" logic.
      Make __{get|put}_user() be just aliases to the regular {get|put}_user()
      functions, and make it impossible to access user space without having
      the proper checks in places.
      
      The raison d'être of the special double-underscore versions used to be
      that the range check was expensive, and if you did multiple user
      accesses, you'd do the range check up front (like the signal frame
      handling code, for example).  But SMAP (on x86) and PAN (on ARM) have
      made that optimization pointless, because the _real_ expense is the "set
      CPU flag to allow user space access".
      
      Do let's not break the valid cases to catch invalid cases that shouldn't
      even exist.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Tobin C. Harding <tobin@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Jann Horn <jannh@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      53a41cb7
    • Linus Walleij's avatar
      ARM: dts: gemini: Re-enable display controller · 014e90ca
      Linus Walleij authored
      
      commit 137cd710
      "ARM: dts: Enable Gemini flash access" contained a bug
      by disabling the display controller, while the whole
      idea with the patch was to enable flash access AND
      the display controller, simultaneously. Fix it up.
      
      Fixes: 137cd710 ("ARM: dts: Enable Gemini flash access")
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      014e90ca
  5. Feb 22, 2019
    • Yu Zhang's avatar
      KVM: MMU: record maximum physical address width in kvm_mmu_extended_role · de3ccd26
      Yu Zhang authored
      
      Previously, commit 7dcd5755 ("x86/kvm/mmu: check if tdp/shadow
      MMU reconfiguration is needed") offered some optimization to avoid
      the unnecessary reconfiguration. Yet one scenario is broken - when
      cpuid changes VM's maximum physical address width, reconfiguration
      is needed to reset the reserved bits.  Also, the TDP may need to
      reset its shadow_root_level when this value is changed.
      
      To fix this, a new field, maxphyaddr, is introduced in the extended
      role structure to keep track of the configured guest physical address
      width.
      
      Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      de3ccd26
    • Yu Zhang's avatar
      kvm: x86: Return LA57 feature based on hardware capability · 511da98d
      Yu Zhang authored
      
      Previously, 'commit 372fddf7 ("x86/mm: Introduce the 'no5lvl' kernel
      parameter")' cleared X86_FEATURE_LA57 in boot_cpu_data, if Linux chooses
      to not run in 5-level paging mode. Yet boot_cpu_data is queried by
      do_cpuid_ent() as the host capability later when creating vcpus, and Qemu
      will not be able to detect this feature and create VMs with LA57 feature.
      
      As discussed earlier, VMs can still benefit from extended linear address
      width, e.g. to enhance features like ASLR. So we would like to fix this,
      by return the true hardware capability when Qemu queries.
      
      Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      511da98d
    • Vitaly Kuznetsov's avatar
      x86/kvm/mmu: fix switch between root and guest MMUs · ad7dc69a
      Vitaly Kuznetsov authored
      
      Commit 14c07ad8 ("x86/kvm/mmu: introduce guest_mmu") brought one subtle
      change: previously, when switching back from L2 to L1, we were resetting
      MMU hooks (like mmu->get_cr3()) in kvm_init_mmu() called from
      nested_vmx_load_cr3() and now we do that in nested_ept_uninit_mmu_context()
      when we re-target vcpu->arch.mmu pointer.
      The change itself looks logical: if nested_ept_init_mmu_context() changes
      something than nested_ept_uninit_mmu_context() restores it back. There is,
      however, one thing: the following call chain:
      
       nested_vmx_load_cr3()
        kvm_mmu_new_cr3()
          __kvm_mmu_new_cr3()
            fast_cr3_switch()
              cached_root_available()
      
      now happens with MMU hooks pointing to the new MMU (root MMU in our case)
      while previously it was happening with the old one. cached_root_available()
      tries to stash current root but it is incorrect to read current CR3 with
      mmu->get_cr3(), we need to use old_mmu->get_cr3() which in case we're
      switching from L2 to L1 is guest_mmu. (BTW, in shadow page tables case this
      is a non-issue because we don't switch MMU).
      
      While we could've tried to guess that we're switching between MMUs and call
      the right ->get_cr3() from cached_root_available() this seems to be overly
      complicated. Instead, just stash the corresponding CR3 when setting
      root_hpa and make cached_root_available() use the stashed value.
      
      Fixes: 14c07ad8 ("x86/kvm/mmu: introduce guest_mmu")
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ad7dc69a
    • Ard Biesheuvel's avatar
      crypto: sha512/arm - fix crash bug in Thumb2 build · c6431650
      Ard Biesheuvel authored
      
      The SHA512 code we adopted from the OpenSSL project uses a rather
      peculiar way to take the address of the round constant table: it
      takes the address of the sha256_block_data_order() routine, and
      substracts a constant known quantity to arrive at the base of the
      table, which is emitted by the same assembler code right before
      the routine's entry point.
      
      However, recent versions of binutils have helpfully changed the
      behavior of references emitted via an ADR instruction when running
      in Thumb2 mode: it now takes the Thumb execution mode bit into
      account, which is bit 0 af the address. This means the produced
      table address also has bit 0 set, and so we end up with an address
      value pointing 1 byte past the start of the table, which results
      in crashes such as
      
        Unable to handle kernel paging request at virtual address bf825000
        pgd = 42f44b11
        [bf825000] *pgd=80000040206003, *pmd=5f1bd003, *pte=00000000
        Internal error: Oops: 207 [#1] PREEMPT SMP THUMB2
        Modules linked in: sha256_arm(+) sha1_arm_ce sha1_arm ...
        CPU: 7 PID: 396 Comm: cryptomgr_test Not tainted 5.0.0-rc6+ #144
        Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
        PC is at sha256_block_data_order+0xaaa/0xb30 [sha256_arm]
        LR is at __this_module+0x17fd/0xffffe800 [sha256_arm]
        pc : [<bf820bca>]    lr : [<bf824ffd>]    psr: 800b0033
        sp : ebc8bbe8  ip : faaabe1c  fp : 2fdd3433
        r10: 4c5f1692  r9 : e43037df  r8 : b04b0a5a
        r7 : c369d722  r6 : 39c3693e  r5 : 7a013189  r4 : 1580d26b
        r3 : 8762a9b0  r2 : eea9c2cd  r1 : 3e9ab536  r0 : 1dea4ae7
        Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment user
        Control: 70c5383d  Table: 6b8467c0  DAC: dbadc0de
        Process cryptomgr_test (pid: 396, stack limit = 0x69e1fe23)
        Stack: (0xebc8bbe8 to 0xebc8c000)
        ...
        unwind: Unknown symbol address bf820bca
        unwind: Index not found bf820bca
        Code: 441a ea80 40f9 440a (f85e) 3b04
        ---[ end trace e560cce92700ef8a ]---
      
      Given that this affects older kernels as well, in case they are built
      with a recent toolchain, apply a minimal backportable fix, which is
      to emit another non-code label at the start of the routine, and
      reference that instead. (This is similar to the current upstream state
      of this file in OpenSSL)
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c6431650
    • Ard Biesheuvel's avatar
      crypto: sha256/arm - fix crash bug in Thumb2 build · 69216a54
      Ard Biesheuvel authored
      
      The SHA256 code we adopted from the OpenSSL project uses a rather
      peculiar way to take the address of the round constant table: it
      takes the address of the sha256_block_data_order() routine, and
      substracts a constant known quantity to arrive at the base of the
      table, which is emitted by the same assembler code right before
      the routine's entry point.
      
      However, recent versions of binutils have helpfully changed the
      behavior of references emitted via an ADR instruction when running
      in Thumb2 mode: it now takes the Thumb execution mode bit into
      account, which is bit 0 af the address. This means the produced
      table address also has bit 0 set, and so we end up with an address
      value pointing 1 byte past the start of the table, which results
      in crashes such as
      
        Unable to handle kernel paging request at virtual address bf825000
        pgd = 42f44b11
        [bf825000] *pgd=80000040206003, *pmd=5f1bd003, *pte=00000000
        Internal error: Oops: 207 [#1] PREEMPT SMP THUMB2
        Modules linked in: sha256_arm(+) sha1_arm_ce sha1_arm ...
        CPU: 7 PID: 396 Comm: cryptomgr_test Not tainted 5.0.0-rc6+ #144
        Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
        PC is at sha256_block_data_order+0xaaa/0xb30 [sha256_arm]
        LR is at __this_module+0x17fd/0xffffe800 [sha256_arm]
        pc : [<bf820bca>]    lr : [<bf824ffd>]    psr: 800b0033
        sp : ebc8bbe8  ip : faaabe1c  fp : 2fdd3433
        r10: 4c5f1692  r9 : e43037df  r8 : b04b0a5a
        r7 : c369d722  r6 : 39c3693e  r5 : 7a013189  r4 : 1580d26b
        r3 : 8762a9b0  r2 : eea9c2cd  r1 : 3e9ab536  r0 : 1dea4ae7
        Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment user
        Control: 70c5383d  Table: 6b8467c0  DAC: dbadc0de
        Process cryptomgr_test (pid: 396, stack limit = 0x69e1fe23)
        Stack: (0xebc8bbe8 to 0xebc8c000)
        ...
        unwind: Unknown symbol address bf820bca
        unwind: Index not found bf820bca
        Code: 441a ea80 40f9 440a (f85e) 3b04
        ---[ end trace e560cce92700ef8a ]---
      
      Given that this affects older kernels as well, in case they are built
      with a recent toolchain, apply a minimal backportable fix, which is
      to emit another non-code label at the start of the routine, and
      reference that instead. (This is similar to the current upstream state
      of this file in OpenSSL)
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      69216a54
  6. Feb 21, 2019
    • Vineet Gupta's avatar
      ARCv2: don't assume core 0x54 has dual issue · 7b2e932f
      Vineet Gupta authored
      
      The first release of core4 (0x54) was dual issue only (HS4x).
      Newer releases allow hardware to be configured as single issue (HS3x)
      or dual issue.
      
      Prevent accessing a HS4x only aux register in HS3x, which otherwise
      leads to illegal instruction exceptions
      
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      7b2e932f
    • Dmitry V. Levin's avatar
      parisc: Fix ptrace syscall number modification · b7dc5a07
      Dmitry V. Levin authored
      
      Commit 910cd32e ("parisc: Fix and enable seccomp filter support")
      introduced a regression in ptrace-based syscall tampering: when tracer
      changes syscall number to -1, the kernel fails to initialize %r28 with
      -ENOSYS and subsequently fails to return the error code of the failed
      syscall to userspace.
      
      This erroneous behaviour could be observed with a simple strace syscall
      fault injection command which is expected to print something like this:
      
      $ strace -a0 -ewrite -einject=write:error=enospc echo hello
      write(1, "hello\n", 6) = -1 ENOSPC (No space left on device) (INJECTED)
      write(2, "echo: ", 6) = -1 ENOSPC (No space left on device) (INJECTED)
      write(2, "write error", 11) = -1 ENOSPC (No space left on device) (INJECTED)
      write(2, "\n", 1) = -1 ENOSPC (No space left on device) (INJECTED)
      +++ exited with 1 +++
      
      After commit 910cd32e it loops printing
      something like this instead:
      
      write(1, "hello\n", 6../strace: Failed to tamper with process 12345: unexpectedly got no error (return value 0, error 0)
      ) = 0 (INJECTED)
      
      This bug was found by strace test suite.
      
      Fixes: 910cd32e ("parisc: Fix and enable seccomp filter support")
      Cc: stable@vger.kernel.org # v4.5+
      Signed-off-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Tested-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      b7dc5a07
    • Alexey Brodkin's avatar
      ARC: define ARCH_SLAB_MINALIGN = 8 · b6835ea7
      Alexey Brodkin authored
      The default value of ARCH_SLAB_MINALIGN in "include/linux/slab.h" is
      "__alignof__(unsigned long long)" which for ARC unexpectedly turns out
      to be 4. This is not a compiler bug, but as defined by ARC ABI [1]
      
      Thus slab allocator would allocate a struct which is 32-bit aligned,
      which is generally OK even if struct has long long members.
      There was however potetial problem when it had any atomic64_t which
      use LLOCKD/SCONDD instructions which are required by ISA to take
      64-bit addresses. This is the problem we ran into
      
      [    4.015732] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
      [    4.167881] Misaligned Access
      [    4.172356] Path: /bin/busybox.nosuid
      [    4.176004] CPU: 2 PID: 171 Comm: rm Not tainted 4.19.14-yocto-standard #1
      [    4.182851]
      [    4.182851] [ECR   ]: 0x000d0000 => Check Programmer's Manual
      [    4.190061] [EFA   ]: 0xbeaec3fc
      [    4.190061] [BLINK ]: ext4_delete_entry+0x210/0x234
      [    4.190061] [ERET  ]: ext4_delete_entry+0x13e/0x234
      [    4.202985] [STAT32]: 0x80080002 : IE K
      [    4.207236] BTA: 0x9009329c   SP: 0xbe5b1ec4  FP: 0x00000000
      [    4.212790] LPS: 0x9074b118  LPE: 0x9074b120 LPC: 0x00000000
      [    4.218348] r00: 0x00000040  r01: 0x00000021 r02: 0x00000001
      ...
      ...
      [    4.270510] Stack Trace:
      [    4.274510]   ext4_delete_entry+0x13e/0x234
      [    4.278695]   ext4_rmdir+0xe0/0x238
      [    4.282187]   vfs_rmdir+0x50/0xf0
      [    4.285492]   do_rmdir+0x9e/0x154
      [    4.288802]   EV_Trap+0x110/0x114
      
      The fix is to make sure slab allocations are 64-bit aligned.
      
      Do note that atomic64_t is __attribute__((aligned(8)) which means gcc
      does generate 64-bit aligned references, relative to beginning of
      container struct. However the issue is if the container itself is not
      64-bit aligned, atomic64_t ends up unaligned which is what this patch
      ensures.
      
      [1] https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/wiki/files/ARCv2_ABI.pdf
      
      
      
      Signed-off-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>
      Cc: <stable@vger.kernel.org> # 4.8+
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      [vgupta: reworked changelog, added dependency on LL64+LLSC]
      b6835ea7
    • Eugeniy Paltsev's avatar
      ARC: enable uboot support unconditionally · 493a2f81
      Eugeniy Paltsev authored
      
      After reworking U-boot args handling code and adding paranoid
      arguments check we can eliminate CONFIG_ARC_UBOOT_SUPPORT and
      enable uboot support unconditionally.
      
      For JTAG case we can assume that core registers will come up
      reset value of 0 or in worst case we rely on user passing
      '-on=clear_regs' to Metaware debugger.
      
      Cc: stable@vger.kernel.org
      Tested-by: default avatarCorentin LABBE <clabbe@baylibre.com>
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      493a2f81
    • Eugeniy Paltsev's avatar
      ARC: U-boot: check arguments paranoidly · a66f2e57
      Eugeniy Paltsev authored
      
      Handle U-boot arguments paranoidly:
       * don't allow to pass unknown tag.
       * try to use external device tree blob only if corresponding tag
         (TAG_DTB) is set.
       * don't check uboot_tag if kernel build with no ARC_UBOOT_SUPPORT.
      
      NOTE:
      If U-boot args are invalid we skip them and try to use embedded device
      tree blob. We can't panic on invalid U-boot args as we really pass
      invalid args due to bug in U-boot code.
      This happens if we don't provide external DTB to U-boot and
      don't set 'bootargs' U-boot environment variable (which is default
      case at least for HSDK board) In that case we will pass
      {r0 = 1 (bootargs in r2); r1 = 0; r2 = 0;} to linux which is invalid.
      
      While I'm at it refactor U-boot arguments handling code.
      
      Cc: stable@vger.kernel.org
      Tested-by: default avatarCorentin LABBE <clabbe@baylibre.com>
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      a66f2e57
    • Vineet Gupta's avatar
      ARCv2: support manual regfile save on interrupts · e494239a
      Vineet Gupta authored
      
      There's a hardware bug which affects the HSDK platform, triggered by
      micro-ops for auto-saving regfile on taken interrupt. The workaround is
      to inhibit autosave.
      
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      e494239a
    • Vineet Gupta's avatar
      ARC: uacces: remove lp_start, lp_end from clobber list · d5e3c55e
      Vineet Gupta authored
      
      Newer ARC gcc handles lp_start, lp_end in a different way and doesn't
      like them in the clobber list.
      
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      d5e3c55e
    • Eugeniy Paltsev's avatar
      ARC: fix actionpoints configuration detection · cdf92962
      Eugeniy Paltsev authored
      
      Fix reversed logic while actionpoints configuration (full/min)
      detection.
      
      Fixies: 7dd380c3 ("ARC: boot log: print Action point details")
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      cdf92962
    • Eugeniy Paltsev's avatar
      ARCv2: lib: memcpy: fix doing prefetchw outside of buffer · f8a15f97
      Eugeniy Paltsev authored
      
      ARCv2 optimized memcpy uses PREFETCHW instruction for prefetching the
      next cache line but doesn't ensure that the line is not past the end of
      the buffer. PRETECHW changes the line ownership and marks it dirty,
      which can cause data corruption if this area is used for DMA IO.
      
      Fix the issue by avoiding the PREFETCHW. This leads to performance
      degradation but it is OK as we'll introduce new memcpy implementation
      optimized for unaligned memory access using.
      
      We also cut off all PREFETCH instructions at they are quite useless
      here:
       * we call PREFETCH right before LOAD instruction call.
       * we copy 16 or 32 bytes of data (depending on CONFIG_ARC_HAS_LL64)
         in a main logical loop. so we call PREFETCH 4 times (or 2 times)
         for each L1 cache line (in case of 64B L1 cache Line which is
         default case). Obviously this is not optimal.
      
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      f8a15f97
    • Eugeniy Paltsev's avatar
      ARCv2: Enable unaligned access in early ASM code · 252f6e8e
      Eugeniy Paltsev authored
      
      It is currently done in arc_init_IRQ() which might be too late
      considering gcc 7.3.1 onwards (GNU 2018.03) generates unaligned
      memory accesses by default
      
      Cc: stable@vger.kernel.org #4.4+
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      [vgupta: rewrote changelog]
      252f6e8e
    • Andrey Konovalov's avatar
      kasan: fix random seed generation for tag-based mode · 3f41b609
      Andrey Konovalov authored
      There are two issues with assigning random percpu seeds right now:
      
      1. We use for_each_possible_cpu() to iterate over cpus, but cpumask is
         not set up yet at the moment of kasan_init(), and thus we only set
         the seed for cpu #0.
      
      2. A call to get_random_u32() always returns the same number and produces
         a message in dmesg, since the random subsystem is not yet initialized.
      
      Fix 1 by calling kasan_init_tags() after cpumask is set up.
      
      Fix 2 by using get_cycles() instead of get_random_u32(). This gives us
      lower quality random numbers, but it's good enough, as KASAN is meant to
      be used as a debugging tool and not a mitigation.
      
      Link: http://lkml.kernel.org/r/1f815cc914b61f3516ed4cc9bfd9eeca9bd5d9de.1550677973.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3f41b609
  7. Feb 20, 2019
  8. Feb 19, 2019
    • Peter Ujfalusi's avatar
      ARM: dts: am335x-evm: Fix PHY mode for ethernet · 37685f6a
      Peter Ujfalusi authored
      
      The PHY must add both tx and rx delay and not only on the tx clock.
      The board uses AR8031_AL1A PHY where the rx delay is enabled by default,
      the tx dealy is disabled.
      
      The reason why rgmii-txid worked because the rx delay was not disabled by
      the driver so essentially we ended up with rgmii-id PHY mode.
      
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      37685f6a
    • Peter Ujfalusi's avatar
      ARM: dts: am335x-evmsk: Fix PHY mode for ethernet · 759c962d
      Peter Ujfalusi authored
      
      The PHY must add both tx and rx delay and not only on the tx clock.
      The board uses AR8031_AL1A PHY where the rx delay is enabled by default,
      the tx dealy is disabled.
      
      The reason why rgmii-txid worked because the rx delay was not disabled by
      the driver so essentially we ended up with rgmii-id PHY mode.
      
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      759c962d
    • Baruch Siach's avatar
      arm64: dts: clearfog-gt-8k: fix SGMII PHY reset signal · bdd22a41
      Baruch Siach authored
      
      The PHY reset signal goes to mpp43 on CP0.
      
      Fixes: babc5544 ("arm64: dts: clearfog-gt-8k: 1G eth PHY reset signal")
      Reported-by: default avatarDenis Odintsov <oversun@me.com>
      Signed-off-by: default avatarBaruch Siach <baruch@tkos.co.il>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      bdd22a41
    • Thomas Petazzoni's avatar
      ARM: dts: armada-xp: fix Armada XP boards NAND description · 6fc97917
      Thomas Petazzoni authored
      
      Commit 3b799199 ("ARM: dts:
      armada-370-xp: update NAND node with new bindings") updated some
      Marvell Armada DT description to use the new NAND controller bindings,
      but did it incorrectly for a number of boards: armada-xp-gp,
      armada-xp-db and armada-xp-lenovo-ix4-300d. Due to this, the NAND is
      no longer detected on those platforms.
      
      This commit fixes that by properly using the new NAND DT binding. This
      commit was runtime-tested on Armada XP GP, the two other platforms are
      only compile-tested.
      
      Fixes: 3b799199 ("ARM: dts: armada-370-xp: update NAND node with new bindings")
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@bootlin.com>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      6fc97917
    • Alexey Kardashevskiy's avatar
      powerpc/powernv/sriov: Register IOMMU groups for VFs · 8f5b2734
      Alexey Kardashevskiy authored
      
      The compound IOMMU group rework moved iommu_register_group() together
      in pnv_pci_ioda_setup_iommu_api() (which is a part of
      ppc_md.pcibios_fixup). As the result, pnv_ioda_setup_bus_iommu_group()
      does not create groups any more, it only adds devices to groups.
      
      This works fine for boot time devices. However IOMMU groups for
      SRIOV's VFs were added by pnv_ioda_setup_bus_iommu_group() so this got
      broken: pnv_tce_iommu_bus_notifier() expects a group to be registered
      for VF and it is not.
      
      This adds missing group registration and adds a NULL pointer check
      into the bus notifier so we won't crash if there is no group, although
      it is not expected to happen now because of the change above.
      
      Example oops seen prior to this patch:
      
        $ echo 1 > /sys/bus/pci/devices/0000\:01\:00.0/sriov_numvfs
        Unable to handle kernel paging request for data at address 0x00000030
        Faulting instruction address: 0xc0000000004a6018
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE SMP NR_CPUS=2048 NUMA PowerNV
        CPU: 46 PID: 7006 Comm: bash Not tainted 4.15-ish
        NIP:  c0000000004a6018 LR: c0000000004a6014 CTR: 0000000000000000
        REGS: c000008fc876b400 TRAP: 0300   Not tainted  (4.15-ish)
        MSR:  900000000280b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>
        CFAR: c000000000d0be20 DAR: 0000000000000030 DSISR: 40000000 SOFTE: 1
        ...
        NIP sysfs_do_create_link_sd.isra.0+0x68/0x150
        LR  sysfs_do_create_link_sd.isra.0+0x64/0x150
        Call Trace:
          pci_dev_type+0x0/0x30 (unreliable)
          iommu_group_add_device+0x8c/0x600
          iommu_add_device+0xe8/0x180
          pnv_tce_iommu_bus_notifier+0xb0/0xf0
          notifier_call_chain+0x9c/0x110
          blocking_notifier_call_chain+0x64/0xa0
          device_add+0x524/0x7d0
          pci_device_add+0x248/0x450
          pci_iov_add_virtfn+0x294/0x3e0
          pci_enable_sriov+0x43c/0x580
          mlx5_core_sriov_configure+0x15c/0x2f0 [mlx5_core]
          sriov_numvfs_store+0x180/0x240
          dev_attr_store+0x3c/0x60
          sysfs_kf_write+0x64/0x90
          kernfs_fop_write+0x1ac/0x240
          __vfs_write+0x3c/0x70
          vfs_write+0xd8/0x220
          SyS_write+0x6c/0x110
          system_call+0x58/0x6c
      
      Fixes: 0bd97167 ("powerpc/powernv/npu: Add compound IOMMU groups")
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reported-by: default avatarSantwana Samantray <santwana.samantray@in.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      8f5b2734
  9. Feb 18, 2019
    • Nathan Chancellor's avatar
      arm64/neon: Disable -Wincompatible-pointer-types when building with Clang · 0738c8b5
      Nathan Chancellor authored
      After commit cc9f8349 ("arm64: crypto: add NEON accelerated XOR
      implementation"), Clang builds for arm64 started failing with the
      following error message.
      
      arch/arm64/lib/xor-neon.c:58:28: error: incompatible pointer types
      assigning to 'const unsigned long *' from 'uint64_t *' (aka 'unsigned
      long long *') [-Werror,-Wincompatible-pointer-types]
                      v3 = veorq_u64(vld1q_u64(dp1 +  6), vld1q_u64(dp2 + 6));
                                               ^~~~~~~~
      /usr/lib/llvm-9/lib/clang/9.0.0/include/arm_neon.h:7538:47: note:
      expanded from macro 'vld1q_u64'
        __ret = (uint64x2_t) __builtin_neon_vld1q_v(__p0, 51); \
                                                    ^~~~
      
      There has been quite a bit of debate and triage that has gone into
      figuring out what the proper fix is, viewable at the link below, which
      is still ongoing. Ard suggested disabling this warning with Clang with a
      pragma so no neon code will have this type of error. While this is not
      at all an ideal solution, this build error is the only thing preventing
      KernelCI from having successful arm64 defconfig and allmodconfig builds
      on linux-next. Getting continuous integration running is more important
      so new warnings/errors or boot failures can be caught and fixed quickly.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/283
      
      
      Suggested-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      0738c8b5
    • Mark Rutland's avatar
      arm64: fix SSBS sanitization · f54dada8
      Mark Rutland authored
      
      In valid_user_regs() we treat SSBS as a RES0 bit, and consequently it is
      unexpectedly cleared when we restore a sigframe or fiddle with GPRs via
      ptrace.
      
      This patch fixes valid_user_regs() to account for this, updating the
      function to refer to the latest ARM ARM (ARM DDI 0487D.a). For AArch32
      tasks, SSBS appears in bit 23 of SPSR_EL1, matching its position in the
      AArch32-native PSR format, and we don't need to translate it as we have
      to for DIT.
      
      There are no other bit assignments that we need to account for today.
      As the recent documentation describes the DIT bit, we can drop our
      comment regarding DIT.
      
      While removing SSBS from the RES0 masks, existing inconsistent
      whitespace is corrected.
      
      Fixes: d71be2b6 ("arm64: cpufeature: Detect SSBS and advertise to userspace")
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      f54dada8
  10. Feb 17, 2019
    • Michael Ellerman's avatar
      powerpc/64s: Fix possible corruption on big endian due to pgd/pud_present() · a5800762
      Michael Ellerman authored
      
      In v4.20 we changed our pgd/pud_present() to check for _PAGE_PRESENT
      rather than just checking that the value is non-zero, e.g.:
      
        static inline int pgd_present(pgd_t pgd)
        {
       -       return !pgd_none(pgd);
       +       return (pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
        }
      
      Unfortunately this is broken on big endian, as the result of the
      bitwise & is truncated to int, which is always zero because
      _PAGE_PRESENT is 0x8000000000000000ul. This means pgd_present() and
      pud_present() are always false at compile time, and the compiler
      elides the subsequent code.
      
      Remarkably with that bug present we are still able to boot and run
      with few noticeable effects. However under some work loads we are able
      to trigger a warning in the ext4 code:
      
        WARNING: CPU: 11 PID: 29593 at fs/ext4/inode.c:3927 .ext4_set_page_dirty+0x70/0xb0
        CPU: 11 PID: 29593 Comm: debugedit Not tainted 4.20.0-rc1 #1
        ...
        NIP .ext4_set_page_dirty+0x70/0xb0
        LR  .set_page_dirty+0xa0/0x150
        Call Trace:
         .set_page_dirty+0xa0/0x150
         .unmap_page_range+0xbf0/0xe10
         .unmap_vmas+0x84/0x130
         .unmap_region+0xe8/0x190
         .__do_munmap+0x2f0/0x510
         .__vm_munmap+0x80/0x110
         .__se_sys_munmap+0x14/0x30
         system_call+0x5c/0x70
      
      The fix is simple, we need to convert the result of the bitwise & to
      an int before returning it.
      
      Thanks to Erhard, Jan Kara and Aneesh for help with debugging.
      
      Fixes: da7ad366 ("powerpc/mm/book3s: Update pmd_present to look at _PAGE_PRESENT bit")
      Cc: stable@vger.kernel.org # v4.20+
      Reported-by: default avatarErhard F. <erhard_f@mailbox.org>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a5800762
  11. Feb 16, 2019
    • Ard Biesheuvel's avatar
      efi/arm: Revert "Defer persistent reservations until after paging_init()" · 582a32e7
      Ard Biesheuvel authored
      
      This reverts commit eff89628, which
      deferred the processing of persistent memory reservations to a point
      where the memory may have already been allocated and overwritten,
      defeating the purpose.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190215123333.21209-3-ard.biesheuvel@linaro.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      582a32e7
    • Ard Biesheuvel's avatar
      arm64, mm, efi: Account for GICv3 LPI tables in static memblock reserve table · 8a5b403d
      Ard Biesheuvel authored
      
      In the irqchip and EFI code, we have what basically amounts to a quirk
      to work around a peculiarity in the GICv3 architecture, which permits
      the system memory address of LPI tables to be programmable only once
      after a CPU reset. This means kexec kernels must use the same memory
      as the first kernel, and thus ensure that this memory has not been
      given out for other purposes by the time the ITS init code runs, which
      is not very early for secondary CPUs.
      
      On systems with many CPUs, these reservations could overflow the
      memblock reservation table, and this was addressed in commit:
      
        eff89628 ("efi/arm: Defer persistent reservations until after paging_init()")
      
      However, this turns out to have made things worse, since the allocation
      of page tables and heap space for the resized memblock reservation table
      itself may overwrite the regions we are attempting to reserve, which may
      cause all kinds of corruption, also considering that the ITS will still
      be poking bits into that memory in response to incoming MSIs.
      
      So instead, let's grow the static memblock reservation table on such
      systems so it can accommodate these reservations at an earlier time.
      This will permit us to revert the above commit in a subsequent patch.
      
      [ mingo: Minor cleanups. ]
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190215123333.21209-2-ard.biesheuvel@linaro.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      8a5b403d
    • Paul Burton's avatar
      MIPS: eBPF: Remove REG_32BIT_ZERO_EX · 1910faeb
      Paul Burton authored
      
      REG_32BIT_ZERO_EX and REG_64BIT are always handled in exactly the same
      way, and reg_val_propagate_range() never actually sets any register to
      type REG_32BIT_ZERO_EX.
      
      Remove the redundant & unused REG_32BIT_ZERO_EX.
      
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      1910faeb
    • Paul Burton's avatar
      MIPS: eBPF: Always return sign extended 32b values · 13443154
      Paul Burton authored
      
      The function prototype used to call JITed eBPF code (ie. the type of the
      struct bpf_prog bpf_func field) returns an unsigned int. The MIPS n64
      ABI that MIPS64 kernels target defines that 32 bit integers should
      always be sign extended when passed in registers as either arguments or
      return values.
      
      This means that when returning any value which may not already be sign
      extended (ie. of type REG_64BIT or REG_32BIT_ZERO_EX) we need to perform
      that sign extension in order to comply with the n64 ABI. Without this we
      see strange looking test failures from test_bpf.ko, such as:
      
        test_bpf: #65 ALU64_MOV_X:
          dst = 4294967295 jited:1 ret -1 != -1 FAIL (1 times)
      
      Although the return value printed matches the expected value, this is
      only because printf is only examining the least significant 32 bits of
      the 64 bit register value we returned. The register holding the expected
      value is sign extended whilst the v0 register was set to a zero extended
      value by our JITed code, so when compared by a conditional branch
      instruction the values are not equal.
      
      We already handle this when the return value register is of type
      REG_32BIT_ZERO_EX, so simply extend this to also cover REG_64BIT.
      
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: b6bd53f9 ("MIPS: Add missing file for eBPF JIT.")
      Cc: stable@vger.kernel.org # v4.13+
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      13443154
Loading