platform/kernel/linux-rpi.git
21 months agopowerpc/64/build: only include .opd with ELFv1
Nicholas Piggin [Fri, 16 Sep 2022 04:07:53 +0000 (14:07 +1000)]
powerpc/64/build: only include .opd with ELFv1

ELFv2 does not use function descriptors so .opd is not required.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916040755.2398112-6-npiggin@gmail.com
21 months agopowerpc/build: move .data.rel.ro, .sdata2 to read-only
Nicholas Piggin [Fri, 16 Sep 2022 04:07:52 +0000 (14:07 +1000)]
powerpc/build: move .data.rel.ro, .sdata2 to read-only

.sdata2 is a readonly small data section for ppc32, and .data.rel.ro
is data that needs relocating but is read-only after that so these
can both be moved to the read only memory region.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916040755.2398112-5-npiggin@gmail.com
21 months agopowerpc/build: move got, toc, plt, branch_lt sections to read-only
Nicholas Piggin [Fri, 16 Sep 2022 04:07:51 +0000 (14:07 +1000)]
powerpc/build: move got, toc, plt, branch_lt sections to read-only

This moves linker-related tables from .data to read-only area.
Relocations are performed at early boot time before memory is protected,
after which there should be no modifications required.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Don't use SPECIAL as reported by lkp@intel.com]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916040755.2398112-4-npiggin@gmail.com
21 months agopowerpc/32/build: move got1/got2 sections out of text
Nicholas Piggin [Fri, 16 Sep 2022 04:07:50 +0000 (14:07 +1000)]
powerpc/32/build: move got1/got2 sections out of text

Following the example from the binutils default linker script, move
.got1 and .got2 out of .text, to just after RO_DATA.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916040755.2398112-3-npiggin@gmail.com
21 months agopowerpc: move __end_rodata to cover arch read-only sections
Nicholas Piggin [Fri, 16 Sep 2022 04:07:49 +0000 (14:07 +1000)]
powerpc: move __end_rodata to cover arch read-only sections

powerpc has a number of read-only sections and tables that are put after
RO_DATA(). Move the __end_rodata symbol to cover these as well.

Setting memory to read-only at boot is done using __init_begin, change
that to use __end_rodata.

This makes is_kernel_rodata() exactly cover the read-only region, as
well as other things using __end_rodata (e.g., kernel/dma/debug.c).
Boot dmesg also prints the rodata size more accurately.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916040755.2398112-2-npiggin@gmail.com
21 months agopowerpc/vmlinux.lds: Add an explicit symbol for the SRWX boundary
Michael Ellerman [Fri, 16 Sep 2022 04:41:24 +0000 (14:41 +1000)]
powerpc/vmlinux.lds: Add an explicit symbol for the SRWX boundary

Currently __init_begin is used as the boundary for strict RWX between
executable/read-only text and data, and non-executable (after boot) code
and data.

But that's a little subtle, so add an explicit symbol to document that
the SRWX boundary lies there, and add a comment making it clear that
__init_begin must also begin there.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916131422.318752-2-mpe@ellerman.id.au
21 months agopowerpc/vmlinux.lds: Ensure STRICT_ALIGN_SIZE is at least page aligned
Michael Ellerman [Fri, 16 Sep 2022 04:40:57 +0000 (14:40 +1000)]
powerpc/vmlinux.lds: Ensure STRICT_ALIGN_SIZE is at least page aligned

Add a check that STRICT_ALIGN_SIZE is aligned to at least PAGE_SIZE.

That then makes the alignment to PAGE_SIZE immediately after the
alignment to STRICT_ALIGN_SIZE redundant, so remove it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220916131422.318752-1-mpe@ellerman.id.au
21 months agopowerpc/64: Remove unused prom_init_toc symbols
Michael Ellerman [Sat, 17 Sep 2022 06:36:47 +0000 (16:36 +1000)]
powerpc/64: Remove unused prom_init_toc symbols

Commit 24d33ac5b8ff ("powerpc/64s: Make prom_init require RELOCATABLE")
made prom_init depend on CONFIG_RELOCATABLE.

But it missed cleaning up a case in the linker script for RELOCATABLE=n,
and associated symbols. Remove them now.

Fixes: 24d33ac5b8ff ("powerpc/64s: Make prom_init require RELOCATABLE")
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220920131157.1032707-1-mpe@ellerman.id.au
21 months agopowerpc/pseries: move hcall_tracepoint_refcount out of .toc
Nicholas Piggin [Mon, 26 Sep 2022 05:38:23 +0000 (15:38 +1000)]
powerpc/pseries: move hcall_tracepoint_refcount out of .toc

The .toc section is not really intended for arbitrary data. Writable
data in particular prevents making the TOC read-only after relocation.
Move hcall_tracepoint_refcount into the .data section.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220926053823.2668799-1-npiggin@gmail.com
21 months agoMerge branch 'fixes' into next
Michael Ellerman [Fri, 23 Sep 2022 14:40:14 +0000 (00:40 +1000)]
Merge branch 'fixes' into next

Merge our fixes branch to bring in a few things that new feature patches
rely on or conflict with.

22 months agoKVM: PPC: remove orphan declarations from kvm_ppc.h
Gaosheng Cui [Tue, 13 Sep 2022 07:50:29 +0000 (15:50 +0800)]
KVM: PPC: remove orphan declarations from kvm_ppc.h

Remove the following orphan declarations from kvm_ppc.h:

1. kvmppc_mmu_priv_switch() has been removed since
commit dd9ebf1f9435 ("KVM: PPC: e500: Add shadow PID
support").
2. kvmppc_core_destroy_mmu() has been removed since
commit ecc0981ff07c ("KVM: ppc: cosmetic changes to mmu
hook names").
3. kvmppc_prepare_vrma() has been removed since
commit aa04b4cc5be6 ("KVM: PPC: Allocate RMAs (Real Mode
Areas) at boot for use by guests").

So remove the declarations for them from header file.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-10-cuigaosheng1@huawei.com
22 months agopowerpc/ps3: remove orphan declarations from ps3av.h
Gaosheng Cui [Tue, 13 Sep 2022 07:50:28 +0000 (15:50 +0800)]
powerpc/ps3: remove orphan declarations from ps3av.h

Remove the following orphan declarations from ps3av.h:
1. ps3av_dev_open()
2. ps3av_dev_close()

They have been removed since commit 13a5e30cf740 ("[POWERPC] PS3:
Rework AV settings driver"), so remove them.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Acked-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-9-cuigaosheng1@huawei.com
22 months agopowerpc/sysdev: remove unused xics_ipi_dispatch() declaration
Gaosheng Cui [Tue, 13 Sep 2022 07:50:27 +0000 (15:50 +0800)]
powerpc/sysdev: remove unused xics_ipi_dispatch() declaration

xics_ipi_dispatch() has been removed since
commit 23d72bfd8f9f ("powerpc: Consolidate ipi message mux
and demux"), so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-8-cuigaosheng1@huawei.com
22 months agopowerpc/powernv: remove orphan declarations from opal.h
Gaosheng Cui [Tue, 13 Sep 2022 07:50:26 +0000 (15:50 +0800)]
powerpc/powernv: remove orphan declarations from opal.h

Remove the following orphan declarations from opal.h:
1. opal_notifier_register()
2. opal_notifier_unregister()
3. opal_notifier_update_evt()
4. opal_notifier_enable()
5. opal_notifier_disable()

They have been removed since commit 81f2f7ce4c5b ("opal:
Remove events notifier"), so remove them.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-7-cuigaosheng1@huawei.com
22 months agopowerpc/mm: remove orphan declarations from mmu_context.h
Gaosheng Cui [Tue, 13 Sep 2022 07:50:25 +0000 (15:50 +0800)]
powerpc/mm: remove orphan declarations from mmu_context.h

Remove the following orphan declarations from mmu_context.h:
1. switch_cop() and drop_cop() have been removed since
commit 6ff4d3e96652 ("powerpc: Remove old unused icswx
based coprocessor support").

2. mm_iommu_cleanup() has been removed since
commit 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put
pages on VFIO container shutdown").

So remove the declarations for them from header file.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-6-cuigaosheng1@huawei.com
22 months agopowerpc: remove unused udbg_init_debug_beat() declaration
Gaosheng Cui [Tue, 13 Sep 2022 07:50:24 +0000 (15:50 +0800)]
powerpc: remove unused udbg_init_debug_beat() declaration

udbg_init_debug_beat() has been removed since
commit bf4981a00636 ("powerpc: Remove the celleb support"),
so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-5-cuigaosheng1@huawei.com
22 months agopowerpc: remove unused chrp_event_scan() declaration
Gaosheng Cui [Tue, 13 Sep 2022 07:50:23 +0000 (15:50 +0800)]
powerpc: remove unused chrp_event_scan() declaration

chrp_event_scan() has been removed since
commit 3d541c4b7f6e ("powerpc/chrp: Use the same RTAS
daemon as pSeries"), so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-4-cuigaosheng1@huawei.com
22 months agopowerpc/spufs: remove orphan declarations from spufs.h
Gaosheng Cui [Tue, 13 Sep 2022 07:50:22 +0000 (15:50 +0800)]
powerpc/spufs: remove orphan declarations from spufs.h

Remove the following orphan declarations from spufs.h:
1. spufs_coredump_calls has been removed since
commit 48cad41f7ee7 ("[POWERPC] spufs: Combine
spufs_coredump_calls with spufs_calls").

2. spufs_coredump_num_notes has been removed since
commit 936d5bf1d7dc ("[POWERPC] spufs: Get rid of spufs_coredump_num_notes,
it's not needed if we NULL terminate").

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-3-cuigaosheng1@huawei.com
22 months agopowerpc/xmon: remove unused ppc_parse_cpu() declaration
Gaosheng Cui [Tue, 13 Sep 2022 07:50:21 +0000 (15:50 +0800)]
powerpc/xmon: remove unused ppc_parse_cpu() declaration

ppc_parse_cpu() has been removed since
commit 5b102782c7f4 ("powerpc/xmon: Enable disassembly
files (compilation changes)"), so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220913075029.682327-2-cuigaosheng1@huawei.com
22 months agoRevert "powerpc/rtas: Implement reentrant rtas call"
Nathan Lynch [Wed, 7 Sep 2022 22:01:11 +0000 (17:01 -0500)]
Revert "powerpc/rtas: Implement reentrant rtas call"

At the time this was submitted by Leonardo, I confirmed -- or thought
I had confirmed -- with PowerVM partition firmware development that
the following RTAS functions:

- ibm,get-xive
- ibm,int-off
- ibm,int-on
- ibm,set-xive

were safe to call on multiple CPUs simultaneously, not only with
respect to themselves as indicated by PAPR, but with arbitrary other
RTAS calls:

https://lore.kernel.org/linuxppc-dev/875zcy2v8o.fsf@linux.ibm.com/

Recent discussion with firmware development makes it clear that this
is not true, and that the code in commit b664db8e3f97 ("powerpc/rtas:
Implement reentrant rtas call") is unsafe, likely explaining several
strange bugs we've seen in internal testing involving DLPAR and
LPM. These scenarios use ibm,configure-connector, whose internal state
can be corrupted by the concurrent use of the "reentrant" functions,
leading to symptoms like endless busy statuses from RTAS.

Fixes: b664db8e3f97 ("powerpc/rtas: Implement reentrant rtas call")
Cc: stable@vger.kernel.org # v5.8+
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Reviewed-by: Laurent Dufour <laurent.dufour@fr.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220907220111.223267-1-nathanl@linux.ibm.com
22 months agopowerpc/powernv: add missing of_node_put() in opal_export_attrs()
Zheng Yongjun [Tue, 6 Sep 2022 14:17:03 +0000 (14:17 +0000)]
powerpc/powernv: add missing of_node_put() in opal_export_attrs()

After using 'np' returned by of_find_node_by_path(), of_node_put()
need be called to decrease the refcount.

Fixes: 11fe909d2362 ("powerpc/powernv: Add OPAL exports attributes to sysfs")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220906141703.118192-1-zhengyongjun3@huawei.com
22 months agopowerpc/85xx: Fix fall-through warning for Clang
Gustavo A. R. Silva [Tue, 6 Sep 2022 21:32:13 +0000 (22:32 +0100)]
powerpc/85xx: Fix fall-through warning for Clang

Fix the following fallthrough warning:

arch/powerpc/platforms/85xx/mpc85xx_cds.c:161:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://github.com/KSPP/linux/issues/198
Link: https://lore.kernel.org/lkml/202209061224.KxORRGVg-lkp@intel.com/
Link: https://lore.kernel.org/r/Yxe8XTY5C9qJLd0Z@work
22 months agopowerpc/64s: add pte_needs_flush and huge_pmd_needs_flush
Nicholas Piggin [Thu, 1 Sep 2022 11:03:34 +0000 (21:03 +1000)]
powerpc/64s: add pte_needs_flush and huge_pmd_needs_flush

Allow PTE changes to avoid flushing the TLB when access permissions are
being relaxed, the dirty bit is being set, and the accessed bit is being
changed.

Relaxing access permissions and setting dirty and accessed bits do not
require a flush because the MMU will re-load the PTE and notice the
updates (it may also cause a spurious fault).

Clearing the accessed bit does not require a flush because of the
imprecise PTE accessed bit accounting that is already performed, as
documented in ptep_clear_flush_young().

This reduces TLB flushing for some mprotect(2) calls.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20220901110334.1618913-1-npiggin@gmail.com
22 months agopowerpc/math-emu: Inhibit W=1 warnings
Christophe Leroy [Wed, 7 Sep 2022 06:12:54 +0000 (08:12 +0200)]
powerpc/math-emu: Inhibit W=1 warnings

When building with W=1 you get:

arch/powerpc/math-emu/fre.c:6:5: error: no previous prototype for 'fre' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fsqrt.c:11:1: error: no previous prototype for 'fsqrt' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fsqrts.c:12:1: error: no previous prototype for 'fsqrts' [-Werror=missing-prototypes]
arch/powerpc/math-emu/frsqrtes.c:6:5: error: no previous prototype for 'frsqrtes' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mtfsf.c:10:1: error: no previous prototype for 'mtfsf' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mtfsfi.c:10:1: error: no previous prototype for 'mtfsfi' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fabs.c:7:1: error: no previous prototype for 'fabs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fadd.c:11:1: error: no previous prototype for 'fadd' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fadds.c:12:1: error: no previous prototype for 'fadds' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fcmpo.c:11:1: error: no previous prototype for 'fcmpo' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fcmpu.c:11:1: error: no previous prototype for 'fcmpu' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fcmpu.c:14:19: error: variable 'B_c' set but not used [-Werror=unused-but-set-variable]
arch/powerpc/math-emu/fcmpu.c:13:19: error: variable 'A_c' set but not used [-Werror=unused-but-set-variable]
arch/powerpc/math-emu/fctiw.c:11:1: error: no previous prototype for 'fctiw' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fctiwz.c:11:1: error: no previous prototype for 'fctiwz' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fdiv.c:11:1: error: no previous prototype for 'fdiv' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fdivs.c:12:1: error: no previous prototype for 'fdivs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmadd.c:11:1: error: no previous prototype for 'fmadd' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmadds.c:12:1: error: no previous prototype for 'fmadds' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmsub.c:11:1: error: no previous prototype for 'fmsub' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmsubs.c:12:1: error: no previous prototype for 'fmsubs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmul.c:11:1: error: no previous prototype for 'fmul' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmuls.c:12:1: error: no previous prototype for 'fmuls' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fnabs.c:7:1: error: no previous prototype for 'fnabs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fneg.c:7:1: error: no previous prototype for 'fneg' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fnmadd.c:11:1: error: no previous prototype for 'fnmadd' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fnmadds.c:12:1: error: no previous prototype for 'fnmadds' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fnmsub.c:11:1: error: no previous prototype for 'fnmsub' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fnmsubs.c:12:1: error: no previous prototype for 'fnmsubs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fres.c:7:1: error: no previous prototype for 'fres' [-Werror=missing-prototypes]
arch/powerpc/math-emu/frsp.c:12:1: error: no previous prototype for 'frsp' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fsel.c:11:1: error: no previous prototype for 'fsel' [-Werror=missing-prototypes]
arch/powerpc/math-emu/lfs.c:12:1: error: no previous prototype for 'lfs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/frsqrte.c:7:1: error: no previous prototype for 'frsqrte' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fsub.c:11:1: error: no previous prototype for 'fsub' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fsubs.c:12:1: error: no previous prototype for 'fsubs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mcrfs.c:10:1: error: no previous prototype for 'mcrfs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mffs.c:10:1: error: no previous prototype for 'mffs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mtfsb0.c:10:1: error: no previous prototype for 'mtfsb0' [-Werror=missing-prototypes]
arch/powerpc/math-emu/mtfsb1.c:10:1: error: no previous prototype for 'mtfsb1' [-Werror=missing-prototypes]
arch/powerpc/math-emu/stfiwx.c:7:1: error: no previous prototype for 'stfiwx' [-Werror=missing-prototypes]
arch/powerpc/math-emu/stfs.c:12:1: error: no previous prototype for 'stfs' [-Werror=missing-prototypes]
arch/powerpc/math-emu/fmr.c:7:1: error: no previous prototype for 'fmr' [-Werror=missing-prototypes]
arch/powerpc/math-emu/lfd.c:10:1: error: no previous prototype for 'lfd' [-Werror=missing-prototypes]
arch/powerpc/math-emu/stfd.c:7:1: error: no previous prototype for 'stfd' [-Werror=missing-prototypes]
arch/powerpc/math-emu/math_efp.c:177:5: error: no previous prototype for 'do_spe_mathemu' [-Werror=missing-prototypes]
arch/powerpc/math-emu/math_efp.c:726:5: error: no previous prototype for 'speround_handler' [-Werror=missing-prototypes]
arch/powerpc/math-emu/math_efp.c:893:12: error: no previous prototype for 'spe_mathemu_init' [-Werror=missing-prototypes]

Fix the warnings in math_efp.c by adding prototypes of do_spe_mathemu()
and speround_handler() to asm/processor.h and declare spe_mathemu_init()
static.

The other warnings are benign and not worth the churn of fixing them,
expecially the 'unused-but-set-variable' which would impact the core
part of 'math-emu'.

So silence them by adding -Wno-missing-prototypes -Wno-unused-but-set-variable.

But then you get:

arch/powerpc/math-emu/fre.c:6:5: error: no previous declaration for 'fre' [-Werror=missing-declarations]
arch/powerpc/math-emu/fsqrt.c:11:1: error: no previous declaration for 'fsqrt' [-Werror=missing-declarations]
arch/powerpc/math-emu/fsqrts.c:12:1: error: no previous declaration for 'fsqrts' [-Werror=missing-declarations]
arch/powerpc/math-emu/frsqrtes.c:6:5: error: no previous declaration for 'frsqrtes' [-Werror=missing-declarations]
arch/powerpc/math-emu/mtfsf.c:10:1: error: no previous declaration for 'mtfsf' [-Werror=missing-declarations]
arch/powerpc/math-emu/mtfsfi.c:10:1: error: no previous declaration for 'mtfsfi' [-Werror=missing-declarations]
arch/powerpc/math-emu/fabs.c:7:1: error: no previous declaration for 'fabs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fadd.c:11:1: error: no previous declaration for 'fadd' [-Werror=missing-declarations]
arch/powerpc/math-emu/fadds.c:12:1: error: no previous declaration for 'fadds' [-Werror=missing-declarations]
arch/powerpc/math-emu/fcmpo.c:11:1: error: no previous declaration for 'fcmpo' [-Werror=missing-declarations]
arch/powerpc/math-emu/fcmpu.c:11:1: error: no previous declaration for 'fcmpu' [-Werror=missing-declarations]
arch/powerpc/math-emu/fctiw.c:11:1: error: no previous declaration for 'fctiw' [-Werror=missing-declarations]
arch/powerpc/math-emu/fctiwz.c:11:1: error: no previous declaration for 'fctiwz' [-Werror=missing-declarations]
arch/powerpc/math-emu/fdiv.c:11:1: error: no previous declaration for 'fdiv' [-Werror=missing-declarations]
arch/powerpc/math-emu/fdivs.c:12:1: error: no previous declaration for 'fdivs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmadd.c:11:1: error: no previous declaration for 'fmadd' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmadds.c:12:1: error: no previous declaration for 'fmadds' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmsub.c:11:1: error: no previous declaration for 'fmsub' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmsubs.c:12:1: error: no previous declaration for 'fmsubs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmul.c:11:1: error: no previous declaration for 'fmul' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmuls.c:12:1: error: no previous declaration for 'fmuls' [-Werror=missing-declarations]
arch/powerpc/math-emu/fnabs.c:7:1: error: no previous declaration for 'fnabs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fneg.c:7:1: error: no previous declaration for 'fneg' [-Werror=missing-declarations]
arch/powerpc/math-emu/fnmadd.c:11:1: error: no previous declaration for 'fnmadd' [-Werror=missing-declarations]
arch/powerpc/math-emu/fnmadds.c:12:1: error: no previous declaration for 'fnmadds' [-Werror=missing-declarations]
arch/powerpc/math-emu/fnmsub.c:11:1: error: no previous declaration for 'fnmsub' [-Werror=missing-declarations]
arch/powerpc/math-emu/fnmsubs.c:12:1: error: no previous declaration for 'fnmsubs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fres.c:7:1: error: no previous declaration for 'fres' [-Werror=missing-declarations]
arch/powerpc/math-emu/frsp.c:12:1: error: no previous declaration for 'frsp' [-Werror=missing-declarations]
arch/powerpc/math-emu/fsel.c:11:1: error: no previous declaration for 'fsel' [-Werror=missing-declarations]
arch/powerpc/math-emu/lfs.c:12:1: error: no previous declaration for 'lfs' [-Werror=missing-declarations]
arch/powerpc/math-emu/frsqrte.c:7:1: error: no previous declaration for 'frsqrte' [-Werror=missing-declarations]
arch/powerpc/math-emu/fsub.c:11:1: error: no previous declaration for 'fsub' [-Werror=missing-declarations]
arch/powerpc/math-emu/fsubs.c:12:1: error: no previous declaration for 'fsubs' [-Werror=missing-declarations]
arch/powerpc/math-emu/mcrfs.c:10:1: error: no previous declaration for 'mcrfs' [-Werror=missing-declarations]
arch/powerpc/math-emu/mffs.c:10:1: error: no previous declaration for 'mffs' [-Werror=missing-declarations]
arch/powerpc/math-emu/mtfsb0.c:10:1: error: no previous declaration for 'mtfsb0' [-Werror=missing-declarations]
arch/powerpc/math-emu/mtfsb1.c:10:1: error: no previous declaration for 'mtfsb1' [-Werror=missing-declarations]
arch/powerpc/math-emu/stfiwx.c:7:1: error: no previous declaration for 'stfiwx' [-Werror=missing-declarations]
arch/powerpc/math-emu/stfs.c:12:1: error: no previous declaration for 'stfs' [-Werror=missing-declarations]
arch/powerpc/math-emu/fmr.c:7:1: error: no previous declaration for 'fmr' [-Werror=missing-declarations]
arch/powerpc/math-emu/lfd.c:10:1: error: no previous declaration for 'lfd' [-Werror=missing-declarations]
arch/powerpc/math-emu/stfd.c:7:1: error: no previous declaration for 'stfd' [-Werror=missing-declarations]

So also add -Wno-missing-declarations.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/688084b40b5ac88f2905cb207d5dad947d8d34dc.1662531153.git.christophe.leroy@csgroup.eu
22 months agopowerpc/pseries: Fix plpks crash on non-pseries
Michael Ellerman [Tue, 6 Sep 2022 23:37:17 +0000 (09:37 +1000)]
powerpc/pseries: Fix plpks crash on non-pseries

As reported[1] by Nathan, the recently added plpks driver will crash if
it's built into the kernel and booted on a non-pseries machine, eg
powernv:

  kernel BUG at arch/powerpc/kernel/syscall.c:39!
  Oops: Exception in kernel mode, sig: 5 [#1]
  LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA PowerNV
  ...
  NIP system_call_exception+0x90/0x3d0
  LR  system_call_common+0xec/0x250
  Call Trace:
    0xc0000000035c3e10 (unreliable)
    system_call_common+0xec/0x250
  --- interrupt: c00 at plpar_hcall+0x38/0x60
  NIP:  c0000000000e4300 LR: c00000000202945c CTR: 0000000000000000
  REGS: c0000000035c3e80 TRAP: 0c00   Not tainted  (6.0.0-rc4)
  MSR:  9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE>  CR: 28000284  XER: 00000000
  ...
  NIP plpar_hcall+0x38/0x60
  LR  pseries_plpks_init+0x64/0x23c
  --- interrupt: c00

On powernv Linux is the hypervisor, so a hypercall just ends up going to
the syscall path, which BUGs if the syscall (hypercall) didn't come from
userspace.

The fix is simply to not probe the plpks driver on non-pseries machines.

[1] https://lore.kernel.org/linuxppc-dev/Yxe06fbq18Wv9y3W@dev-arch.thelio-3990X/

Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Tested-by: Dan Horák <dan@danny.cz>
Reviewed-by: Dan Horák <dan@danny.cz>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20220907065038.1604504-1-mpe@ellerman.id.au
22 months agopowerpc/pasemi: Use of_root in pas_pci_init()
Michael Ellerman [Mon, 5 Sep 2022 04:56:37 +0000 (14:56 +1000)]
powerpc/pasemi: Use of_root in pas_pci_init()

Currently in pas_pci_init() a reference to the root node is leaked due
to a missing of_node_put(). Instead just use of_root directly.

Note that converting to of_find_compatible_node(NULL, ...) would
not be entirely equivalent, because that would check the compatible
property of the root node, whereas using of_root skips checking the root
node and start the search at the first child of the root.

Reported-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220906010313.1296714-1-mpe@ellerman.id.au
22 months agopowerpc/pasemi: Use strscpy instead of strlcpy
Russell Currey [Sat, 27 Aug 2022 06:39:46 +0000 (16:39 +1000)]
powerpc/pasemi: Use strscpy instead of strlcpy

find_i2c_driver() contained the last usage of strlcpy() in arch/powerpc.
The return value was used to check if strlen(src) >= n, for which
strscpy() returns -E2BIG.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220827063946.9073-1-ruscur@russell.cc
22 months agopowerpc/xive: fix repeated words in comments
Jilin Yuan [Wed, 31 Aug 2022 00:47:06 +0000 (08:47 +0800)]
powerpc/xive: fix repeated words in comments

Delete the redundant word 'set'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220831004706.35280-1-yuanjilin@cdjrlc.com
22 months agopowerpc/vas: fix repeated words in comments
Jilin Yuan [Wed, 31 Aug 2022 00:49:14 +0000 (08:49 +0800)]
powerpc/vas: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220831004914.37055-1-yuanjilin@cdjrlc.com
22 months agopowerpc/mobility: fix repeated words in comments
Jilin Yuan [Wed, 31 Aug 2022 00:51:09 +0000 (08:51 +0800)]
powerpc/mobility: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220831005109.38314-1-yuanjilin@cdjrlc.com
22 months agopowerpc/powermac/udbg_scc: Add missing of_node_put()s in udbg_scc_init()
Liang He [Sat, 16 Jul 2022 07:43:44 +0000 (15:43 +0800)]
powerpc/powermac/udbg_scc: Add missing of_node_put()s in udbg_scc_init()

During the iteration of for_each_child_of_node(), we need to call
of_node_put() for the old references stored in to 'ch_def' and 'ch_a'
as their refcounters have been increased in last iteration.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716074344.540049-1-windhl@126.com
22 months agopowerpc/powermac/pfunc_base: Add missing of_node_put() in macio_gpio_init_one()
Liang He [Sat, 16 Jul 2022 07:31:11 +0000 (15:31 +0800)]
powerpc/powermac/pfunc_base: Add missing of_node_put() in macio_gpio_init_one()

Call of_node_put() for the reference 'gparent' escaped out of the
previous for_each_child_of_node() as it has increased the refcount.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716073111.539739-1-windhl@126.com
22 months agopowerpc/powermac/low_i2c: Add missing of_node_put() in kw_i2c_probe()
Liang He [Sat, 16 Jul 2022 07:07:58 +0000 (15:07 +0800)]
powerpc/powermac/low_i2c: Add missing of_node_put() in kw_i2c_probe()

Call of_node_put() for the reference 'parent' returned by
of_get_parent() which has increased the refcount.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716070758.539434-1-windhl@126.com
22 months agopowerpc/powermac/feature: Add missing of_node_put()
Liang He [Sat, 16 Jul 2022 06:54:12 +0000 (14:54 +0800)]
powerpc/powermac/feature: Add missing of_node_put()

In probe_one_macio(), call of_node_put() for the refernece 'node'
escaped out of the for_each_node_by_name() which has increased its
refcount. While the 'node' will finally escaped into a global reference,
we should still call of_node_put() in fail path which will stop global
reference creation.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716065412.539153-1-windhl@126.com
22 months agopowerpc/pci-common: Fix refcount bug for 'phb->dn'
Liang He [Sat, 2 Jul 2022 02:29:36 +0000 (10:29 +0800)]
powerpc/pci-common: Fix refcount bug for 'phb->dn'

In pcibios_alloc_controller(), 'phb' is allocated and escaped into
global 'hose_list'. So we should call of_node_get() when a new reference
created into 'phb->dn'. And when phb is freed, we should call
of_node_put() on it.

NOTE: This function is called in the iteration of for_each_xx in
chrp_find_bridges() and pSeries_discover_phbs(). If there is no
of_node_get(), the object may be prematurely freed.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220702022936.266146-1-windhl@126.com
22 months agopowerpc/powernv: Add missing of_node_put()s
Liang He [Mon, 20 Jun 2022 13:25:53 +0000 (21:25 +0800)]
powerpc/powernv: Add missing of_node_put()s

In these driver init functions, there are two kinds of errors:

(1) missing of_put_node() for of_find_compatible_node()'s returned
    pointer (refcount incremented)  in fail path or when it is not
    used anymore.
(2) missing of_put_node() for 'for_each_xxx' loop's break

Signed-off-by: Liang He <windhl@126.com>
[mpe: Use out_put_xxx goto label naming]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620132553.4073863-1-windhl@126.com
22 months agopowerpc/fsl_pci: Remove of_node_put() when reference escaped out
Liang He [Wed, 20 Jul 2022 12:45:57 +0000 (20:45 +0800)]
powerpc/fsl_pci: Remove of_node_put() when reference escaped out

In fsl_pci_assign_primary(), we should remove the of_node_put()
when breaking out of the for_each_matching_node() as the 'np'
is escaped out by global 'fsl_pci_primary'.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220720124557.1256243-1-windhl@126.com
22 months agopowerpc/85xx: Add missing of_node_get/put() in ge_imp3a_pci_assign_primary()
Liang He [Fri, 1 Jul 2022 14:01:19 +0000 (22:01 +0800)]
powerpc/85xx: Add missing of_node_get/put() in ge_imp3a_pci_assign_primary()

for_each_node_by_type() will automatically increase and decrease
the refcount during the iteration. However, there is a reference
escaped into global 'fsl_pci_primary' and we need to handle it.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220701140119.245435-1-windhl@126.com
22 months agopowerpc/44x: Add of_node_put() when break out from for_each
Liang He [Fri, 1 Jul 2022 13:31:26 +0000 (21:31 +0800)]
powerpc/44x: Add of_node_put() when break out from for_each

In ppc47x_init_irq(), we need to call of_node_put() when there is
a break during the iteration of for_each_node_with_property() which
will automatically increase and decrease the refcount.

Signed-off-by: Liang He <windhl@126.com>
[mpe: mpic_alloc() takes its own reference]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220701133126.243102-1-windhl@126.com
22 months agopowerpc/pci_dn: Add missing of_node_put()
Liang He [Fri, 1 Jul 2022 13:17:50 +0000 (21:17 +0800)]
powerpc/pci_dn: Add missing of_node_put()

In pci_add_device_node_info(), use of_node_put() to drop the reference
to 'parent' returned by of_get_parent() to keep refcount balance.

Fixes: cca87d303c85 ("powerpc/pci: Refactor pci_dn")
Co-authored-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Link: https://lore.kernel.org/r/20220701131750.240170-1-windhl@126.com
22 months agopowerpc/pseries: Add missing of_node_put()s in hotplug-cpu.c
Liang He [Tue, 21 Jun 2022 11:17:01 +0000 (19:17 +0800)]
powerpc/pseries: Add missing of_node_put()s in hotplug-cpu.c

In pseries_cpuhp_cache_use_count() and pseries_cpuhp_detach_nodes(),
we need carefully hold the reference returned by
of_find_next_cache_node() and use it to call of_node_put() to keep
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220621111701.4082889-1-windhl@126.com
22 months agomacintosh: Add missing of_node_get() in do_attach()
Liang He [Wed, 22 Jun 2022 06:16:52 +0000 (14:16 +0800)]
macintosh: Add missing of_node_get() in do_attach()

We need a of_node_get() for of_find_compatible_node() to keep refcount
balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220622061652.4095330-1-windhl@126.com
22 months agopowerpc/83xx: Add missing of_node_put() in mpc832x_spi_init()
Liang He [Tue, 21 Jun 2022 08:09:32 +0000 (16:09 +0800)]
powerpc/83xx: Add missing of_node_put() in mpc832x_spi_init()

In mpc832x_spi_init(), hold the reference returned by
of_find_compatible_node() and use it to call of_node_put() for refcount
balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220621080932.4081935-1-windhl@126.com
22 months agopowerpc/512x: Add missing of_node_put() in clock-commonclk.c
Liang He [Tue, 21 Jun 2022 08:03:49 +0000 (16:03 +0800)]
powerpc/512x: Add missing of_node_put() in clock-commonclk.c

In mpc5121_clk_provide_migration_support(), hold the reference returned
by of_find_compatible_node() and use it to call of_node_put() for refcount
balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220621080349.4081689-1-windhl@126.com
22 months agopowerpc/powermac: Add missing of_node_put() in smp_core99_setup()
Liang He [Mon, 20 Jun 2022 15:05:18 +0000 (23:05 +0800)]
powerpc/powermac: Add missing of_node_put() in smp_core99_setup()

In smp_core99_setup(), add of_node_put() to drop the reference once it's
no longer needed.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620150518.4074910-1-windhl@126.com
22 months agopowerpc/sysdev/fsl_msi: Add missing of_node_put()
Liang He [Mon, 4 Jul 2022 14:52:33 +0000 (22:52 +0800)]
powerpc/sysdev/fsl_msi: Add missing of_node_put()

In fsl_setup_msi_irqs(), use of_node_put() to drop the reference
returned by of_parse_phandle().

Fixes: 895d603f945ba ("powerpc/fsl_msi: add support for the fsl, msi property in PCI nodes")
Co-authored-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220704145233.278539-1-windhl@126.com
22 months agopowerpc/sysdev: Add missing of_node_put()s
Liang He [Mon, 20 Jun 2022 13:02:21 +0000 (21:02 +0800)]
powerpc/sysdev: Add missing of_node_put()s

Add of_node_put() in various paths to drop references once they are no
longer needed.

Signed-off-by: Liang He <windhl@126.com>
[mpe: Rewrite change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620130221.4073228-1-windhl@126.com
22 months agopowerpc/embedded6xx/ls_uart: Add missing of_node_put()
Liang He [Mon, 20 Jun 2022 06:59:04 +0000 (14:59 +0800)]
powerpc/embedded6xx/ls_uart: Add missing of_node_put()

In ls_uarts_init(), add an of_node_put() to keep refcount balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620065904.4071787-1-windhl@126.com
22 months agopowerpc/pseries: Add missing of_node_put() in ibmebus
Liang He [Sun, 19 Jun 2022 07:40:16 +0000 (15:40 +0800)]
powerpc/pseries: Add missing of_node_put() in ibmebus

In ibmebus_match_path(), use of_node_put() to drop the reference
returned by of_find_node_by_path() before testing for equality of the
pointers.

Signed-off-by: Liang He <windhl@126.com>
[mpe: Rewrite change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220619074016.4068105-1-windhl@126.com
22 months agopowerpc/cell: Add missing of_node_put() in iommu.c
Liang He [Fri, 1 Jul 2022 14:49:49 +0000 (22:49 +0800)]
powerpc/cell: Add missing of_node_put() in iommu.c

In cell_iommu_init_disabled(), hold the reference returned by
of_find_node_by_name() and use it to call of_node_put() for reference
balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220701144949.252364-2-windhl@126.com
22 months agopowerpc/cell: Add missing of_node_put()s in cbe_regs.c
Liang He [Fri, 1 Jul 2022 14:49:48 +0000 (22:49 +0800)]
powerpc/cell: Add missing of_node_put()s in cbe_regs.c

There are several bugs as following:

(1) In cbe_get_be_node(), hold the reference returned by of_find_xxx and
    of_get_xxx OF APIs and use it to call of_node_put().
(2) In cbe_fill_regs_map(), same as above.
(3) In cbe_regs_init(), during the iteration of for_each_node_by_type(),
    the refcount of 'cpu' will be automatically increased and decreased.
    However, there is a reference escaped out into 'map->cpu_node' and
    it should be properly handled.

Signed-off-by: Liang He <windhl@126.com>
[mpe: Drop references before pointer equality test in cbe_get_be_node()]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220701144949.252364-1-windhl@126.com
22 months agopowerpc/cell: Add missing of_node_put()s
Liang He [Sun, 19 Jun 2022 07:23:35 +0000 (15:23 +0800)]
powerpc/cell: Add missing of_node_put()s

Use of_node_put() for of_find_node_by_path() and
of_find_node_by_phandle() to keep refcount balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220619072335.4067728-1-windhl@126.com
22 months agopowerpc/kernel: Add missing of_node_put() in legacy_serial.c
Liang He [Sun, 19 Jun 2022 07:08:11 +0000 (15:08 +0800)]
powerpc/kernel: Add missing of_node_put() in legacy_serial.c

In find_legacy_serial_ports(), of_find_node_by_path() will return a node
pointer with refcount incremented. The reference should be dropped with
of_node_put() when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220619070811.4067215-1-windhl@126.com
22 months agopowerpc/perf: Add missing of_node_put()s in imc-pmu.c
Liang He [Sat, 18 Jun 2022 07:13:53 +0000 (15:13 +0800)]
powerpc/perf: Add missing of_node_put()s in imc-pmu.c

In update_events_in_group(), of_find_node_by_phandle() will return
a node pointer with refcount incremented. The reference should be
dropped with of_node_put() in the failure path or when it is not used
anymore.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20220618071353.4059000-1-windhl@126.com
22 months agopowerpc/embedded6xx: Add missing of_node_put()s
Liang He [Sat, 18 Jun 2022 04:10:42 +0000 (12:10 +0800)]
powerpc/embedded6xx: Add missing of_node_put()s

Add missing of_node_put()s in various paths.

Signed-off-by: Liang He <windhl@126.com>
[mpe: Rewrite change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220618041042.4058066-1-windhl@126.com
22 months agopowerpc/8xx: Add missing of_node_put() in tqm8xx_setup.c
Liang He [Sat, 18 Jun 2022 02:49:30 +0000 (10:49 +0800)]
powerpc/8xx: Add missing of_node_put() in tqm8xx_setup.c

In init_ioports(), of_find_node_by_name() will return a node pointer
with refcount incremented. The reference should be dropped with
of_node_put() when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220618024930.4056825-1-windhl@126.com
22 months agopowerpc/maple: Add missing of_node_put() in time.c
Liang He [Fri, 17 Jun 2022 12:40:45 +0000 (20:40 +0800)]
powerpc/maple: Add missing of_node_put() in time.c

In maple_get_boot_time(), of_find_compatible_node() will return
a node pointer with refcount incremented. The reference should be
dropped with of_node_put() when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220617124045.4048757-1-windhl@126.com
22 months agopowerpc/85xx: Add missing of_node_put() in sgy_cst1000
Liang He [Fri, 17 Jun 2022 10:50:11 +0000 (18:50 +0800)]
powerpc/85xx: Add missing of_node_put() in sgy_cst1000

In gpio_halt_probe(), of_find_matching_node() will return a node
pointer with refcount incremented. The reference should be dropped with
of_node_put() in the failure path.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220617105011.4041123-1-windhl@126.com
22 months agopowerpc/52xx: Add missing of_node_put() in media5200.c
Liang He [Thu, 16 Jun 2022 14:40:07 +0000 (22:40 +0800)]
powerpc/52xx: Add missing of_node_put() in media5200.c

In media5200_init_irq(), of_find_compatible_node() will return a
node pointer with refcount incremented. The reference should be dropped
with of_node_put() in the failure path or when it is not used anymore.

Don't worry about 'fpga_np == NULL' as of_node_put() can correctly
handle that.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220616144007.3987743-1-windhl@126.com
22 months agopowerpc/85xx: Add missing of_node_put() in ksi8560.c
Liang He [Thu, 16 Jun 2022 13:29:22 +0000 (21:29 +0800)]
powerpc/85xx: Add missing of_node_put() in ksi8560.c

In ksi8560_setup_arch(), of_find_compatible_node() will return a
node pointer with refcount incremented. The reference should be dropped
with of_node_put() when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220616132922.3987053-1-windhl@126.com
22 months agopowerpc/512x: Add missing of_node_put() in mpc5121_clk_init()
Liang He [Wed, 15 Jun 2022 14:37:03 +0000 (22:37 +0800)]
powerpc/512x: Add missing of_node_put() in mpc5121_clk_init()

In mpc5121_clk_init(), of_find_compatible_node() will return a
node pointer with refcount incremented. The reference should be dropped
with of_node_put() when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
[mpe: of_clk_add_provider() will take its own reference.]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220615143703.3968898-1-windhl@126.com
22 months agopowerpc/vdso: link with -z noexecstack
Christophe Leroy [Fri, 2 Sep 2022 15:25:24 +0000 (17:25 +0200)]
powerpc/vdso: link with -z noexecstack

With recent binutils, the following warning appears:

  VDSO32L arch/powerpc/kernel/vdso/vdso32.so.dbg
/opt/gcc-12.2.0-nolibc/powerpc64-linux/bin/../lib/gcc/powerpc64-linux/12.2.0/../../../../powerpc64-linux/bin/ld: warning: arch/powerpc/kernel/vdso/getcpu-32.o: missing .note.GNU-stack section implies executable stack
/opt/gcc-12.2.0-nolibc/powerpc64-linux/bin/../lib/gcc/powerpc64-linux/12.2.0/../../../../powerpc64-linux/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

To avoid that, explicitly tell the linker we don't want executable
stack.

For more explanations, see commit ffcf9c5700e4 ("x86: link vdso
and boot with -z noexecstack --no-warn-rwx-segments")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b95f2e3216a574837dd61208444e9515c3423da4.1662132312.git.christophe.leroy@csgroup.eu
22 months agopowerpc/math-emu: Remove -w build flag and fix warnings
Christophe Leroy [Fri, 2 Sep 2022 16:00:09 +0000 (18:00 +0200)]
powerpc/math-emu: Remove -w build flag and fix warnings

As reported by Nathan, the module_init() macro was not taken into
account because the header was missing. That means spe_mathemu_init()
was never called.

This should have been detected by gcc at build time, but due to
'-w' flag it went undetected.

Removing that flag leads to many warnings hence errors.

Fix those warnings then remove the -w flag.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/2663961738a46073713786d4efeb53100ca156e7.1662134272.git.christophe.leroy@csgroup.eu
22 months agopowerpc/math_emu/efp: Include module.h
Nathan Chancellor [Fri, 2 Sep 2022 16:00:08 +0000 (18:00 +0200)]
powerpc/math_emu/efp: Include module.h

When building with a recent version of clang, there are a couple of
errors around the call to module_init():

  arch/powerpc/math-emu/math_efp.c:927:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
  module_init(spe_mathemu_init);
  ^
  int
  arch/powerpc/math-emu/math_efp.c:927:13: error: a parameter list without types is only allowed in a function definition
  module_init(spe_mathemu_init);
              ^
  2 errors generated.

module_init() is a macro, which is not getting expanded because module.h
is not included in this file. Add the include so that the macro can
expand properly, clearing up the build failure.

Fixes: ac6f120369ff ("powerpc/85xx: Workaroudn e500 CPU erratum A005")
[chleroy: added fixes tag]
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/8403854a4c187459b2f4da3537f51227b70b9223.1662134272.git.christophe.leroy@csgroup.eu
22 months agopowerpc/pseries: Move dtl scanning and steal time accounting to pseries platform
Nicholas Piggin [Fri, 2 Sep 2022 08:53:16 +0000 (18:53 +1000)]
powerpc/pseries: Move dtl scanning and steal time accounting to pseries platform

dtl is the PAPR Dispatch Trace Log, which is entirely a pseries feature.
The pseries platform alrady has a file dealing with the dtl, so move
scanning for stolen time accounting there from kernel/time.c.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220902085316.2071519-5-npiggin@gmail.com
22 months agopowerpc/64: Remove PPC64 special case for cputime accounting default
Nicholas Piggin [Fri, 2 Sep 2022 08:53:15 +0000 (18:53 +1000)]
powerpc/64: Remove PPC64 special case for cputime accounting default

Distro kernels tend to be moving to VIRT_CPU_ACCOUNTING_GEN, and there
is not much reason why PPC64 should be special here. Remove the special
case and make the ppc64 and pseries defconfigs use GEN accounting
(others will use TICK, as-per Kconfig defaults).

VIRT_CPU_ACCOUNTING_NATIVE does provide scaled vtime and stolen time
apportioned between system and user time, and vtime accounting is not
unconditionally enabled, and possibly other things. But it would be
better at this point to extend GEN to cover important missing features
rather than directing users back to a less used option.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220902085316.2071519-4-npiggin@gmail.com
22 months agopowerpc/pseries: Implement CONFIG_PARAVIRT_TIME_ACCOUNTING
Nicholas Piggin [Fri, 2 Sep 2022 08:53:14 +0000 (18:53 +1000)]
powerpc/pseries: Implement CONFIG_PARAVIRT_TIME_ACCOUNTING

CONFIG_VIRT_CPU_ACCOUNTING_GEN under pseries does not provide stolen
time accounting unless CONFIG_PARAVIRT_TIME_ACCOUNTING is enabled.
Implement this using the VPA accumulated wait counters.

Note this will not work on current KVM hosts because KVM does not
implement the VPA dispatch counters (yet). It could be implemented
with the dispatch trace log as it is for VIRT_CPU_ACCOUNTING_NATIVE,
but that is not necessary for the more limited accounting provided
by PARAVIRT_TIME_ACCOUNTING, and it is more expensive, complex, and
has downsides like potential log wrap.

From Shrikanth:

  [...] it was tested on Power10 [PowerVM] Shared LPAR. system has two
  LPAR. we will call first one LPAR1 and second one as LPAR2. Test was
  carried out in SMT=1. Similar observation was seen in SMT=8 as well.

  LPAR config header from each LPAR is below. LPAR1 is twice as big as
  LPAR2. Since Both are sharing the same underlying hardware, work
  stealing will happen when both the LPAR's are contending for the same
  resource.

  LPAR1:
  type=Shared mode=Uncapped smt=Off lcpu=40 cpus=40 ent=20.00
  LPAR2:
  type=Shared mode=Uncapped smt=Off lcpu=20 cpus=40 ent=10.00

  mpstat was used to check for the utilization. stress-ng has been used
  as the workload. Few cases are tested. when the both LPAR are idle
  there is no steal time. when LPAR1 starts running at 100% which
  consumes all of the physical resource, steal time starts to get
  accounted.  With LPAR1 running at 100% and LPAR2 starts running, steal
  time starts increasing. This is as expected. When the LPAR2 Load is
  increased further, steal time increases further.

  Case 1: 0% LPAR1; 0% LPAR2
   %usr  %nice   %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
   0.00   0.00   0.05   0.00   0.00   0.00   0.00   0.00   0.00  99.95

  Case 2: 100% LPAR1; 0% LPAR2
   %usr  %nice   %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
  97.68   0.00   0.00   0.00   0.00   0.00   2.32   0.00   0.00   0.00

  Case 3: 100% LPAR1; 50% LPAR2
   %usr  %nice   %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
  86.34   0.00   0.10   0.00   0.00   0.03  13.54   0.00   0.00   0.00

  Case 4: 100% LPAR1; 100% LPAR2
   %usr  %nice   %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
  78.54   0.00   0.07   0.00   0.00   0.02  21.36   0.00   0.00   0.00

  Case 5: 50% LPAR1; 100% LPAR2
   %usr  %nice   %sys %iowait  %irq  %soft %steal %guest %gnice  %idle
  49.37   0.00   0.00   0.00   0.00   0.00   1.17   0.00   0.00  49.47

  Patch is accounting for the steal time and basic tests are holding
  good.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com>
[mpe: Add SPDX tag to new paravirt_api_clock.h]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220902085316.2071519-3-npiggin@gmail.com
22 months agopowerpc/pseries: Add wait interval counter definitions to struct lppaca
Nicholas Piggin [Fri, 2 Sep 2022 08:53:13 +0000 (18:53 +1000)]
powerpc/pseries: Add wait interval counter definitions to struct lppaca

The hypervisor exposes accumulated partition scheduling interval times
in the VPA (lppaca). These can be used to implement a simple stolen time
in the guest without complex and costly dtl scanning.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Link: https://lore.kernel.org/r/20220902085316.2071519-2-npiggin@gmail.com
22 months agoselftests/powerpc: Skip 4PB test on 4K PAGE_SIZE systems
Michael Ellerman [Thu, 1 Sep 2022 02:02:15 +0000 (12:02 +1000)]
selftests/powerpc: Skip 4PB test on 4K PAGE_SIZE systems

Systems using the hash MMU with a 4K page size don't support 4PB address
space, so skip the test because the bug it tests for can't be triggered.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220901020215.254097-1-mpe@ellerman.id.au
22 months agopowerpc/configs: Properly enable PAPR_SCM in pseries_defconfig
Michael Ellerman [Thu, 1 Sep 2022 01:42:53 +0000 (11:42 +1000)]
powerpc/configs: Properly enable PAPR_SCM in pseries_defconfig

My commit to add PAPR_SCM to pseries_defconfig failed to add the
required dependencies, meaning the driver doesn't get built.

Add the required LIBNVDIMM=m.

Fixes: d6481a7195df ("powerpc/configs: Add PAPR_SCM to pseries_defconfig")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220901014253.252927-1-mpe@ellerman.id.au
22 months agopowerpc/papr_scm: Ensure rc is always initialized in papr_scm_pmu_register()
Nathan Chancellor [Tue, 30 Aug 2022 15:12:56 +0000 (08:12 -0700)]
powerpc/papr_scm: Ensure rc is always initialized in papr_scm_pmu_register()

Clang warns:

  arch/powerpc/platforms/pseries/papr_scm.c:492:6: warning: variable 'rc' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
          if (!p->stat_buffer_len)
              ^~~~~~~~~~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:523:64: note: uninitialized use occurs here
          dev_info(&p->pdev->dev, "nvdimm pmu didn't register rc=%d\n", rc);
                                                                        ^~
  include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
          dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                          ^~~~~~~~~~~
  include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                  _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                      ^~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:492:2: note: remove the 'if' if its condition is always false
          if (!p->stat_buffer_len)
          ^~~~~~~~~~~~~~~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:484:8: note: initialize the variable 'rc' to silence this warning
          int rc, nodeid;
                ^
                = 0
  1 warning generated.

The call to papr_scm_pmu_check_events() was eliminated but a return code
was not added to the if statement. Add the same return code from
papr_scm_pmu_check_events() for this condition so there is no more
warning.

Fixes: 9b1ac04698a4 ("powerpc/papr_scm: Fix nvdimm event mappings")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://github.com/ClangBuiltLinux/linux/issues/1701
Link: https://lore.kernel.org/r/20220830151256.1473169-1-nathan@kernel.org
22 months agoRevert "powerpc/irq: Don't open code irq_soft_mask helpers"
Michael Ellerman [Wed, 31 Aug 2022 13:10:52 +0000 (23:10 +1000)]
Revert "powerpc/irq: Don't open code irq_soft_mask helpers"

This reverts commit ef5b570d3700fbb8628a58da0487486ceeb713cd.

Zhouyi reported that commit is causing crashes when running rcutorture
with KASAN enabled:

  BUG: using smp_processor_id() in preemptible [00000000] code: rcu_torture_rea/100
  caller is rcu_preempt_deferred_qs_irqrestore+0x74/0xed0
  CPU: 4 PID: 100 Comm: rcu_torture_rea Tainted: G        W          5.19.0-rc5-next-20220708-dirty #253
  Call Trace:
    dump_stack_lvl+0xbc/0x108 (unreliable)
    check_preemption_disabled+0x154/0x160
    rcu_preempt_deferred_qs_irqrestore+0x74/0xed0
    __rcu_read_unlock+0x290/0x3b0
    rcu_torture_read_unlock+0x30/0xb0
    rcutorture_one_extend+0x198/0x810
    rcu_torture_one_read+0x58c/0xc90
    rcu_torture_reader+0x12c/0x360
    kthread+0x1e8/0x220
    ret_from_kernel_thread+0x5c/0x64

KASAN will generate instrumentation instructions around the
WRITE_ONCE(local_paca->irq_soft_mask, mask):

   0xc000000000295cb0 <+0>: addis   r2,r12,774
   0xc000000000295cb4 <+4>: addi    r2,r2,16464
   0xc000000000295cb8 <+8>: mflr    r0
   0xc000000000295cbc <+12>: bl      0xc00000000008bb4c <mcount>
   0xc000000000295cc0 <+16>: mflr    r0
   0xc000000000295cc4 <+20>: std     r31,-8(r1)
   0xc000000000295cc8 <+24>: addi    r3,r13,2354
   0xc000000000295ccc <+28>: mr      r31,r13
   0xc000000000295cd0 <+32>: std     r0,16(r1)
   0xc000000000295cd4 <+36>: stdu    r1,-48(r1)
   0xc000000000295cd8 <+40>: bl      0xc000000000609b98 <__asan_store1+8>
   0xc000000000295cdc <+44>: nop
   0xc000000000295ce0 <+48>: li      r9,1
   0xc000000000295ce4 <+52>: stb     r9,2354(r31)
   0xc000000000295ce8 <+56>: addi    r1,r1,48
   0xc000000000295cec <+60>: ld      r0,16(r1)
   0xc000000000295cf0 <+64>: ld      r31,-8(r1)
   0xc000000000295cf4 <+68>: mtlr    r0

If there is a context switch before "stb     r9,2354(r31)", r31 may
not equal to r13, in such case, irq soft mask will not work.

The usual solution of marking the code ineligible for instrumentation
forces the code out-of-line, which we would prefer to avoid. Christophe
proposed a partial revert, but Nick raised some concerns with that. So
for now do a full revert.

Reported-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
[mpe: Construct change log based on Zhouyi's original report]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220831131052.42250-1-mpe@ellerman.id.au
22 months agopowerpc/32: Remove wii_memory_fixups()
Christophe Leroy [Wed, 31 Aug 2022 09:32:09 +0000 (11:32 +0200)]
powerpc/32: Remove wii_memory_fixups()

wii_memory_fixups() is not called anymore, remove it.

Also remove left-overs in mmu_decl.h which were forgotten by
commit 160985f3025b ("powerpc/wii: remove wii_mmu_mapin_mem2()")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/5f2091f86528b59ef92ef1daed5d3dd8c0d7bebd.1661938317.git.christophe.leroy@csgroup.eu
22 months agopowerpc/32: Allow fragmented physical memory
Christophe Leroy [Wed, 31 Aug 2022 09:32:08 +0000 (11:32 +0200)]
powerpc/32: Allow fragmented physical memory

Since commit 9e849f231c3c ("powerpc/mm/32s: use generic mmu_mapin_ram()
for all blocks.") it is possible to map all blocks as RAM on any PPC32.

Remove related restrictions.

And remove call to wii_memory_fixups() which doesn't do anything else
than checks since commit 160985f3025b ("powerpc/wii: remove
wii_mmu_mapin_mem2()")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/fc9a5b8ef49f6eb86e970d4c7ccfba9b407fd4eb.1661938317.git.christophe.leroy@csgroup.eu
22 months agopowerpc/32: Drop a stale comment about reservation of gigantic pages
Christophe Leroy [Wed, 31 Aug 2022 09:32:07 +0000 (11:32 +0200)]
powerpc/32: Drop a stale comment about reservation of gigantic pages

A comment about the reservation of gigantic pages was left in MMU_init()
after commit 79cc38ded1e1 ("powerpc/mm/hugetlb: Add support for
reserving gigantic huge pages via kernel command line")

Remove it.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/959d77be630b9b46a7458f0fbd41dc3a94ec811a.1661938317.git.christophe.leroy@csgroup.eu
22 months agopowerpc/code-patching: Speed up page mapping/unmapping
Christophe Leroy [Mon, 15 Aug 2022 11:48:40 +0000 (21:48 +1000)]
powerpc/code-patching: Speed up page mapping/unmapping

Since commit 591b4b268435 ("powerpc/code-patching: Pre-map patch area")
the patch area is premapped so intermediate page tables are already
allocated.

Use __set_pte_at() directly instead of the heavy map_kernel_page(),
at for unmapping just do a pte_clear() followed by a flush.

__set_pte_at() can be used directly without the filters in
set_pte_at() because we are mapping a normal page non executable.

Make sure gcc knows text_poke_area is page aligned in order to
optimise the flush.

This change reduces by 66% the time needed to activate ftrace on
an 8xx (588000 tb ticks instead of 1744000).

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Add ptesync needed on radix to avoid spurious fault]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220815114840.1468656-1-mpe@ellerman.id.au
22 months agopowerpc: Fix hard_irq_disable() with sanitizer
Christophe Leroy [Tue, 23 Aug 2022 16:36:35 +0000 (18:36 +0200)]
powerpc: Fix hard_irq_disable() with sanitizer

As reported by Zhouyi Zhou, WRITE_ONCE() is not atomic
as expected when KASAN or KCSAN are compiled in.

Fix it by re-implementing it using inline assembly.

Fixes: 077fc62b2b66 ("powerpc/irq: remove inline assembly in hard_irq_disable macro")
Reported-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a8298991b3df049a54ee8e558838e34265812014.1661272586.git.christophe.leroy@csgroup.eu
22 months agopowerpc/82xx: remove spidev node from mgcoge
Wolfram Sang [Wed, 24 Aug 2022 08:21:29 +0000 (10:21 +0200)]
powerpc/82xx: remove spidev node from mgcoge

Commit 956b200a846e ("spi: spidev: Warn loudly if instantiated from DT
as "spidev"") states that there should not be spidev nodes in DTs.
Remove this non-HW description. There won't be a regression because it
won't bind since 2015 anyhow.

Fixes: 5d1d67e361ea ("powerpc/82xx: add SPI support for mgcoge")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220824082130.21934-3-wsa+renesas@sang-engineering.com
22 months agopowerpc/microwatt: Add LiteX MMC driver
Joel Stanley [Thu, 4 Aug 2022 01:57:08 +0000 (11:27 +0930)]
powerpc/microwatt: Add LiteX MMC driver

Enable the LiteX MMC device and it's dependency the common clock
framework.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220804015708.5928-1-joel@jms.id.au
22 months agoselftests/powerpc: Add a test for execute-only memory
Nicholas Miehlbradt [Wed, 17 Aug 2022 05:06:40 +0000 (15:06 +1000)]
selftests/powerpc: Add a test for execute-only memory

This selftest is designed to cover execute-only protections
on the Radix MMU but will also work with Hash.

The tests are based on those found in pkey_exec_test with modifications
to use the generic mprotect() instead of the pkey variants.

Signed-off-by: Nicholas Miehlbradt <nicholas@linux.ibm.com>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220817050640.406017-2-ruscur@russell.cc
22 months agopowerpc/mm: Support execute-only memory on the Radix MMU
Russell Currey [Wed, 17 Aug 2022 05:06:39 +0000 (15:06 +1000)]
powerpc/mm: Support execute-only memory on the Radix MMU

Add support for execute-only memory (XOM) for the Radix MMU by using an
execute-only mapping, as opposed to the RX mapping used by powerpc's
other MMUs.

The Hash MMU already supports XOM through the execute-only pkey,
which is a separate mechanism shared with x86.  A PROT_EXEC-only mapping
will map to RX, and then the pkey will be applied on top of it.

mmap() and mprotect() consumers in userspace should observe the same
behaviour on Hash and Radix despite the differences in implementation.

Replacing the vma_is_accessible() check in access_error() with a read
check should be functionally equivalent for non-Radix MMUs, since it
follows write and execute checks.  For Radix, the change enables
detecting faults on execute-only mappings where vma_is_accessible() would
return true.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220817050640.406017-1-ruscur@russell.cc
22 months agomacintosh: move from strlcpy with unused retval to strscpy
Wolfram Sang [Thu, 18 Aug 2022 21:00:26 +0000 (23:00 +0200)]
macintosh: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Link: https://lore.kernel.org/r/20220818210026.6940-1-wsa+renesas@sang-engineering.com
22 months agopowerpc: move from strlcpy with unused retval to strscpy
Wolfram Sang [Thu, 18 Aug 2022 20:59:46 +0000 (22:59 +0200)]
powerpc: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Link: https://lore.kernel.org/r/20220818205946.6336-1-wsa+renesas@sang-engineering.com
22 months agopowerpc/fsl_booke: Make calc_cam_sz() static
Christophe Leroy [Fri, 19 Aug 2022 14:26:49 +0000 (16:26 +0200)]
powerpc/fsl_booke: Make calc_cam_sz() static

calc_cam_sz() is used only in fsl_book3e.c, make it static.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a7469848371b2cf5e8f654ec79800e209d88595e.1660919200.git.christophe.leroy@csgroup.eu
22 months agopowerpc: Remove stale declarations in mmu_decl.h
Christophe Leroy [Fri, 19 Aug 2022 14:23:43 +0000 (16:23 +0200)]
powerpc: Remove stale declarations in mmu_decl.h

rtas_size and rtas_data are not used anymore since at least
commit 7c8c6b9776fb ("powerpc: Merge lmb.c and make MM initialization
use it.")

Remove them.

Since commit 4b74a35fc7e9 ("powerpc/32s: Make Hash var static")
the forward declaration of struct hash_pte is unneeded.

Remove it.

__initial_memory_limit_addr was removed by commit e63075a3c937 ("memblock:
Introduce default allocation limit and use it to replace explicit ones")

Remove the declaration.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a821e8397dd56b8177ecc04966d3b3a7c4bda6d4.1660919016.git.christophe.leroy@csgroup.eu
22 months agopowerpc: Update ISA versions to mention e5500/e6500
Michael Ellerman [Wed, 3 Aug 2022 06:32:28 +0000 (16:32 +1000)]
powerpc: Update ISA versions to mention e5500/e6500

Add the NXP (nee Freescale) e5500 and e6500 to the ISA versions
documentation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220803063228.1250030-1-mpe@ellerman.id.au
22 months agopowerpc: Move patch sites out of asm-prototypes.h
Michael Ellerman [Thu, 18 Aug 2022 05:06:59 +0000 (15:06 +1000)]
powerpc: Move patch sites out of asm-prototypes.h

The definitions for the patch sites etc. don't belong in
asm-prototypes.h, they are not EXPORT'ed asm symbols.

Move them into sections.h which is traditionally used for asm symbols.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220818050659.187181-1-mpe@ellerman.id.au
22 months agopowerpc/boot: Drop unused dummy.c
Michael Ellerman [Fri, 19 Aug 2022 11:05:56 +0000 (21:05 +1000)]
powerpc/boot: Drop unused dummy.c

The last use of dummy.c was dropped in commit 2bf118197cb4 ("[POWERPC]
Create a "wrapper" script and use it in arch/powerpc/boot").

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220819110556.434970-1-mpe@ellerman.id.au
22 months agopowerpc/boot: Convert more files to use SPDX tags
Michael Ellerman [Fri, 19 Aug 2022 11:04:30 +0000 (21:04 +1000)]
powerpc/boot: Convert more files to use SPDX tags

These files are all plain GPL 2.0, with a second sentence about being
licensed as-is.

Similar to the rule in commit 577b61cee5b2 ("treewide: Replace GPLv2
boilerplate/reference with SPDX - gpl-2.0_398.RULE").

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220819110430.433984-1-mpe@ellerman.id.au
22 months agopowerpc/rtas: Fix RTAS MSR[HV] handling for Cell
Michael Ellerman [Tue, 23 Aug 2022 11:59:52 +0000 (21:59 +1000)]
powerpc/rtas: Fix RTAS MSR[HV] handling for Cell

The semi-recent changes to MSR handling when entering RTAS (firmware)
cause crashes on IBM Cell machines. An example trace:

  kernel tried to execute user page (2fff01a8) - exploit attempt? (uid: 0)
  BUG: Unable to handle kernel instruction fetch
  Faulting instruction address: 0x2fff01a8
  Oops: Kernel access of bad area, sig: 11 [#1]
  BE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=4 NUMA Cell
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W          6.0.0-rc2-00433-gede0a8d3307a #207
  NIP:  000000002fff01a8 LR: 0000000000032608 CTR: 0000000000000000
  REGS: c0000000015236b0 TRAP: 0400   Tainted: G        W           (6.0.0-rc2-00433-gede0a8d3307a)
  MSR:  0000000008001002 <ME,RI>  CR: 00000000  XER: 20000000
  ...
  NIP 0x2fff01a8
  LR  0x32608
  Call Trace:
    0xc00000000143c5f8 (unreliable)
    .rtas_call+0x224/0x320
    .rtas_get_boot_time+0x70/0x150
    .read_persistent_clock64+0x114/0x140
    .read_persistent_wall_and_boot_offset+0x24/0x80
    .timekeeping_init+0x40/0x29c
    .start_kernel+0x674/0x8f0
    start_here_common+0x1c/0x50

Unlike PAPR platforms where RTAS is only used in guests, on the IBM Cell
machines Linux runs with MSR[HV] set but also uses RTAS, provided by
SLOF.

Fix it by copying the MSR[HV] bit from the MSR value we've just read
using mfmsr into the value used for RTAS.

It seems like we could also fix it using an #ifdef CELL to set MSR[HV],
but that doesn't work because it's possible to build a single kernel
image that runs on both Cell native and pseries.

Fixes: b6b1c3ce06ca ("powerpc/rtas: Keep MSR[RI] set when calling RTAS")
Cc: stable@vger.kernel.org # v5.19+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Jordan Niethe <jniethe5@gmail.com>
Link: https://lore.kernel.org/r/20220823115952.1203106-2-mpe@ellerman.id.au
22 months agoRevert "powerpc: Remove unused FW_FEATURE_NATIVE references"
Michael Ellerman [Tue, 23 Aug 2022 11:59:51 +0000 (21:59 +1000)]
Revert "powerpc: Remove unused FW_FEATURE_NATIVE references"

This reverts commit 79b74a68486765a4fe685ac4069bc71366c538f5.

It broke booting on IBM Cell machines when the kernel is also built with
CONFIG_PPC_PS3=y.

That's because FW_FEATURE_NATIVE_ALWAYS = 0 does have an important
effect, which is to clear the PS3 ALWAYS features from
FW_FEATURE_ALWAYS.

Note that CONFIG_PPC_NATIVE has since been renamed
CONFIG_PPC_HASH_MMU_NATIVE.

Fixes: 79b74a684867 ("powerpc: Remove unused FW_FEATURE_NATIVE references")
Cc: stable@vger.kernel.org # v5.17+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220823115952.1203106-1-mpe@ellerman.id.au
22 months agopowerpc: align syscall table for ppc32
Masahiro Yamada [Sat, 20 Aug 2022 16:51:29 +0000 (01:51 +0900)]
powerpc: align syscall table for ppc32

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link
symbol CRCs at final link,  removing CONFIG_MODULE_REL_CRCS") broke
mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

    LD      vmlinux
    SYSMAP  System.map
    SORTTAB vmlinux
    CHKREL  vmlinux
  WARNING: 451 bad relocations
  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by
arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

  $ powerpc-linux-gnu-nm -n vmlinux
    ...
  c0b31258 d spe_aligninfo
  c0b31298 d __func__.0
  c0b312a9 D sys_call_table
  c0b319b8 d __func__.0

Commit 7b4537199a4a is not the root cause. Even before that, I can
reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

It is just that nobody noticed because when CONFIG_MODVERSIONS is
enabled, a __crc_* symbol inserted before sys_call_table was hiding the
unalignment issue.

Adding alignment to the syscall table for ppc32 fixes the issue.

Cc: stable@vger.kernel.org
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Trim change log discussion, add Cc stable]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/lkml/38605f6a-a568-f884-f06f-ea4da5b214f0@csgroup.eu/
Link: https://lore.kernel.org/r/20220820165129.1147589-1-masahiroy@kernel.org
22 months agopowerpc/pci: Enable PCI domains in /proc when PCI bus numbers are not unique
Pali Rohár [Sat, 20 Aug 2022 11:51:13 +0000 (13:51 +0200)]
powerpc/pci: Enable PCI domains in /proc when PCI bus numbers are not unique

On 32-bit powerpc systems with more PCIe controllers and more PCI
domains, where on more PCI domains are same PCI numbers, when kernel is
compiled with CONFIG_PROC_FS=y and
CONFIG_PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT=y options, kernel prints
"proc_dir_entry 'pci/01' already registered" error message.

  proc_dir_entry 'pci/01' already registered
  WARNING: CPU: 0 PID: 1 at fs/proc/generic.c:377 proc_register+0x1a8/0x1ac
  ...
  NIP proc_register+0x1a8/0x1ac
  LR  proc_register+0x1a8/0x1ac
  Call Trace:
    proc_register+0x1a8/0x1ac (unreliable)
    _proc_mkdir+0x78/0xa4
    pci_proc_attach_device+0x11c/0x168
    pci_proc_init+0x80/0x98
    do_one_initcall+0x80/0x284
    kernel_init_freeable+0x1f4/0x2a0
    kernel_init+0x24/0x150
    ret_from_kernel_thread+0x5c/0x64

This regression started appearing after commit
566356813082 ("powerpc/pci: Add config option for using all 256 PCI
buses") in case in each mPCIe slot is connected PCIe card and therefore
PCI bus 1 is populated in for every PCIe controller / PCI domain.

The reason is that PCI procfs code expects that when PCI bus numbers are
not unique across all PCI domains, function pci_proc_domain() returns
true for domain dependent buses.

Fix this issue by setting PCI_ENABLE_PROC_DOMAINS and
PCI_COMPAT_DOMAIN_0 flags for 32-bit powerpc code when
CONFIG_PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT is enabled. Same approach is
already implemented for 64-bit powerpc code (where PCI bus numbers are
always domain dependent).

Fixes: 566356813082 ("powerpc/pci: Add config option for using all 256 PCI buses")
Signed-off-by: Pali Rohár <pali@kernel.org>
[mpe: Trim change log oops message]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220820115113.30581-1-pali@kernel.org
22 months agopowerpc/papr_scm: Fix nvdimm event mappings
Kajol Jain [Thu, 4 Aug 2022 07:48:52 +0000 (13:18 +0530)]
powerpc/papr_scm: Fix nvdimm event mappings

Commit 4c08d4bbc089 ("powerpc/papr_scm: Add perf interface support")
added performance monitoring support for papr-scm nvdimm devices via
perf interface. Commit also added an array in papr_scm_priv
structure called "nvdimm_events_map", which got filled based on the
result of H_SCM_PERFORMANCE_STATS hcall.

Currently there is an assumption that the order of events in the
stats buffer, returned by the hypervisor is same. And order also
happens to matches with the events specified in nvdimm driver code.
But this assumption is not documented in Power Architecture
Platform Requirements (PAPR) document. Although the order
of events happens to be same on current generation od system, but
it might not be true in future generation systems. Fix the issue, by
adding a static mapping for nvdimm events to corresponding stat-id,
and removing the dynamic map from papr_scm_priv structure. Also
remove the function papr_scm_pmu_check_events from papr_scm.c file,
as we no longer need to copy stat-ids dynamically.

Fixes: 4c08d4bbc089 ("powerpc/papr_scm: Add perf interface support")
Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220804074852.55157-1-kjain@linux.ibm.com
23 months agopowerpc/vdso: Don't map VDSO at a fixed address on PPC32
Christophe Leroy [Thu, 18 Aug 2022 17:31:25 +0000 (19:31 +0200)]
powerpc/vdso: Don't map VDSO at a fixed address on PPC32

PPC64 removed default mapping address from VDSO in
commit 30d0b3682887 ("powerpc: Move 64bit VDSO to improve context
switch performance").

Do like PPC64 and let get_unmapped_area() place the VDSO mapping
at the address it wants, don't force a default address.

This allows randomisation of VDSO address.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/cba76f5a5b01fcc49415e632d92c11c1c5998cab.1660843877.git.christophe.leroy@csgroup.eu
23 months agopowerpc/selftests: Use timersub() for gettimeofday()
ye xingchen [Tue, 16 Aug 2022 10:51:06 +0000 (10:51 +0000)]
powerpc/selftests: Use timersub() for gettimeofday()

Use timersub() function to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220816105106.82666-1-ye.xingchen@zte.com.cn
23 months agoLinux 6.0-rc2
Linus Torvalds [Mon, 22 Aug 2022 00:32:54 +0000 (17:32 -0700)]
Linux 6.0-rc2

23 months agoMerge tag 'irq-urgent-2022-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 21 Aug 2022 22:09:55 +0000 (15:09 -0700)]
Merge tag 'irq-urgent-2022-08-21' of git://git./linux/kernel/git/tip/tip

Pull irq fixes from Ingo Molnar:
 "Misc irqchip fixes: LoongArch driver fixes and a Hyper-V IOMMU fix"

* tag 'irq-urgent-2022-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  irqchip/loongarch: Fix irq_domain_alloc_fwnode() abuse
  irqchip/loongson-pch-pic: Move find_pch_pic() into CONFIG_ACPI
  irqchip/loongson-eiointc: Fix a build warning
  irqchip/loongson-eiointc: Fix irq affinity setting
  iommu/hyper-v: Use helper instead of directly accessing affinity

23 months agoMerge tag 'perf-urgent-2022-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 21 Aug 2022 22:01:51 +0000 (15:01 -0700)]
Merge tag 'perf-urgent-2022-08-21' of git://git./linux/kernel/git/tip/tip

Pull x86 kprobes fix from Ingo Molnar:
 "Fix a kprobes bug in JNG/JNLE emulation when a kprobe is installed at
  such instructions, possibly resulting in incorrect execution (the
  wrong branch taken)"

* tag 'perf-urgent-2022-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/kprobes: Fix JNG/JNLE emulation

23 months agoMerge tag 'trace-v6.0-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
Linus Torvalds [Sun, 21 Aug 2022 21:49:42 +0000 (14:49 -0700)]
Merge tag 'trace-v6.0-rc1-2' of git://git./linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Various fixes for tracing:

   - Fix a return value of traceprobe_parse_event_name()

   - Fix NULL pointer dereference from failed ftrace enabling

   - Fix NULL pointer dereference when asking for registers from eprobes

   - Make eprobes consistent with kprobes/uprobes, filters and
     histograms"

* tag 'trace-v6.0-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Have filter accept "common_cpu" to be consistent
  tracing/probes: Have kprobes and uprobes use $COMM too
  tracing/eprobes: Have event probes be consistent with kprobes and uprobes
  tracing/eprobes: Fix reading of string fields
  tracing/eprobes: Do not hardcode $comm as a string
  tracing/eprobes: Do not allow eprobes to use $stack, or % for regs
  ftrace: Fix NULL pointer dereference in is_ftrace_trampoline when ftrace is dead
  tracing/perf: Fix double put of trace event when init fails
  tracing: React to error return from traceprobe_parse_event_name()