1. 01 Mar, 2024 1 commit
  2. 23 Feb, 2024 2 commits
    • Nathan Lynch's avatar
      powerpc/rtas: use correct function name for resetting TCE tables · fad87dbd
      Nathan Lynch authored
      The PAPR spec spells the function name as
      
        "ibm,reset-pe-dma-windows"
      
      but in practice firmware uses the singular form:
      
        "ibm,reset-pe-dma-window"
      
      in the device tree. Since we have the wrong spelling in the RTAS
      function table, reverse lookups (token -> name) fail and warn:
      
        unexpected failed lookup for token 86
        WARNING: CPU: 1 PID: 545 at arch/powerpc/kernel/rtas.c:659 __do_enter_rtas_trace+0x2a4/0x2b4
        CPU: 1 PID: 545 Comm: systemd-udevd Not tainted 6.8.0-rc4 #30
        Hardware name: IBM,9105-22A POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NL1060_028) hv:phyp pSeries
        NIP [c0000000000417f0] __do_enter_rtas_trace+0x2a4/0x2b4
        LR [c0000000000417ec] __do_enter_rtas_trace+0x2a0/0x2b4
        Call Trace:
         __do_enter_rtas_trace+0x2a0/0x2b4 (unreliable)
         rtas_call+0x1f8/0x3e0
         enable_ddw.constprop.0+0x4d0/0xc84
         dma_iommu_dma_supported+0xe8/0x24c
         dma_set_mask+0x5c/0xd8
         mlx5_pci_init.constprop.0+0xf0/0x46c [mlx5_core]
         probe_one+0xfc/0x32c [mlx5_core]
         local_pci_probe+0x68/0x12c
         pci_call_probe+0x68/0x1ec
         pci_device_probe+0xbc/0x1a8
         really_probe+0x104/0x570
         __driver_probe_device+0xb8/0x224
         driver_probe_device+0x54/0x130
         __driver_attach+0x158/0x2b0
         bus_for_each_dev+0xa8/0x120
         driver_attach+0x34/0x48
         bus_add_driver+0x174/0x304
         driver_register+0x8c/0x1c4
         __pci_register_driver+0x68/0x7c
         mlx5_init+0xb8/0x118 [mlx5_core]
         do_one_initcall+0x60/0x388
         do_init_module+0x7c/0x2a4
         init_module_from_file+0xb4/0x108
         idempotent_init_module+0x184/0x34c
         sys_finit_module+0x90/0x114
      
      And oopses are possible when lockdep is enabled or the RTAS
      tracepoints are active, since those paths dereference the result of
      the lookup.
      
      Use the correct spelling to match firmware's behavior, adjusting the
      related constants to match.
      Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Fixes: 8252b882 ("powerpc/rtas: improve function information lookups")
      Reported-by: default avatarGaurav Batra <gbatra@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240222-rtas-fix-ibm-reset-pe-dma-window-v1-1-7aaf235ac63c@linux.ibm.com
      fad87dbd
    • Gaurav Batra's avatar
      powerpc/pseries/iommu: IOMMU table is not initialized for kdump over SR-IOV · 09a3c1e4
      Gaurav Batra authored
      When kdump kernel tries to copy dump data over SR-IOV, LPAR panics due
      to NULL pointer exception:
      
        Kernel attempted to read user page (0) - exploit attempt? (uid: 0)
        BUG: Kernel NULL pointer dereference on read at 0x00000000
        Faulting instruction address: 0xc000000020847ad4
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in: mlx5_core(+) vmx_crypto pseries_wdt papr_scm libnvdimm mlxfw tls psample sunrpc fuse overlay squashfs loop
        CPU: 12 PID: 315 Comm: systemd-udevd Not tainted 6.4.0-Test102+ #12
        Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_008) hv:phyp pSeries
        NIP:  c000000020847ad4 LR: c00000002083b2dc CTR: 00000000006cd18c
        REGS: c000000029162ca0 TRAP: 0300   Not tainted  (6.4.0-Test102+)
        MSR:  800000000280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 48288244  XER: 00000008
        CFAR: c00000002083b2d8 DAR: 0000000000000000 DSISR: 40000000 IRQMASK: 1
        ...
        NIP _find_next_zero_bit+0x24/0x110
        LR  bitmap_find_next_zero_area_off+0x5c/0xe0
        Call Trace:
          dev_printk_emit+0x38/0x48 (unreliable)
          iommu_area_alloc+0xc4/0x180
          iommu_range_alloc+0x1e8/0x580
          iommu_alloc+0x60/0x130
          iommu_alloc_coherent+0x158/0x2b0
          dma_iommu_alloc_coherent+0x3c/0x50
          dma_alloc_attrs+0x170/0x1f0
          mlx5_cmd_init+0xc0/0x760 [mlx5_core]
          mlx5_function_setup+0xf0/0x510 [mlx5_core]
          mlx5_init_one+0x84/0x210 [mlx5_core]
          probe_one+0x118/0x2c0 [mlx5_core]
          local_pci_probe+0x68/0x110
          pci_call_probe+0x68/0x200
          pci_device_probe+0xbc/0x1a0
          really_probe+0x104/0x540
          __driver_probe_device+0xb4/0x230
          driver_probe_device+0x54/0x130
          __driver_attach+0x158/0x2b0
          bus_for_each_dev+0xa8/0x130
          driver_attach+0x34/0x50
          bus_add_driver+0x16c/0x300
          driver_register+0xa4/0x1b0
          __pci_register_driver+0x68/0x80
          mlx5_init+0xb8/0x100 [mlx5_core]
          do_one_initcall+0x60/0x300
          do_init_module+0x7c/0x2b0
      
      At the time of LPAR dump, before kexec hands over control to kdump
      kernel, DDWs (Dynamic DMA Windows) are scanned and added to the FDT.
      For the SR-IOV case, default DMA window "ibm,dma-window" is removed from
      the FDT and DDW added, for the device.
      
      Now, kexec hands over control to the kdump kernel.
      
      When the kdump kernel initializes, PCI busses are scanned and IOMMU
      group/tables created, in pci_dma_bus_setup_pSeriesLP(). For the SR-IOV
      case, there is no "ibm,dma-window". The original commit: b1fc44ea,
      fixes the path where memory is pre-mapped (direct mapped) to the DDW.
      When TCEs are direct mapped, there is no need to initialize IOMMU
      tables.
      
      iommu_table_setparms_lpar() only considers "ibm,dma-window" property
      when initiallizing IOMMU table. In the scenario where TCEs are
      dynamically allocated for SR-IOV, newly created IOMMU table is not
      initialized. Later, when the device driver tries to enter TCEs for the
      SR-IOV device, NULL pointer execption is thrown from iommu_area_alloc().
      
      The fix is to initialize the IOMMU table with DDW property stored in the
      FDT. There are 2 points to remember:
      
      	1. For the dedicated adapter, kdump kernel would encounter both
      	   default and DDW in FDT. In this case, DDW property is used to
      	   initialize the IOMMU table.
      
      	2. A DDW could be direct or dynamic mapped. kdump kernel would
      	   initialize IOMMU table and mark the existing DDW as
      	   "dynamic". This works fine since, at the time of table
      	   initialization, iommu_table_clear() makes some space in the
      	   DDW, for some predefined number of TCEs which are needed for
      	   kdump to succeed.
      
      Fixes: b1fc44ea ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
      Signed-off-by: default avatarGaurav Batra <gbatra@linux.vnet.ibm.com>
      Reviewed-by: default avatarBrian King <brking@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240125203017.61014-1-gbatra@linux.ibm.com
      09a3c1e4
  3. 20 Feb, 2024 1 commit
    • Amit Machhiwal's avatar
      KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat' · 20c8c4da
      Amit Machhiwal authored
      Currently, rebooting a pseries nested qemu-kvm guest (L2) results in
      below error as L1 qemu sends PVR value 'arch_compat' == 0 via
      ppc_set_compat ioctl. This triggers a condition failure in
      kvmppc_set_arch_compat() resulting in an EINVAL.
      
      qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid
      argument
      
      Also, a value of 0 for arch_compat generally refers the default
      compatibility of the host. But, arch_compat, being a Guest Wide Element
      in nested API v2, cannot be set to 0 in GSB as PowerVM (L0) expects a
      non-zero value. A value of 0 triggers a kernel trap during a reboot and
      consequently causes it to fail:
      
      [   22.106360] reboot: Restarting system
      KVM: unknown exit, hardware reason ffffffffffffffea
      NIP 0000000000000100   LR 000000000000fe44 CTR 0000000000000000 XER 0000000020040092 CPU#0
      MSR 0000000000001000 HID0 0000000000000000  HF 6c000000 iidx 3 didx 3
      TB 00000000 00000000 DECR 0
      GPR00 0000000000000000 0000000000000000 c000000002a8c300 000000007fe00000
      GPR04 0000000000000000 0000000000000000 0000000000001002 8000000002803033
      GPR08 000000000a000000 0000000000000000 0000000000000004 000000002fff0000
      GPR12 0000000000000000 c000000002e10000 0000000105639200 0000000000000004
      GPR16 0000000000000000 000000010563a090 0000000000000000 0000000000000000
      GPR20 0000000105639e20 00000001056399c8 00007fffe54abab0 0000000105639288
      GPR24 0000000000000000 0000000000000001 0000000000000001 0000000000000000
      GPR28 0000000000000000 0000000000000000 c000000002b30840 0000000000000000
      CR 00000000  [ -  -  -  -  -  -  -  -  ]     RES 000@ffffffffffffffff
       SRR0 0000000000000000  SRR1 0000000000000000    PVR 0000000000800200 VRSAVE 0000000000000000
      SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
      SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
      HSRR0 0000000000000000 HSRR1 0000000000000000
       CFAR 0000000000000000
       LPCR 0000000000020400
       PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000
      
       kernel:trap=0xffffffea | pc=0x100 | msr=0x1000
      
      This patch updates kvmppc_set_arch_compat() to use the host PVR value if
      'compat_pvr' == 0 indicating that qemu doesn't want to enforce any
      specific PVR compat mode.
      
      The relevant part of the code might need a rework if PowerVM implements
      a support for `arch_compat == 0` in nestedv2 API.
      
      Fixes: 19d31c5f ("KVM: PPC: Add support for nestedv2 guests")
      Reviewed-by: default avatar"Aneesh Kumar K.V (IBM)" <aneesh.kumar@kernel.org>
      Reviewed-by: default avatarVaibhav Jain <vaibhav@linux.ibm.com>
      Signed-off-by: default avatarAmit Machhiwal <amachhiw@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240207054526.3720087-1-amachhiw@linux.ibm.com
      20c8c4da
  4. 19 Feb, 2024 1 commit
    • Gaurav Batra's avatar
      powerpc/pseries/iommu: DLPAR add doesn't completely initialize pci_controller · a5c57fd2
      Gaurav Batra authored
      When a PCI device is dynamically added, the kernel oopses with a NULL
      pointer dereference:
      
        BUG: Kernel NULL pointer dereference on read at 0x00000030
        Faulting instruction address: 0xc0000000006bbe5c
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in: rpadlpar_io rpaphp rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs xsk_diag bonding nft_compat nf_tables nfnetlink rfkill binfmt_misc dm_multipath rpcrdma sunrpc rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod ib_umad ib_iser libiscsi scsi_transport_iscsi ib_ipoib rdma_cm iw_cm ib_cm mlx5_ib ib_uverbs ib_core pseries_rng drm drm_panel_orientation_quirks xfs libcrc32c mlx5_core mlxfw sd_mod t10_pi sg tls ibmvscsi ibmveth scsi_transport_srp vmx_crypto pseries_wdt psample dm_mirror dm_region_hash dm_log dm_mod fuse
        CPU: 17 PID: 2685 Comm: drmgr Not tainted 6.7.0-203405+ #66
        Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_008) hv:phyp pSeries
        NIP:  c0000000006bbe5c LR: c000000000a13e68 CTR: c0000000000579f8
        REGS: c00000009924f240 TRAP: 0300   Not tainted  (6.7.0-203405+)
        MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24002220  XER: 20040006
        CFAR: c000000000a13e64 DAR: 0000000000000030 DSISR: 40000000 IRQMASK: 0
        ...
        NIP sysfs_add_link_to_group+0x34/0x94
        LR  iommu_device_link+0x5c/0x118
        Call Trace:
         iommu_init_device+0x26c/0x318 (unreliable)
         iommu_device_link+0x5c/0x118
         iommu_init_device+0xa8/0x318
         iommu_probe_device+0xc0/0x134
         iommu_bus_notifier+0x44/0x104
         notifier_call_chain+0xb8/0x19c
         blocking_notifier_call_chain+0x64/0x98
         bus_notify+0x50/0x7c
         device_add+0x640/0x918
         pci_device_add+0x23c/0x298
         of_create_pci_dev+0x400/0x884
         of_scan_pci_dev+0x124/0x1b0
         __of_scan_bus+0x78/0x18c
         pcibios_scan_phb+0x2a4/0x3b0
         init_phb_dynamic+0xb8/0x110
         dlpar_add_slot+0x170/0x3b8 [rpadlpar_io]
         add_slot_store.part.0+0xb4/0x130 [rpadlpar_io]
         kobj_attr_store+0x2c/0x48
         sysfs_kf_write+0x64/0x78
         kernfs_fop_write_iter+0x1b0/0x290
         vfs_write+0x350/0x4a0
         ksys_write+0x84/0x140
         system_call_exception+0x124/0x330
         system_call_vectored_common+0x15c/0x2ec
      
      Commit a9409044 ("powerpc/iommu: Add iommu_ops to report capabilities
      and allow blocking domains") broke DLPAR add of PCI devices.
      
      The above added iommu_device structure to pci_controller. During
      system boot, PCI devices are discovered and this newly added iommu_device
      structure is initialized by a call to iommu_device_register().
      
      During DLPAR add of a PCI device, a new pci_controller structure is
      allocated but there are no calls made to iommu_device_register()
      interface.
      
      Fix is to register the iommu device during DLPAR add as well.
      
      Fixes: a9409044 ("powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains")
      Signed-off-by: default avatarGaurav Batra <gbatra@linux.ibm.com>
      Reviewed-by: default avatarBrian King <brking@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240215221833.4817-1-gbatra@linux.ibm.com
      a5c57fd2
  5. 14 Feb, 2024 6 commits
  6. 06 Feb, 2024 2 commits
    • Arnd Bergmann's avatar
      powerpc: 85xx: mark local functions static · 1c57b9f6
      Arnd Bergmann authored
      These functions are either used in only one file and can just be
      made static or need an #include statement to avoid a warning:
      
      arch/powerpc/platforms/85xx/mpc8536_ds.c:30:13: error: no previous prototype for 'mpc8536_ds_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1010rdb.c:27:13: error: no previous prototype for 'p1010_rdb_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_ds.c:373:6: error: no previous prototype for 'p1022ds_set_pixel_clock' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_ds.c:422:1: error: no previous prototype for 'p1022ds_valid_monitor_port' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_ds.c:435:13: error: no previous prototype for 'p1022_ds_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_rdk.c:43:6: error: no previous prototype for 'p1022rdk_set_pixel_clock' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_rdk.c:92:1: error: no previous prototype for 'p1022rdk_valid_monitor_port' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/p1022_rdk.c:99:13: error: no previous prototype for 'p1022_rdk_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/socrates_fpga_pic.c:273:13: error: no previous prototype for 'socrates_fpga_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/xes_mpc85xx.c:40:13: error: no previous prototype for 'xes_mpc85xx_pic_init' [-Werror=missing-prototypes]
      arch/powerpc/platforms/85xx/mvme2500.c:24:13: error: no previous prototype for 'mvme2500_pic_init' [-Werror=missing-prototypes]
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240123125148.2004648-2-arnd@kernel.org
      1c57b9f6
    • Arnd Bergmann's avatar
      powerpc: udbg_memcons: mark functions static · 5c84bc8b
      Arnd Bergmann authored
      ppc64_book3e_allmodconfig has one more driver that triggeres a
      few missing-prototypes warnings:
      
      arch/powerpc/sysdev/udbg_memcons.c:44:6: error: no previous prototype for 'memcons_putc' [-Werror=missing-prototypes]
      arch/powerpc/sysdev/udbg_memcons.c:57:5: error: no previous prototype for 'memcons_getc_poll' [-Werror=missing-prototypes]
      arch/powerpc/sysdev/udbg_memcons.c:80:5: error: no previous prototype for 'memcons_getc' [-Werror=missing-prototypes]
      
      Mark all these function static as there are no other users.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240123125148.2004648-1-arnd@kernel.org
      5c84bc8b
  7. 05 Feb, 2024 6 commits
    • Jiangfeng Xiao's avatar
      powerpc/kasan: Fix addr error caused by page alignment · 4a7aee96
      Jiangfeng Xiao authored
      In kasan_init_region, when k_start is not page aligned, at the begin of
      for loop, k_cur = k_start & PAGE_MASK is less than k_start, and then
      `va = block + k_cur - k_start` is less than block, the addr va is invalid,
      because the memory address space from va to block is not alloced by
      memblock_alloc, which will not be reserved by memblock_reserve later, it
      will be used by other places.
      
      As a result, memory overwriting occurs.
      
      for example:
      int __init __weak kasan_init_region(void *start, size_t size)
      {
      [...]
      	/* if say block(dcd97000) k_start(feef7400) k_end(feeff3fe) */
      	block = memblock_alloc(k_end - k_start, PAGE_SIZE);
      	[...]
      	for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
      		/* at the begin of for loop
      		 * block(dcd97000) va(dcd96c00) k_cur(feef7000) k_start(feef7400)
      		 * va(dcd96c00) is less than block(dcd97000), va is invalid
      		 */
      		void *va = block + k_cur - k_start;
      		[...]
      	}
      [...]
      }
      
      Therefore, page alignment is performed on k_start before
      memblock_alloc() to ensure the validity of the VA address.
      
      Fixes: 663c0c94 ("powerpc/kasan: Fix shadow area set up for modules.")
      Signed-off-by: default avatarJiangfeng Xiao <xiaojiangfeng@huawei.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/1705974359-43790-1-git-send-email-xiaojiangfeng@huawei.com
      4a7aee96
    • Matthias Schiffer's avatar
      powerpc/6xx: set High BAT Enable flag on G2_LE cores · a038a3ff
      Matthias Schiffer authored
      MMU_FTR_USE_HIGH_BATS is set for G2_LE cores and derivatives like e300cX,
      but the high BATs need to be enabled in HID2 to work. Add register
      definitions and add the needed setup to __setup_cpu_603.
      
      This fixes boot on CPUs like the MPC5200B with STRICT_KERNEL_RWX enabled
      on systems where the flag has not been set by the bootloader already.
      
      Fixes: e4d6654e ("powerpc/mm/32s: rework mmu_mapin_ram()")
      Signed-off-by: default avatarMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
      Reviewed-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240124103838.43675-1-matthias.schiffer@ew.tq-group.com
      a038a3ff
    • R Nageswara Sastry's avatar
      selftests/powerpc/papr_vpd: Check devfd before get_system_loc_code() · f0969627
      R Nageswara Sastry authored
      Calling get_system_loc_code before checking devfd and errno fails the test
      when the device is not available, the expected behaviour is a SKIP.
      
      Change the order of 'SKIP_IF_MSG' to correctly SKIP when the /dev/
      papr-vpd device is not available.
      
      Test output before:
        Test FAILED on line 271
      
      Test output after:
        [SKIP] Test skipped on line 266: /dev/papr-vpd not present
      Signed-off-by: default avatarR Nageswara Sastry <rnsastry@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240131130859.14968-1-rnsastry@linux.ibm.com
      f0969627
    • Naveen N Rao's avatar
      powerpc/64: Set task pt_regs->link to the LR value on scv entry · aad98efd
      Naveen N Rao authored
      Nysal reported that userspace backtraces are missing in offcputime bcc
      tool. As an example:
          $ sudo ./bcc/tools/offcputime.py -uU
          Tracing off-CPU time (us) of user threads by user stack... Hit Ctrl-C to end.
      
          ^C
      	write
      	-                python (9107)
      	    8
      
      	write
      	-                sudo (9105)
      	    9
      
      	mmap
      	-                python (9107)
      	    16
      
      	clock_nanosleep
      	-                multipathd (697)
      	    3001604
      
      The offcputime bcc tool attaches a bpf program to a kprobe on
      finish_task_switch(), which is usually hit on a syscall from userspace.
      With the switch to system call vectored, we started setting
      pt_regs->link to zero. This is because system call vectored behaves like
      a function call with LR pointing to the system call return address, and
      with no modification to SRR0/SRR1. The LR value does indicate our next
      instruction, so it is being saved as pt_regs->nip, and pt_regs->link is
      being set to zero. This is not a problem by itself, but BPF uses perf
      callchain infrastructure for capturing stack traces, and that stores LR
      as the second entry in the stack trace. perf has code to cope with the
      second entry being zero, and skips over it. However, generic userspace
      unwinders assume that a zero entry indicates end of the stack trace,
      resulting in a truncated userspace stack trace.
      
      Rather than fixing all userspace unwinders to ignore/skip past the
      second entry, store the real LR value in pt_regs->link so that there
      continues to be a valid, though duplicate entry in the stack trace.
      
      With this change:
          $ sudo ./bcc/tools/offcputime.py -uU
          Tracing off-CPU time (us) of user threads by user stack... Hit Ctrl-C to end.
      
          ^C
      	write
      	write
      	[unknown]
      	[unknown]
      	[unknown]
      	[unknown]
      	[unknown]
      	PyObject_VectorcallMethod
      	[unknown]
      	[unknown]
      	PyObject_CallOneArg
      	PyFile_WriteObject
      	PyFile_WriteString
      	[unknown]
      	[unknown]
      	PyObject_Vectorcall
      	_PyEval_EvalFrameDefault
      	PyEval_EvalCode
      	[unknown]
      	[unknown]
      	[unknown]
      	_PyRun_SimpleFileObject
      	_PyRun_AnyFileObject
      	Py_RunMain
      	[unknown]
      	Py_BytesMain
      	[unknown]
      	__libc_start_main
      	-                python (1293)
      	    7
      
      	write
      	write
      	[unknown]
      	sudo_ev_loop_v1
      	sudo_ev_dispatch_v1
      	[unknown]
      	[unknown]
      	[unknown]
      	[unknown]
      	__libc_start_main
      	-                sudo (1291)
      	    7
      
      	syscall
      	syscall
      	bpf_open_perf_buffer_opts
      	[unknown]
      	[unknown]
      	[unknown]
      	[unknown]
      	_PyObject_MakeTpCall
      	PyObject_Vectorcall
      	_PyEval_EvalFrameDefault
      	PyEval_EvalCode
      	[unknown]
      	[unknown]
      	[unknown]
      	_PyRun_SimpleFileObject
      	_PyRun_AnyFileObject
      	Py_RunMain
      	[unknown]
      	Py_BytesMain
      	[unknown]
      	__libc_start_main
      	-                python (1293)
      	    11
      
      	clock_nanosleep
      	clock_nanosleep
      	nanosleep
      	sleep
      	[unknown]
      	[unknown]
      	__clone
      	-                multipathd (698)
      	    3001661
      
      Fixes: 7fa95f9a ("powerpc/64s: system call support for scv/rfscv instructions")
      Cc: stable@vger.kernel.org
      Reported-by: default avatar"Nysal Jan K.A" <nysal@linux.ibm.com>
      Signed-off-by: default avatarNaveen N Rao <naveen@kernel.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240202154316.395276-1-naveen@kernel.org
      aad98efd
    • Gaurav Batra's avatar
      powerpc/pseries/iommu: Fix iommu initialisation during DLPAR add · ed8b94f6
      Gaurav Batra authored
      When a PCI device is dynamically added, the kernel oopses with a NULL
      pointer dereference:
      
        BUG: Kernel NULL pointer dereference on read at 0x00000030
        Faulting instruction address: 0xc0000000006bbe5c
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in: rpadlpar_io rpaphp rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs xsk_diag bonding nft_compat nf_tables nfnetlink rfkill binfmt_misc dm_multipath rpcrdma sunrpc rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod ib_umad ib_iser libiscsi scsi_transport_iscsi ib_ipoib rdma_cm iw_cm ib_cm mlx5_ib ib_uverbs ib_core pseries_rng drm drm_panel_orientation_quirks xfs libcrc32c mlx5_core mlxfw sd_mod t10_pi sg tls ibmvscsi ibmveth scsi_transport_srp vmx_crypto pseries_wdt psample dm_mirror dm_region_hash dm_log dm_mod fuse
        CPU: 17 PID: 2685 Comm: drmgr Not tainted 6.7.0-203405+ #66
        Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_008) hv:phyp pSeries
        NIP:  c0000000006bbe5c LR: c000000000a13e68 CTR: c0000000000579f8
        REGS: c00000009924f240 TRAP: 0300   Not tainted  (6.7.0-203405+)
        MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24002220  XER: 20040006
        CFAR: c000000000a13e64 DAR: 0000000000000030 DSISR: 40000000 IRQMASK: 0
        ...
        NIP sysfs_add_link_to_group+0x34/0x94
        LR  iommu_device_link+0x5c/0x118
        Call Trace:
         iommu_init_device+0x26c/0x318 (unreliable)
         iommu_device_link+0x5c/0x118
         iommu_init_device+0xa8/0x318
         iommu_probe_device+0xc0/0x134
         iommu_bus_notifier+0x44/0x104
         notifier_call_chain+0xb8/0x19c
         blocking_notifier_call_chain+0x64/0x98
         bus_notify+0x50/0x7c
         device_add+0x640/0x918
         pci_device_add+0x23c/0x298
         of_create_pci_dev+0x400/0x884
         of_scan_pci_dev+0x124/0x1b0
         __of_scan_bus+0x78/0x18c
         pcibios_scan_phb+0x2a4/0x3b0
         init_phb_dynamic+0xb8/0x110
         dlpar_add_slot+0x170/0x3b8 [rpadlpar_io]
         add_slot_store.part.0+0xb4/0x130 [rpadlpar_io]
         kobj_attr_store+0x2c/0x48
         sysfs_kf_write+0x64/0x78
         kernfs_fop_write_iter+0x1b0/0x290
         vfs_write+0x350/0x4a0
         ksys_write+0x84/0x140
         system_call_exception+0x124/0x330
         system_call_vectored_common+0x15c/0x2ec
      
      Commit a9409044 ("powerpc/iommu: Add iommu_ops to report capabilities
      and allow blocking domains") broke DLPAR add of PCI devices.
      
      The above added iommu_device structure to pci_controller. During
      system boot, PCI devices are discovered and this newly added iommu_device
      structure is initialized by a call to iommu_device_register().
      
      During DLPAR add of a PCI device, a new pci_controller structure is
      allocated but there are no calls made to iommu_device_register()
      interface.
      
      Fix is to register the iommu device during DLPAR add as well.
      
      Fixes: a9409044 ("powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains")
      Signed-off-by: default avatarGaurav Batra <gbatra@linux.ibm.com>
      [mpe: Trim oops and tweak some change log wording]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240122222407.39603-1-gbatra@linux.ibm.com
      ed8b94f6
    • Nathan Lynch's avatar
      powerpc/pseries/papr-sysparm: use u8 arrays for payloads · 8ded03ae
      Nathan Lynch authored
      Some PAPR system parameter values are formatted by firmware as
      nul-terminated strings (e.g. LPAR name, shared processor attributes).
      But the values returned for other parameters, such as processor module
      info and TLB block invalidate characteristics, are binary data with
      parameter-specific layouts. So char[] isn't the appropriate type for
      the general case. Use u8/__u8.
      Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Fixes: 905b9e48 ("powerpc/pseries/papr-sysparm: Expose character device to user space")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240202-papr-sysparm-ioblock-data-use-u8-v1-1-f5c6c89f65ec@linux.ibm.com
      8ded03ae
  8. 29 Jan, 2024 1 commit
  9. 28 Jan, 2024 7 commits
  10. 27 Jan, 2024 9 commits
  11. 26 Jan, 2024 4 commits
    • Linus Torvalds's avatar
      Merge tag 'ata-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux · 3a5879d4
      Linus Torvalds authored
      Pull ata updates from Niklas Cassel:
      
       - Fix an incorrect link_power_management_policy sysfs attribute value.
      
         We were previously using the same attribute value for two different
         LPM policies (me)
      
       - Add a ASMedia ASM1166 quirk.
      
         The SATA host controller always reports that it has 32 ports, even
         though it only has six ports. Add a quirk that overrides the value
         reported by the controller (Conrad)
      
       - Add a ASMedia ASM1061 quirk.
      
         The SATA host controller completely ignores the upper 21 bits of the
         DMA address. This causes IOMMU error events when a (valid) DMA
         address actually has any of the upper 21 bits set. Add a quirk that
         limits the dma_mask to 43-bits (Lennert)
      
      * tag 'ata-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
        ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers
        ahci: asm1166: correct count of reported ports
        ata: libata-sata: improve sysfs description for ATA_LPM_UNKNOWN
      3a5879d4
    • Linus Torvalds's avatar
      Merge tag 'block-6.8-2024-01-26' of git://git.kernel.dk/linux · 914e1708
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - RCU warning fix for md (Mikulas)
      
       - Fix for an aoe issue that lockdep rightfully complained about
         (Maksim)
      
       - Fix for an error code change in partitioning that caused a regression
         with some tools (Li)
      
       - Fix for a data direction warning with bi-direction commands
         (Christian)
      
      * tag 'block-6.8-2024-01-26' of git://git.kernel.dk/linux:
        md: fix a suspicious RCU usage warning
        aoe: avoid potential deadlock at set_capacity
        block: Fix WARNING in _copy_from_iter
        block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
      914e1708
    • Linus Torvalds's avatar
      Merge tag 'io_uring-6.8-2024-01-26' of git://git.kernel.dk/linux · cced1c5e
      Linus Torvalds authored
      Pull io_uring fix from Jens Axboe:
       "Just a single tweak to the newly added IORING_OP_FIXED_FD_INSTALL from
        Paul, ensuring it goes via the audit path and playing it safe by
        excluding it from using registered creds"
      
      * tag 'io_uring-6.8-2024-01-26' of git://git.kernel.dk/linux:
        io_uring: enable audit and restrict cred override for IORING_OP_FIXED_FD_INSTALL
      cced1c5e
    • Linus Torvalds's avatar
      Merge tag 'thermal-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 667c8893
      Linus Torvalds authored
      Pull thermal control update from Rafael Wysocki:
       "Remove some dead code from the Intel powerclamp thermal control driver
        (Srinivas Pandruvada)"
      
      * tag 'thermal-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        thermal: intel: powerclamp: Remove dead code for target mwait value
      667c8893