1. 01 Dec, 2022 1 commit
  2. 30 Nov, 2022 6 commits
    • Palmer Dabbelt's avatar
      Merge patch series "riscv: kexec: Fxiup crash_save percpu and machine_kexec_mask_interrupts" · d556a9ae
      Palmer Dabbelt authored
      guoren@kernel.org <guoren@kernel.org> says:
      
      From: Guo Ren <guoren@linux.alibaba.com>
      
      Current riscv kexec can't crash_save percpu states and disable
      interrupts properly. The patch series fix them, make kexec work correct.
      
      * b4-shazam-merge:
        riscv: kexec: Fixup crash_smp_send_stop without multi cores
        riscv: kexec: Fixup irq controller broken in kexec crash path
      
      Link: https://lore.kernel.org/r/20221020141603.2856206-1-guoren@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      d556a9ae
    • Guo Ren's avatar
      riscv: kexec: Fixup crash_smp_send_stop without multi cores · 9b932aad
      Guo Ren authored
      Current crash_smp_send_stop is the same as the generic one in
      kernel/panic and misses crash_save_cpu in percpu. This patch is inspired
      by 78fd584c ("arm64: kdump: implement machine_crash_shutdown()")
      and adds the same mechanism for riscv.
      
      Before this patch, test result:
      crash> help -r
      CPU 0: [OFFLINE]
      
      CPU 1:
      epc : ffffffff80009ff0 ra : ffffffff800b789a sp : ff2000001098bb40
       gp : ffffffff815fca60 tp : ff60000004680000 t0 : 6666666666663c5b
       t1 : 0000000000000000 t2 : 666666666666663c s0 : ff2000001098bc90
       s1 : ffffffff81600798 a0 : ff2000001098bb48 a1 : 0000000000000000
       a2 : 0000000000000000 a3 : 0000000000000001 a4 : 0000000000000000
       a5 : ff60000004690800 a6 : 0000000000000000 a7 : 0000000000000000
       s2 : ff2000001098bb48 s3 : ffffffff81093ec8 s4 : ffffffff816004ac
       s5 : 0000000000000000 s6 : 0000000000000007 s7 : ffffffff80e7f720
       s8 : 00fffffffffff3f0 s9 : 0000000000000007 s10: 00aaaaaaaab98700
       s11: 0000000000000001 t3 : ffffffff819a8097 t4 : ffffffff819a8097
       t5 : ffffffff819a8098 t6 : ff2000001098b9a8
      
      CPU 2: [OFFLINE]
      
      CPU 3: [OFFLINE]
      
      After this patch, test result:
      crash> help -r
      CPU 0:
      epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ffffffff81403eb0
       gp : ffffffff815fcb48 tp : ffffffff81413400 t0 : 0000000000000000
       t1 : 0000000000000000 t2 : 0000000000000000 s0 : ffffffff81403ec0
       s1 : 0000000000000000 a0 : 0000000000000000 a1 : 0000000000000000
       a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000
       a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000
       s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18
       s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000
       s8 : 0000000000000000 s9 : 0000000080039eac s10: 0000000000000000
       s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000
       t5 : 0000000000000000 t6 : 0000000000000000
      
      CPU 1:
      epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ff2000000068bf30
       gp : ffffffff815fcb48 tp : ff6000000240d400 t0 : 0000000000000000
       t1 : 0000000000000000 t2 : 0000000000000000 s0 : ff2000000068bf40
       s1 : 0000000000000001 a0 : 0000000000000000 a1 : 0000000000000000
       a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000
       a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000
       s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18
       s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000
       s8 : 0000000000000000 s9 : 0000000080039ea8 s10: 0000000000000000
       s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000
       t5 : 0000000000000000 t6 : 0000000000000000
      
      CPU 2:
      epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ff20000000693f30
       gp : ffffffff815fcb48 tp : ff6000000240e900 t0 : 0000000000000000
       t1 : 0000000000000000 t2 : 0000000000000000 s0 : ff20000000693f40
       s1 : 0000000000000002 a0 : 0000000000000000 a1 : 0000000000000000
       a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000
       a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000
       s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18
       s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000
       s8 : 0000000000000000 s9 : 0000000080039eb0 s10: 0000000000000000
       s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000
       t5 : 0000000000000000 t6 : 0000000000000000
      
      CPU 3:
      epc : ffffffff8000a1e4 ra : ffffffff800b7bba sp : ff200000109bbb40
       gp : ffffffff815fcb48 tp : ff6000000373aa00 t0 : 6666666666663c5b
       t1 : 0000000000000000 t2 : 666666666666663c s0 : ff200000109bbc90
       s1 : ffffffff816007a0 a0 : ff200000109bbb48 a1 : 0000000000000000
       a2 : 0000000000000000 a3 : 0000000000000001 a4 : 0000000000000000
       a5 : ff60000002c61c00 a6 : 0000000000000000 a7 : 0000000000000000
       s2 : ff200000109bbb48 s3 : ffffffff810941a8 s4 : ffffffff816004b4
       s5 : 0000000000000000 s6 : 0000000000000007 s7 : ffffffff80e7f7a0
       s8 : 00fffffffffff3f0 s9 : 0000000000000007 s10: 00aaaaaaaab98700
       s11: 0000000000000001 t3 : ffffffff819a8097 t4 : ffffffff819a8097
       t5 : ffffffff819a8098 t6 : ff200000109bb9a8
      
      Fixes: ad943893 ("RISC-V: Fixup schedule out issue in machine_crash_shutdown()")
      Reviewed-by: default avatarXianting Tian <xianting.tian@linux.alibaba.com>
      Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
      Signed-off-by: default avatarGuo Ren <guoren@kernel.org>
      Cc: Nick Kossifidis <mick@ics.forth.gr>
      Link: https://lore.kernel.org/r/20221020141603.2856206-3-guoren@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      9b932aad
    • Guo Ren's avatar
      riscv: kexec: Fixup irq controller broken in kexec crash path · b17d19a5
      Guo Ren authored
      If a crash happens on cpu3 and all interrupts are binding on cpu0, the
      bad irq routing will cause a crash kernel which can't receive any irq.
      Because crash kernel won't clean up all harts' PLIC enable bits in
      enable registers. This patch is similar to 9141a003 ("ARM: 7316/1:
      kexec: EOI active and mask all interrupts in kexec crash path") and
      78fd584c ("arm64: kdump: implement machine_crash_shutdown()"), and
      PowerPC also has the same mechanism.
      
      Fixes: fba8a867 ("RISC-V: Add kexec support")
      Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
      Signed-off-by: default avatarGuo Ren <guoren@kernel.org>
      Reviewed-by: default avatarXianting Tian <xianting.tian@linux.alibaba.com>
      Cc: Nick Kossifidis <mick@ics.forth.gr>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Link: https://lore.kernel.org/r/20221020141603.2856206-2-guoren@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      b17d19a5
    • Björn Töpel's avatar
      riscv: mm: Proper page permissions after initmem free · 6fdd5d2f
      Björn Töpel authored
      64-bit RISC-V kernels have the kernel image mapped separately to alias
      the linear map. The linear map and the kernel image map are documented
      as "direct mapping" and "kernel" respectively in [1].
      
      At image load time, the linear map corresponding to the kernel image
      is set to PAGE_READ permission, and the kernel image map is set to
      PAGE_READ|PAGE_EXEC.
      
      When the initmem is freed, the pages in the linear map should be
      restored to PAGE_READ|PAGE_WRITE, whereas the corresponding pages in
      the kernel image map should be restored to PAGE_READ, by removing the
      PAGE_EXEC permission.
      
      This is not the case. For 64-bit kernels, only the linear map is
      restored to its proper page permissions at initmem free, and not the
      kernel image map.
      
      In practise this results in that the kernel can potentially jump to
      dead __init code, and start executing invalid instructions, without
      getting an exception.
      
      Restore the freed initmem properly, by setting both the kernel image
      map to the correct permissions.
      
      [1] Documentation/riscv/vm-layout.rst
      
      Fixes: e5c35fa0 ("riscv: Map the kernel with correct permissions the first time")
      Signed-off-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
      Reviewed-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Link: https://lore.kernel.org/r/20221115090641.258476-1-bjorn@kernel.org
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      6fdd5d2f
    • Jisheng Zhang's avatar
      riscv: vdso: fix section overlapping under some conditions · 74f6bb55
      Jisheng Zhang authored
      lkp reported a build error, I tried the config and can reproduce
      build error as below:
      
        VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
      ld.lld: error: section .note file range overlaps with .text
      >>> .note range is [0x7C8, 0x803]
      >>> .text range is [0x800, 0x1993]
      
      ld.lld: error: section .text file range overlaps with .dynamic
      >>> .text range is [0x800, 0x1993]
      >>> .dynamic range is [0x808, 0x937]
      
      ld.lld: error: section .note virtual address range overlaps with .text
      >>> .note range is [0x7C8, 0x803]
      >>> .text range is [0x800, 0x1993]
      
      Fix it by setting DISABLE_BRANCH_PROFILING which will disable branch
      tracing for vdso, thus avoid useless _ftrace_annotated_branch section
      and _ftrace_branch section. Although we can also fix it by removing
      the hardcoded .text begin address, but I think that's another story
      and should be put into another patch.
      
      Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#rReported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Link: https://lore.kernel.org/r/20221102170254.1925-1-jszhang@kernel.org
      Fixes: ad5d1122 ("riscv: use vDSO common flow to reduce the latency of the time-related functions")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      74f6bb55
    • Jisheng Zhang's avatar
      riscv: fix race when vmap stack overflow · 7e186433
      Jisheng Zhang authored
      Currently, when detecting vmap stack overflow, riscv firstly switches
      to the so called shadow stack, then use this shadow stack to call the
      get_overflow_stack() to get the overflow stack. However, there's
      a race here if two or more harts use the same shadow stack at the same
      time.
      
      To solve this race, we introduce spin_shadow_stack atomic var, which
      will be swap between its own address and 0 in atomic way, when the
      var is set, it means the shadow_stack is being used; when the var
      is cleared, it means the shadow_stack isn't being used.
      
      Fixes: 31da94c2 ("riscv: add VMAP_STACK overflow detection")
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Suggested-by: default avatarGuo Ren <guoren@kernel.org>
      Reviewed-by: default avatarGuo Ren <guoren@kernel.org>
      Link: https://lore.kernel.org/r/20221030124517.2370-1-jszhang@kernel.org
      [Palmer: Add AQ to the swap, and also some comments.]
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      7e186433
  3. 29 Nov, 2022 1 commit
  4. 28 Nov, 2022 1 commit
  5. 10 Nov, 2022 4 commits
    • Nathan Chancellor's avatar
      RISC-V: vdso: Do not add missing symbols to version section in linker script · fcae44fd
      Nathan Chancellor authored
      Recently, ld.lld moved from '--undefined-version' to
      '--no-undefined-version' as the default, which breaks the compat vDSO
      build:
      
        ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_gettimeofday' failed: symbol not defined
        ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_clock_gettime' failed: symbol not defined
        ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_clock_getres' failed: symbol not defined
      
      These symbols are not present in the compat vDSO or the regular vDSO for
      32-bit but they are unconditionally included in the version section of
      the linker script, which is prohibited with '--no-undefined-version'.
      
      Fix this issue by only including the symbols that are actually exported
      in the version section of the linker script.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1756Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20221108171324.3377226-1-nathan@kernel.org/Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      fcae44fd
    • Conor Dooley's avatar
      riscv: fix reserved memory setup · 50e63dd8
      Conor Dooley authored
      Currently, RISC-V sets up reserved memory using the "early" copy of the
      device tree. As a result, when trying to get a reserved memory region
      using of_reserved_mem_lookup(), the pointer to reserved memory regions
      is using the early, pre-virtual-memory address which causes a kernel
      panic when trying to use the buffer's name:
      
       Unable to handle kernel paging request at virtual address 00000000401c31ac
       Oops [#1]
       Modules linked in:
       CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc1-00001-g0d9d6953d834 #1
       Hardware name: Microchip PolarFire-SoC Icicle Kit (DT)
       epc : string+0x4a/0xea
        ra : vsnprintf+0x1e4/0x336
       epc : ffffffff80335ea0 ra : ffffffff80338936 sp : ffffffff81203be0
        gp : ffffffff812e0a98 tp : ffffffff8120de40 t0 : 0000000000000000
        t1 : ffffffff81203e28 t2 : 7265736572203a46 s0 : ffffffff81203c20
        s1 : ffffffff81203e28 a0 : ffffffff81203d22 a1 : 0000000000000000
        a2 : ffffffff81203d08 a3 : 0000000081203d21 a4 : ffffffffffffffff
        a5 : 00000000401c31ac a6 : ffff0a00ffffff04 a7 : ffffffffffffffff
        s2 : ffffffff81203d08 s3 : ffffffff81203d00 s4 : 0000000000000008
        s5 : ffffffff000000ff s6 : 0000000000ffffff s7 : 00000000ffffff00
        s8 : ffffffff80d9821a s9 : ffffffff81203d22 s10: 0000000000000002
        s11: ffffffff80d9821c t3 : ffffffff812f3617 t4 : ffffffff812f3617
        t5 : ffffffff812f3618 t6 : ffffffff81203d08
       status: 0000000200000100 badaddr: 00000000401c31ac cause: 000000000000000d
       [<ffffffff80338936>] vsnprintf+0x1e4/0x336
       [<ffffffff80055ae2>] vprintk_store+0xf6/0x344
       [<ffffffff80055d86>] vprintk_emit+0x56/0x192
       [<ffffffff80055ed8>] vprintk_default+0x16/0x1e
       [<ffffffff800563d2>] vprintk+0x72/0x80
       [<ffffffff806813b2>] _printk+0x36/0x50
       [<ffffffff8068af48>] print_reserved_mem+0x1c/0x24
       [<ffffffff808057ec>] paging_init+0x528/0x5bc
       [<ffffffff808031ae>] setup_arch+0xd0/0x592
       [<ffffffff8080070e>] start_kernel+0x82/0x73c
      
      early_init_fdt_scan_reserved_mem() takes no arguments as it operates on
      initial_boot_params, which is populated by early_init_dt_verify(). On
      RISC-V, early_init_dt_verify() is called twice. Once, directly, in
      setup_arch() if CONFIG_BUILTIN_DTB is not enabled and once indirectly,
      very early in the boot process, by parse_dtb() when it calls
      early_init_dt_scan_nodes().
      
      This first call uses dtb_early_va to set initial_boot_params, which is
      not usable later in the boot process when
      early_init_fdt_scan_reserved_mem() is called. On arm64 for example, the
      corresponding call to early_init_dt_scan_nodes() uses fixmap addresses
      and doesn't suffer the same fate.
      
      Move early_init_fdt_scan_reserved_mem() further along the boot sequence,
      after the direct call to early_init_dt_verify() in setup_arch() so that
      the names use the correct virtual memory addresses. The above supposed
      that CONFIG_BUILTIN_DTB was not set, but should work equally in the case
      where it is - unflatted_and_copy_device_tree() also updates
      initial_boot_params.
      Reported-by: default avatarValentina Fernandez <valentina.fernandezalanis@microchip.com>
      Reported-by: default avatarEvgenii Shatokhin <e.shatokhin@yadro.com>
      Link: https://lore.kernel.org/linux-riscv/f8e67f82-103d-156c-deb0-d6d6e2756f5e@microchip.com/
      Fixes: 922b0375 ("riscv: Fix memblock reservation for device tree blob")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Tested-by: default avatarEvgenii Shatokhin <e.shatokhin@yadro.com>
      Link: https://lore.kernel.org/r/20221107151524.3941467-1-conor.dooley@microchip.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      50e63dd8
    • Jisheng Zhang's avatar
      riscv: vdso: fix build with llvm · 50f4dd65
      Jisheng Zhang authored
      Even after commit 89fd4a1d ("riscv: jump_label: mark arguments as
      const to satisfy asm constraints"), building with CC_OPTIMIZE_FOR_SIZE
      + LLVM=1 can reproduce below build error:
      
        CC      arch/riscv/kernel/vdso/vgettimeofday.o
      In file included from <built-in>:4:
      In file included from lib/vdso/gettimeofday.c:5:
      In file included from include/vdso/datapage.h:17:
      In file included from include/vdso/processor.h:10:
      In file included from arch/riscv/include/asm/vdso/processor.h:7:
      In file included from include/linux/jump_label.h:112:
      arch/riscv/include/asm/jump_label.h:42:3: error:
      invalid operand for inline asm constraint 'i'
                      "       .option push                            \n\t"
                      ^
      1 error generated.
      
      I think the problem is when "-Os" is passed as CFLAGS, it's removed by
      "CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os" which is
      introduced in commit e05d57dc ("riscv: Fixup __vdso_gettimeofday
      broke dynamic ftrace"), thus no optimization at all for vgettimeofday.c
      arm64 does remove "-Os" as well, but it forces "-O2" after removing
      "-Os".
      
      I compared the generated vgettimeofday.o with "-O2" and "-Os",
      I think no big performance difference. So let's tell the kbuild not
      to remove "-Os" rather than follow arm64 style.
      
      vdso related performance can be improved a lot when building kernel with
      CC_OPTIMIZE_FOR_SIZE after this commit, ("-Os" VS no optimization)
      
      Fixes: e05d57dc ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace")
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20221031182943.2453-1-jszhang@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      50f4dd65
    • Jisheng Zhang's avatar
      riscv: process: fix kernel info leakage · 6510c784
      Jisheng Zhang authored
      thread_struct's s[12] may contain random kernel memory content, which
      may be finally leaked to userspace. This is a security hole. Fix it
      by clearing the s[12] array in thread_struct when fork.
      
      As for kthread case, it's better to clear the s[12] array as well.
      
      Fixes: 7db91e57 ("RISC-V: Task implementation")
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Tested-by: default avatarGuo Ren <guoren@kernel.org>
      Link: https://lore.kernel.org/r/20221029113450.4027-1-jszhang@kernel.orgReviewed-by: default avatarGuo Ren <guoren@kernel.org>
      Link: https://lore.kernel.org/r/CAJF2gTSdVyAaM12T%2B7kXAdRPGS4VyuO08X1c7paE-n4Fr8OtRA@mail.gmail.com/Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      6510c784
  6. 28 Oct, 2022 1 commit
  7. 27 Oct, 2022 5 commits
  8. 26 Oct, 2022 2 commits
  9. 16 Oct, 2022 10 commits
    • Linus Torvalds's avatar
      Linux 6.1-rc1 · 9abf2313
      Linus Torvalds authored
      9abf2313
    • Linus Torvalds's avatar
      Merge tag 'random-6.1-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random · f1947d7c
      Linus Torvalds authored
      Pull more random number generator updates from Jason Donenfeld:
       "This time with some large scale treewide cleanups.
      
        The intent of this pull is to clean up the way callers fetch random
        integers. The current rules for doing this right are:
      
         - If you want a secure or an insecure random u64, use get_random_u64()
      
         - If you want a secure or an insecure random u32, use get_random_u32()
      
           The old function prandom_u32() has been deprecated for a while
           now and is just a wrapper around get_random_u32(). Same for
           get_random_int().
      
         - If you want a secure or an insecure random u16, use get_random_u16()
      
         - If you want a secure or an insecure random u8, use get_random_u8()
      
         - If you want secure or insecure random bytes, use get_random_bytes().
      
           The old function prandom_bytes() has been deprecated for a while
           now and has long been a wrapper around get_random_bytes()
      
         - If you want a non-uniform random u32, u16, or u8 bounded by a
           certain open interval maximum, use prandom_u32_max()
      
           I say "non-uniform", because it doesn't do any rejection sampling
           or divisions. Hence, it stays within the prandom_*() namespace, not
           the get_random_*() namespace.
      
           I'm currently investigating a "uniform" function for 6.2. We'll see
           what comes of that.
      
        By applying these rules uniformly, we get several benefits:
      
         - By using prandom_u32_max() with an upper-bound that the compiler
           can prove at compile-time is ≤65536 or ≤256, internally
           get_random_u16() or get_random_u8() is used, which wastes fewer
           batched random bytes, and hence has higher throughput.
      
         - By using prandom_u32_max() instead of %, when the upper-bound is
           not a constant, division is still avoided, because
           prandom_u32_max() uses a faster multiplication-based trick instead.
      
         - By using get_random_u16() or get_random_u8() in cases where the
           return value is intended to indeed be a u16 or a u8, we waste fewer
           batched random bytes, and hence have higher throughput.
      
        This series was originally done by hand while I was on an airplane
        without Internet. Later, Kees and I worked on retroactively figuring
        out what could be done with Coccinelle and what had to be done
        manually, and then we split things up based on that.
      
        So while this touches a lot of files, the actual amount of code that's
        hand fiddled is comfortably small"
      
      * tag 'random-6.1-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
        prandom: remove unused functions
        treewide: use get_random_bytes() when possible
        treewide: use get_random_u32() when possible
        treewide: use get_random_{u8,u16}() when possible, part 2
        treewide: use get_random_{u8,u16}() when possible, part 1
        treewide: use prandom_u32_max() when possible, part 2
        treewide: use prandom_u32_max() when possible, part 1
      f1947d7c
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-for-v6.1-2-2022-10-16' of... · 8636df94
      Linus Torvalds authored
      Merge tag 'perf-tools-for-v6.1-2-2022-10-16' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull more perf tools updates from Arnaldo Carvalho de Melo:
      
       - Use BPF CO-RE (Compile Once, Run Everywhere) to support old kernels
         when using bperf (perf BPF based counters) with cgroups.
      
       - Support HiSilicon PCIe Performance Monitoring Unit (PMU), that
         monitors bandwidth, latency, bus utilization and buffer occupancy.
      
         Documented in Documentation/admin-guide/perf/hisi-pcie-pmu.rst.
      
       - User space tasks can migrate between CPUs, so when tracing selected
         CPUs, system-wide sideband is still needed, fix it in the setup of
         Intel PT on hybrid systems.
      
       - Fix metricgroups title message in 'perf list', it should state that
         the metrics groups are to be used with the '-M' option, not '-e'.
      
       - Sync the msr-index.h copy with the kernel sources, adding support for
         using "AMD64_TSC_RATIO" in filter expressions in 'perf trace' as well
         as decoding it when printing the MSR tracepoint arguments.
      
       - Fix program header size and alignment when generating a JIT ELF in
         'perf inject'.
      
       - Add multiple new Intel PT 'perf test' entries, including a jitdump
         one.
      
       - Fix the 'perf test' entries for 'perf stat' CSV and JSON output when
         running on PowerPC due to an invalid topology number in that arch.
      
       - Fix the 'perf test' for arm_coresight failures on the ARM Juno
         system.
      
       - Fix the 'perf test' attr entry for PERF_FORMAT_LOST, adding this
         option to the or expression expected in the intercepted
         perf_event_open() syscall.
      
       - Add missing condition flags ('hs', 'lo', 'vc', 'vs') for arm64 in the
         'perf annotate' asm parser.
      
       - Fix 'perf mem record -C' option processing, it was being chopped up
         when preparing the underlying 'perf record -e mem-events' and thus
         being ignored, requiring using '-- -C CPUs' as a workaround.
      
       - Improvements and tidy ups for 'perf test' shell infra.
      
       - Fix Intel PT information printing segfault in uClibc, where a NULL
         format was being passed to fprintf.
      
      * tag 'perf-tools-for-v6.1-2-2022-10-16' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (23 commits)
        tools arch x86: Sync the msr-index.h copy with the kernel sources
        perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet
        perf auxtrace arm64: Add support for HiSilicon PCIe Tune and Trace device driver
        perf auxtrace arm: Refactor event list iteration in auxtrace_record__init()
        perf tests stat+json_output: Include sanity check for topology
        perf tests stat+csv_output: Include sanity check for topology
        perf intel-pt: Fix system_wide dummy event for hybrid
        perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
        perf test: Fix attr tests for PERF_FORMAT_LOST
        perf test: test_intel_pt.sh: Add 9 tests
        perf inject: Fix GEN_ELF_TEXT_OFFSET for jit
        perf test: test_intel_pt.sh: Add jitdump test
        perf test: test_intel_pt.sh: Tidy some alignment
        perf test: test_intel_pt.sh: Print a message when skipping kernel tracing
        perf test: test_intel_pt.sh: Tidy some perf record options
        perf test: test_intel_pt.sh: Fix return checking again
        perf: Skip and warn on unknown format 'configN' attrs
        perf list: Fix metricgroups title message
        perf mem: Fix -C option behavior for perf mem record
        perf annotate: Add missing condition flags for arm64
        ...
      8636df94
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v6.1' of... · 2df76606
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Fix CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y compile error for the
         combination of Clang >= 14 and GAS <= 2.35.
      
       - Drop vmlinux.bz2 from the rpm package as it just annoyingly increased
         the package size.
      
       - Fix modpost error under build environments using musl.
      
       - Make *.ll files keep value names for easier debugging
      
       - Fix single directory build
      
       - Prevent RISC-V from selecting the broken DWARF5 support when Clang
         and GAS are used together.
      
      * tag 'kbuild-fixes-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
        kbuild: fix single directory build
        kbuild: add -fno-discard-value-names to cmd_cc_ll_c
        scripts/clang-tools: Convert clang-tidy args to list
        modpost: put modpost options before argument
        kbuild: Stop including vmlinux.bz2 in the rpm's
        Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
        Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
      2df76606
    • Linus Torvalds's avatar
      Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 2fcd8f10
      Linus Torvalds authored
      Pull more clk updates from Stephen Boyd:
       "This is the final part of the clk patches for this merge window.
      
        The clk rate range series needed another week to fully bake. Maxime
        fixed the bug that broke clk notifiers and prevented this from being
        included in the first pull request. He also added a unit test on top
        to make sure it doesn't break so easily again. The majority of the
        series fixes up how the clk_set_rate_*() APIs work, particularly
        around when the rate constraints are dropped and how they move around
        when reparenting clks. Overall it's a much needed improvement to the
        clk rate range APIs that used to be pretty broken if you looked
        sideways.
      
        Beyond the core changes there are a few driver fixes for a compilation
        issue or improper data causing clks to fail to register or have the
        wrong parents. These are good to get in before the first -rc so that
        the system actually boots on the affected devices"
      
      * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (31 commits)
        clk: tegra: Fix Tegra PWM parent clock
        clk: at91: fix the build with binutils 2.27
        clk: qcom: gcc-msm8660: Drop hardcoded fixed board clocks
        clk: mediatek: clk-mux: Add .determine_rate() callback
        clk: tests: Add tests for notifiers
        clk: Update req_rate on __clk_recalc_rates()
        clk: tests: Add missing test case for ranges
        clk: qcom: clk-rcg2: Take clock boundaries into consideration for gfx3d
        clk: Introduce the clk_hw_get_rate_range function
        clk: Zero the clk_rate_request structure
        clk: Stop forwarding clk_rate_requests to the parent
        clk: Constify clk_has_parent()
        clk: Introduce clk_core_has_parent()
        clk: Switch from __clk_determine_rate to clk_core_round_rate_nolock
        clk: Add our request boundaries in clk_core_init_rate_req
        clk: Introduce clk_hw_init_rate_request()
        clk: Move clk_core_init_rate_req() from clk_core_round_rate_nolock() to its caller
        clk: Change clk_core_init_rate_req prototype
        clk: Set req_rate on reparenting
        clk: Take into account uncached clocks in clk_set_rate_range()
        ...
      2fcd8f10
    • Linus Torvalds's avatar
      Merge tag '6.1-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6 · b08cd744
      Linus Torvalds authored
      Pull more cifs updates from Steve French:
      
       - fix a regression in guest mounts to old servers
      
       - improvements to directory leasing (caching directory entries safely
         beyond the root directory)
      
       - symlink improvement (reducing roundtrips needed to process symlinks)
      
       - an lseek fix (to problem where some dir entries could be skipped)
      
       - improved ioctl for returning more detailed information on directory
         change notifications
      
       - clarify multichannel interface query warning
      
       - cleanup fix (for better aligning buffers using ALIGN and round_up)
      
       - a compounding fix
      
       - fix some uninitialized variable bugs found by Coverity and the kernel
         test robot
      
      * tag '6.1-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6:
        smb3: improve SMB3 change notification support
        cifs: lease key is uninitialized in two additional functions when smb1
        cifs: lease key is uninitialized in smb1 paths
        smb3: must initialize two ACL struct fields to zero
        cifs: fix double-fault crash during ntlmssp
        cifs: fix static checker warning
        cifs: use ALIGN() and round_up() macros
        cifs: find and use the dentry for cached non-root directories also
        cifs: enable caching of directories for which a lease is held
        cifs: prevent copying past input buffer boundaries
        cifs: fix uninitialised var in smb2_compound_op()
        cifs: improve symlink handling for smb2+
        smb3: clarify multichannel warning
        cifs: fix regression in very old smb1 mounts
        cifs: fix skipping to incorrect offset in emit_cached_dirents
      b08cd744
    • Tetsuo Handa's avatar
      Revert "cpumask: fix checking valid cpu range". · 80493877
      Tetsuo Handa authored
      This reverts commit 78e5a339 ("cpumask: fix checking valid cpu range").
      
      syzbot is hitting WARN_ON_ONCE(cpu >= nr_cpumask_bits) warning at
      cpu_max_bits_warn() [1], for commit 78e5a339 ("cpumask: fix checking
      valid cpu range") is broken.  Obviously that patch hits WARN_ON_ONCE()
      when e.g.  reading /proc/cpuinfo because passing "cpu + 1" instead of
      "cpu" will trivially hit cpu == nr_cpumask_bits condition.
      
      Although syzbot found this problem in linux-next.git on 2022/09/27 [2],
      this problem was not fixed immediately.  As a result, that patch was
      sent to linux.git before the patch author recognizes this problem, and
      syzbot started failing to test changes in linux.git since 2022/10/10
      [3].
      
      Andrew Jones proposed a fix for x86 and riscv architectures [4].  But
      [2] and [5] indicate that affected locations are not limited to arch
      code.  More delay before we find and fix affected locations, less tested
      kernel (and more difficult to bisect and fix) before release.
      
      We should have inspected and fixed basically all cpumask users before
      applying that patch.  We should not crash kernels in order to ask
      existing cpumask users to update their code, even if limited to
      CONFIG_DEBUG_PER_CPU_MAPS=y case.
      
      Link: https://syzkaller.appspot.com/bug?extid=d0fd2bf0dd6da72496dd [1]
      Link: https://syzkaller.appspot.com/bug?extid=21da700f3c9f0bc40150 [2]
      Link: https://syzkaller.appspot.com/bug?extid=51a652e2d24d53e75734 [3]
      Link: https://lkml.kernel.org/r/20221014155845.1986223-1-ajones@ventanamicro.com [4]
      Link: https://syzkaller.appspot.com/bug?extid=4d46c43d81c3bd155060 [5]
      Reported-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Reported-by: syzbot+d0fd2bf0dd6da72496dd@syzkaller.appspotmail.com
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      80493877
    • Nathan Chancellor's avatar
      lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5 · 0a6de78c
      Nathan Chancellor authored
      When building with a RISC-V kernel with DWARF5 debug info using clang
      and the GNU assembler, several instances of the following error appear:
      
        /tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supported
      
      Dumping the .s file reveals these .uleb128 directives come from
      .debug_loc and .debug_ranges:
      
        .Ldebug_loc0:
                .byte   4                               # DW_LLE_offset_pair
                .uleb128 .Lfunc_begin0-.Lfunc_begin0    #   starting offset
                .uleb128 .Ltmp1-.Lfunc_begin0           #   ending offset
                .byte   1                               # Loc expr size
                .byte   90                              # DW_OP_reg10
                .byte   0                               # DW_LLE_end_of_list
      
        .Ldebug_ranges0:
                .byte   4                               # DW_RLE_offset_pair
                .uleb128 .Ltmp6-.Lfunc_begin0           #   starting offset
                .uleb128 .Ltmp27-.Lfunc_begin0          #   ending offset
                .byte   4                               # DW_RLE_offset_pair
                .uleb128 .Ltmp28-.Lfunc_begin0          #   starting offset
                .uleb128 .Ltmp30-.Lfunc_begin0          #   ending offset
                .byte   0                               # DW_RLE_end_of_list
      
      There is an outstanding binutils issue to support a non-constant operand
      to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to
      be any movement on it, due to concerns over how it would work with
      linker relaxation.
      
      To avoid these build errors, prevent DWARF5 from being selected when
      using clang and an assembler that does not have support for these symbol
      deltas, which can be easily checked in Kconfig with as-instr plus the
      small test program from the dwz test suite from the binutils issue.
      
      Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
      Link: https://github.com/ClangBuiltLinux/linux/issues/1719Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      0a6de78c
    • Masahiro Yamada's avatar
      kbuild: fix single directory build · 3753af77
      Masahiro Yamada authored
      Commit f110e5a2 ("kbuild: refactor single builds of *.ko") was wrong.
      
      KBUILD_MODULES _is_ needed for single builds.
      
      Otherwise, "make foo/bar/baz/" does not build module objects at all.
      
      Fixes: f110e5a2 ("kbuild: refactor single builds of *.ko")
      Reported-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: default avatarDavid Sterba <dsterba@suse.com>
      3753af77
    • Linus Torvalds's avatar
      Merge tag 'slab-for-6.1-rc1-hotfix' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab · 1501278b
      Linus Torvalds authored
      Pull slab hotfix from Vlastimil Babka:
       "A single fix for the common-kmalloc series, for warnings on mips and
        sparc64 reported by Guenter Roeck"
      
      * tag 'slab-for-6.1-rc1-hotfix' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
        mm/slab: use kmalloc_node() for off slab freelist_idx_t array allocation
      1501278b
  10. 15 Oct, 2022 9 commits