1. 22 10月, 2019 2 次提交
    • S
      KVM: arm64: Support stolen time reporting via shared structure · 8564d637
      Steven Price 提交于
      Implement the service call for configuring a shared structure between a
      VCPU and the hypervisor in which the hypervisor can write the time
      stolen from the VCPU's execution time by other tasks on the host.
      
      User space allocates memory which is placed at an IPA also chosen by user
      space. The hypervisor then updates the shared structure using
      kvm_put_guest() to ensure single copy atomicity of the 64-bit value
      reporting the stolen time in nanoseconds.
      
      Whenever stolen time is enabled by the guest, the stolen time counter is
      reset.
      
      The stolen time itself is retrieved from the sched_info structure
      maintained by the Linux scheduler code. We enable SCHEDSTATS when
      selecting KVM Kconfig to ensure this value is meaningful.
      Signed-off-by: NSteven Price <steven.price@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      8564d637
    • S
      KVM: arm64: Implement PV_TIME_FEATURES call · b48c1a45
      Steven Price 提交于
      This provides a mechanism for querying which paravirtualized time
      features are available in this hypervisor.
      
      Also add the header file which defines the ABI for the paravirtualized
      time features we're about to add.
      Signed-off-by: NSteven Price <steven.price@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      b48c1a45
  2. 07 10月, 2019 2 次提交
  3. 04 10月, 2019 1 次提交
    • W
      arm64: Mark functions using explicit register variables as '__always_inline' · a48e61de
      Will Deacon 提交于
      As of ac7c3e4f ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly"),
      inline functions are no longer annotated with '__always_inline', which
      allows the compiler to decide whether inlining is really a good idea or
      not. Although this is a great idea on paper, the reality is that AArch64
      GCC prior to 9.1 has been shown to get confused when creating an
      out-of-line copy of a function passing explicit 'register' variables
      into an inline assembly block:
      
        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91111
      
      It's not clear whether this is specific to arm64 or not but, for now,
      ensure that all of our functions using 'register' variables are marked
      as '__always_inline' so that the old behaviour is effectively preserved.
      
      Hopefully other architectures are luckier with their compilers.
      
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      a48e61de
  4. 02 10月, 2019 1 次提交
  5. 27 9月, 2019 1 次提交
    • M
      mm: treewide: clarify pgtable_page_{ctor,dtor}() naming · b4ed71f5
      Mark Rutland 提交于
      The naming of pgtable_page_{ctor,dtor}() seems to have confused a few
      people, and until recently arm64 used these erroneously/pointlessly for
      other levels of page table.
      
      To make it incredibly clear that these only apply to the PTE level, and to
      align with the naming of pgtable_pmd_page_{ctor,dtor}(), let's rename them
      to pgtable_pte_page_{ctor,dtor}().
      
      These changes were generated with the following shell script:
      
      ----
      git grep -lw 'pgtable_page_.tor' | while read FILE; do
          sed -i '{s/pgtable_page_ctor/pgtable_pte_page_ctor/}' $FILE;
          sed -i '{s/pgtable_page_dtor/pgtable_pte_page_dtor/}' $FILE;
      done
      ----
      
      ... with the documentation re-flowed to remain under 80 columns, and
      whitespace fixed up in macros to keep backslashes aligned.
      
      There should be no functional change as a result of this patch.
      
      Link: http://lkml.kernel.org/r/20190722141133.3116-1-mark.rutland@arm.comSigned-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMike Rapoport <rppt@linux.ibm.com>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>	[m68k]
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b4ed71f5
  6. 25 9月, 2019 3 次提交
  7. 17 9月, 2019 2 次提交
  8. 11 9月, 2019 3 次提交
  9. 10 9月, 2019 1 次提交
  10. 09 9月, 2019 1 次提交
    • M
      KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE · 92f35b75
      Marc Zyngier 提交于
      While parts of the VGIC support a large number of vcpus (we
      bravely allow up to 512), other parts are more limited.
      
      One of these limits is visible in the KVM_IRQ_LINE ioctl, which
      only allows 256 vcpus to be signalled when using the CPU or PPI
      types. Unfortunately, we've cornered ourselves badly by allocating
      all the bits in the irq field.
      
      Since the irq_type subfield (8 bit wide) is currently only taking
      the values 0, 1 and 2 (and we have been careful not to allow anything
      else), let's reduce this field to only 4 bits, and allocate the
      remaining 4 bits to a vcpu2_index, which acts as a multiplier:
      
        vcpu_id = 256 * vcpu2_index + vcpu_index
      
      With that, and a new capability (KVM_CAP_ARM_IRQ_LINE_LAYOUT_2)
      allowing this to be discovered, it becomes possible to inject
      PPIs to up to 4096 vcpus. But please just don't.
      
      Whilst we're there, add a clarification about the use of KVM_IRQ_LINE
      on arm, which is not completely conditionned by KVM_CAP_IRQCHIP.
      Reported-by: NZenghui Yu <yuzenghui@huawei.com>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NZenghui Yu <yuzenghui@huawei.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      92f35b75
  11. 04 9月, 2019 1 次提交
  12. 01 9月, 2019 1 次提交
    • S
      tracing/arm64: Have max stack tracer handle the case of return address after data · f7edb451
      Steven Rostedt (VMware) 提交于
      Most archs (well at least x86) store the function call return address on the
      stack before storing the local variables for the function. The max stack
      tracer depends on this in its algorithm to display the stack size of each
      function it finds in the back trace.
      
      Some archs (arm64), may store the return address (from its link register)
      just before calling a nested function. There's no reason to save the link
      register on leaf functions, as it wont be updated. This breaks the algorithm
      of the max stack tracer.
      
      Add a new define ARCH_FTRACE_SHIFT_STACK_TRACER that an architecture may set
      if it stores the return address (link register) after it stores the
      function's local variables, and have the stack trace shift the values of the
      mapped stack size to the appropriate functions.
      
      Link: 20190802094103.163576-1-jiping.ma2@windriver.com
      Reported-by: NJiping Ma <jiping.ma2@windriver.com>
      Acked-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      f7edb451
  13. 30 8月, 2019 4 次提交
  14. 29 8月, 2019 5 次提交
    • A
      arm64: avoid using hard-coded registers for LSE atomics · 3337cb5a
      Andrew Murray 提交于
      Now that we have removed the out-of-line ll/sc atomics we can give
      the compiler the freedom to choose its own register allocation.
      
      Remove the hard-coded use of x30.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      3337cb5a
    • A
      arm64: atomics: avoid out-of-line ll/sc atomics · addfc386
      Andrew Murray 提交于
      When building for LSE atomics (CONFIG_ARM64_LSE_ATOMICS), if the hardware
      or toolchain doesn't support it the existing code will fallback to ll/sc
      atomics. It achieves this by branching from inline assembly to a function
      that is built with special compile flags. Further this results in the
      clobbering of registers even when the fallback isn't used increasing
      register pressure.
      
      Improve this by providing inline implementations of both LSE and
      ll/sc and use a static key to select between them, which allows for the
      compiler to generate better atomics code. Put the LL/SC fallback atomics
      in their own subsection to improve icache performance.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      addfc386
    • C
      arm64: document the choice of page attributes for pgprot_dmacoherent · 3e4e1d3f
      Christoph Hellwig 提交于
      Based on an email from Will Deacon.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NWill Deacon <will@kernel.org>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      3e4e1d3f
    • C
      dma-mapping: remove arch_dma_mmap_pgprot · 419e2f18
      Christoph Hellwig 提交于
      arch_dma_mmap_pgprot is used for two things:
      
       1) to override the "normal" uncached page attributes for mapping
          memory coherent to devices that can't snoop the CPU caches
       2) to provide the special DMA_ATTR_WRITE_COMBINE semantics on older
          arm systems and some mips platforms
      
      Replace one with the pgprot_dmacoherent macro that is already provided
      by arm and much simpler to use, and lift the DMA_ATTR_WRITE_COMBINE
      handling to common code with an explicit arch opt-in.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>	# m68k
      Acked-by: Paul Burton <paul.burton@mips.com>		# mips
      419e2f18
    • A
      arm64: Use correct ll/sc atomic constraints · 580fa1b8
      Andrew Murray 提交于
      The A64 ISA accepts distinct (but overlapping) ranges of immediates for:
      
       * add arithmetic instructions ('I' machine constraint)
       * sub arithmetic instructions ('J' machine constraint)
       * 32-bit logical instructions ('K' machine constraint)
       * 64-bit logical instructions ('L' machine constraint)
      
      ... but we currently use the 'I' constraint for many atomic operations
      using sub or logical instructions, which is not always valid.
      
      When CONFIG_ARM64_LSE_ATOMICS is not set, this allows invalid immediates
      to be passed to instructions, potentially resulting in a build failure.
      When CONFIG_ARM64_LSE_ATOMICS is selected the out-of-line ll/sc atomics
      always use a register as they have no visibility of the value passed by
      the caller.
      
      This patch adds a constraint parameter to the ATOMIC_xx and
      __CMPXCHG_CASE macros so that we can pass appropriate constraints for
      each case, with uses updated accordingly.
      
      Unfortunately prior to GCC 8.1.0 the 'K' constraint erroneously accepted
      '4294967295', so we must instead force the use of a register.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      580fa1b8
  15. 28 8月, 2019 5 次提交
    • J
      arm64: KVM: Device mappings should be execute-never · e8688ba3
      James Morse 提交于
      Since commit 2f6ea23f ("arm64: KVM: Avoid marking pages as XN in
      Stage-2 if CTR_EL0.DIC is set"), KVM has stopped marking normal memory
      as execute-never at stage2 when the system supports D->I Coherency at
      the PoU. This avoids KVM taking a trap when the page is first executed,
      in order to clean it to PoU.
      
      The patch that added this change also wrapped PAGE_S2_DEVICE mappings
      up in this too. The upshot is, if your CPU caches support DIC ...
      you can execute devices.
      
      Revert the PAGE_S2_DEVICE change so PTE_S2_XN is always used
      directly.
      
      Fixes: 2f6ea23f ("arm64: KVM: Avoid marking pages as XN in Stage-2 if CTR_EL0.DIC is set")
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      e8688ba3
    • W
      arm64: sysreg: Add some field definitions for PAR_EL1 · e8620cff
      Will Deacon 提交于
      PAR_EL1 is a mysterious creature, but sometimes it's necessary to read
      it when translating addresses in situations where we cannot walk the
      page table directly.
      
      Add a couple of system register definitions for the fault indication
      field ('F') and the fault status code ('FST').
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      e8620cff
    • W
      arm64: mm: Add ISB instruction to set_pgd() · eb6a4dcc
      Will Deacon 提交于
      Commit 6a4cbd63c25a ("Revert "arm64: Remove unnecessary ISBs from
      set_{pte,pmd,pud}"") reintroduced ISB instructions to some of our
      page table setter functions in light of a recent clarification to the
      Armv8 architecture. Although 'set_pgd()' isn't currently used to update
      a live page table, add the ISB instruction there too for consistency
      with the other macros and to provide some future-proofing if we use it
      on live tables in the future.
      Reported-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      eb6a4dcc
    • W
      arm64: tlb: Ensure we execute an ISB following walk cache invalidation · 51696d34
      Will Deacon 提交于
      05f2d2f8 ("arm64: tlbflush: Introduce __flush_tlb_kernel_pgtable")
      added a new TLB invalidation helper which is used when freeing
      intermediate levels of page table used for kernel mappings, but is
      missing the required ISB instruction after completion of the TLBI
      instruction.
      
      Add the missing barrier.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 05f2d2f8 ("arm64: tlbflush: Introduce __flush_tlb_kernel_pgtable")
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      51696d34
    • W
      Revert "arm64: Remove unnecessary ISBs from set_{pte,pmd,pud}" · d0b7a302
      Will Deacon 提交于
      This reverts commit 24fe1b0e.
      
      Commit 24fe1b0e ("arm64: Remove unnecessary ISBs from
      set_{pte,pmd,pud}") removed ISB instructions immediately following updates
      to the page table, on the grounds that they are not required by the
      architecture and a DSB alone is sufficient to ensure that subsequent data
      accesses use the new translation:
      
        DDI0487E_a, B2-128:
      
        | ... no instruction that appears in program order after the DSB
        | instruction can alter any state of the system or perform any part of
        | its functionality until the DSB completes other than:
        |
        | * Being fetched from memory and decoded
        | * Reading the general-purpose, SIMD and floating-point,
        |   Special-purpose, or System registers that are directly or indirectly
        |   read without causing side-effects.
      
      However, the same document also states the following:
      
        DDI0487E_a, B2-125:
      
        | DMB and DSB instructions affect reads and writes to the memory system
        | generated by Load/Store instructions and data or unified cache
        | maintenance instructions being executed by the PE. Instruction fetches
        | or accesses caused by a hardware translation table access are not
        | explicit accesses.
      
      which appears to claim that the DSB alone is insufficient.  Unfortunately,
      some CPU designers have followed the second clause above, whereas in Linux
      we've been relying on the first. This means that our mapping sequence:
      
      	MOV	X0, <valid pte>
      	STR	X0, [Xptep]	// Store new PTE to page table
      	DSB	ISHST
      	LDR	X1, [X2]	// Translates using the new PTE
      
      can actually raise a translation fault on the load instruction because the
      translation can be performed speculatively before the page table update and
      then marked as "faulting" by the CPU. For user PTEs, this is ok because we
      can handle the spurious fault, but for kernel PTEs and intermediate table
      entries this results in a panic().
      
      Revert the offending commit to reintroduce the missing barriers.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 24fe1b0e ("arm64: Remove unnecessary ISBs from set_{pte,pmd,pud}")
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      d0b7a302
  16. 23 8月, 2019 1 次提交
  17. 22 8月, 2019 1 次提交
    • J
      arm64: entry: Move ct_user_exit before any other exception · 2671828c
      James Morse 提交于
      When taking an SError or Debug exception from EL0, we run the C
      handler for these exceptions before updating the context tracking
      code and unmasking lower priority interrupts.
      
      When booting with nohz_full lockdep tells us we got this wrong:
      | =============================
      | WARNING: suspicious RCU usage
      | 5.3.0-rc2-00010-gb4b5e9dcb11b-dirty #11271 Not tainted
      | -----------------------------
      | include/linux/rcupdate.h:643 rcu_read_unlock() used illegally wh!
      |
      | other info that might help us debug this:
      |
      |
      | RCU used illegally from idle CPU!
      | rcu_scheduler_active = 2, debug_locks = 1
      | RCU used illegally from extended quiescent state!
      | 1 lock held by a.out/432:
      |  #0: 00000000c7a79515 (rcu_read_lock){....}, at: brk_handler+0x00
      |
      | stack backtrace:
      | CPU: 1 PID: 432 Comm: a.out Not tainted 5.3.0-rc2-00010-gb4b5e9d1
      | Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno De8
      | Call trace:
      |  dump_backtrace+0x0/0x140
      |  show_stack+0x14/0x20
      |  dump_stack+0xbc/0x104
      |  lockdep_rcu_suspicious+0xf8/0x108
      |  brk_handler+0x164/0x1b0
      |  do_debug_exception+0x11c/0x278
      |  el0_dbg+0x14/0x20
      
      Moving the ct_user_exit calls to be before do_debug_exception() means
      they are also before trace_hardirqs_off() has been updated. Add a new
      ct_user_exit_irqoff macro to avoid the context-tracking code using
      irqsave/restore before we've updated trace_hardirqs_off(). To be
      consistent, do this everywhere.
      
      The C helper is called enter_from_user_mode() to match x86 in the hope
      we can merge them into kernel/context_tracking.c later.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Fixes: 6c81fe79 ("arm64: enable context tracking")
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      2671828c
  18. 15 8月, 2019 3 次提交
    • S
      arm64: smp: disable hotplug on trusted OS resident CPU · d55c5f28
      Sudeep Holla 提交于
      The trusted OS may reject CPU_OFF calls to its resident CPU, so we must
      avoid issuing those. We never migrate a Trusted OS and we already take
      care to prevent CPU_OFF PSCI call. However, this is not reflected
      explicitly to the userspace. Any user can attempt to hotplug trusted OS
      resident CPU. The entire motion of going through the various state
      transitions in the CPU hotplug state machine gets executed and the
      PSCI layer finally refuses to make CPU_OFF call.
      
      This results is unnecessary unwinding of CPU hotplug state machine in
      the kernel. Instead we can mark the trusted OS resident CPU as not
      available for hotplug, so that the user attempt or request to do the
      same will get immediately rejected.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      d55c5f28
    • M
      arm64: Clarify when cpu_enable() is called · 38d16667
      Mark Brown 提交于
      Strengthen the wording in the documentation for cpu_enable() to make it
      more obvious to readers not already familiar with the code when the core
      will call this callback and that this is intentional.
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Reviewed-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      [will: minor tweak to emphasis in the comment]
      Signed-off-by: NWill Deacon <will@kernel.org>
      38d16667
    • M
      arm64: memory: rename VA_START to PAGE_END · 77ad4ce6
      Mark Rutland 提交于
      Prior to commit:
      
        14c127c9 ("arm64: mm: Flip kernel VA space")
      
      ... VA_START described the start of the TTBR1 address space for a given
      VA size described by VA_BITS, where all kernel mappings began.
      
      Since that commit, VA_START described a portion midway through the
      address space, where the linear map ends and other kernel mappings
      begin.
      
      To avoid confusion, let's rename VA_START to PAGE_END, making it clear
      that it's not the start of the TTBR1 address space and implying that
      it's related to PAGE_OFFSET. Comments and other mnemonics are updated
      accordingly, along with a typo fix in the decription of VMEMMAP_SIZE.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Tested-by: NSteve Capper <steve.capper@arm.com>
      Reviewed-by: NSteve Capper <steve.capper@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      77ad4ce6
  19. 14 8月, 2019 2 次提交