1. 31 3月, 2021 2 次提交
  2. 26 3月, 2021 2 次提交
  3. 25 3月, 2021 7 次提交
  4. 23 3月, 2021 2 次提交
  5. 22 3月, 2021 4 次提交
    • P
      arm64: mm: correct the inside linear map range during hotplug check · ee7febce
      Pavel Tatashin 提交于
      Memory hotplug may fail on systems with CONFIG_RANDOMIZE_BASE because the
      linear map range is not checked correctly.
      
      The start physical address that linear map covers can be actually at the
      end of the range because of randomization. Check that and if so reduce it
      to 0.
      
      This can be verified on QEMU with setting kaslr-seed to ~0ul:
      
      memstart_offset_seed = 0xffff
      START: __pa(_PAGE_OFFSET(vabits_actual)) = ffff9000c0000000
      END:   __pa(PAGE_END - 1) =  1000bfffffff
      Signed-off-by: NPavel Tatashin <pasha.tatashin@soleen.com>
      Fixes: 58284a90 ("arm64/mm: Validate hotplug range before creating linear mapping")
      Tested-by: NTyler Hicks <tyhicks@linux.microsoft.com>
      Reviewed-by: NAnshuman Khandual <anshuman.khandual@arm.com>
      Link: https://lore.kernel.org/r/20210216150351.129018-2-pasha.tatashin@soleen.comSigned-off-by: NWill Deacon <will@kernel.org>
      ee7febce
    • P
      arm64: kdump: update ppos when reading elfcorehdr · 141f8202
      Pavel Tatashin 提交于
      The ppos points to a position in the old kernel memory (and in case of
      arm64 in the crash kernel since elfcorehdr is passed as a segment). The
      function should update the ppos by the amount that was read. This bug is
      not exposed by accident, but other platforms update this value properly.
      So, fix it in ARM64 version of elfcorehdr_read() as well.
      Signed-off-by: NPavel Tatashin <pasha.tatashin@soleen.com>
      Fixes: e62aaeac ("arm64: kdump: provide /proc/vmcore file")
      Reviewed-by: NTyler Hicks <tyhicks@linux.microsoft.com>
      Link: https://lore.kernel.org/r/20210319205054.743368-1-pasha.tatashin@soleen.comSigned-off-by: NWill Deacon <will@kernel.org>
      141f8202
    • B
    • M
      arm64: stacktrace: don't trace arch_stack_walk() · c607ab4f
      Mark Rutland 提交于
      We recently converted arm64 to use arch_stack_walk() in commit:
      
        5fc57df2 ("arm64: stacktrace: Convert to ARCH_STACKWALK")
      
      The core stacktrace code expects that (when tracing the current task)
      arch_stack_walk() starts a trace at its caller, and does not include
      itself in the trace. However, arm64's arch_stack_walk() includes itself,
      and so traces include one more entry than callers expect. The core
      stacktrace code which calls arch_stack_walk() tries to skip a number of
      entries to prevent itself appearing in a trace, and the additional entry
      prevents skipping one of the core stacktrace functions, leaving this in
      the trace unexpectedly.
      
      We can fix this by having arm64's arch_stack_walk() begin the trace with
      its caller. The first value returned by the trace will be
      __builtin_return_address(0), i.e. the caller of arch_stack_walk(). The
      first frame record to be unwound will be __builtin_frame_address(1),
      i.e. the caller's frame record. To prevent surprises, arch_stack_walk()
      is also marked noinline.
      
      While __builtin_frame_address(1) is not safe in portable code, local GCC
      developers have confirmed that it is safe on arm64. To find the caller's
      frame record, the builtin can safely dereference the current function's
      frame record or (in theory) could stash the original FP into another GPR
      at function entry time, neither of which are problematic.
      
      Prior to this patch, the tracing code would unexpectedly show up in
      traces of the current task, e.g.
      
      | # cat /proc/self/stack
      | [<0>] stack_trace_save_tsk+0x98/0x100
      | [<0>] proc_pid_stack+0xb4/0x130
      | [<0>] proc_single_show+0x60/0x110
      | [<0>] seq_read_iter+0x230/0x4d0
      | [<0>] seq_read+0xdc/0x130
      | [<0>] vfs_read+0xac/0x1e0
      | [<0>] ksys_read+0x6c/0xfc
      | [<0>] __arm64_sys_read+0x20/0x30
      | [<0>] el0_svc_common.constprop.0+0x60/0x120
      | [<0>] do_el0_svc+0x24/0x90
      | [<0>] el0_svc+0x2c/0x54
      | [<0>] el0_sync_handler+0x1a4/0x1b0
      | [<0>] el0_sync+0x170/0x180
      
      After this patch, the tracing code will not show up in such traces:
      
      | # cat /proc/self/stack
      | [<0>] proc_pid_stack+0xb4/0x130
      | [<0>] proc_single_show+0x60/0x110
      | [<0>] seq_read_iter+0x230/0x4d0
      | [<0>] seq_read+0xdc/0x130
      | [<0>] vfs_read+0xac/0x1e0
      | [<0>] ksys_read+0x6c/0xfc
      | [<0>] __arm64_sys_read+0x20/0x30
      | [<0>] el0_svc_common.constprop.0+0x60/0x120
      | [<0>] do_el0_svc+0x24/0x90
      | [<0>] el0_svc+0x2c/0x54
      | [<0>] el0_sync_handler+0x1a4/0x1b0
      | [<0>] el0_sync+0x170/0x180
      
      Erring on the side of caution, I've given this a spin with a bunch of
      toolchains, verifying the output of /proc/self/stack and checking that
      the assembly looked sound. For GCC (where we require version 5.1.0 or
      later) I tested with the kernel.org crosstool binares for versions
      5.5.0, 6.4.0, 6.5.0, 7.3.0, 7.5.0, 8.1.0, 8.3.0, 8.4.0, 9.2.0, and
      10.1.0. For clang (where we require version 10.0.1 or later) I tested
      with the llvm.org binary releases of 11.0.0, and 11.0.1.
      
      Fixes: 5fc57df2 ("arm64: stacktrace: Convert to ARCH_STACKWALK")
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Chen Jun <chenjun102@huawei.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: <stable@vger.kernel.org> # 5.10.x
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: NMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210319184106.5688-1-mark.rutland@arm.comSigned-off-by: NWill Deacon <will@kernel.org>
      c607ab4f
  6. 20 3月, 2021 2 次提交
  7. 19 3月, 2021 4 次提交
    • T
      x86/ioapic: Ignore IRQ2 again · a501b048
      Thomas Gleixner 提交于
      Vitaly ran into an issue with hotplugging CPU0 on an Amazon instance where
      the matrix allocator claimed to be out of vectors. He analyzed it down to
      the point that IRQ2, the PIC cascade interrupt, which is supposed to be not
      ever routed to the IO/APIC ended up having an interrupt vector assigned
      which got moved during unplug of CPU0.
      
      The underlying issue is that IRQ2 for various reasons (see commit
      af174783 ("x86: I/O APIC: Never configure IRQ2" for details) is treated
      as a reserved system vector by the vector core code and is not accounted as
      a regular vector. The Amazon BIOS has an routing entry of pin2 to IRQ2
      which causes the IO/APIC setup to claim that interrupt which is granted by
      the vector domain because there is no sanity check. As a consequence the
      allocation counter of CPU0 underflows which causes a subsequent unplug to
      fail with:
      
        [ ... ] CPU 0 has 4294967295 vectors, 589 available. Cannot disable CPU
      
      There is another sanity check missing in the matrix allocator, but the
      underlying root cause is that the IO/APIC code lost the IRQ2 ignore logic
      during the conversion to irqdomains.
      
      For almost 6 years nobody complained about this wreckage, which might
      indicate that this requirement could be lifted, but for any system which
      actually has a PIC IRQ2 is unusable by design so any routing entry has no
      effect and the interrupt cannot be connected to a device anyway.
      
      Due to that and due to history biased paranoia reasons restore the IRQ2
      ignore logic and treat it as non existent despite a routing entry claiming
      otherwise.
      
      Fixes: d32932d0 ("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces")
      Reported-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Tested-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210318192819.636943062@linutronix.de
      
      a501b048
    • W
      x86/kvm: Fix broken irq restoration in kvm_wait · f4e61f0c
      Wanpeng Li 提交于
      After commit 997acaf6 (lockdep: report broken irq restoration), the guest
      splatting below during boot:
      
       raw_local_irq_restore() called with IRQs enabled
       WARNING: CPU: 1 PID: 169 at kernel/locking/irqflag-debug.c:10 warn_bogus_irq_restore+0x26/0x30
       Modules linked in: hid_generic usbhid hid
       CPU: 1 PID: 169 Comm: systemd-udevd Not tainted 5.11.0+ #25
       RIP: 0010:warn_bogus_irq_restore+0x26/0x30
       Call Trace:
        kvm_wait+0x76/0x90
        __pv_queued_spin_lock_slowpath+0x285/0x2e0
        do_raw_spin_lock+0xc9/0xd0
        _raw_spin_lock+0x59/0x70
        lockref_get_not_dead+0xf/0x50
        __legitimize_path+0x31/0x60
        legitimize_root+0x37/0x50
        try_to_unlazy_next+0x7f/0x1d0
        lookup_fast+0xb0/0x170
        path_openat+0x165/0x9b0
        do_filp_open+0x99/0x110
        do_sys_openat2+0x1f1/0x2e0
        do_sys_open+0x5c/0x80
        __x64_sys_open+0x21/0x30
        do_syscall_64+0x32/0x50
        entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The new consistency checking,  expects local_irq_save() and
      local_irq_restore() to be paired and sanely nested, and therefore expects
      local_irq_restore() to be called with irqs disabled.
      The irqflags handling in kvm_wait() which ends up doing:
      
      	local_irq_save(flags);
      	safe_halt();
      	local_irq_restore(flags);
      
      instead triggers it.  This patch fixes it by using
      local_irq_disable()/enable() directly.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Reported-by: NDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NWanpeng Li <wanpengli@tencent.com>
      Message-Id: <1615791328-2735-1-git-send-email-wanpengli@tencent.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f4e61f0c
    • W
      KVM: X86: Fix missing local pCPU when executing wbinvd on all dirty pCPUs · c2162e13
      Wanpeng Li 提交于
      In order to deal with noncoherent DMA, we should execute wbinvd on
      all dirty pCPUs when guest wbinvd exits to maintain data consistency.
      smp_call_function_many() does not execute the provided function on the
      local core, therefore replace it by on_each_cpu_mask().
      Reported-by: NNadav Amit <namit@vmware.com>
      Cc: Nadav Amit <namit@vmware.com>
      Signed-off-by: NWanpeng Li <wanpengli@tencent.com>
      Message-Id: <1615517151-7465-1-git-send-email-wanpengli@tencent.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c2162e13
    • S
      KVM: x86: Protect userspace MSR filter with SRCU, and set atomically-ish · b318e8de
      Sean Christopherson 提交于
      Fix a plethora of issues with MSR filtering by installing the resulting
      filter as an atomic bundle instead of updating the live filter one range
      at a time.  The KVM_X86_SET_MSR_FILTER ioctl() isn't truly atomic, as
      the hardware MSR bitmaps won't be updated until the next VM-Enter, but
      the relevant software struct is atomically updated, which is what KVM
      really needs.
      
      Similar to the approach used for modifying memslots, make arch.msr_filter
      a SRCU-protected pointer, do all the work configuring the new filter
      outside of kvm->lock, and then acquire kvm->lock only when the new filter
      has been vetted and created.  That way vCPU readers either see the old
      filter or the new filter in their entirety, not some half-baked state.
      
      Yuan Yao pointed out a use-after-free in ksm_msr_allowed() due to a
      TOCTOU bug, but that's just the tip of the iceberg...
      
        - Nothing is __rcu annotated, making it nigh impossible to audit the
          code for correctness.
        - kvm_add_msr_filter() has an unpaired smp_wmb().  Violation of kernel
          coding style aside, the lack of a smb_rmb() anywhere casts all code
          into doubt.
        - kvm_clear_msr_filter() has a double free TOCTOU bug, as it grabs
          count before taking the lock.
        - kvm_clear_msr_filter() also has memory leak due to the same TOCTOU bug.
      
      The entire approach of updating the live filter is also flawed.  While
      installing a new filter is inherently racy if vCPUs are running, fixing
      the above issues also makes it trivial to ensure certain behavior is
      deterministic, e.g. KVM can provide deterministic behavior for MSRs with
      identical settings in the old and new filters.  An atomic update of the
      filter also prevents KVM from getting into a half-baked state, e.g. if
      installing a filter fails, the existing approach would leave the filter
      in a half-baked state, having already committed whatever bits of the
      filter were already processed.
      
      [*] https://lkml.kernel.org/r/20210312083157.25403-1-yaoyuan0329os@gmail.com
      
      Fixes: 1a155254 ("KVM: x86: Introduce MSR filtering")
      Cc: stable@vger.kernel.org
      Cc: Alexander Graf <graf@amazon.com>
      Reported-by: NYuan Yao <yaoyuan0329os@gmail.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210316184436.2544875-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b318e8de
  8. 18 3月, 2021 5 次提交
    • V
      KVM: x86: hyper-v: Don't touch TSC page values when guest opted for re-enlightenment · 0469f2f7
      Vitaly Kuznetsov 提交于
      When guest opts for re-enlightenment notifications upon migration, it is
      in its right to assume that TSC page values never change (as they're only
      supposed to change upon migration and the host has to keep things as they
      are before it receives confirmation from the guest). This is mostly true
      until the guest is migrated somewhere. KVM userspace (e.g. QEMU) will
      trigger masterclock update by writing to HV_X64_MSR_REFERENCE_TSC, by
      calling KVM_SET_CLOCK,... and as TSC value and kvmclock reading drift
      apart (even slightly), the update causes TSC page values to change.
      
      The issue at hand is that when Hyper-V is migrated, it uses stale (cached)
      TSC page values to compute the difference between its own clocksource
      (provided by KVM) and its guests' TSC pages to program synthetic timers
      and in some cases, when TSC page is updated, this puts all stimer
      expirations in the past. This, in its turn, causes an interrupt storm
      and L2 guests not making much forward progress.
      
      Note, KVM doesn't fully implement re-enlightenment notification. Basically,
      the support for reenlightenment MSRs is just a stub and userspace is only
      expected to expose the feature when TSC scaling on the expected destination
      hosts is available. With TSC scaling, no real re-enlightenment is needed
      as TSC frequency doesn't change. With TSC scaling becoming ubiquitous, it
      likely makes little sense to fully implement re-enlightenment in KVM.
      
      Prevent TSC page from being updated after migration. In case it's not the
      guest who's initiating the change and when TSC page is already enabled,
      just keep it as it is: TSC value is supposed to be preserved across
      migration and TSC frequency can't change with re-enlightenment enabled.
      The guest is doomed anyway if any of this is not true.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Message-Id: <20210316143736.964151-5-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0469f2f7
    • V
      KVM: x86: hyper-v: Track Hyper-V TSC page status · cc9cfddb
      Vitaly Kuznetsov 提交于
      Create an infrastructure for tracking Hyper-V TSC page status, i.e. if it
      was updated from guest/host side or if we've failed to set it up (because
      e.g. guest wrote some garbage to HV_X64_MSR_REFERENCE_TSC) and there's no
      need to retry.
      
      Also, in a hypothetical situation when we are in 'always catchup' mode for
      TSC we can now avoid contending 'hv->hv_lock' on every guest enter by
      setting the state to HV_TSC_PAGE_BROKEN after compute_tsc_page_parameters()
      returns false.
      
      Check for HV_TSC_PAGE_SET state instead of '!hv->tsc_ref.tsc_sequence' in
      get_time_ref_counter() to properly handle the situation when we failed to
      write the updated TSC page values to the guest.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Message-Id: <20210316143736.964151-4-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cc9cfddb
    • D
      ARM: dts: imx6ull: fix ubi filesystem mount failed · e4817a1b
      dillon min 提交于
      For NAND Ecc layout, there is a dependency from old kernel's nand driver
      setting and current. if old kernel use 4 bit ecc , we should use 4 bit
      in new kernel either. else will run into following error at filesystem
      mounting.
      
      So, enable fsl,use-minimum-ecc from device tree, to fix this mismatch
      
      [    9.449265] ubi0: scanning is finished
      [    9.463968] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
      22528 bytes from PEB 513:4096, read only 22528 bytes, retry
      [    9.486940] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
      22528 bytes from PEB 513:4096, read only 22528 bytes, retry
      [    9.509906] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
      22528 bytes from PEB 513:4096, read only 22528 bytes, retry
      [    9.532845] ubi0 error: ubi_io_read: error -74 (ECC error) while reading
      22528 bytes from PEB 513:4096, read 22528 bytes
      
      Fixes: f9ecf10c ("ARM: dts: imx6ull: add MYiR MYS-6ULX SBC")
      Signed-off-by: Ndillon min <dillon.minfei@gmail.com>
      Reviewed-by: NFabio Estevam <festevam@gmail.com>
      Signed-off-by: NShawn Guo <shawnguo@kernel.org>
      e4817a1b
    • A
      bpf: Fix fexit trampoline. · e21aa341
      Alexei Starovoitov 提交于
      The fexit/fmod_ret programs can be attached to kernel functions that can sleep.
      The synchronize_rcu_tasks() will not wait for such tasks to complete.
      In such case the trampoline image will be freed and when the task
      wakes up the return IP will point to freed memory causing the crash.
      Solve this by adding percpu_ref_get/put for the duration of trampoline
      and separate trampoline vs its image life times.
      The "half page" optimization has to be removed, since
      first_half->second_half->first_half transition cannot be guaranteed to
      complete in deterministic time. Every trampoline update becomes a new image.
      The image with fmod_ret or fexit progs will be freed via percpu_ref_kill and
      call_rcu_tasks. Together they will wait for the original function and
      trampoline asm to complete. The trampoline is patched from nop to jmp to skip
      fexit progs. They are freed independently from the trampoline. The image with
      fentry progs only will be freed via call_rcu_tasks_trace+call_rcu_tasks which
      will wait for both sleepable and non-sleepable progs to complete.
      
      Fixes: fec56f58 ("bpf: Introduce BPF trampoline")
      Reported-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: Paul E. McKenney <paulmck@kernel.org>  # for RCU
      Link: https://lore.kernel.org/bpf/20210316210007.38949-1-alexei.starovoitov@gmail.com
      e21aa341
    • L
      module: remove never implemented MODULE_SUPPORTED_DEVICE · 6417f031
      Leon Romanovsky 提交于
      MODULE_SUPPORTED_DEVICE was added in pre-git era and never was
      implemented. We can safely remove it, because the kernel has grown
      to have many more reliable mechanisms to determine if device is
      supported or not.
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6417f031
  9. 17 3月, 2021 12 次提交