1. 27 8月, 2015 3 次提交
    • R
      ARM: software-based priviledged-no-access support · a5e090ac
      Russell King 提交于
      Provide a software-based implementation of the priviledged no access
      support found in ARMv8.1.
      
      Userspace pages are mapped using a different domain number from the
      kernel and IO mappings.  If we switch the user domain to "no access"
      when we enter the kernel, we can prevent the kernel from touching
      userspace.
      
      However, the kernel needs to be able to access userspace via the
      various user accessor functions.  With the wrapping in the previous
      patch, we can temporarily enable access when the kernel needs user
      access, and re-disable it afterwards.
      
      This allows us to trap non-intended accesses to userspace, eg, caused
      by an inadvertent dereference of the LIST_POISON* values, which, with
      appropriate user mappings setup, can be made to succeed.  This in turn
      can allow use-after-free bugs to be further exploited than would
      otherwise be possible.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      a5e090ac
    • R
      ARM: entry: provide uaccess assembly macro hooks · 2190fed6
      Russell King 提交于
      Provide hooks into the kernel entry and exit paths to permit control
      of userspace visibility to the kernel.  The intended use is:
      
      - on entry to kernel from user, uaccess_disable will be called to
        disable userspace visibility
      - on exit from kernel to user, uaccess_enable will be called to
        enable userspace visibility
      - on entry from a kernel exception, uaccess_save_and_disable will be
        called to save the current userspace visibility setting, and disable
        access
      - on exit from a kernel exception, uaccess_restore will be called to
        restore the userspace visibility as it was before the exception
        occurred.
      
      These hooks allows us to keep userspace visibility disabled for the
      vast majority of the kernel, except for localised regions where we
      want to explicitly access userspace.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      2190fed6
    • R
      ARM: entry: get rid of multiple macro definitions · aa06e5c1
      Russell King 提交于
      The following structure is just asking for trouble:
      
       #ifdef CONFIG_symbol
      	.macro foo
      	...
      	.endm
      	.macro bar
      	...
      	.endm
      	.macro baz
      	...
      	.endm
       #else
      	.macro foo
      	...
      	.endm
      	.macro bar
      	...
      	.endm
       #ifdef CONFIG_symbol2
      	.macro baz
      	...
      	.endm
       #else
      	.macro baz
      	...
      	.endm
       #endif
       #endif
      
      such as one defintion being updated, but the other definitions miss out.
      Where the contents of a macro needs to be conditional, the hint is in
      the first clause of this very sentence.  "contents" "conditional".  Not
      multiple separate definitions, especially not when much of the macro
      is the same between different configs.
      
      This patch fixes this bad style, which had caused the Thumb2 code to
      miss-out on the uaccess updates.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      aa06e5c1
  2. 26 8月, 2015 1 次提交
  3. 25 8月, 2015 6 次提交
  4. 21 8月, 2015 6 次提交
  5. 18 8月, 2015 6 次提交
    • M
      ARM: 8419/1: dma-mapping: harmonize definition of DMA_ERROR_CODE · 96231b26
      Marek Szyprowski 提交于
      All architectures except arm that define DMA_ERROR_CODE are casting it
      to (dma_addr_t) - as it is always compared to dma_addr_t in arm as well
      this could be harmonized.
      Signed-off-by: NNicholas Mc Guire <hofrat@osadl.org>
      Acked-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      96231b26
    • M
      ARM: 8417/1: refactor bitops functions with BIT_MASK() and BIT_WORD() · 8901925d
      Masahiro Yamada 提交于
      Use BIT_MASK() and BIT_WORD() rather than hard-coding the size
      of the "long" type.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      8901925d
    • M
      ARM: 8416/1: Feroceon: use of_iomap() to map register base · da4f295b
      Masahiro Yamada 提交于
      The chain of of_address_to_resource() and ioremap() can be replaced
      with of_iomap().
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NOlof Johansson <olof@lixom.net>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      da4f295b
    • S
      ARM: 8415/1: early fixmap support for earlycon · a5f4c561
      Stefan Agner 提交于
      Add early fixmap support, initially to support permanent, fixed
      mapping support for early console. A temporary, early pte is
      created which is migrated to a permanent mapping in paging_init.
      This is also needed since the attributes may change as the memory
      types are initialized. The 3MiB range of fixmap spans two pte
      tables, but currently only one pte is created for early fixmap
      support.
      
      Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
      the index for kmap does not start at zero anymore. This reverts
      4221e2e6 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
      FIX_KMAP_END") to some extent.
      
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Laura Abbott <lauraa@codeaurora.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      a5f4c561
    • M
      ARM: 8418/1: add boot image dependencies to not generate invalid images · 3939f334
      Masahiro Yamada 提交于
      U-Boot is often used to boot the kernel on ARM boards, but uImage
      is not built by "make all", so we are often inclined to do
      "make all uImage" to generate DTBs, modules and uImage in a single
      command, but we should notice a pitfall behind it.  In fact,
      "make all uImage" could generate an invalid uImage if it is run with
      the parallel option (-j).
      
      You can reproduce this problem with the following procedure:
      
      [1] First, build "all" and "uImage" separately.
          You will get a valid uImage
      
        $ git clean -f -x -d
        $ export CROSS_COMPILE=<your-tools-prefix>
        $ make -s -j8 ARCH=arm multi_v7_defconfig
        $ make -s -j8 ARCH=arm all
        $ make -j8 ARCH=arm UIMAGE_LOADADDR=0x80208000 uImage
          CHK     include/config/kernel.release
          CHK     include/generated/uapi/linux/version.h
          CHK     include/generated/utsrelease.h
        make[1]: `include/generated/mach-types.h' is up to date.
          CHK     include/generated/timeconst.h
          CHK     include/generated/bounds.h
          CHK     include/generated/asm-offsets.h
          CALL    scripts/checksyscalls.sh
          CHK     include/generated/compile.h
          Kernel: arch/arm/boot/Image is ready
          Kernel: arch/arm/boot/zImage is ready
          UIMAGE  arch/arm/boot/uImage
        Image Name:   Linux-4.2.0-rc5-00156-gdd2384a7-d
        Created:      Sat Aug  8 23:21:35 2015
        Image Type:   ARM Linux Kernel Image (uncompressed)
        Data Size:    6138648 Bytes = 5994.77 kB = 5.85 MB
        Load Address: 80208000
        Entry Point:  80208000
          Image arch/arm/boot/uImage is ready
        $ ls -l arch/arm/boot/*Image
        -rwxrwxr-x 1 masahiro masahiro 13766656 Aug  8 23:20 arch/arm/boot/Image
        -rw-rw-r-- 1 masahiro masahiro  6138712 Aug  8 23:21 arch/arm/boot/uImage
        -rwxrwxr-x 1 masahiro masahiro  6138648 Aug  8 23:20 arch/arm/boot/zImage
      
      [2] Update some source file(s)
      
        $ touch init/main.c
      
      [3] Then, re-build "all" and "uImage" simultaneously.
          You will get an invalid uImage at random.
      
        $ make -j8 ARCH=arm UIMAGE_LOADADDR=0x80208000 all uImage
          CHK     include/config/kernel.release
          CHK     include/generated/uapi/linux/version.h
          CHK     include/generated/utsrelease.h
        make[1]: `include/generated/mach-types.h' is up to date.
          CHK     include/generated/timeconst.h
          CHK     include/generated/bounds.h
          CHK     include/generated/asm-offsets.h
          CALL    scripts/checksyscalls.sh
          CC      init/main.o
          CHK     include/generated/compile.h
          LD      init/built-in.o
          LINK    vmlinux
          LD      vmlinux.o
          MODPOST vmlinux.o
          GEN     .version
          CHK     include/generated/compile.h
          UPD     include/generated/compile.h
          CC      init/version.o
          LD      init/built-in.o
          KSYM    .tmp_kallsyms1.o
          KSYM    .tmp_kallsyms2.o
          LD      vmlinux
          SORTEX  vmlinux
          SYSMAP  System.map
          OBJCOPY arch/arm/boot/Image
          Building modules, stage 2.
          Kernel: arch/arm/boot/Image is ready
          GZIP    arch/arm/boot/compressed/piggy.gzip
          AS      arch/arm/boot/compressed/piggy.gzip.o
          Kernel: arch/arm/boot/Image is ready
          LD      arch/arm/boot/compressed/vmlinux
          GZIP    arch/arm/boot/compressed/piggy.gzip
          OBJCOPY arch/arm/boot/zImage
          Kernel: arch/arm/boot/zImage is ready
          UIMAGE  arch/arm/boot/uImage
        Image Name:   Linux-4.2.0-rc5-00156-gdd2384a7-d
        Created:      Sat Aug  8 23:23:14 2015
        Image Type:   ARM Linux Kernel Image (uncompressed)
        Data Size:    26472 Bytes = 25.85 kB = 0.03 MB
        Load Address: 80208000
        Entry Point:  80208000
          Image arch/arm/boot/uImage is ready
          MODPOST 192 modules
          AS      arch/arm/boot/compressed/piggy.gzip.o
          LD      arch/arm/boot/compressed/vmlinux
          OBJCOPY arch/arm/boot/zImage
          Kernel: arch/arm/boot/zImage is ready
        $ ls -l arch/arm/boot/*Image
        -rwxrwxr-x 1 masahiro masahiro 13766656 Aug  8 23:23 arch/arm/boot/Image
        -rw-rw-r-- 1 masahiro masahiro    26536 Aug  8 23:23 arch/arm/boot/uImage
        -rwxrwxr-x 1 masahiro masahiro  6138648 Aug  8 23:23 arch/arm/boot/zImage
      
      Please notice the uImage is extremely small when this issue is
      encountered.  Besides, "Kernel: arch/arm/boot/zImage is ready" is
      displayed twice, before and after the uImage log.
      
      The root cause of this is the race condition between zImage and
      uImage.  Actually, uImage depends on zImage, but the dependency
      between the two is only described in arch/arm/boot/Makefile.
      Because arch/arm/boot/Makefile is not included from the top-level
      Makefile, it cannot know the dependency between zImage and uImage.
      
      Consequently, when we run make with the parallel option, Kbuild
      updates vmlinux first, and then two different threads descends into
      the arch/arm/boot/Makefile almost at the same time, one for updating
      zImage and the other for uImage.  While one thread is re-generating
      zImage, the other also tries to update zImage before creating uImage
      on top of that.  zImage is overwritten by the slower thread and then
      uImage is created based on the half-written zImage.
      
      This is the reason why "Kernel: arch/arm/boot/zImage is ready" is
      displayed twice, and a broken uImage is created.
      
      The same problem could happen on bootpImage.
      
      This commit adds dependencies among Image, zImage, uImage, and
      bootpImage to arch/arm/Makefile, which is included from the
      top-level Makefile.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      3939f334
    • N
      ARM: 8414/1: __copy_to_user_memcpy: fix mmap semaphore usage · 0f64b247
      Nicolas Pitre 提交于
      The mmap semaphore should not be taken when page faults are disabled.
      Since pagefault_disable() no longer disables preemption, we now need
      to use faulthandler_disabled() in place of in_atomic().
      Signed-off-by: NNicolas Pitre <nico@linaro.org>
      Tested-by: NMark Salter <msalter@redhat.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      0f64b247
  6. 12 8月, 2015 1 次提交
  7. 11 8月, 2015 1 次提交
    • N
      ARM: 8410/1: VDSO: fix coarse clock monotonicity regression · 09edea4f
      Nathan Lynch 提交于
      Since 906c5557 ("timekeeping: Copy the shadow-timekeeper over the
      real timekeeper last") it has become possible on ARM to:
      
      - Obtain a CLOCK_MONOTONIC_COARSE or CLOCK_REALTIME_COARSE timestamp
        via syscall.
      - Subsequently obtain a timestamp for the same clock ID via VDSO which
        predates the first timestamp (by one jiffy).
      
      This is because ARM's update_vsyscall is deriving the coarse time
      using the __current_kernel_time interface, when it should really be
      using the timekeeper object provided to it by the timekeeping core.
      It happened to work before only because __current_kernel_time would
      access the same timekeeper object which had been passed to
      update_vsyscall.  This is no longer the case.
      
      Cc: stable@vger.kernel.org
      Fixes: 906c5557 ("timekeeping: Copy the shadow-timekeeper over the real timekeeper last")
      Signed-off-by: NNathan Lynch <nathan_lynch@mentor.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      09edea4f
  8. 08 8月, 2015 2 次提交
  9. 04 8月, 2015 1 次提交
  10. 02 8月, 2015 1 次提交
    • R
      ARM: reduce visibility of dmac_* functions · 1234e3fd
      Russell King 提交于
      The dmac_* functions are private to the ARM DMA API implementation, and
      should not be used by drivers.  In order to discourage their use, remove
      their prototypes and macros from asm/*.h.
      
      We have to leave dmac_flush_range() behind as Exynos and MSM IOMMU code
      use these; once these sites are fixed, this can be moved also.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      1234e3fd
  11. 01 8月, 2015 3 次提交
    • W
      ARM: 8407/1: switch_to: Remove finish_arch_switch · 9ac87c5a
      Will Deacon 提交于
      Fold finish_arch_switch() into switch_to(), in preparation for the
      removal of the finish_arch_switch call from core sched code.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      9ac87c5a
    • S
      ARM: 8392/3: smp: Only expose /sys/.../cpuX/online if hotpluggable · 787047ee
      Stephen Boyd 提交于
      Writes to /sys/.../cpuX/online fail if we determine the platform
      doesn't support hotplug for that CPU. Furthermore, if the cpu_die
      op isn't specified the system hangs when we try to offline a CPU
      and it comes right back online unexpectedly. Let's figure this
      stuff out before we make the sysfs nodes so that the online file
      doesn't even exist if it isn't (at least sometimes) possible to
      hotplug the CPU.
      
      Add a new 'cpu_can_disable' op and repoint all 'cpu_disable'
      implementations at it because all implementers use the op to
      indicate if a CPU can be hotplugged or not in a static fashion.
      With PSCI we may need to add a 'cpu_disable' op so that the
      secure OS can be migrated off the CPU we're trying to hotplug.
      In this case, the 'cpu_can_disable' op will indicate that all
      CPUs are hotpluggable by returning true, but the 'cpu_disable' op
      will make a PSCI migration call and occasionally fail, denying
      the hotplug of a CPU. This shouldn't be any worse than x86 where
      we may indicate that all CPUs are hotpluggable but occasionally
      we can't offline a CPU due to check_irq_vectors_for_cpu_disable()
      failing to find a CPU to move vectors to.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Nicolas Pitre <nico@linaro.org>
      Cc: Dave Martin <Dave.Martin@arm.com>
      Acked-by: Simon Horman <horms@verge.net.au> [shmobile portion]
      Tested-by: NSimon Horman <horms@verge.net.au>
      Cc: Magnus Damm <magnus.damm@gmail.com>
      Cc: <linux-sh@vger.kernel.org>
      Tested-by: NTyler Baker <tyler.baker@linaro.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      787047ee
    • N
      ARM: 8405/1: VDSO: fix regression with toolchains lacking ld.bfd executable · 3473f265
      Nathan Lynch 提交于
      The Sourcery CodeBench Lite 2014.05 toolchain (gcc 4.8.3, binutils
      2.24.51) has a GCC which implements -fuse-ld, and it doesn't include
      the gold linker, but it lacks an ld.bfd executable in its
      installation.  This means that passing -fuse-ld=bfd fails with:
      
            VDSO    arch/arm/vdso/vdso.so.raw
          collect2: fatal error: cannot find 'ld'
      
      Arguably this is a deficiency in the toolchain, but I suspect it's
      commonly used enough that it's worth accommodating: just use
      
      cc-ldoption (to cause a link attempt) instead of cc-option to test
      whether we can use -fuse-ld.  So -fuse-ld=bfd won't be used with this
      toolchain, but the build will rightly succeed, just as it does for
      toolchains which don't implement -fuse-ld (and don't use gold as the
      default linker).
      
      Note: this will change the failure mode for a corner case I was trying
      to handle in d2b30cd4, where the toolchain defaults to the gold
      linker and the BFD linker is not found in PATH, from:
      
            VDSO    arch/arm/vdso/vdso.so.raw
          collect2: fatal error: cannot find 'ld'
      
      i.e. the BFD linker is not found, to:
      
            OBJCOPY arch/arm/vdso/vdso.so
          BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try
          linking with -N
      
      that is, we fail to prevent gold from being used as the linker, and it
      produces an object that objcopy can't digest.
      Reported-by: NBaruch Siach <baruch@tkos.co.il>
      Tested-by: NBaruch Siach <baruch@tkos.co.il>
      Tested-by: NRaphaël Poggi <poggi.raph@gmail.com>
      Fixes: d2b30cd4 ("ARM: 8384/1: VDSO: force use of BFD linker")
      Cc: stable@vger.kernel.org
      Signed-off-by: NNathan Lynch <nathan_lynch@mentor.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      3473f265
  12. 25 7月, 2015 4 次提交
    • R
      ARM: omap2: restore OMAP4 barrier behaviour · 3fa60975
      Russell King 提交于
      Restore the OMAP4 barrier behaviour using the new implementation which
      allows multiplatform systems to hook into the mb() and wmb() ARM
      implementations to perform any necessary additional barrier maintanence.
      Acked-by: NTony Lindgren <tony@atomide.com>
      Acked-by: NRichard Woodruff <r-woodruff2@ti.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      3fa60975
    • R
      Revert "ARM: OMAP4: remove dead kconfig option OMAP4_ERRATA_I688" · f746929f
      Russell King 提交于
      This reverts commit 606da482.
      
      We actually need this code for proper behaviour of OMAP4, and it needs
      fixing a different way other than just removing the code.  Disabling
      code which is necessary in the hopes of persuing multiplatform kernels
      is a stupid approach.
      Acked-by: NTony Lindgren <tony@atomide.com>
      Acked-by: NRichard Woodruff <r-woodruff2@ti.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      f746929f
    • R
      ARM: add soc memory barrier extension · 4e1f8a6f
      Russell King 提交于
      Add an extension to the heavy barrier code to allow a SoC specific
      memory barrier function to be provided.  This is needed for platforms
      where the interconnect has weak ordering, and thus needs assistance
      to ensure that memory writes are properly visible in the correct order
      to other parts of the system.
      Acked-by: NTony Lindgren <tony@atomide.com>
      Acked-by: NRichard Woodruff <r-woodruff2@ti.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      4e1f8a6f
    • R
      ARM: move heavy barrier support out of line · f8130906
      Russell King 提交于
      The existing memory barrier macro causes a significant amount of code
      to be inserted inline at every call site.  For example, in
      gpio_set_irq_type(), we have this for mb():
      
      c0344c08:       f57ff04e        dsb     st
      c0344c0c:       e59f8190        ldr     r8, [pc, #400]  ; c0344da4 <gpio_set_irq_type+0x230>
      c0344c10:       e3590004        cmp     r9, #4
      c0344c14:       e5983014        ldr     r3, [r8, #20]
      c0344c18:       0a000054        beq     c0344d70 <gpio_set_irq_type+0x1fc>
      c0344c1c:       e3530000        cmp     r3, #0
      c0344c20:       0a000004        beq     c0344c38 <gpio_set_irq_type+0xc4>
      c0344c24:       e50b2030        str     r2, [fp, #-48]  ; 0xffffffd0
      c0344c28:       e50bc034        str     ip, [fp, #-52]  ; 0xffffffcc
      c0344c2c:       e12fff33        blx     r3
      c0344c30:       e51bc034        ldr     ip, [fp, #-52]  ; 0xffffffcc
      c0344c34:       e51b2030        ldr     r2, [fp, #-48]  ; 0xffffffd0
      c0344c38:       e5963004        ldr     r3, [r6, #4]
      
      Moving the outer_cache_sync() call out of line reduces the impact of
      the barrier:
      
      c0344968:       f57ff04e        dsb     st
      c034496c:       e35a0004        cmp     sl, #4
      c0344970:       e50b2030        str     r2, [fp, #-48]  ; 0xffffffd0
      c0344974:       0a000044        beq     c0344a8c <gpio_set_irq_type+0x1b8>
      c0344978:       ebf363dd        bl      c001d8f4 <arm_heavy_mb>
      c034497c:       e5953004        ldr     r3, [r5, #4]
      
      This should reduce the cache footprint of this code.  Overall, this
      results in a reduction of around 20K in the kernel size:
      
          text    data      bss      dec     hex filename
      10773970  667392 10369656 21811018 14ccf4a ../build/imx6/vmlinux-old
      10754219  667392 10369656 21791267 14c8223 ../build/imx6/vmlinux-new
      
      Another advantage to this approach is that we can finally resolve the
      issue of SoCs which have their own memory barrier requirements within
      multiplatform kernels (such as OMAP.)  Here, the bus interconnects
      need additional handling to ensure that writes become visible in the
      correct order (eg, between dma_map() operations, writes to DMA
      coherent memory, and MMIO accesses.)
      Acked-by: NTony Lindgren <tony@atomide.com>
      Acked-by: NRichard Woodruff <r-woodruff2@ti.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      f8130906
  13. 17 7月, 2015 5 次提交