Skip to content
Snippets Groups Projects
  1. Jul 11, 2018
    • Steven Rostedt (VMware)'s avatar
      ARM: 8780/1: ftrace: Only set kernel memory back to read-only after boot · b4c7e2bd
      Steven Rostedt (VMware) authored
      Dynamic ftrace requires modifying the code segments that are usually
      set to read-only. To do this, a per arch function is called both before
      and after the ftrace modifications are performed. The "before" function
      will set kernel code text to read-write to allow for ftrace to make the
      modifications, and the "after" function will set the kernel code text
      back to "read-only" to keep the kernel code text protected.
      
      The issue happens when dynamic ftrace is tested at boot up. The test is
      done before the kernel code text has been set to read-only. But the
      "before" and "after" calls are still performed. The "after" call will
      change the kernel code text to read-only prematurely, and other boot
      code that expects this code to be read-write will fail.
      
      The solution is to add a variable that is set when the kernel code text
      is expected to be converted to read-only, and make the ftrace "before"
      and "after" calls do nothing if that variable is not yet set. This is
      similar to the x86 solution from commit 16239630 ("ftrace, x86:
      make kernel text writable only for conversions").
      
      Link: http://lkml.kernel.org/r/20180620212906.24b7b66e@vmware.local.home
      
      
      
      Reported-by: default avatarStefan Agner <stefan@agner.ch>
      Tested-by: default avatarStefan Agner <stefan@agner.ch>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      b4c7e2bd
    • Yandong Zhao's avatar
      arm64: neon: Fix function may_use_simd() return error status · 2fd8eb4a
      Yandong Zhao authored
      
      It does not matter if the caller of may_use_simd() migrates to
      another cpu after the call, but it is still important that the
      kernel_neon_busy percpu instance that is read matches the cpu the
      task is running on at the time of the read.
      
      This means that raw_cpu_read() is not sufficient.  kernel_neon_busy
      may appear true if the caller migrates during the execution of
      raw_cpu_read() and the next task to be scheduled in on the initial
      cpu calls kernel_neon_begin().
      
      This patch replaces raw_cpu_read() with this_cpu_read() to protect
      against this race.
      
      Cc: <stable@vger.kernel.org>
      Fixes: cb84d11e ("arm64: neon: Remove support for nested or hardirq kernel-mode NEON")
      Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reviewed-by: default avatarDave Martin <Dave.Martin@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarYandong Zhao <yandong77520@gmail.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      2fd8eb4a
    • Ard Biesheuvel's avatar
      efi/x86: Fix mixed mode reboot loop by removing pointless call to PciIo->Attributes() · e2967018
      Ard Biesheuvel authored
      
      Hans de Goede reported that his mixed EFI mode Bay Trail tablet
      would not boot at all any more, but enter a reboot loop without
      any logs printed by the kernel.
      
      Unbreak 64-bit Linux/x86 on 32-bit UEFI:
      
      When it was first introduced, the EFI stub code that copies the
      contents of PCI option ROMs originally only intended to do so if
      the EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM attribute was *not* set.
      
      The reason was that the UEFI spec permits PCI option ROM images
      to be provided by the platform directly, rather than via the ROM
      BAR, and in this case, the OS can only access them at runtime if
      they are preserved at boot time by copying them from the areas
      described by PciIo->RomImage and PciIo->RomSize.
      
      However, it implemented this check erroneously, as can be seen in
      commit:
      
        dd5fc854 ("EFI: Stash ROMs if they're not in the PCI BAR")
      
      which introduced:
      
          if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM)
                  continue;
      
      and given that the numeric value of EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM
      is 0x4000, this condition never becomes true, and so the option ROMs
      were copied unconditionally.
      
      This was spotted and 'fixed' by commit:
      
        886d751a ("x86, efi: correct precedence of operators in setup_efi_pci")
      
      but inadvertently inverted the logic at the same time, defeating
      the purpose of the code, since it now only preserves option ROM
      images that can be read from the ROM BAR as well.
      
      Unsurprisingly, this broke some systems, and so the check was removed
      entirely in the following commit:
      
        73970188 ("x86, efi: remove attribute check from setup_efi_pci")
      
      It is debatable whether this check should have been included in the
      first place, since the option ROM image provided to the UEFI driver by
      the firmware may be different from the one that is actually present in
      the card's flash ROM, and so whatever PciIo->RomImage points at should
      be preferred regardless of whether the attribute is set.
      
      As this was the only use of the attributes field, we can remove
      the call to PciIo->Attributes() entirely, which is especially
      nice because its prototype involves uint64_t type by-value
      arguments which the EFI mixed mode has trouble dealing with.
      
      Any mixed mode system with PCI is likely to be affected.
      
      Tested-by: default avatarWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
      Tested-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180711090235.9327-2-ard.biesheuvel@linaro.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e2967018
    • Vladimir Murzin's avatar
      ARM: 8775/1: NOMMU: Use instr_sync instead of plain isb in common code · cea39477
      Vladimir Murzin authored
      
      Greg reported that commit 3c241210 ("ARM: 8756/1: NOMMU: Postpone
      MPU activation till __after_proc_init") is causing breakage for the
      old Versatile platform in no-MMU mode (with out-of-tree patches):
      
        AS      arch/arm/kernel/head-nommu.o
      arch/arm/kernel/head-nommu.S: Assembler messages:
      arch/arm/kernel/head-nommu.S:180: Error: selected processor does not support `isb' in ARM mode
      scripts/Makefile.build:417: recipe for target 'arch/arm/kernel/head-nommu.o' failed
      make[2]: *** [arch/arm/kernel/head-nommu.o] Error 1
      Makefile:1034: recipe for target 'arch/arm/kernel' failed
      make[1]: *** [arch/arm/kernel] Error 2
      
      Since the code is common for all NOMMU builds usage of the isb was a
      bad idea (please, note that isb also used in MPU related code which is
      fine because MPU has dependency on CPU_V7/CPU_V7M), instead use more
      robust instr_sync assembler macro.
      
      Fixes: 3c241210 ("ARM: 8756/1: NOMMU: Postpone MPU activation till __after_proc_init")
      Reported-by: default avatarGreg Ungerer <gerg@kernel.org>
      Tested-by: default avatarGreg Ungerer <gerg@kernel.org>
      Signed-off-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      cea39477
  2. Jul 10, 2018
    • Laura Abbott's avatar
      Revert "arm64: Use aarch64elf and aarch64elfb emulation mode variants" · 96f95a17
      Laura Abbott authored
      
      This reverts commit 38fc4248.
      
      Distributions such as Fedora and Debian do not package the ELF linker
      scripts with their toolchains, resulting in kernel build failures such
      as:
      
        |   CHK     include/generated/compile.h
        |   LD [M]  arch/arm64/crypto/sha512-ce.o
        | aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory
        | make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
        | make: *** [Makefile:1029: arch/arm64/crypto] Error 2
      
      Revert back to the linux targets for now, adding a comment to the Makefile
      so we don't accidentally break this in the future.
      
      Cc: Paul Kocialkowski <contact@paulk.fr>
      Cc: <stable@vger.kernel.org>
      Fixes: 38fc4248 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")
      Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      96f95a17
  3. Jul 07, 2018
  4. Jul 06, 2018
  5. Jul 05, 2018
    • Paul Burton's avatar
      MIPS: Fix ioremap() RAM check · 523402fa
      Paul Burton authored
      
      We currently attempt to check whether a physical address range provided
      to __ioremap() may be in use by the page allocator by examining the
      value of PageReserved for each page in the region - lowmem pages not
      marked reserved are presumed to be in use by the page allocator, and
      requests to ioremap them fail.
      
      The way we check this has been broken since commit 92923ca3 ("mm:
      meminit: only set page reserved in the memblock region"), because
      memblock will typically not have any knowledge of non-RAM pages and
      therefore those pages will not have the PageReserved flag set. Thus when
      we attempt to ioremap a region outside of RAM we incorrectly fail
      believing that the region is RAM that may be in use.
      
      In most cases ioremap() on MIPS will take a fast-path to use the
      unmapped kseg1 or xkphys virtual address spaces and never hit this path,
      so the only way to hit it is for a MIPS32 system to attempt to ioremap()
      an address range in lowmem with flags other than _CACHE_UNCACHED.
      Perhaps the most straightforward way to do this is using
      ioremap_uncached_accelerated(), which is how the problem was discovered.
      
      Fix this by making use of walk_system_ram_range() to test the address
      range provided to __ioremap() against only RAM pages, rather than all
      lowmem pages. This means that if we have a lowmem I/O region, which is
      very common for MIPS systems, we're free to ioremap() address ranges
      within it. A nice bonus is that the test is no longer limited to lowmem.
      
      The approach here matches the way x86 performed the same test after
      commit c81c8a1e ("x86, ioremap: Speed up check for RAM pages") until
      x86 moved towards a slightly more complicated check using walk_mem_res()
      for unrelated reasons with commit 0e4c12b4 ("x86/mm, resource: Use
      PAGE_KERNEL protection for ioremap of memory pages").
      
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Reported-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Tested-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Fixes: 92923ca3 ("mm: meminit: only set page reserved in the memblock region")
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org # v4.2+
      Patchwork: https://patchwork.linux-mips.org/patch/19786/
      Unverified
      523402fa
    • Greg Hackmann's avatar
      arm64: remove no-op -p linker flag · 1a381d4a
      Greg Hackmann authored
      
      Linking the ARM64 defconfig kernel with LLVM lld fails with the error:
      
        ld.lld: error: unknown argument: -p
        Makefile:1015: recipe for target 'vmlinux' failed
      
      Without this flag, the ARM64 defconfig kernel successfully links with
      lld and boots on Dragonboard 410c.
      
      After digging through binutils source and changelogs, it turns out that
      -p is only relevant to ancient binutils installations targeting 32-bit
      ARM.  binutils accepts -p for AArch64 too, but it's always been
      undocumented and silently ignored.  A comment in
      ld/emultempl/aarch64elf.em explains that it's "Only here for backwards
      compatibility".
      
      Since this flag is a no-op on ARM64, we can safely drop it.
      
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      1a381d4a
  6. Jul 04, 2018
  7. Jul 03, 2018
  8. Jul 02, 2018
    • Roger Quadros's avatar
      ARM: dts: dra7: Disable metastability workaround for USB2 · 07eaa43e
      Roger Quadros authored
      
      Disable the metastability workaround for USB2. The original
      patch disabled the workaround on the wrong USB port.
      
      Fixes: b8c9c6fa ("ARM: dts: dra7: Disable USB metastability workaround for USB2")
      Cc: <stable@vger.kernel.org>        [4.16+]
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      07eaa43e
    • Eric Farman's avatar
      s390/mm: fix refcount usage for 4K pgste · dfa75863
      Eric Farman authored
      
      s390 no longer uses the _mapcount field in struct page to identify
      the page table format being used. While the code was diligent in handling
      the different mappings, it neglected to turn "off" the map bits when
      alloc_pgste was being used. This resulted in bits remaining "on" in the
      _refcount field, and thus an artifically huge "in use" count that prevents
      the pages from actually being released by __free_page.
      
      There's opportunity for improvement in the "1 vs 3" vs "1U vs 3U" vs
      "0x1 vs 0x11" etc. variations for all these calls, I am just keeping
      things simple compared to neighboring code.
      
      Fixes: 620b4e90 ("s390: use _refcount for pgtables")
      Reported-by: default avatarHalil Pasic <pasic@linux.ibm.com>
      Bisected-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarEric Farman <farman@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      dfa75863
    • Greg Ungerer's avatar
      m68k: fix "bad page state" oops on ColdFire boot · ecd60532
      Greg Ungerer authored
      
      Booting a ColdFire m68k core with MMU enabled causes a "bad page state"
      oops since commit 1d40a5ea ("mm: mark pages in use for page tables"):
      
       BUG: Bad page state in process sh  pfn:01ce2
       page:004fefc8 count:0 mapcount:-1024 mapping:00000000 index:0x0
       flags: 0x0()
       raw: 00000000 00000000 00000000 fffffbff 00000000 00000100 00000200 00000000
       raw: 039c4000
       page dumped because: nonzero mapcount
       Modules linked in:
       CPU: 0 PID: 22 Comm: sh Not tainted 4.17.0-07461-g1d40a5ea01d5 #13
      
      Fix by calling pgtable_page_dtor() in our __pte_free_tlb() code path,
      so that the PG_table flag is cleared before we free the pte page.
      
      Note that I had to change the type of pte_free() to be static from
      extern. Otherwise you get a lot of warnings like this:
      
      ./arch/m68k/include/asm/mcf_pgalloc.h:80:2: warning: ‘pgtable_page_dtor’ is static but used in inline function ‘pte_free’ which is not static
        pgtable_page_dtor(page);
        ^
      
      And making it static is consistent with our use of this in the other
      m68k pgalloc definitions of pte_free().
      
      Signed-off-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      CC: Matthew Wilcox <willy@infradead.org>
      Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      ecd60532
  9. Jul 01, 2018
  10. Jun 29, 2018
Loading