1. 03 2月, 2022 3 次提交
    • J
      KVM: arm64: Workaround Cortex-A510's single-step and PAC trap errata · 1dd498e5
      James Morse 提交于
      Cortex-A510's erratum #2077057 causes SPSR_EL2 to be corrupted when
      single-stepping authenticated ERET instructions. A single step is
      expected, but a pointer authentication trap is taken instead. The
      erratum causes SPSR_EL1 to be copied to SPSR_EL2, which could allow
      EL1 to cause a return to EL2 with a guest controlled ELR_EL2.
      
      Because the conditions require an ERET into active-not-pending state,
      this is only a problem for the EL2 when EL2 is stepping EL1. In this case
      the previous SPSR_EL2 value is preserved in struct kvm_vcpu, and can be
      restored.
      
      Cc: stable@vger.kernel.org # 53960faf: arm64: Add Cortex-A510 CPU part definition
      Cc: stable@vger.kernel.org
      Signed-off-by: NJames Morse <james.morse@arm.com>
      [maz: fixup cpucaps ordering]
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220127122052.1584324-5-james.morse@arm.com
      1dd498e5
    • J
      KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs · 1229630a
      James Morse 提交于
      Prior to commit defe21f4 ("KVM: arm64: Move PC rollback on SError to
      HYP"), when an SError is synchronised due to another exception, KVM
      handles the SError first. If the guest survives, the instruction that
      triggered the original exception is re-exectued to handle the first
      exception. HVC is treated as a special case as the instruction wouldn't
      normally be re-exectued, as its not a trap.
      
      Commit defe21f4 didn't preserve the behaviour of the 'return 1'
      that skips the rest of handle_exit().
      
      Since commit defe21f4, KVM will try to handle the SError and the
      original exception at the same time. When the exception was an HVC,
      fixup_guest_exit() has already rolled back ELR_EL2, meaning if the
      guest has virtual SError masked, it will execute and handle the HVC
      twice.
      
      Restore the original behaviour.
      
      Fixes: defe21f4 ("KVM: arm64: Move PC rollback on SError to HYP")
      Cc: stable@vger.kernel.org
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220127122052.1584324-4-james.morse@arm.com
      1229630a
    • J
      KVM: arm64: Avoid consuming a stale esr value when SError occur · 1c71dbc8
      James Morse 提交于
      When any exception other than an IRQ occurs, the CPU updates the ESR_EL2
      register with the exception syndrome. An SError may also become pending,
      and will be synchronised by KVM. KVM notes the exception type, and whether
      an SError was synchronised in exit_code.
      
      When an exception other than an IRQ occurs, fixup_guest_exit() updates
      vcpu->arch.fault.esr_el2 from the hardware register. When an SError was
      synchronised, the vcpu esr value is used to determine if the exception
      was due to an HVC. If so, ELR_EL2 is moved back one instruction. This
      is so that KVM can process the SError first, and re-execute the HVC if
      the guest survives the SError.
      
      But if an IRQ synchronises an SError, the vcpu's esr value is stale.
      If the previous non-IRQ exception was an HVC, KVM will corrupt ELR_EL2,
      causing an unrelated guest instruction to be executed twice.
      
      Check ARM_EXCEPTION_CODE() before messing with ELR_EL2, IRQs don't
      update this register so don't need to check.
      
      Fixes: defe21f4 ("KVM: arm64: Move PC rollback on SError to HYP")
      Cc: stable@vger.kernel.org
      Reported-by: NSteven Price <steven.price@arm.com>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220127122052.1584324-3-james.morse@arm.com
      1c71dbc8
  2. 02 2月, 2022 1 次提交
    • M
      kvm/arm64: rework guest entry logic · 8cfe148a
      Mark Rutland 提交于
      In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state
      (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to
      exiting the EQS by calling guest_exit(). As the IRQ entry code will not
      wake RCU in this case, we may run the core IRQ code and IRQ handler
      without RCU watching, leading to various potential problems.
      
      Additionally, we do not inform lockdep or tracing that interrupts will
      be enabled during guest execution, which caan lead to misleading traces
      and warnings that interrupts have been enabled for overly-long periods.
      
      This patch fixes these issues by using the new timing and context
      entry/exit helpers to ensure that interrupts are handled during guest
      vtime but with RCU watching, with a sequence:
      
      	guest_timing_enter_irqoff();
      
      	guest_state_enter_irqoff();
      	< run the vcpu >
      	guest_state_exit_irqoff();
      
      	< take any pending IRQs >
      
      	guest_timing_exit_irqoff();
      
      Since instrumentation may make use of RCU, we must also ensure that no
      instrumented code is run during the EQS. I've split out the critical
      section into a new kvm_arm_enter_exit_vcpu() helper which is marked
      noinstr.
      
      Fixes: 1b3d546d ("arm/arm64: KVM: Properly account for guest CPU time")
      Reported-by: NNicolas Saenz Julienne <nsaenzju@redhat.com>
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMarc Zyngier <maz@kernel.org>
      Reviewed-by: NNicolas Saenz Julienne <nsaenzju@redhat.com>
      Cc: Alexandru Elisei <alexandru.elisei@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8cfe148a
  3. 29 1月, 2022 1 次提交
  4. 28 1月, 2022 4 次提交
  5. 27 1月, 2022 1 次提交
    • E
      arm64: extable: fix load_unaligned_zeropad() reg indices · 3758a6c7
      Evgenii Stepanov 提交于
      In ex_handler_load_unaligned_zeropad() we erroneously extract the data and
      addr register indices from ex->type rather than ex->data. As ex->type will
      contain EX_TYPE_LOAD_UNALIGNED_ZEROPAD (i.e. 4):
       * We'll always treat X0 as the address register, since EX_DATA_REG_ADDR is
         extracted from bits [9:5]. Thus, we may attempt to dereference an
         arbitrary address as X0 may hold an arbitrary value.
       * We'll always treat X4 as the data register, since EX_DATA_REG_DATA is
         extracted from bits [4:0]. Thus we will corrupt X4 and cause arbitrary
         behaviour within load_unaligned_zeropad() and its caller.
      
      Fix this by extracting both values from ex->data as originally intended.
      
      On an MTE-enabled QEMU image we are hitting the following crash:
       Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
       Call trace:
        fixup_exception+0xc4/0x108
        __do_kernel_fault+0x3c/0x268
        do_tag_check_fault+0x3c/0x104
        do_mem_abort+0x44/0xf4
        el1_abort+0x40/0x64
        el1h_64_sync_handler+0x60/0xa0
        el1h_64_sync+0x7c/0x80
        link_path_walk+0x150/0x344
        path_openat+0xa0/0x7dc
        do_filp_open+0xb8/0x168
        do_sys_openat2+0x88/0x17c
        __arm64_sys_openat+0x74/0xa0
        invoke_syscall+0x48/0x148
        el0_svc_common+0xb8/0xf8
        do_el0_svc+0x28/0x88
        el0_svc+0x24/0x84
        el0t_64_sync_handler+0x88/0xec
        el0t_64_sync+0x1b4/0x1b8
       Code: f8695a69 71007d1f 540000e0 927df12a (f940014a)
      
      Fixes: 753b3236 ("arm64: extable: add load_unaligned_zeropad() handler")
      Cc: <stable@vger.kernel.org> # 5.16.x
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NEvgenii Stepanov <eugenis@google.com>
      Link: https://lore.kernel.org/r/20220125182217.2605202-1-eugenis@google.comSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      3758a6c7
  6. 24 1月, 2022 5 次提交
  7. 22 1月, 2022 1 次提交
  8. 20 1月, 2022 3 次提交
    • P
      arm64: mm: apply __ro_after_init to memory_limit · bb425a75
      Peng Fan 提交于
      This variable is only set during initialization, so mark with
      __ro_after_init.
      Signed-off-by: NPeng Fan <peng.fan@nxp.com>
      Reviewed-by: NDavid Hildenbrand <david@redhat.com>
      Acked-by: NArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20211215064559.2843555-1-peng.fan@oss.nxp.comSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      bb425a75
    • K
      arm64: atomics: lse: Dereference matching size · 3364c6ce
      Kees Cook 提交于
      When building with -Warray-bounds, the following warning is generated:
      
      In file included from ./arch/arm64/include/asm/lse.h:16,
                       from ./arch/arm64/include/asm/cmpxchg.h:14,
                       from ./arch/arm64/include/asm/atomic.h:16,
                       from ./include/linux/atomic.h:7,
                       from ./include/asm-generic/bitops/atomic.h:5,
                       from ./arch/arm64/include/asm/bitops.h:25,
                       from ./include/linux/bitops.h:33,
                       from ./include/linux/kernel.h:22,
                       from kernel/printk/printk.c:22:
      ./arch/arm64/include/asm/atomic_lse.h:247:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'atomic_t[1]' [-Warray-bounds]
        247 |         asm volatile(                                                   \
            |         ^~~
      ./arch/arm64/include/asm/atomic_lse.h:266:1: note: in expansion of macro '__CMPXCHG_CASE'
        266 | __CMPXCHG_CASE(w,  , acq_, 32,  a, "memory")
            | ^~~~~~~~~~~~~~
      kernel/printk/printk.c:3606:17: note: while referencing 'printk_cpulock_owner'
       3606 | static atomic_t printk_cpulock_owner = ATOMIC_INIT(-1);
            |                 ^~~~~~~~~~~~~~~~~~~~
      
      This is due to the compiler seeing an unsigned long * cast against
      something (atomic_t) that is int sized. Replace the cast with the
      matching size cast. This results in no change in binary output.
      
      Note that __ll_sc__cmpxchg_case_##name##sz already uses the same
      constraint:
      
      	[v] "+Q" (*(u##sz *)ptr
      
      Which is why only the LSE form needs updating and not the
      LL/SC form, so this change is unlikely to be problematic.
      
      Cc: Will Deacon <will@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Acked-by: NArd Biesheuvel <ardb@kernel.org>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220112202259.3950286-1-keescook@chromium.orgSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      3364c6ce
    • K
      mm: percpu: generalize percpu related config · 7ecd19cf
      Kefeng Wang 提交于
      Patch series "mm: percpu: Cleanup percpu first chunk function".
      
      When supporting page mapping percpu first chunk allocator on arm64, we
      found there are lots of duplicated codes in percpu embed/page first chunk
      allocator.  This patchset is aimed to cleanup them and should no function
      change.
      
      The currently supported status about 'embed' and 'page' in Archs shows
      below,
      
      	embed: NEED_PER_CPU_PAGE_FIRST_CHUNK
      	page:  NEED_PER_CPU_EMBED_FIRST_CHUNK
      
      		embed	page
      	------------------------
      	arm64	  Y	 Y
      	mips	  Y	 N
      	powerpc	  Y	 Y
      	riscv	  Y	 N
      	sparc	  Y	 Y
      	x86	  Y	 Y
      	------------------------
      
      There are two interfaces about percpu first chunk allocator,
      
       extern int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
                                      size_t atom_size,
                                      pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
      -                               pcpu_fc_alloc_fn_t alloc_fn,
      -                               pcpu_fc_free_fn_t free_fn);
      +                               pcpu_fc_cpu_to_node_fn_t cpu_to_nd_fn);
      
       extern int __init pcpu_page_first_chunk(size_t reserved_size,
      -                               pcpu_fc_alloc_fn_t alloc_fn,
      -                               pcpu_fc_free_fn_t free_fn,
      -                               pcpu_fc_populate_pte_fn_t populate_pte_fn);
      +                               pcpu_fc_cpu_to_node_fn_t cpu_to_nd_fn);
      
      The pcpu_fc_alloc_fn_t/pcpu_fc_free_fn_t is killed, we provide generic
      pcpu_fc_alloc() and pcpu_fc_free() function, which are called in the
      pcpu_embed/page_first_chunk().
      
      1) For pcpu_embed_first_chunk(), pcpu_fc_cpu_to_node_fn_t is needed to be
         provided when archs supported NUMA.
      
      2) For pcpu_page_first_chunk(), the pcpu_fc_populate_pte_fn_t is killed too,
         a generic pcpu_populate_pte() which marked '__weak' is provided, if you
         need a different function to populate pte on the arch(like x86), please
         provide its own implementation.
      
      [1] https://github.com/kevin78/linux.git percpu-cleanup
      
      This patch (of 4):
      
      The HAVE_SETUP_PER_CPU_AREA/NEED_PER_CPU_EMBED_FIRST_CHUNK/
      NEED_PER_CPU_PAGE_FIRST_CHUNK/USE_PERCPU_NUMA_NODE_ID configs, which have
      duplicate definitions on platforms that subscribe it.
      
      Move them into mm, drop these redundant definitions and instead just
      select it on applicable platforms.
      
      Link: https://lkml.kernel.org/r/20211216112359.103822-1-wangkefeng.wang@huawei.com
      Link: https://lkml.kernel.org/r/20211216112359.103822-2-wangkefeng.wang@huawei.comSigned-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
      Acked-by: Catalin Marinas <catalin.marinas@arm.com>	[arm64]
      Cc: Will Deacon <will@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7ecd19cf
  9. 16 1月, 2022 2 次提交
  10. 15 1月, 2022 3 次提交
  11. 14 1月, 2022 1 次提交
  12. 12 1月, 2022 1 次提交
  13. 06 1月, 2022 1 次提交
    • H
      bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC · e4a41c2c
      Hou Tao 提交于
      The following error is reported when running "./test_progs -t for_each"
      under arm64:
      
        bpf_jit: multi-func JIT bug 58 != 56
        [...]
        JIT doesn't support bpf-to-bpf calls
      
      The root cause is the size of BPF_PSEUDO_FUNC instruction increases
      from 2 to 3 after the address of called bpf-function is settled and
      there are two bpf-to-bpf calls in test_pkt_access. The generated
      instructions are shown below:
      
        0x48:  21 00 C0 D2    movz x1, #0x1, lsl #32
        0x4c:  21 00 80 F2    movk x1, #0x1
      
        0x48:  E1 3F C0 92    movn x1, #0x1ff, lsl #32
        0x4c:  41 FE A2 F2    movk x1, #0x17f2, lsl #16
        0x50:  81 70 9F F2    movk x1, #0xfb84
      
      Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so
      the size of jited image will not change.
      
      Fixes: 69c087ba ("bpf: Add bpf_for_each_map_elem() helper")
      Signed-off-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211231151018.3781550-1-houtao1@huawei.com
      e4a41c2c
  14. 05 1月, 2022 2 次提交
  15. 04 1月, 2022 2 次提交
  16. 01 1月, 2022 1 次提交
  17. 27 12月, 2021 1 次提交
    • D
      ARM: dts: socfpga: change qspi to "intel,socfpga-qspi" · 36de991e
      Dinh Nguyen 提交于
      Because of commit 9cb2ff11 ("spi: cadence-quadspi: Disable Auto-HW polling"),
      which does a write to the CQSPI_REG_WR_COMPLETION_CTRL register
      regardless of any condition. Well, the Cadence QuadSPI controller on
      Intel's SoCFPGA platforms does not implement the
      CQSPI_REG_WR_COMPLETION_CTRL register, thus a write to this register
      results in a crash!
      
      So starting with v5.16, I introduced the patch
      98d948eb ("spi: cadence-quadspi: fix write completion support"),
      which adds the dts compatible "intel,socfpga-qspi" that is specific for
      versions that doesn't have the CQSPI_REG_WR_COMPLETION_CTRL register implemented.
      Signed-off-by: NDinh Nguyen <dinguyen@kernel.org>
      ---
      v3: revert back to "intel,socfpga-qspi"
      v2: use both "cdns,qspi-nor" and "cdns,qspi-nor-0010"
      36de991e
  18. 22 12月, 2021 4 次提交
  19. 21 12月, 2021 3 次提交