1. 12 Feb, 2022 2 commits
    • Christophe Leroy's avatar
      powerpc/set_memory: Avoid spinlock recursion in change_page_attr() · a4c182ec
      Christophe Leroy authored
      Commit 1f9ad21c ("powerpc/mm: Implement set_memory() routines")
      included a spin_lock() to change_page_attr() in order to
      safely perform the three step operations. But then
      commit 9f7853d7 ("powerpc/mm: Fix set_memory_*() against
      concurrent accesses") modify it to use pte_update() and do
      the operation safely against concurrent access.
      
      In the meantime, Maxime reported some spinlock recursion.
      
      [   15.351649] BUG: spinlock recursion on CPU#0, kworker/0:2/217
      [   15.357540]  lock: init_mm+0x3c/0x420, .magic: dead4ead, .owner: kworker/0:2/217, .owner_cpu: 0
      [   15.366563] CPU: 0 PID: 217 Comm: kworker/0:2 Not tainted 5.15.0+ #523
      [   15.373350] Workqueue: events do_free_init
      [   15.377615] Call Trace:
      [   15.380232] [e4105ac0] [800946a4] do_raw_spin_lock+0xf8/0x120 (unreliable)
      [   15.387340] [e4105ae0] [8001f4ec] change_page_attr+0x40/0x1d4
      [   15.393413] [e4105b10] [801424e0] __apply_to_page_range+0x164/0x310
      [   15.400009] [e4105b60] [80169620] free_pcp_prepare+0x1e4/0x4a0
      [   15.406045] [e4105ba0] [8016c5a0] free_unref_page+0x40/0x2b8
      [   15.411979] [e4105be0] [8018724c] kasan_depopulate_vmalloc_pte+0x6c/0x94
      [   15.418989] [e4105c00] [801424e0] __apply_to_page_range+0x164/0x310
      [   15.425451] [e4105c50] [80187834] kasan_release_vmalloc+0xbc/0x134
      [   15.431898] [e4105c70] [8015f7a8] __purge_vmap_area_lazy+0x4e4/0xdd8
      [   15.438560] [e4105d30] [80160d10] _vm_unmap_aliases.part.0+0x17c/0x24c
      [   15.445283] [e4105d60] [801642d0] __vunmap+0x2f0/0x5c8
      [   15.450684] [e4105db0] [800e32d0] do_free_init+0x68/0x94
      [   15.456181] [e4105dd0] [8005d094] process_one_work+0x4bc/0x7b8
      [   15.462283] [e4105e90] [8005d614] worker_thread+0x284/0x6e8
      [   15.468227] [e4105f00] [8006aaec] kthread+0x1f0/0x210
      [   15.473489] [e4105f40] [80017148] ret_from_kernel_thread+0x14/0x1c
      
      Remove the read / modify / write sequence to make the operation atomic
      and remove the spin_lock() in change_page_attr().
      
      To do the operation atomically, we can't use pte modification helpers
      anymore. Because all platforms have different combination of bits, it
      is not easy to use those bits directly. But all have the
      _PAGE_KERNEL_{RO/ROX/RW/RWX} set of flags. All we need it to compare
      two sets to know which bits are set or cleared.
      
      For instance, by comparing _PAGE_KERNEL_ROX and _PAGE_KERNEL_RO you
      know which bit gets cleared and which bit get set when changing exec
      permission.
      Reported-by: default avatarMaxime Bizon <mbizon@freebox.fr>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/all/20211212112152.GA27070@sakura/
      Link: https://lore.kernel.org/r/43c3c76a1175ae6dc1a3d3b5c3f7ecb48f683eea.1640344012.git.christophe.leroy@csgroup.eu
      a4c182ec
    • Christophe Leroy's avatar
      powerpc/ftrace: Remove ftrace_32.S · 4ee83a2c
      Christophe Leroy authored
      Functions in ftrace_32.S are common with PPC64.
      
      Reuse the ones defined for PPC64 with slight modification
      when required.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      [mpe: Squash in fixup diff from Christophe]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/5e837fc190504c4ef834272e70d60ae33f175d49.1640017960.git.christophe.leroy@csgroup.eu
      4ee83a2c
  2. 07 Feb, 2022 18 commits
  3. 03 Feb, 2022 12 commits
  4. 02 Feb, 2022 5 commits
    • Michael Ellerman's avatar
      powerpc/ptdump: Fix sparse warning in hashpagetable.c · 961f649f
      Michael Ellerman authored
      As reported by sparse:
      
        arch/powerpc/mm/ptdump/hashpagetable.c:264:29: warning: restricted __be64 degrades to integer
        arch/powerpc/mm/ptdump/hashpagetable.c:265:49: warning: restricted __be64 degrades to integer
        arch/powerpc/mm/ptdump/hashpagetable.c:267:36: warning: incorrect type in assignment (different base types)
        arch/powerpc/mm/ptdump/hashpagetable.c:267:36:    expected unsigned long long [usertype]
        arch/powerpc/mm/ptdump/hashpagetable.c:267:36:    got restricted __be64 [usertype] v
        arch/powerpc/mm/ptdump/hashpagetable.c:268:36: warning: incorrect type in assignment (different base types)
        arch/powerpc/mm/ptdump/hashpagetable.c:268:36:    expected unsigned long long [usertype]
        arch/powerpc/mm/ptdump/hashpagetable.c:268:36:    got restricted __be64 [usertype] r
      
      The values returned by plpar_pte_read_4() are CPU endian, not __be64, so
      assigning them to struct hash_pte confuses sparse. As a minimal fix open
      code a struct to hold the values with CPU endian types.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220202053039.691917-1-mpe@ellerman.id.au
      961f649f
    • Corentin Labbe's avatar
      macintosh: macio_asic: remove useless cast for driver.name · ccafe7c2
      Corentin Labbe authored
      pci_driver name is const char pointer, so the cast it not necessary.
      Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220125135421.4081740-1-clabbe@baylibre.com
      ccafe7c2
    • Michael Ellerman's avatar
      powerpc/64: Move paca allocation later in boot · 2e7f1e2b
      Michael Ellerman authored
      Mahesh & Sourabh identified two problems[1][2] with ppc64_bolted_size()
      and paca allocation.
      
      The first is that on a Radix capable machine but with "disable_radix" on
      the command line, there is a window during early boot where
      early_radix_enabled() is true, even though it will later become false.
      
        early_init_devtree:                       <- early_radix_enabled() = false
          early_init_dt_scan_cpus:                <- early_radix_enabled() = false
              ...
              check_cpu_pa_features:              <- early_radix_enabled() = false
              ...                               ^ <- early_radix_enabled() = TRUE
              allocate_paca:                    | <- early_radix_enabled() = TRUE
                  ...                           |
                  ppc64_bolted_size:            | <- early_radix_enabled() = TRUE
                      if (early_radix_enabled())| <- early_radix_enabled() = TRUE
                          return ULONG_MAX;     |
              ...                               |
          ...                                   | <- early_radix_enabled() = TRUE
          ...                                   | <- early_radix_enabled() = TRUE
          mmu_early_init_devtree()              V
          ...                                     <- early_radix_enabled() = false
      
      This causes ppc64_bolted_size() to return ULONG_MAX for the boot CPU's
      paca allocation, even though later it will return a different value.
      This is not currently a bug because the paca allocation is also limited
      by the RMA size, but that is very fragile.
      
      The second issue is that when using the Hash MMU, when we call
      ppc64_bolted_size() for the boot CPU's paca allocation, we have not yet
      detected whether 1T segments are available. That causes
      ppc64_bolted_size() to return 256MB, even if the machine can actually
      support up to 1T. This is usually OK, we generally have space below
      256MB for one paca, but for a kdump kernel placed above 256MB it causes
      the boot to fail.
      
      At boot we cannot discover all the features of the machine
      instantaneously, so there will always be some periods where we have
      incomplete knowledge of the system. However both the above problems stem
      from the fact that we allocate the boot CPU's paca (and paca pointers
      array) before we decide which MMU we are using, or discover its exact
      features.
      
      Moving the paca allocation slightly later still can solve both the
      issues described above, and means for a normal boot we don't do any
      permanent allocations until after we've discovered the MMU.
      
      Note that although we move the boot CPU's paca allocation later, we
      still have a temporary paca (boot_paca) accessible via r13, so code that
      does read only access to paca fields is safe. The only risk is that some
      code writes to the boot_paca, and that write will then be lost when we
      switch away from the boot_paca later in early_setup().
      
      The additional code that runs before the paca allocation is primarily
      mmu_early_init_devtree(), which is scanning the device tree and
      populating globals and cur_cpu_spec with MMU related flags. I do not see
      any additional code that writes to paca fields.
      
      [1]: https://lore.kernel.org/r/20211018084434.217772-2-sourabhjain@linux.ibm.com
      [2]: https://lore.kernel.org/r/20211018084434.217772-3-sourabhjain@linux.ibm.comSigned-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220124130544.408675-1-mpe@ellerman.id.au
      2e7f1e2b
    • Maxim Kiselev's avatar
      powerpc: dts: t1040rdb: fix ports names for Seville Ethernet switch · 5ebb7474
      Maxim Kiselev authored
      On board rev A, the network interface labels for the switch ports
      written on the front panel are different than on rev B and later.
      
      This patch fixes network interface names for the switch ports according
      to labels that are written on the front panel of the board rev B.
      They start from ETH3 and end at ETH10.
      
      This patch also introduces a separate device tree for rev A.
      The main device tree is supposed to cover rev B and later.
      
      Fixes: e69eb082 ("powerpc: dts: t1040rdb: add ports for Seville Ethernet switch")
      Signed-off-by: default avatarMaxim Kiselev <bigunclemax@gmail.com>
      Reviewed-by: default avatarMaxim Kochetkov <fido_max@inbox.ru>
      Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220121091447.3412907-1-bigunclemax@gmail.com
      5ebb7474
    • Laurent Dufour's avatar
      powerpc/pseries: read the lpar name from the firmware · eddaa9a4
      Laurent Dufour authored
      The LPAR name may be changed after the LPAR has been started in the HMC.
      In that case lparstat command is not reporting the updated value because
      it reads it from the device tree which is read at boot time.
      
      However this value could be read from RTAS.
      
      Adding this value in the /proc/powerpc/lparcfg output allows to read the
      updated value.
      
      However the hypervisor, like Qemu/KVM, may not support this RTAS
      parameter. In that case the value reported in lparcfg is read from the
      device tree and so is not updated accordingly.
      Signed-off-by: default avatarLaurent Dufour <ldufour@linux.ibm.com>
      Reviewed-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Reviewed-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      [mpe: Drop doc-comment syntax, change RTAS/DT to lower case, use of_root
            to fix missing of_node_put(), use of_property_read_string()]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220106161339.74656-1-ldufour@linux.ibm.com
      eddaa9a4
  5. 31 Jan, 2022 3 commits