1. 28 10月, 2022 3 次提交
  2. 26 10月, 2022 1 次提交
  3. 14 10月, 2022 5 次提交
    • H
      parisc: Fix userspace graphics card breakage due to pgtable special bit · 70be49f2
      Helge Deller 提交于
      Commit df24e178 ("parisc: Add vDSO support") introduced the vDSO
      support, for which a _PAGE_SPECIAL page table flag was needed.  Since we
      wanted to keep every page table entry in 32-bits, this patch re-used the
      existing - but yet unused - _PAGE_DMB flag (which triggers a hardware break
      if a page is accessed) to store the special bit.
      
      But when graphics card memory is mmapped into userspace, the kernel uses
      vm_iomap_memory() which sets the the special flag. So, with the DMB bit
      set, every access to the graphics memory now triggered a hardware
      exception and segfaulted the userspace program.
      
      Fix this breakage by dropping the DMB bit when writing the page
      protection bits to the CPU TLB.
      
      In addition this patch adds a small optimization: if huge pages aren't
      configured (which is at least the case for 32-bit kernels), then the
      special bit is stored in the hpage (HUGE PAGE) bit instead. That way we
      can skip to reset the DMB bit.
      
      Fixes: df24e178 ("parisc: Add vDSO support")
      Cc: <stable@vger.kernel.org> # 5.18+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      70be49f2
    • M
      RISC-V: Make port I/O string accessors actually work · 9cc205e3
      Maciej W. Rozycki 提交于
      Fix port I/O string accessors such as `insb', `outsb', etc. which use
      the physical PCI port I/O address rather than the corresponding memory
      mapping to get at the requested location, which in turn breaks at least
      accesses made by our parport driver to a PCIe parallel port such as:
      
      PCI parallel port detected: 1415:c118, I/O at 0x1000(0x1008), IRQ 20
      parport0: PC-style at 0x1000 (0x1008), irq 20, using FIFO [PCSPP,TRISTATE,COMPAT,EPP,ECP]
      
      causing a memory access fault:
      
      Unable to handle kernel access to user memory without uaccess routines at virtual address 0000000000001008
      Oops [#1]
      Modules linked in:
      CPU: 1 PID: 350 Comm: cat Not tainted 6.0.0-rc2-00283-g10d4879f-dirty #23
      Hardware name: SiFive HiFive Unmatched A00 (DT)
      epc : parport_pc_fifo_write_block_pio+0x266/0x416
       ra : parport_pc_fifo_write_block_pio+0xb4/0x416
      epc : ffffffff80542c3e ra : ffffffff80542a8c sp : ffffffd88899fc60
       gp : ffffffff80fa2700 tp : ffffffd882b1e900 t0 : ffffffd883d0b000
       t1 : ffffffffff000002 t2 : 4646393043330a38 s0 : ffffffd88899fcf0
       s1 : 0000000000001000 a0 : 0000000000000010 a1 : 0000000000000000
       a2 : ffffffd883d0a010 a3 : 0000000000000023 a4 : 00000000ffff8fbb
       a5 : ffffffd883d0a001 a6 : 0000000100000000 a7 : ffffffc800000000
       s2 : ffffffffff000002 s3 : ffffffff80d28880 s4 : ffffffff80fa1f50
       s5 : 0000000000001008 s6 : 0000000000000008 s7 : ffffffd883d0a000
       s8 : 0004000000000000 s9 : ffffffff80dc1d80 s10: ffffffd8807e4000
       s11: 0000000000000000 t3 : 00000000000000ff t4 : 393044410a303930
       t5 : 0000000000001000 t6 : 0000000000040000
      status: 0000000200000120 badaddr: 0000000000001008 cause: 000000000000000f
      [<ffffffff80543212>] parport_pc_compat_write_block_pio+0xfe/0x200
      [<ffffffff8053bbc0>] parport_write+0x46/0xf8
      [<ffffffff8050530e>] lp_write+0x158/0x2d2
      [<ffffffff80185716>] vfs_write+0x8e/0x2c2
      [<ffffffff80185a74>] ksys_write+0x52/0xc2
      [<ffffffff80185af2>] sys_write+0xe/0x16
      [<ffffffff80003770>] ret_from_syscall+0x0/0x2
      ---[ end trace 0000000000000000 ]---
      
      For simplicity address the problem by adding PCI_IOBASE to the physical
      address requested in the respective wrapper macros only, observing that
      the raw accessors such as `__insb', `__outsb', etc. are not supposed to
      be used other than by said macros.  Remove the cast to `long' that is no
      longer needed on `addr' now that it is used as an offset from PCI_IOBASE
      and add parentheses around `addr' needed for predictable evaluation in
      macro expansion.  No need to make said adjustments in separate changes
      given that current code is gravely broken and does not ever work.
      Signed-off-by: NMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: fab957c1 ("RISC-V: Atomic and Locking Code")
      Cc: stable@vger.kernel.org # v4.15+
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2209220223080.29493@angie.orcam.me.ukSigned-off-by: NPalmer Dabbelt <palmer@rivosinc.com>
      9cc205e3
    • C
      riscv: enable software resend of irqs · c45fc916
      Conor Dooley 提交于
      The PLIC specification does not describe the interrupt pendings bits as
      read-write, only that they "can be read". To allow for retriggering of
      interrupts (and the use of the irq debugfs interface) enable
      HARDIRQS_SW_RESEND for RISC-V.
      
      Link: https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc#interrupt-pending-bitsSigned-off-by: NConor Dooley <conor.dooley@microchip.com>
      Acked-by: NMarc Zyngier <maz@kernel.org>
      Acked-by: NPalmer Dabbelt <palmer@rivosinc.com>
      Tested-by: Palmer Dabbelt <palmer@rivosinc.com> # on QEMU
      Reviewed-by: NBjörn Töpel <bjorn@kernel.org>
      Link: https://lore.kernel.org/r/20220729111116.259146-1-conor.dooley@microchip.comSigned-off-by: NPalmer Dabbelt <palmer@rivosinc.com>
      c45fc916
    • J
      riscv: vdso: fix NULL deference in vdso_join_timens() when vfork · a8616d2d
      Jisheng Zhang 提交于
      Testing tools/testing/selftests/timens/vfork_exec.c got below
      kernel log:
      
      [    6.838454] Unable to handle kernel access to user memory without uaccess routines at virtual address 0000000000000020
      [    6.842255] Oops [#1]
      [    6.842871] Modules linked in:
      [    6.844249] CPU: 1 PID: 64 Comm: vfork_exec Not tainted 6.0.0-rc3-rt15+ #8
      [    6.845861] Hardware name: riscv-virtio,qemu (DT)
      [    6.848009] epc : vdso_join_timens+0xd2/0x110
      [    6.850097]  ra : vdso_join_timens+0xd2/0x110
      [    6.851164] epc : ffffffff8000635c ra : ffffffff8000635c sp : ff6000000181fbf0
      [    6.852562]  gp : ffffffff80cff648 tp : ff60000000fdb700 t0 : 3030303030303030
      [    6.853852]  t1 : 0000000000000030 t2 : 3030303030303030 s0 : ff6000000181fc40
      [    6.854984]  s1 : ff60000001e6c000 a0 : 0000000000000010 a1 : ffffffff8005654c
      [    6.856221]  a2 : 00000000ffffefff a3 : 0000000000000000 a4 : 0000000000000000
      [    6.858114]  a5 : 0000000000000000 a6 : 0000000000000008 a7 : 0000000000000038
      [    6.859484]  s2 : ff60000001e6c068 s3 : ff6000000108abb0 s4 : 0000000000000000
      [    6.860751]  s5 : 0000000000001000 s6 : ffffffff8089dc40 s7 : ffffffff8089dc38
      [    6.862029]  s8 : ffffffff8089dc30 s9 : ff60000000fdbe38 s10: 000000000000005e
      [    6.863304]  s11: ffffffff80cc3510 t3 : ffffffff80d1112f t4 : ffffffff80d1112f
      [    6.864565]  t5 : ffffffff80d11130 t6 : ff6000000181fa00
      [    6.865561] status: 0000000000000120 badaddr: 0000000000000020 cause: 000000000000000d
      [    6.868046] [<ffffffff8008dc94>] timens_commit+0x38/0x11a
      [    6.869089] [<ffffffff8008dde8>] timens_on_fork+0x72/0xb4
      [    6.870055] [<ffffffff80190096>] begin_new_exec+0x3c6/0x9f0
      [    6.871231] [<ffffffff801d826c>] load_elf_binary+0x628/0x1214
      [    6.872304] [<ffffffff8018ee7a>] bprm_execve+0x1f2/0x4e4
      [    6.873243] [<ffffffff8018f90c>] do_execveat_common+0x16e/0x1ee
      [    6.874258] [<ffffffff8018f9c8>] sys_execve+0x3c/0x48
      [    6.875162] [<ffffffff80003556>] ret_from_syscall+0x0/0x2
      [    6.877484] ---[ end trace 0000000000000000 ]---
      
      This is because the mm->context.vdso_info is NULL in vfork case. From
      another side, mm->context.vdso_info either points to vdso info
      for RV64 or vdso info for compat, there's no need to bloat riscv's
      mm_context_t, we can handle the difference when setup the additional
      page for vdso.
      Signed-off-by: NJisheng Zhang <jszhang@kernel.org>
      Suggested-by: NPalmer Dabbelt <palmer@rivosinc.com>
      Fixes: 3092eb45 ("riscv: compat: vdso: Add setup additional pages implementation")
      Link: https://lore.kernel.org/r/20220924070737.3048-1-jszhang@kernel.org
      Cc: stable@vger.kernel.org
      Signed-off-by: NPalmer Dabbelt <palmer@rivosinc.com>
      a8616d2d
    • G
      riscv: Add cache information in AUX vector · da29dbcd
      Greentime Hu 提交于
      There are no standard CSR registers to provide cache information, the
      way for RISC-V is to get this information from DT. sysconf syscall
      could use them to get information of cache through AUX vector.
      
      The result of 'getconf -a|grep -i cache' as follows:
      LEVEL1_ICACHE_SIZE                 32768
      LEVEL1_ICACHE_ASSOC                2
      LEVEL1_ICACHE_LINESIZE             64
      LEVEL1_DCACHE_SIZE                 32768
      LEVEL1_DCACHE_ASSOC                4
      LEVEL1_DCACHE_LINESIZE             64
      LEVEL2_CACHE_SIZE                  524288
      LEVEL2_CACHE_ASSOC                 8
      LEVEL2_CACHE_LINESIZE              64
      LEVEL3_CACHE_SIZE                  4194304
      LEVEL3_CACHE_ASSOC                 16
      LEVEL3_CACHE_LINESIZE              64
      LEVEL4_CACHE_SIZE                  0
      LEVEL4_CACHE_ASSOC                 0
      LEVEL4_CACHE_LINESIZE              0
      Signed-off-by: NGreentime Hu <greentime.hu@sifive.com>
      Signed-off-by: NZong Li <zong.li@sifive.com>
      Suggested-by: NZong Li <zong.li@sifive.com>
      Reviewed-by: NConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20220913061817.22564-8-zong.li@sifive.comSigned-off-by: NPalmer Dabbelt <palmer@rivosinc.com>
      da29dbcd
  4. 13 10月, 2022 13 次提交
  5. 12 10月, 2022 18 次提交
    • N
      powerpc/32: fix syscall wrappers with 64-bit arguments of unaligned register-pairs · e2375062
      Nicholas Piggin 提交于
      powerpc 32-bit system call (and function) calling convention for 64-bit
      arguments requires the next available odd-pair (two sequential registers
      with the first being odd-numbered) from the standard register argument
      allocation.
      
      The first argument register is r3, so a 64-bit argument that appears at
      an even position in the argument list must skip a register (unless there
      were preceding 64-bit arguments, which might throw things off). This
      requires non-standard compat definitions to deal with the holes in the
      argument register allocation.
      
      With pt_regs syscall wrappers which use a standard mapper to map pt_regs
      GPRs to function arguments, 32-bit kernels hit the same basic problem,
      the standard definitions don't cope with the unused argument registers.
      
      Fix this by having 32-bit kernels share those syscall definitions with
      compat.
      
      Thanks to Jason for spending a lot of time finding and bisecting this
      and developing a trivial reproducer. The perfect bug report.
      Reported-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Fixes: 7e92e01b ("powerpc: Provide syscall wrapper")
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20221012035335.866440-1-npiggin@gmail.com
      e2375062
    • C
      arm64: mte: Avoid setting PG_mte_tagged if no tags cleared or restored · a8e5e514
      Catalin Marinas 提交于
      Prior to commit 69e3b846 ("arm64: mte: Sync tags for pages where PTE
      is untagged"), mte_sync_tags() was only called for pte_tagged() entries
      (those mapped with PROT_MTE). Therefore mte_sync_tags() could safely use
      test_and_set_bit(PG_mte_tagged, &page->flags) without inadvertently
      setting PG_mte_tagged on an untagged page.
      
      The above commit was required as guests may enable MTE without any
      control at the stage 2 mapping, nor a PROT_MTE mapping in the VMM.
      However, the side-effect was that any page with a PTE that looked like
      swap (or migration) was getting PG_mte_tagged set automatically. A
      subsequent page copy (e.g. migration) copied the tags to the destination
      page even if the tags were owned by KASAN.
      
      This issue was masked by the page_kasan_tag_reset() call introduced in
      commit e5b8d921 ("arm64: mte: reset the page tag in page->flags").
      When this commit was reverted (20794545), KASAN started reporting
      access faults because the overriding tags in a page did not match the
      original page->flags (with CONFIG_KASAN_HW_TAGS=y):
      
        BUG: KASAN: invalid-access in copy_page+0x10/0xd0 arch/arm64/lib/copy_page.S:26
        Read at addr f5ff000017f2e000 by task syz-executor.1/2218
        Pointer tag: [f5], memory tag: [f2]
      
      Move the PG_mte_tagged bit setting from mte_sync_tags() to the actual
      place where tags are cleared (mte_sync_page_tags()) or restored
      (mte_restore_tags()).
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Reported-by: syzbot+c2c79c6d6eddc5262b77@syzkaller.appspotmail.com
      Fixes: 69e3b846 ("arm64: mte: Sync tags for pages where PTE is untagged")
      Cc: <stable@vger.kernel.org> # 5.14.x
      Cc: Steven Price <steven.price@arm.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/0000000000004387dc05e5888ae5@google.com/Reviewed-by: NSteven Price <steven.price@arm.com>
      Link: https://lore.kernel.org/r/20221006163354.3194102-1-catalin.marinas@arm.comSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      a8e5e514
    • H
      LoongArch: Update Loongson-3 default config file · 2c8577f5
      Huacai Chen 提交于
      1, Enable ZBOOT, KEXEC and BPF_JIT;
      2, Add more patition types;
      3, Add some USB Type-C options;
      4, Add some common network options;
      5, Add some Bluetooth device drivers;
      6, Remove obsolete config options (for some detailed information, see
         Link).
      
      Link: https://lore.kernel.org/kernel-janitors/20220929090645.1389-1-lukas.bulwahn@gmail.com/Co-developed-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Co-developed-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Co-developed-by: NLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: NLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      2c8577f5
    • T
      LoongArch: Add BPF JIT support · 5dc61552
      Tiezhu Yang 提交于
      BPF programs are normally handled by a BPF interpreter, add BPF JIT
      support for LoongArch to allow the kernel to generate native code when
      a program is loaded into the kernel. This will significantly speed-up
      processing of BPF programs.
      Co-developed-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      5dc61552
    • T
      LoongArch: Add some instruction opcodes and formats · 4e59e5a4
      Tiezhu Yang 提交于
      According to the "Table of Instruction Encoding" in LoongArch Reference
      Manual [1], add some instruction opcodes and formats which are used in
      the BPF JIT for LoongArch.
      
      [1] https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#table-of-instruction-encodingSigned-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      4e59e5a4
    • T
      LoongArch: Move {signed,unsigned}_imm_check() to inst.h · 8a34228e
      Tiezhu Yang 提交于
      {signed,unsigned}_imm_check() will also be used in the bpf jit, so move
      them from module.c to inst.h, this is preparation for later patches.
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      8a34228e
    • Y
      LoongArch: Add kdump support · 4e62d1d8
      Youling Tang 提交于
      This patch adds support for kdump. In kdump case the normal kernel will
      reserve a region for the crash kernel and jump there on panic.
      
      Arch-specific functions are added to allow for implementing a crash dump
      file interface, /proc/vmcore, which can be viewed as a ELF file.
      
      A user-space tool, such as kexec-tools, is responsible for allocating a
      separate region for the core's ELF header within the crash kdump kernel
      memory and filling it in when executing kexec_load().
      
      Then, its location will be advertised to the crash dump kernel via a
      command line argument "elfcorehdr=", and the crash dump kernel will
      preserve this region for later use with arch_reserve_vmcore() at boot
      time.
      
      At the same time, the crash kdump kernel is also limited within the
      "crashkernel" area via a command line argument "mem=", so as not to
      destroy the original kernel dump data.
      
      In the crash dump kernel environment, /proc/vmcore is used to access the
      primary kernel's memory with copy_oldmem_page().
      
      I tested kdump on LoongArch machines (Loongson-3A5000) and it works as
      expected (suggested crashkernel parameter is "crashkernel=512M@2560M"),
      you may test it by triggering a crash through /proc/sysrq-trigger:
      
       $ sudo kexec -p /boot/vmlinux-kdump --reuse-cmdline --append="nr_cpus=1"
       # echo c > /proc/sysrq-trigger
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      4e62d1d8
    • Y
      LoongArch: Add kexec support · 4a03b2ac
      Youling Tang 提交于
      Add three new files, kexec.h, machine_kexec.c and relocate_kernel.S to
      the LoongArch architecture, so as to add support for the kexec re-boot
      mechanism (CONFIG_KEXEC) on LoongArch platforms.
      
      Kexec supports loading vmlinux.elf in ELF format and vmlinux.efi in PE
      format.
      
      I tested kexec on LoongArch machines (Loongson-3A5000) and it works as
      expected:
      
       $ sudo kexec -l /boot/vmlinux.efi --reuse-cmdline
       $ sudo kexec -e
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      4a03b2ac
    • Y
      LoongArch: Use generic BUG() handler · 2d2c3952
      Youling Tang 提交于
      Inspired by commit 9fb7410f("arm64/BUG: Use BRK instruction for
      generic BUG traps"), do similar for LoongArch to use generic BUG()
      handler.
      
      This patch uses the BREAK software breakpoint instruction to generate
      a trap instead, similarly to most other arches, with the generic BUG
      code generating the dmesg boilerplate.
      
      This allows bug metadata to be moved to a separate table and reduces
      the amount of inline code at BUG() and WARN() sites. This also avoids
      clobbering any registers before they can be dumped.
      
      To mitigate the size of the bug table further, this patch makes use of
      the existing infrastructure for encoding addresses within the bug table
      as 32-bit relative pointers instead of absolute pointers.
      
      (Note: this limits the max kernel size to 2GB.)
      
      Before patch:
      [ 3018.338013] lkdtm: Performing direct entry BUG
      [ 3018.342445] Kernel bug detected[#5]:
      [ 3018.345992] CPU: 2 PID: 865 Comm: cat Tainted: G D 6.0.0-rc6+ #35
      
      After patch:
      [  125.585985] lkdtm: Performing direct entry BUG
      [  125.590433] ------------[ cut here ]------------
      [  125.595020] kernel BUG at drivers/misc/lkdtm/bugs.c:78!
      [  125.600211] Oops - BUG[#1]:
      [  125.602980] CPU: 3 PID: 410 Comm: cat Not tainted 6.0.0-rc6+ #36
      
      Out-of-line file/line data information obtained compared to before.
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      2d2c3952
    • H
      LoongArch: Add SysRq-x (TLB Dump) support · dea2df3c
      Huacai Chen 提交于
      Add SysRq-x (TLB Dump) support for LoongArch, which is useful for
      debugging.
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      dea2df3c
    • H
      LoongArch: Add perf events support · b37042b2
      Huacai Chen 提交于
      The perf events infrastructure of LoongArch is very similar to old MIPS-
      based Loongson, so most of the codes are derived from MIPS.
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      b37042b2
    • H
      LoongArch: Add qspinlock support · 5f1e001b
      Huacai Chen 提交于
      On NUMA system, the performance of qspinlock is better than generic
      spinlock. Below is the UnixBench test results on a 8 nodes (4 cores
      per node, 32 cores in total) machine.
      
      A. With generic spinlock:
      
      System Benchmarks Index Values               BASELINE       RESULT    INDEX
      Dhrystone 2 using register variables         116700.0  449574022.5  38523.9
      Double-Precision Whetstone                       55.0      85190.4  15489.2
      Execl Throughput                                 43.0      14696.2   3417.7
      File Copy 1024 bufsize 2000 maxblocks          3960.0     143157.8    361.5
      File Copy 256 bufsize 500 maxblocks            1655.0      37631.8    227.4
      File Copy 4096 bufsize 8000 maxblocks          5800.0     444814.2    766.9
      Pipe Throughput                               12440.0    5047490.7   4057.5
      Pipe-based Context Switching                   4000.0    2021545.7   5053.9
      Process Creation                                126.0      23829.8   1891.3
      Shell Scripts (1 concurrent)                     42.4      33756.7   7961.5
      Shell Scripts (8 concurrent)                      6.0       4062.9   6771.5
      System Call Overhead                          15000.0    2479748.6   1653.2
                                                                         ========
      System Benchmarks Index Score                                        2955.6
      
      B. With qspinlock:
      
      System Benchmarks Index Values               BASELINE       RESULT    INDEX
      Dhrystone 2 using register variables         116700.0  449467876.9  38514.8
      Double-Precision Whetstone                       55.0      85174.6  15486.3
      Execl Throughput                                 43.0      14769.1   3434.7
      File Copy 1024 bufsize 2000 maxblocks          3960.0     146150.5    369.1
      File Copy 256 bufsize 500 maxblocks            1655.0      37496.8    226.6
      File Copy 4096 bufsize 8000 maxblocks          5800.0     447527.0    771.6
      Pipe Throughput                               12440.0    5175989.2   4160.8
      Pipe-based Context Switching                   4000.0    2207747.8   5519.4
      Process Creation                                126.0      25125.5   1994.1
      Shell Scripts (1 concurrent)                     42.4      33461.2   7891.8
      Shell Scripts (8 concurrent)                      6.0       4024.7   6707.8
      System Call Overhead                          15000.0    2917278.6   1944.9
                                                                         ========
      System Benchmarks Index Score                                        3040.1
      Signed-off-by: NRui Wang <wangrui@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      5f1e001b
    • H
      LoongArch: Use TLB for ioremap() · d2791341
      Huacai Chen 提交于
      We can support more cache attributes (e.g., CC, SUC and WUC) and page
      protection when we use TLB for ioremap(). The implementation is based
      on GENERIC_IOREMAP.
      
      The existing simple ioremap() implementation has better performance so
      we keep it and introduce ARCH_IOREMAP to control the selection.
      
      We move pagetable_init() earlier to make early ioremap() works, and we
      modify the PCI ecam mapping because the TLB-based version of ioremap()
      will actually take the size into account.
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      d2791341
    • H
      LoongArch: Support access filter to /dev/mem interface · 235d074f
      Huacai Chen 提交于
      Accidental access to /dev/mem is obviously disastrous, but specific
      access can be used by people debugging the kernel. So select GENERIC_
      LIB_DEVMEM_IS_ALLOWED, as well as define ARCH_HAS_VALID_PHYS_ADDR_RANGE
      and related helpers, to support access filter to /dev/mem interface.
      Signed-off-by: NWeihao Li <liweihao@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      235d074f
    • H
      LoongArch: Refactor cache probe and flush methods · b61a40af
      Huacai Chen 提交于
      Current cache probe and flush methods have some drawbacks:
      1, Assume there are 3 cache levels and only 3 levels;
      2, Assume L1 = I + D, L2 = V, L3 = S, V is exclusive, S is inclusive.
      
      However, the fact is I + D, I + D + V, I + D + S and I + D + V + S are
      all valid. So, refactor the cache probe and flush methods to adapt more
      types of cache hierarchy.
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      b61a40af
    • R
      LoongArch: mm: Refactor TLB exception handlers · a2a84e36
      Rui Wang 提交于
      This patch simplifies TLB load, store and modify exception handlers:
      
      1. Reduce instructions, such as alu/csr and memory access;
      2. Execute tlb search instruction only in the fast path;
      3. Return directly from the fast path for both normal and huge pages;
      4. Re-tab the assembly for better vertical alignment.
      
      And fixes the concurrent modification issue of fast path for huge pages.
      
      This issue will occur in the following steps:
      
         CPU-1 (In TLB exception)         CPU-2 (In THP splitting)
      1: Load PMD entry (HUGE=1)
      2: Goto huge path
      3:                                  Store PMD entry (HUGE=0)
      4: Reload PMD entry (HUGE=0)
      5: Fill TLB entry (PA is incorrect)
      
      This patch also slightly improves the TLB processing performance:
      
      * Normal pages: 2.15%, Huge pages: 1.70%.
      
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
        #include <sys/mman.h>
      
        int main(int argc, char *argv[])
        {
              size_t page_size;
              size_t mem_size;
              size_t off;
              void *base;
              int flags;
              int i;
      
              if (argc < 2) {
                      fprintf(stderr, "%s MEM_SIZE [HUGE]\n", argv[0]);
                      return -1;
              }
      
              page_size = sysconf(_SC_PAGESIZE);
              flags = MAP_PRIVATE | MAP_ANONYMOUS;
              mem_size = strtoul(argv[1], NULL, 10);
              if (argc > 2)
                      flags |= MAP_HUGETLB;
      
              for (i = 0; i < 10; i++) {
                      base = mmap(NULL, mem_size, PROT_READ, flags, -1, 0);
                      if (base == MAP_FAILED) {
                              fprintf(stderr, "Map memory failed!\n");
                              return -1;
                      }
      
                      for (off = 0; off < mem_size; off += page_size)
                              *(volatile int *)(base + off);
      
                      munmap(base, mem_size);
              }
      
              return 0;
        }
      Signed-off-by: NRui Wang <wangrui@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      a2a84e36
    • X
      LoongArch: Support R_LARCH_GOT_PC_{LO12,HI20} in modules · 59b3d4a9
      Xi Ruoyao 提交于
      GCC >= 13 and GNU assembler >= 2.40 use these relocations to address
      external symbols, so we need to add them.
      
      Let the module loader emit GOT entries for data symbols so we would be
      able to handle GOT relocations. The GOT entry is just the data's symbol
      address.
      
      In module.lds, emit a stub .got section for a section header entry. The
      actual content of the section entry will be filled at runtime by module_
      frob_arch_sections().
      Tested-by: NWANG Xuerui <git@xen0n.name>
      Signed-off-by: NXi Ruoyao <xry111@xry111.site>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      59b3d4a9
    • X
      LoongArch: Support PC-relative relocations in modules · 9bd1e380
      Xi Ruoyao 提交于
      Binutils >= 2.40 uses R_LARCH_B26 instead of R_LARCH_SOP_PUSH_PLT_PCREL,
      and R_LARCH_PCALA* instead of R_LARCH_SOP_PUSH_PCREL.
      
      Handle R_LARCH_B26 and R_LARCH_PCALA* in the module loader. For R_LARCH_
      B26, also create a PLT entry as needed.
      Tested-by: NWANG Xuerui <git@xen0n.name>
      Signed-off-by: NXi Ruoyao <xry111@xry111.site>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      9bd1e380