14 Nov, 2018

1 commit

  • commit 2a6c7c367de82951c98a290a21156770f6f82c84 upstream.

    x0 is not callee-saved in the PCS. So there is no need to specify
    -fcall-used-x0.

    Clang doesn't currently support -fcall-used flags. This patch will help
    building the kernel with clang.

    Tested-by: Nick Desaulniers
    Acked-by: Will Deacon
    Signed-off-by: Tri Vo
    Signed-off-by: Catalin Marinas
    Signed-off-by: Greg Kroah-Hartman

    Tri Vo
     

21 Jun, 2018

1 commit

  • The implementations are built around
    the atomic-fetch ops, which we implement efficiently for both LSE and
    LL/SC systems. Use that instead of our hand-rolled, out-of-line bitops.S.

    Signed-off-by: Will Deacon
    Acked-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: yamada.masahiro@socionext.com
    Link: https://lore.kernel.org/lkml/1529412794-17720-9-git-send-email-will.deacon@arm.com
    Signed-off-by: Ingo Molnar

    Will Deacon
     

22 May, 2018

1 commit

  • Otherwise modules that use these arithmetic operations will fail to
    link. We accomplish this with the usual EXPORT_SYMBOL, which on most
    architectures goes in the .S file but the ARM64 maintainers prefer that
    insead it goes into arm64ksyms.

    While we're at it, we also fix this up to use SPDX, and I personally
    choose to relicense this as GPL2||BSD so that these symbols don't need
    to be export_symbol_gpl, so all modules can use the routines, since
    these are important general purpose compiler-generated function calls.

    Signed-off-by: Jason A. Donenfeld
    Reported-by: PaX Team
    Cc: stable@vger.kernel.org
    Signed-off-by: Will Deacon

    Jason A. Donenfeld
     

27 Apr, 2018

1 commit

  • Our out-of-line atomics are built with a special calling convention,
    preventing pointless stack spilling, and allowing us to patch call sites
    with ARMv8.1 atomic instructions.

    Instrumentation inserted by the compiler may result in calls to
    functions not following this special calling convention, resulting in
    registers being unexpectedly clobbered, and various problems resulting
    from this.

    For example, if a kernel is built with KCOV and ARM64_LSE_ATOMICS, the
    compiler inserts calls to __sanitizer_cov_trace_pc in the prologues of
    the atomic functions. This has been observed to result in spurious
    cmpxchg failures, leading to a hang early on in the boot process.

    This patch avoids such issues by preventing instrumentation of our
    out-of-line atomics.

    Signed-off-by: Mark Rutland
    Cc: Catalin Marinas
    Cc: Will Deacon
    Signed-off-by: Will Deacon

    Mark Rutland
     

06 Apr, 2018

1 commit

  • Pull DeviceTree updates from Rob Herring:

    - Sync dtc to upstream version v1.4.6-9-gaadd0b65c987. This adds a
    bunch more warnings (hidden behind W=1).

    - Build dtc lexer and parser files instead of using shipped versions.

    - Rework overlay apply API to take an FDT as input and apply overlays
    in a single step.

    - Add a phandle lookup cache. This improves boot time by hundreds of
    msec on systems with large DT.

    - Add trivial mcp4017/18/19 potentiometers bindings.

    - Remove VLA stack usage in DT code.

    * tag 'devicetree-for-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (26 commits)
    of: unittest: fix an error code in of_unittest_apply_overlay()
    of: unittest: move misplaced function declaration
    of: unittest: Remove VLA stack usage
    of: overlay: Fix forgotten reference to of_overlay_apply()
    of: Documentation: Fix forgotten reference to of_overlay_apply()
    of: unittest: local return value variable related cleanups
    of: unittest: remove unneeded local return value variables
    dt-bindings: trivial: add various mcp4017/18/19 potentiometers
    of: unittest: fix an error test in of_unittest_overlay_8()
    of: cache phandle nodes to reduce cost of of_find_node_by_phandle()
    dt-bindings: rockchip-dw-mshc: use consistent clock names
    MAINTAINERS: Add linux/of_*.h headers to appropriate subsystems
    scripts: turn off some new dtc warnings by default
    scripts/dtc: Update to upstream version v1.4.6-9-gaadd0b65c987
    scripts/dtc: generate lexer and parser during build instead of shipping
    powerpc: boot: add strrchr function
    of: overlay: do not include path in full_name of added nodes
    of: unittest: clean up changeset test
    arm64/efi: Make strrchr() available to the EFI namespace
    ARM: boot: add strrchr function
    ...

    Linus Torvalds
     

07 Mar, 2018

1 commit

  • In cases where x30 is used as a temporary in the out-of-line ll/sc atomics
    (e.g. atomic_fetch_add), the compiler tends to put out a full stackframe,
    which included pointing the x29 at the new frame.

    Since these things aren't traceable anyway, we can pass -fomit-frame-pointer
    to reduce the work when spilling. Since this is incompatible with -pg, we
    also remove that from the CFLAGS for this file.

    Signed-off-by: Will Deacon

    Will Deacon
     

06 Mar, 2018

1 commit


07 Feb, 2018

1 commit


17 Jan, 2018

1 commit

  • With ARM64_SW_TTBR0_PAN enabled, the exception entry code checks the
    active ASID to decide whether user access was enabled (non-zero ASID)
    when the exception was taken. On return from exception, if user access
    was previously disabled, it re-instates TTBR0_EL1 from the per-thread
    saved value (updated in switch_mm() or efi_set_pgd()).

    Commit 7655abb95386 ("arm64: mm: Move ASID from TTBR0 to TTBR1") makes a
    TTBR0_EL1 + ASID switching non-atomic. Subsequently, commit 27a921e75711
    ("arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN") changes the
    __uaccess_ttbr0_disable() function and asm macro to first write the
    reserved TTBR0_EL1 followed by the ASID=0 update in TTBR1_EL1. If an
    exception occurs between these two, the exception return code will
    re-instate a valid TTBR0_EL1. Similar scenario can happen in
    cpu_switch_mm() between setting the reserved TTBR0_EL1 and the ASID
    update in cpu_do_switch_mm().

    This patch reverts the entry.S check for ASID == 0 to TTBR0_EL1 and
    disables the interrupts around the TTBR0_EL1 and ASID switching code in
    __uaccess_ttbr0_disable(). It also ensures that, when returning from the
    EFI runtime services, efi_set_pgd() doesn't leave a non-zero ASID in
    TTBR1_EL1 by using uaccess_ttbr0_{enable,disable}.

    The accesses to current_thread_info()->ttbr0 are updated to use
    READ_ONCE/WRITE_ONCE.

    As a safety measure, __uaccess_ttbr0_enable() always masks out any
    existing non-zero ASID TTBR1_EL1 before writing in the new ASID.

    Fixes: 27a921e75711 ("arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN")
    Acked-by: Will Deacon
    Reported-by: Ard Biesheuvel
    Tested-by: Ard Biesheuvel
    Reviewed-by: James Morse
    Tested-by: James Morse
    Co-developed-by: Marc Zyngier
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     

02 Jan, 2018

1 commit


11 Dec, 2017

1 commit

  • With the ASID now installed in TTBR1, we can re-enable ARM64_SW_TTBR0_PAN
    by ensuring that we switch to a reserved ASID of zero when disabling
    user access and restore the active user ASID on the uaccess enable path.

    Reviewed-by: Mark Rutland
    Tested-by: Laura Abbott
    Tested-by: Shanker Donthineni
    Signed-off-by: Will Deacon

    Will Deacon
     

16 Nov, 2017

1 commit

  • Pull arm64 updates from Will Deacon:
    "The big highlight is support for the Scalable Vector Extension (SVE)
    which required extensive ABI work to ensure we don't break existing
    applications by blowing away their signal stack with the rather large
    new vector context ( of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (97 commits)
    arm64: Make ARMV8_DEPRECATED depend on SYSCTL
    arm64: Implement __lshrti3 library function
    arm64: support __int128 on gcc 5+
    arm64/sve: Add documentation
    arm64/sve: Detect SVE and activate runtime support
    arm64/sve: KVM: Hide SVE from CPU features exposed to guests
    arm64/sve: KVM: Treat guest SVE use as undefined instruction execution
    arm64/sve: KVM: Prevent guests from using SVE
    arm64/sve: Add sysctl to set the default vector length for new processes
    arm64/sve: Add prctl controls for userspace vector length management
    arm64/sve: ptrace and ELF coredump support
    arm64/sve: Preserve SVE registers around EFI runtime service calls
    arm64/sve: Preserve SVE registers around kernel-mode NEON use
    arm64/sve: Probe SVE capabilities and usable vector lengths
    arm64: cpufeature: Move sys_caps_initialised declarations
    arm64/sve: Backend logic for setting the vector length
    arm64/sve: Signal handling support
    arm64/sve: Support vector length resetting for new processes
    arm64/sve: Core task context handling
    arm64/sve: Low-level CPU setup
    ...

    Linus Torvalds
     

14 Nov, 2017

1 commit

  • Commit fb8722735f50 ("arm64: support __int128 on gcc 5+") added support
    for the __int128 data type, but this breaks the build in some configurations
    where GCC ends up emitting calls to the __lshrti3 helper in libgcc, which
    results in a link error:

    kernel/sched/fair.o: In function `__calc_delta':
    fair.c:(.text+0xca0): undefined reference to `__lshrti3'
    kernel/time/timekeeping.o: In function `timekeeping_resume':
    timekeeping.c:(.text+0x3f60): undefined reference to `__lshrti3'
    make: *** [vmlinux] Error 1

    Fix the build by providing an implementation of __lshrti3, like we do
    already for __ashlti3 and __ashrti3.

    Reported-by: Arnd Bergmann
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Will Deacon

    Jason A. Donenfeld
     

03 Nov, 2017

1 commit

  • Versions of gcc prior to gcc 5 emitted a __multi3 function call when
    dealing with TI types, resulting in failures when trying to link to
    libgcc, and more generally, bad performance. However, since gcc 5,
    the compiler supports actually emitting fast instructions, which means
    we can at long last enable this option and receive the speedups.

    The gcc commit that added proper Aarch64 support is:
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
    This commit appears to be part of the gcc 5 release.

    There are still a few instructions, __ashlti3 and __ashrti3, which
    require libgcc, which is fine. Rather than linking to libgcc, we
    simply provide them ourselves, since they're not that complicated.

    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Will Deacon

    Jason A. Donenfeld
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

14 Oct, 2017

1 commit

  • The current delay implementation uses the yield instruction, which is a
    hint that it is beneficial to schedule another thread. As this is a hint,
    it may be implemented as a NOP, causing all delays to be busy loops. This
    is the case for many existing CPUs.

    Taking advantage of the generic timer sending periodic events to all
    cores, we can use WFE during delays to reduce power consumption. This is
    beneficial only for delays longer than the period of the timer event
    stream.

    If timer event stream is not enabled, delays will behave as yield/busy
    loops.

    Signed-off-by: Julien Thierry
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: Mark Rutland
    Signed-off-by: Will Deacon

    Julien Thierry
     

10 Aug, 2017

1 commit


09 Aug, 2017

1 commit


25 Jul, 2017

1 commit

  • The optional prefetch instructions in the copy_page() routine are
    inconsistent: at the start of the function, two cachelines are
    prefetched beyond the one being loaded in the first iteration, but
    in the loop, the prefetch is one more line ahead. This appears to
    be unintentional, so let's fix it.

    While at it, fix the comment style and white space.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon

    Ard Biesheuvel
     

29 Mar, 2017

1 commit


28 Feb, 2017

1 commit


27 Dec, 2016

1 commit


25 Dec, 2016

1 commit


22 Nov, 2016

1 commit

  • This patch moves the directly coded alternatives for turning PAN on/off
    into separate uaccess_{enable,disable} macros or functions. The asm
    macros take a few arguments which will be used in subsequent patches.

    Note that any (unlikely) access that the compiler might generate between
    uaccess_enable() and uaccess_disable(), other than those explicitly
    specified by the user access code, will not be protected by PAN.

    Cc: Will Deacon
    Cc: James Morse
    Cc: Kees Cook
    Reviewed-by: Mark Rutland
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     

15 Oct, 2016

1 commit


16 Sep, 2016

1 commit


12 Sep, 2016

1 commit

  • Make use of the new alternative_if and alternative_else_nop_endif and
    get rid of our homebew NOP sleds, making the code simpler to read.

    Note that for cpu_do_switch_mm the ret has been moved out of the
    alternative sequence, and in the default case there will be three
    additional NOPs executed.

    Signed-off-by: Mark Rutland
    Cc: Catalin Marinas
    Cc: James Morse
    Cc: Will Deacon
    Signed-off-by: Will Deacon

    Mark Rutland
     

21 Jun, 2016

1 commit

  • The upstream commit 1771c6e1a567ea0ba2cccc0a4ffe68a1419fd8ef
    ("x86/kasan: instrument user memory access API") added KASAN instrument to
    x86 user memory access API, so added such instrument to ARM64 too.

    Define __copy_to/from_user in C in order to add kasan_check_read/write call,
    rename assembly implementation to __arch_copy_to/from_user.

    Tested by test_kasan module.

    Acked-by: Andrey Ryabinin
    Reviewed-by: Mark Rutland
    Tested-by: Mark Rutland
    Signed-off-by: Yang Shi
    Signed-off-by: Catalin Marinas

    Yang Shi
     

18 Mar, 2016

1 commit

  • Pull arm64 updates from Catalin Marinas:
    "Here are the main arm64 updates for 4.6. There are some relatively
    intrusive changes to support KASLR, the reworking of the kernel
    virtual memory layout and initial page table creation.

    Summary:

    - Initial page table creation reworked to avoid breaking large block
    mappings (huge pages) into smaller ones. The ARM architecture
    requires break-before-make in such cases to avoid TLB conflicts but
    that's not always possible on live page tables

    - Kernel virtual memory layout: the kernel image is no longer linked
    to the bottom of the linear mapping (PAGE_OFFSET) but at the bottom
    of the vmalloc space, allowing the kernel to be loaded (nearly)
    anywhere in physical RAM

    - Kernel ASLR: position independent kernel Image and modules being
    randomly mapped in the vmalloc space with the randomness is
    provided by UEFI (efi_get_random_bytes() patches merged via the
    arm64 tree, acked by Matt Fleming)

    - Implement relative exception tables for arm64, required by KASLR
    (initial code for ARCH_HAS_RELATIVE_EXTABLE added to lib/extable.c
    but actual x86 conversion to deferred to 4.7 because of the merge
    dependencies)

    - Support for the User Access Override feature of ARMv8.2: this
    allows uaccess functions (get_user etc.) to be implemented using
    LDTR/STTR instructions. Such instructions, when run by the kernel,
    perform unprivileged accesses adding an extra level of protection.
    The set_fs() macro is used to "upgrade" such instruction to
    privileged accesses via the UAO bit

    - Half-precision floating point support (part of ARMv8.2)

    - Optimisations for CPUs with or without a hardware prefetcher (using
    run-time code patching)

    - copy_page performance improvement to deal with 128 bytes at a time

    - Sanity checks on the CPU capabilities (via CPUID) to prevent
    incompatible secondary CPUs from being brought up (e.g. weird
    big.LITTLE configurations)

    - valid_user_regs() reworked for better sanity check of the
    sigcontext information (restored pstate information)

    - ACPI parking protocol implementation

    - CONFIG_DEBUG_RODATA enabled by default

    - VDSO code marked as read-only

    - DEBUG_PAGEALLOC support

    - ARCH_HAS_UBSAN_SANITIZE_ALL enabled

    - Erratum workaround Cavium ThunderX SoC

    - set_pte_at() fix for PROT_NONE mappings

    - Code clean-ups"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (99 commits)
    arm64: kasan: Fix zero shadow mapping overriding kernel image shadow
    arm64: kasan: Use actual memory node when populating the kernel image shadow
    arm64: Update PTE_RDONLY in set_pte_at() for PROT_NONE permission
    arm64: Fix misspellings in comments.
    arm64: efi: add missing frame pointer assignment
    arm64: make mrs_s prefixing implicit in read_cpuid
    arm64: enable CONFIG_DEBUG_RODATA by default
    arm64: Rework valid_user_regs
    arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly
    arm64: KVM: Move kvm_call_hyp back to its original localtion
    arm64: mm: treat memstart_addr as a signed quantity
    arm64: mm: list kernel sections in order
    arm64: lse: deal with clobbered IP registers after branch via PLT
    arm64: mm: dump: Use VA_START directly instead of private LOWEST_ADDR
    arm64: kconfig: add submenu for 8.2 architectural features
    arm64: kernel: acpi: fix ioremap in ACPI parking protocol cpu_postboot
    arm64: Add support for Half precision floating point
    arm64: Remove fixmap include fragility
    arm64: Add workaround for Cavium erratum 27456
    arm64: mm: Mark .rodata as RO
    ...

    Linus Torvalds
     

05 Mar, 2016

1 commit


27 Feb, 2016

1 commit

  • The LSE atomics implementation uses runtime patching to patch in calls
    to out of line non-LSE atomics implementations on cores that lack hardware
    support for LSE. To avoid paying the overhead cost of a function call even
    if no call ends up being made, the bl instruction is kept invisible to the
    compiler, and the out of line implementations preserve all registers, not
    just the ones that they are required to preserve as per the AAPCS64.

    However, commit fd045f6cd98e ("arm64: add support for module PLTs") added
    support for routing branch instructions via veneers if the branch target
    offset exceeds the range of the ordinary relative branch instructions.
    Since this deals with jump and call instructions that are exposed to ELF
    relocations, the PLT code uses x16 to hold the address of the branch target
    when it performs an indirect branch-to-register, something which is
    explicitly allowed by the AAPCS64 (and ordinary compiler generated code
    does not expect register x16 or x17 to retain their values across a bl
    instruction).

    Since the lse runtime patched bl instructions don't adhere to the AAPCS64,
    they don't deal with this clobbering of registers x16 and x17. So add them
    to the clobber list of the asm() statements that perform the call
    instructions, and drop x16 and x17 from the list of registers that are
    callee saved in the out of line non-LSE implementations.

    In addition, since we have given these functions two scratch registers,
    they no longer need to stack/unstack temp registers.

    Signed-off-by: Ard Biesheuvel
    [will: factored clobber list into #define, updated Makefile comment]
    Signed-off-by: Will Deacon

    Signed-off-by: Catalin Marinas

    Ard Biesheuvel
     

19 Feb, 2016

2 commits

  • If a CPU supports both Privileged Access Never (PAN) and User Access
    Override (UAO), we don't need to disable/re-enable PAN round all
    copy_to_user() like calls.

    UAO alternatives cause these calls to use the 'unprivileged' load/store
    instructions, which are overridden to be the privileged kind when
    fs==KERNEL_DS.

    This patch changes the copy_to_user() calls to have their PAN toggling
    depend on a new composite 'feature' ARM64_ALT_PAN_NOT_UAO.

    If both features are detected, PAN will be enabled, but the copy_to_user()
    alternatives will not be applied. This means PAN will be enabled all the
    time for these functions. If only PAN is detected, the toggling will be
    enabled as normal.

    This will save the time taken to disable/re-enable PAN, and allow us to
    catch copy_to_user() accesses that occur with fs==KERNEL_DS.

    Futex and swp-emulation code continue to hang their PAN toggling code on
    ARM64_HAS_PAN.

    Signed-off-by: James Morse
    Signed-off-by: Catalin Marinas

    James Morse
     
  • 'User Access Override' is a new ARMv8.2 feature which allows the
    unprivileged load and store instructions to be overridden to behave in
    the normal way.

    This patch converts {get,put}_user() and friends to use ldtr*/sttr*
    instructions - so that they can only access EL0 memory, then enables
    UAO when fs==KERNEL_DS so that these functions can access kernel memory.

    This allows user space's read/write permissions to be checked against the
    page tables, instead of testing addr
    [catalin.marinas@arm.com: move uao_thread_switch() above dsb()]
    Signed-off-by: Catalin Marinas

    James Morse
     

16 Feb, 2016

3 commits

  • On ThunderX T88 pass 1 and pass 2, there is no hardware prefetching so
    we need to patch in explicit software prefetching instructions

    Prefetching improves this code by 60% over the original code and 2x
    over the code without prefetching for the affected hardware using the
    benchmark code at https://github.com/apinski-cavium/copy_page_benchmark

    Signed-off-by: Andrew Pinski
    Signed-off-by: Will Deacon
    Tested-by: Andrew Pinski
    Signed-off-by: Catalin Marinas

    Andrew Pinski
     
  • We want to avoid lots of different copy_page implementations, settling
    for something that is "good enough" everywhere and hopefully easy to
    understand and maintain whilst we're at it.

    This patch reworks our copy_page implementation based on discussions
    with Cavium on the list and benchmarking on Cortex-A processors so that:

    - The loop is unrolled to copy 128 bytes per iteration

    - The reads are offset so that we read from the next 128-byte block
    in the same iteration that we store the previous block

    - Explicit prefetch instructions are removed for now, since they hurt
    performance on CPUs with hardware prefetching

    - The loop exit condition is calculated at the start of the loop

    Signed-off-by: Will Deacon
    Tested-by: Andrew Pinski
    Signed-off-by: Catalin Marinas

    Will Deacon
     
  • Changes introduced in the upstream version of libfdt pulled in by commit
    91feabc2e224 ("scripts/dtc: Update to upstream commit b06e55c88b9b") use
    the strnlen() function, which isn't currently available to the EFI name-
    space. Add it to the EFI namespace to avoid a linker error.

    Cc: Catalin Marinas
    Cc: Rob Herring
    Reviewed-by: Ard Biesheuvel
    Signed-off-by: Thierry Reding
    Signed-off-by: Will Deacon

    Thierry Reding
     

13 Oct, 2015

1 commit

  • This patch adds arch specific code for kernel address sanitizer
    (see Documentation/kasan.txt).

    1/8 of kernel addresses reserved for shadow memory. There was no
    big enough hole for this, so virtual addresses for shadow were
    stolen from vmalloc area.

    At early boot stage the whole shadow region populated with just
    one physical page (kasan_zero_page). Later, this page reused
    as readonly zero shadow for some memory that KASan currently
    don't track (vmalloc).
    After mapping the physical memory, pages for shadow memory are
    allocated and mapped.

    Functions like memset/memmove/memcpy do a lot of memory accesses.
    If bad pointer passed to one of these function it is important
    to catch this. Compiler's instrumentation cannot do this since
    these functions are written in assembly.
    KASan replaces memory functions with manually instrumented variants.
    Original functions declared as weak symbols so strong definitions
    in mm/kasan/kasan.c could replace them. Original functions have aliases
    with '__' prefix in name, so we could call non-instrumented variant
    if needed.
    Some files built without kasan instrumentation (e.g. mm/slub.c).
    Original mem* function replaced (via #define) with prefixed variants
    to disable memory access checks for such files.

    Signed-off-by: Andrey Ryabinin
    Tested-by: Linus Walleij
    Reviewed-by: Catalin Marinas
    Signed-off-by: Catalin Marinas

    Andrey Ryabinin
     

12 Oct, 2015

1 commit


07 Oct, 2015

2 commits