Skip to content
Snippets Groups Projects
  1. Aug 21, 2022
  2. Aug 19, 2022
    • Aaron Lu's avatar
      x86/mm: Use proper mask when setting PUD mapping · 88e0a749
      Aaron Lu authored
      
      Commit c164fbb4("x86/mm: thread pgprot_t through
      init_memory_mapping()") mistakenly used __pgprot() which doesn't respect
      __default_kernel_pte_mask when setting PUD mapping.
      
      Fix it by only setting the one bit we actually need (PSE) and leaving
      the other bits (that have been properly masked) alone.
      
      Fixes: c164fbb4 ("x86/mm: thread pgprot_t through init_memory_mapping()")
      Signed-off-by: default avatarAaron Lu <aaron.lu@intel.com>
      Cc: stable@kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      88e0a749
    • Josh Poimboeuf's avatar
      x86/kvm: Fix "missing ENDBR" BUG for fastop functions · 3d9606b0
      Josh Poimboeuf authored
      
      The following BUG was reported:
      
        traps: Missing ENDBR: andw_ax_dx+0x0/0x10 [kvm]
        ------------[ cut here ]------------
        kernel BUG at arch/x86/kernel/traps.c:253!
        invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
         <TASK>
         asm_exc_control_protection+0x2b/0x30
        RIP: 0010:andw_ax_dx+0x0/0x10 [kvm]
        Code: c3 cc cc cc cc 0f 1f 44 00 00 66 0f 1f 00 48 19 d0 c3 cc cc cc
              cc 0f 1f 40 00 f3 0f 1e fa 20 d0 c3 cc cc cc cc 0f 1f 44 00 00
              <66> 0f 1f 00 66 21 d0 c3 cc cc cc cc 0f 1f 40 00 66 0f 1f 00 21
              d0
      
         ? andb_al_dl+0x10/0x10 [kvm]
         ? fastop+0x5d/0xa0 [kvm]
         x86_emulate_insn+0x822/0x1060 [kvm]
         x86_emulate_instruction+0x46f/0x750 [kvm]
         complete_emulated_mmio+0x216/0x2c0 [kvm]
         kvm_arch_vcpu_ioctl_run+0x604/0x650 [kvm]
         kvm_vcpu_ioctl+0x2f4/0x6b0 [kvm]
         ? wake_up_q+0xa0/0xa0
      
      The BUG occurred because the ENDBR in the andw_ax_dx() fastop function
      had been incorrectly "sealed" (converted to a NOP) by apply_ibt_endbr().
      
      Objtool marked it to be sealed because KVM has no compile-time
      references to the function.  Instead KVM calculates its address at
      runtime.
      
      Prevent objtool from annotating fastop functions as sealable by creating
      throwaway dummy compile-time references to the functions.
      
      Fixes: 6649fa87 ("x86/ibt,kvm: Add ENDBR to fastops")
      Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Debugged-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Message-Id: <0d4116f90e9d0c1b754bb90c585e6f0415a1c508.1660837839.git.jpoimboe@kernel.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      3d9606b0
    • Josh Poimboeuf's avatar
      x86/kvm: Simplify FOP_SETCC() · 22472d12
      Josh Poimboeuf authored
      
      SETCC_ALIGN and FOP_ALIGN are both 16.  Remove the special casing for
      FOP_SETCC() and just make it a normal fastop.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Message-Id: <7c13d94d1a775156f7e36eed30509b274a229140.1660837839.git.jpoimboe@kernel.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      22472d12
    • Josh Poimboeuf's avatar
      x86/ibt, objtool: Add IBT_NOSEAL() · e27e5bea
      Josh Poimboeuf authored
      
      Add a macro which prevents a function from getting sealed if there are
      no compile-time references to it.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Message-Id: <20220818213927.e44fmxkoq4yj6ybn@treble>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e27e5bea
    • Chao Peng's avatar
      KVM: Rename mmu_notifier_* to mmu_invalidate_* · 20ec3ebd
      Chao Peng authored
      
      The motivation of this renaming is to make these variables and related
      helper functions less mmu_notifier bound and can also be used for non
      mmu_notifier based page invalidation. mmu_invalidate_* was chosen to
      better describe the purpose of 'invalidating' a page that those
      variables are used for.
      
        - mmu_notifier_seq/range_start/range_end are renamed to
          mmu_invalidate_seq/range_start/range_end.
      
        - mmu_notifier_retry{_hva} helper functions are renamed to
          mmu_invalidate_retry{_hva}.
      
        - mmu_notifier_count is renamed to mmu_invalidate_in_progress to
          avoid confusion with mn_active_invalidate_count.
      
        - While here, also update kvm_inc/dec_notifier_count() to
          kvm_mmu_invalidate_begin/end() to match the change for
          mmu_notifier_count.
      
      No functional change intended.
      
      Signed-off-by: default avatarChao Peng <chao.p.peng@linux.intel.com>
      Message-Id: <20220816125322.1110439-3-chao.p.peng@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      20ec3ebd
    • Chao Peng's avatar
      KVM: Rename KVM_PRIVATE_MEM_SLOTS to KVM_INTERNAL_MEM_SLOTS · bdd1c37a
      Chao Peng authored
      
      KVM_INTERNAL_MEM_SLOTS better reflects the fact those slots are KVM
      internally used (invisible to userspace) and avoids confusion to future
      private slots that can have different meaning.
      
      Signed-off-by: default avatarChao Peng <chao.p.peng@linux.intel.com>
      Message-Id: <20220816125322.1110439-2-chao.p.peng@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      bdd1c37a
    • Paolo Bonzini's avatar
      KVM: MIPS: remove unnecessary definition of KVM_PRIVATE_MEM_SLOTS · b0754508
      Paolo Bonzini authored
      
      KVM_PRIVATE_MEM_SLOTS defaults to zero, so it is not necessary to
      define it in MIPS's asm/kvm_host.h.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b0754508
  3. Aug 17, 2022
  4. Aug 16, 2022
    • Linus Torvalds's avatar
      x86: simplify load_unaligned_zeropad() implementation · c4e34dd9
      Linus Torvalds authored
      
      The exception for the "unaligned access at the end of the page, next
      page not mapped" never happens, but the fixup code ends up causing
      trouble for compilers to optimize well.
      
      clang in particular ends up seeing it being in the middle of a loop, and
      tries desperately to optimize the exception fixup code that is never
      really reached.
      
      The simple solution is to just move all the fixups into the exception
      handler itself, which moves it all out of the hot case code, and means
      that the compiler never sees it or needs to worry about it.
      
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c4e34dd9
    • Michael S. Tsirkin's avatar
      virtio: Revert "virtio: find_vqs() add arg sizes" · 9993a4f9
      Michael S. Tsirkin authored
      
      This reverts commit a10fba03: the
      proposed API isn't supported on all transports but no
      effort was made to address this.
      
      It might not be hard to fix if we want to: maybe just
      rename size to size_hint and make sure legacy
      transports ignore the hint.
      
      But it's not sure what the benefit is in any case, so
      let's drop it.
      
      Fixes: a10fba03 ("virtio: find_vqs() add arg sizes")
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Message-Id: <20220816053602.173815-8-mst@redhat.com>
      9993a4f9
  5. Aug 15, 2022
  6. Aug 14, 2022
  7. Aug 12, 2022
    • Atish Patra's avatar
      RISC-V: KVM: Support sstc extension · 8f5cb44b
      Atish Patra authored
      
      Sstc extension allows the guest to program the vstimecmp CSR directly
      instead of making an SBI call to the hypervisor to program the next
      event. The timer interrupt is also directly injected to the guest by
      the hardware in this case. To maintain backward compatibility, the
      hypervisors also update the vstimecmp in an SBI set_time call if
      the hardware supports it. Thus, the older kernels in guest also
      take advantage of the sstc extension.
      
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarAtish Patra <atishp@rivosinc.com>
      Acked-by: default avatarAnup Patel <anup@brainfault.org>
      Link: https://lore.kernel.org/all/CAAhSdy2mb6wyqy0NAn9BcTWKMYEc0Z4zU3s3j7oNqBz6eDQ9sg@mail.gmail.com/
      
      
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      8f5cb44b
    • Jane Malalane's avatar
      x86/xen: Add support for HVMOP_set_evtchn_upcall_vector · b1c3497e
      Jane Malalane authored
      
      Implement support for the HVMOP_set_evtchn_upcall_vector hypercall in
      order to set the per-vCPU event channel vector callback on Linux and
      use it in preference of HVM_PARAM_CALLBACK_IRQ.
      
      If the per-VCPU vector setup is successful on BSP, use this method
      for the APs. If not, fallback to the global vector-type callback.
      
      Also register callback_irq at per-vCPU event channel setup to trick
      toolstack to think the domain is enlightened.
      
      Suggested-by: default avatar"Roger Pau Monné" <roger.pau@citrix.com>
      Signed-off-by: default avatarJane Malalane <jane.malalane@citrix.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Link: https://lore.kernel.org/r/20220729070416.23306-1-jane.malalane@citrix.com
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      b1c3497e
    • Huacai Chen's avatar
      LoongArch: Update Loongson-3 default config file · 27b161a4
      Huacai Chen authored
      
      1, Add NVME related options;
      2, Add compressed firmware support;
      3, Add virtio drivers in order to run in qemu.
      
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      27b161a4
    • Qing Zhang's avatar
      LoongArch: Add USER_STACKTRACE support · 4d7bf939
      Qing Zhang authored
      
      To get the best stacktrace output, you can compile your userspace
      programs with frame pointers (at least glibc + the app you are tracing).
      
      1, export "CC = gcc -fno-omit-frame-pointer";
      2, compile your programs with "CC";
      3, use uprobe to get stacktrace output.
      
      ...
           echo 'p:malloc /usr/lib64/libc.so.6:0x0a4704 size=%r4:u64' > uprobe_events
           echo 'p:free /usr/lib64/libc.so.6:0x0a4d50 ptr=%r4:x64' >> uprobe_events
           echo 'comm == "demo"' > ./events/uprobes/malloc/filter
           echo 'comm == "demo"' > ./events/uprobes/free/filter
           echo 1 > ./options/userstacktrace
           echo 1 > ./options/sym-userobj
      ...
      
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4d7bf939
    • Qing Zhang's avatar
      LoongArch: Add STACKTRACE support · 93a4fa62
      Qing Zhang authored
      
      1. Use common arch_stack_walk() infrastructure to avoid duplicated code
         and avoid taking care of the stack storage and filtering.
      2. Add sched_ra (means sched return address) and sched_cfa (means sched
         call frame address) to thread_info, and store them in switch_to().
      3. Add __get_wchan() implementation.
      
      Now we can print the process stack and wait channel by cat /proc/*/stack
      and /proc/*/wchan.
      
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      93a4fa62
    • Qing Zhang's avatar
      LoongArch: Add prologue unwinder support · 49aef111
      Qing Zhang authored
      
      It unwind the stack frame based on prologue code analyze.
      CONFIG_KALLSYMS is needed, at least the address and length
      of each function.
      
      Three stages when we do unwind,
        1) unwind_start(), the prapare of unwinding, fill unwind_state.
        2) unwind_done(), judge whether the unwind process is finished or not.
        3) unwind_next_frame(), unwind the next frame.
      
      Dividing unwinder helps to add new unwinders in the future, e.g.:
      unwinder_frame, unwinder_orc, .etc.
      
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      49aef111
    • Qing Zhang's avatar
      LoongArch: Add guess unwinder support · 49232773
      Qing Zhang authored
      
      Name "guess unwinder" comes from x86, it scans the stack and reports
      every kernel text address it finds.
      
      Unwinders can be used by dump_stack() and other stacktrace functions.
      
      Three stages when we do unwind,
        1) unwind_start(), the prapare of unwinding, fill unwind_state.
        2) unwind_done(), judge whether the unwind process is finished or not.
        3) unwind_next_frame(), unwind the next frame.
      
      Add get_stack_info() to get stack info. At present we have irq stack and
      task stack. The next_sp is the key info between two types of stacks.
      
      Dividing unwinder helps to add new unwinders in the future.
      
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      49232773
    • Huacai Chen's avatar
      LoongArch: Add vDSO syscall __vdso_getcpu() · dce6098b
      Huacai Chen authored
      
      We test 20 million times of getcpu(), the real syscall version take 25
      seconds, while the vsyscall version take only 2.4 seconds.
      
      Signed-off-by: default avatarRui Wang <wangrui@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      dce6098b
    • Huacai Chen's avatar
      LoongArch: Add PCI controller support · 57fc7323
      Huacai Chen authored
      
      Loongson64 based systems are PC-like systems which use PCI/PCIe as its
      I/O bus, This patch adds the PCI host controller support for LoongArch.
      
      Reviewed-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarJianmin Lv <lvjianmin@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      57fc7323
    • Huacai Chen's avatar
      LoongArch: Parse MADT to get multi-processor information · e9e7ff16
      Huacai Chen authored
      
      Parse MADT to get multi-processor information, in order to fix the boot
      problem and cpu-hotplug problem for SMP platform.
      
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      e9e7ff16
    • Huacai Chen's avatar
      LoongArch: Jump to the link address before enable PG · ab2579d7
      Huacai Chen authored
      
      The kernel entry points of both boot CPU (i.e., kernel_entry) and non-
      boot CPUs (i.e., smpboot_entry) may be physical address from BootLoader
      (in DA mode or identity-mapping PG mode). So we should jump to the link
      address before PG enabled (because DA is disabled at the same time) and
      just after DMW configured.
      
      Specifically: With some older firmwares, non-boot CPUs started with PG
      enabled, but this need firmware cooperation in the form of a temporary
      page table, which is deemed unnecessary. OTOH, latest firmware versions
      configure the non-boot CPUs to start in DA mode, so kernel-side changes
      are needed.
      
      Reviewed-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      ab2579d7
    • Qing Zhang's avatar
      LoongArch: Requires __force attributes for any casts · 5e8be07c
      Qing Zhang authored
      
      This fix a warning when "make C=2":
      arch/loongarch/kernel/ptrace.c: note: in included file (through include/linux/uaccess.h, include/linux/sched/task.h, include/linux/sched/signal.h, include/linux/ptrace.h, include/linux/audit.h):
      ./arch/loongarch/include/asm/uaccess.h:232:32: warning: incorrect type in argument 2 (different address spaces)
      ./arch/loongarch/include/asm/uaccess.h:232:32:    expected void const *from
      ./arch/loongarch/include/asm/uaccess.h:232:32:    got void const [noderef] __user *from
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      5e8be07c
    • Yang Li's avatar
      LoongArch: Fix unsigned comparison with less than zero · aafcac81
      Yang Li authored
      
      The return value from the call to get_timer_irq() is int, which can be
      a negative error code. However, the return value is being assigned to an
      unsigned int variable 'irq', so making 'irq' an int.
      
      Eliminate the following coccicheck warning:
      ./arch/loongarch/kernel/time.c:146:5-8: WARNING: Unsigned expression compared with zero: irq < 0
      
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      aafcac81
    • Huacai Chen's avatar
      LoongArch: Adjust arch/loongarch/Kconfig · f30d1f49
      Huacai Chen authored
      
      1, ACPI, EFI and SMP are mandatories for LoongArch, select them
      unconditionally to avoid various build errors for 'make randconfig'.
      2, Move the MMU_GATHER_MERGE_VMAS selection to the correct place.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      f30d1f49
    • Huacai Chen's avatar
      LoongArch: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK · 28e112af
      Huacai Chen authored
      
      When CONFIG_CPUMASK_OFFSTACK and CONFIG_DEBUG_PER_CPU_MAPS is selected,
      cpu_max_bits_warn() generates a runtime warning similar as below while
      we show /proc/cpuinfo. Fix this by using nr_cpu_ids (the runtime limit)
      instead of NR_CPUS to iterate CPUs.
      
      [    3.052463] ------------[ cut here ]------------
      [    3.059679] WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:108 show_cpuinfo+0x5e8/0x5f0
      [    3.070072] Modules linked in: efivarfs autofs4
      [    3.076257] CPU: 0 PID: 1 Comm: systemd Not tainted 5.19-rc5+ #1052
      [    3.084034] Hardware name: Loongson Loongson-3A5000-7A1000-1w-V0.1-CRB/Loongson-LS3A5000-7A1000-1w-EVB-V1.21, BIOS Loongson-UDK2018-V2.0.04082-beta7 04/27
      [    3.099465] Stack : 9000000100157b08 9000000000f18530 9000000000cf846c 9000000100154000
      [    3.109127]         9000000100157a50 0000000000000000 9000000100157a58 9000000000ef7430
      [    3.118774]         90000001001578e8 0000000000000040 0000000000000020 ffffffffffffffff
      [    3.128412]         0000000000aaaaaa 1ab25f00eec96a37 900000010021de80 900000000101c890
      [    3.138056]         0000000000000000 0000000000000000 0000000000000000 0000000000aaaaaa
      [    3.147711]         ffff8000339dc220 0000000000000001 0000000006ab4000 0000000000000000
      [    3.157364]         900000000101c998 0000000000000004 9000000000ef7430 0000000000000000
      [    3.167012]         0000000000000009 000000000000006c 0000000000000000 0000000000000000
      [    3.176641]         9000000000d3de08 9000000001639390 90000000002086d8 00007ffff0080286
      [    3.186260]         00000000000000b0 0000000000000004 0000000000000000 0000000000071c1c
      [    3.195868]         ...
      [    3.199917] Call Trace:
      [    3.203941] [<90000000002086d8>] show_stack+0x38/0x14c
      [    3.210666] [<9000000000cf846c>] dump_stack_lvl+0x60/0x88
      [    3.217625] [<900000000023d268>] __warn+0xd0/0x100
      [    3.223958] [<9000000000cf3c90>] warn_slowpath_fmt+0x7c/0xcc
      [    3.231150] [<9000000000210220>] show_cpuinfo+0x5e8/0x5f0
      [    3.238080] [<90000000004f578c>] seq_read_iter+0x354/0x4b4
      [    3.245098] [<90000000004c2e90>] new_sync_read+0x17c/0x1c4
      [    3.252114] [<90000000004c5174>] vfs_read+0x138/0x1d0
      [    3.258694] [<90000000004c55f8>] ksys_read+0x70/0x100
      [    3.265265] [<9000000000cfde9c>] do_syscall+0x7c/0x94
      [    3.271820] [<9000000000202fe4>] handle_syscall+0xc4/0x160
      [    3.281824] ---[ end trace 8b484262b4b8c24c ]---
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      28e112af
  8. Aug 11, 2022
Loading