1. 11 Dec, 2014 3 commits
    • Mark Rutland's avatar
      arm64: mm: dump: don't skip final region · fb59d007
      Mark Rutland authored
      If the final page table entry we walk is a valid mapping, the page table
      dumping code will not log the region this entry is part of, as the final
      note_page call in ptdump_show will trigger an early return. Luckily this
      isn't seen on contemporary systems as they typically don't have enough
      RAM to extend the linear mapping right to the end of the address space.
      
      In note_page, we log a region  when we reach its end (i.e. we hit an
      entry immediately afterwards which has different prot bits or is
      invalid). The final entry has no subsequent entry, so we will not log
      this immediately. We try to cater for this with a subsequent call to
      note_page in ptdump_show, but this returns early as 0 < LOWEST_ADDR, and
      hence we will skip a valid mapping if it spans to the final entry we
      note.
      
      Unlike 32-bit ARM, the pgd with the kernel mapping is never shared with
      user mappings, so we do not need the check to ensure we don't log user
      page tables. Due to the way addr is constructed in the walk_* functions,
      it can never be less than LOWEST_ADDR when walking the page tables, so
      it is not necessary to avoid dereferencing invalid table addresses. The
      existing checks for st->current_prot and st->marker[1].start_address are
      sufficient to ensure we will not print and/or dereference garbage when
      trying to log information.
      
      This patch removes the unnecessary check against LOWEST_ADDR, ensuring
      we log all regions in the kernel page table, including those which span
      right to the end of the address space.
      
      Cc: Kees Cook <keescook@chromium.org>
      Acked-by: default avatarLaura Abbott <lauraa@codeaurora.org>
      Acked-by: default avatarSteve Capper <steve.capper@linaro.org>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      fb59d007
    • Mark Rutland's avatar
      arm64: mm: dump: fix shift warning · 35545f0c
      Mark Rutland authored
      When building with 48-bit VAs, it's possible to get the following
      warning when building the arm64 page table dumping code:
      
      arch/arm64/mm/dump.c: In function ‘walk_pgd’:
      arch/arm64/mm/dump.c:266:2: warning: right shift count >= width of type
        pgd_t *pgd = pgd_offset(mm, 0);
        ^
      
      As pgd_offset is a macro and the second argument is not cast to any
      particular type, the zero will be given integer type by the compiler.
      As pgd_offset passes the pargument to pgd_index, we then try to shift
      the 32-bit integer by at least 39 bits (for 4k pages).
      
      Elsewhere the pgd_offset is passed a second argument of unsigned long
      type, so let's do the same here by passing '0UL' rather than '0'.
      
      Cc: Kees Cook <keescook@chromium.org>
      Acked-by: default avatarLaura Abbott <lauraa@codeaurora.org>
      Acked-by: default avatarSteve Capper <steve.capper@arm.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      35545f0c
    • Krzysztof Kozlowski's avatar
      arm64: psci: Fix build breakage without PM_SLEEP · e5e62d47
      Krzysztof Kozlowski authored
      Fix build failure of defconfig when PM_SLEEP is disabled (e.g. by
      disabling SUSPEND) and CPU_IDLE enabled:
      
      arch/arm64/kernel/psci.c:543:2: error: unknown field ‘cpu_suspend’ specified in initializer
        .cpu_suspend = cpu_psci_cpu_suspend,
        ^
      arch/arm64/kernel/psci.c:543:2: warning: initialization from incompatible pointer type [enabled by default]
      arch/arm64/kernel/psci.c:543:2: warning: (near initialization for ‘cpu_psci_ops.cpu_prepare’) [enabled by default]
      make[1]: *** [arch/arm64/kernel/psci.o] Error 1
      
      The cpu_operations.cpu_suspend field exists only if ARM64_CPU_SUSPEND is
      defined, not CPU_IDLE.
      Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      e5e62d47
  2. 05 Dec, 2014 1 commit
  3. 04 Dec, 2014 4 commits
    • Andre Przywara's avatar
      arm64: add module support for alternatives fixups · 932ded4b
      Andre Przywara authored
      Currently the kernel patches all necessary instructions once at boot
      time, so modules are not covered by this.
      Change the apply_alternatives() function to take a beginning and an
      end pointer and introduce a new variant (apply_alternatives_all()) to
      cover the existing use case for the static kernel image section.
      Add a module_finalize() function to arm64 to check for an
      alternatives section in a module and patch only the instructions from
      that specific area.
      Since that module code is not touched before the module
      initialization has ended, we don't need to halt the machine before
      doing the patching in the module's code.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      932ded4b
    • Daniel Thompson's avatar
      arm64: perf: Prevent wraparound during overflow · cbbf2e6e
      Daniel Thompson authored
      If the overflow threshold for a counter is set above or near the
      0xffffffff boundary then the kernel may lose track of the overflow
      causing only events that occur *after* the overflow to be recorded.
      Specifically the problem occurs when the value of the performance counter
      overtakes its original programmed value due to wrap around.
      
      Typical solutions to this problem are either to avoid programming in
      values likely to be overtaken or to treat the overflow bit as the 33rd
      bit of the counter.
      
      Its somewhat fiddly to refactor the code to correctly handle the 33rd bit
      during irqsave sections (context switches for example) so instead we take
      the simpler approach of avoiding values likely to be overtaken.
      
      We set the limit to half of max_period because this matches the limit
      imposed in __hw_perf_event_init(). This causes a doubling of the interrupt
      rate for large threshold values, however even with a very fast counter
      ticking at 4GHz the interrupt rate would only be ~1Hz.
      Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      cbbf2e6e
    • Chunyan Zhang's avatar
      arm64/include/asm: Fixed a warning about 'struct pt_regs' · af2c632e
      Chunyan Zhang authored
      If I include asm/irq.h on the top of my code, and set ARCH=arm64,
      I'll get a compile warning, details are below:
      warning: ‘struct pt_regs’
      declared inside parameter list [enabled by default]
      
      This patch is suggested by Arnd, see:
      http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308270.htmlSigned-off-by: default avatarChunyan Zhang <chunyan.zhang@spreadtrum.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      af2c632e
    • Fabio Estevam's avatar
      arm64: Provide a namespace to NCAPS · 06f9eb88
      Fabio Estevam authored
      Building arm64.allmodconfig leads to the following warning:
      
      usb/gadget/function/f_ncm.c:203:0: warning: "NCAPS" redefined
       #define NCAPS (USB_CDC_NCM_NCAP_ETH_FILTER | USB_CDC_NCM_NCAP_CRC_MODE)
       ^
      In file included from /home/build/work/batch/arch/arm64/include/asm/io.h:32:0,
                       from /home/build/work/batch/include/linux/clocksource.h:19,
                       from /home/build/work/batch/include/clocksource/arm_arch_timer.h:19,
                       from /home/build/work/batch/arch/arm64/include/asm/arch_timer.h:27,
                       from /home/build/work/batch/arch/arm64/include/asm/timex.h:19,
                       from /home/build/work/batch/include/linux/timex.h:65,
                       from /home/build/work/batch/include/linux/sched.h:19,
                       from /home/build/work/batch/arch/arm64/include/asm/compat.h:25,
                       from /home/build/work/batch/arch/arm64/include/asm/stat.h:23,
                       from /home/build/work/batch/include/linux/stat.h:5,
                       from /home/build/work/batch/include/linux/module.h:10,
                       from /home/build/work/batch/drivers/usb/gadget/function/f_ncm.c:19:
      arch/arm64/include/asm/cpufeature.h:27:0: note: this is the location of the previous definition
       #define NCAPS     2
      
      So add a ARM64 prefix to avoid such problem.
      Reported-by: default avatarOlof's autobuilder <build@lixom.net>
      Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      06f9eb88
  4. 03 Dec, 2014 2 commits
  5. 01 Dec, 2014 1 commit
  6. 28 Nov, 2014 6 commits
  7. 26 Nov, 2014 4 commits
    • Laura Abbott's avatar
      arm64: Move some head.text functions to executable section · 034edabe
      Laura Abbott authored
      The head.text section is intended to be run at early bootup
      before any of the regular kernel mappings have been setup.
      Parts of head.text may be freed back into the buddy allocator
      due to TEXT_OFFSET so for security requirements this memory
      must not be executable. The suspend/resume/hotplug code path
      requires some of these head.S functions to run however which
      means they need to be executable. Support these conflicting
      requirements by moving the few head.text functions that need
      to be executable to the text section which has the appropriate
      page table permissions.
      Tested-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      034edabe
    • Mark Rutland's avatar
      arm64: jump labels: NOP out NOP -> NOP replacement · 6ddae418
      Mark Rutland authored
      In the arm64 arch_static_branch implementation we place an A64 NOP into
      the instruction stream and log relevant details to a jump_entry in a
      __jump_table section. Later this may be replaced with an immediate
      branch without link to the code for the unlikely case.
      
      At init time, the core calls arch_jump_label_transform_static to
      initialise the NOPs. On x86 this involves inserting the optimal NOP for
      a given microarchitecture, but on arm64 we only use the architectural
      NOP, and hence replace each NOP with the exact same NOP. This is
      somewhat pointless.
      
      Additionally, at module load time we don't call jump_label_apply_nops to
      patch the optimal NOPs in, unlike other architectures, but get away with
      this because we only use the architectural NOP anyway. A later notifier
      will patch NOPs with branches as required.
      
      Similarly to x86 commit 11570da1 (x86/jump-label: Do not bother
      updating NOPs if they are correct), we can avoid patching NOPs with
      identical NOPs. Given that we only use a single NOP encoding, this means
      we can NOP-out the body of arch_jump_label_transform_static entirely. As
      the default __weak arch_jump_label_transform_static implementation
      performs a patch, we must use an empty function to achieve this.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Jiang Liu <liuj97@gmail.com>
      Cc: Laura Abbott <lauraa@codeaurora.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      6ddae418
    • Laura Abbott's avatar
      arm64: add support to dump the kernel page tables · c9465b4e
      Laura Abbott authored
      In a similar manner to arm, it's useful to be able to dump the page
      tables to verify permissions and memory types. Add a debugfs file
      to check the page tables.
      Acked-by: default avatarSteve Capper <steve.capper@linaro.org>
      Tested-by: default avatarSteve Capper <steve.capper@linaro.org>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
      [will: s/BUFFERABLE/NORMAL-NC/]
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      c9465b4e
    • Laura Abbott's avatar
      arm64: Add FIX_HOLE to permanent fixed addresses · dab78b6d
      Laura Abbott authored
      Every other architecture with permanent fixed addresses has
      FIX_HOLE as the first entry. This seems to be designed as a
      debugging aid but there are a couple of side effects of not
      having FIX_HOLE:
      
      - If the first fixed address is 0, fix_to_virt -> virt_to_fix
      triggers a BUG_ON for the virtual address being equal to
      FIXADDR_TOP
      - fix_to_virt may return a value outside of FIXADDR_START
      and FIXADDR_TOP which may look like a bug to a developer.
      
      Match up with other architectures and make everything clearer
      by adding FIX_HOLE.
      Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      dab78b6d
  8. 25 Nov, 2014 17 commits
  9. 21 Nov, 2014 1 commit
    • Will Deacon's avatar
      arm64: mm: report unhandled level-0 translation faults correctly · 7f73f7ae
      Will Deacon authored
      Translation faults that occur due to the input address being outside
      of the address range mapped by the relevant base register are reported
      as level 0 faults in ESR.DFSC.
      
      If the faulting access cannot be resolved by the kernel (e.g. because
      it is not mapped by a vma), then we report "input address range fault"
      on the console. This was fine until we added support for 48-bit VAs,
      which actually place PGDs at level 0 and can trigger faults for invalid
      addresses that are within the range of the page tables.
      
      This patch changes the string to report "level 0 translation fault",
      which is far less confusing.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      7f73f7ae
  10. 20 Nov, 2014 1 commit