-bg...@linux.ibm.com/
v2:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20231016050147.115686-1-bg...@linux.ibm.com/
v1:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230207015643.590684-1-bg...@linux.ibm.com/
Benjamin Gray (5):
powerpc/code-patching: Add generic memory
Extend the code patching selftests with some basic coverage of the new
data patching variants too.
Signed-off-by: Benjamin Gray
---
v4: * Change store to a check
* Account for doubleword alignment
v3: * New in v3
---
arch/powerpc/lib/test-code-patching.c | 41
-by: Benjamin Gray
---
v3: * Rename from *_memory to *_mem
* Change type of ppc32 patch_uint() address to void*
* Explain introduction of val32 for big endian
* Some formatting
v2: * Deduplicate patch_32() definition
* Use u32 for val32
* Remove noinline
---
arch/powerpc/include/asm
The new data patching still needs to be aligned within a
cacheline too for the flushes to work correctly. To simplify
this requirement, we just say data patches must be aligned.
Detect when data patching is not aligned, returning an invalid
argument error.
Signed-off-by: Benjamin Gray
---
v3
flushing when patching data).
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/static_call.c | 2 +-
arch/powerpc/platforms/powermac/smp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/static_call.c
b/arch/powerpc/kernel/static_call.c
index
ink: https://lore.kernel.org/all/20230203004649.1f59dbd4@yea/
Signed-off-by: Benjamin Gray
---
v2: * Added the fixes tag, it seems appropriate even if the subject does
mention a more robust solution being required.
patch_u64() should be more efficient, but judging from the bug report
it doesn't
On Tue, 2024-04-23 at 15:09 +0530, Naveen N Rao wrote:
> On Mon, Mar 25, 2024 at 04:53:00PM +1100, Benjamin Gray wrote:
> > This use of patch_instruction() is working on 32 bit data, and can
> > fail
> > if the data looks like a prefixed instruction and the extra write
> &
Documents how to use the PR_PPC_GET_DEXCR and PR_PPC_SET_DEXCR prctl()'s
for changing a process's DEXCR or its process tree default value.
Signed-off-by: Benjamin Gray
---
Documentation/arch/powerpc/dexcr.rst | 141 ++-
1 file changed, 139 insertions(+), 2 deletions
Adds a utility to exercise the prctl DEXCR inheritance in the shell.
Supports setting and clearing each aspect.
Signed-off-by: Benjamin Gray
---
.../selftests/powerpc/dexcr/.gitignore| 1 +
.../testing/selftests/powerpc/dexcr/Makefile | 2 +-
.../testing/selftests/powerpc/dexcr
Now that the DEXCR can be configured with prctl, add a section in
lsdexcr that explains why each aspect is set the way it is.
Signed-off-by: Benjamin Gray
---
.../testing/selftests/powerpc/dexcr/lsdexcr.c | 113 +-
1 file changed, 111 insertions(+), 2 deletions(-)
diff --git
Now that a process can control its DEXCR to some extent, make the
hashchk tests more reliable by explicitly setting the local and onexec
NPHIE aspect.
Signed-off-by: Benjamin Gray
---
tools/testing/selftests/powerpc/dexcr/hashchk_test.c | 8 +++-
1 file changed, 7 insertions(+), 1 deletion
Some basic tests of the prctl interface of the DEXCR.
Signed-off-by: Benjamin Gray
---
.../selftests/powerpc/dexcr/.gitignore| 1 +
.../testing/selftests/powerpc/dexcr/Makefile | 4 +-
tools/testing/selftests/powerpc/dexcr/dexcr.c | 40
tools/testing/selftests/powerpc/dexcr
binaries that expect hash
instructions to act as NOPs could configure the reset value of the
container root to control the default reset value for all members of the
container.
Signed-off-by: Benjamin Gray
---
This differs from the previous iterations by making the reset value
totally independent
or in future). The
getter shows the current state of the process config, and the setter
allows setting/clearing the aspect.
Signed-off-by: Benjamin Gray
---
I'm intentionally trying to avoid saying 'enabling' or 'disabling' the
aspect, as that could be confusing when the aspects themselves may
added, -no-pie is also required.
Fixes: ca64da7574f8 ("selftests/powerpc/dexcr: Add hashst/hashchk test")
Signed-off-by: Benjamin Gray
---
This is not related to features introduced in this series, just fixes
the test added in the static DEXCR series.
---
tools/testing/selftests/pow
aspects will synchronize upon returning to
userspace).
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/processor.h | 1 +
arch/powerpc/kernel/process.c| 10 ++
arch/powerpc/kernel/ptrace/ptrace-view.c | 7 +--
3 files changed, 12 insertions(+), 6 deletions
. These features could be added in
a future series (or the next version of this one :) ) though.
Benjamin Gray (9):
selftests/powerpc/dexcr: Add -no-pie to hashchk tests
powerpc/dexcr: Track the DEXCR per-process
powerpc/dexcr: Reset DEXCR value across exec
powerpc/dexcr: Add DEXCR prctl interface
as the immediate value 5.
To prevent this in assembly files and inline assembly, add the
-fatal-warnings option to assembler invocations.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kbuild | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kbuild b/arch/powerpc
flushing selection.
[1]:
https://lore.kernel.org/all/77fdcdeb-4af5-4ad0-a4c6-57bf0762d...@csgroup.eu/
Suggested-by: Christophe Leroy
Signed-off-by: Benjamin Gray
---
v2: * New in v2
I think Suggested-by is an appropriate tag. The patch is Christophe's
from the link, I just added the commit
-by: Benjamin Gray
---
v1: https://lore.kernel.org/all/20240315025937.407590-1-bg...@linux.ibm.com/
This design can be readily extended to remap the writable page to
another physical page without incurring all of the entry and exit
overhead. But that might have problems with spending too long
and flushing beyond the changes they make in the
patching window.
Signed-off-by: Benjamin Gray
---
v2: * Removed an outdated comment about syncing
---
arch/powerpc/lib/code-patching.c | 179 +++
1 file changed, 15 insertions(+), 164 deletions(-)
diff --git a/arch
OK, so I compile for corenet64 but not corenet32 apparently. I'll fix
the shift overflow in the next round.
Extend the code patching selftests with some basic coverage of the new
data patching variants too.
Signed-off-by: Benjamin Gray
---
v3: * New in v3
---
arch/powerpc/lib/test-code-patching.c | 36 +++
1 file changed, 36 insertions(+)
diff --git a/arch/powerpc/lib/test
-by: Benjamin Gray
---
v3: * Rename from *_memory to *_mem
* Change type of ppc32 patch_uint() address to void*
* Explain introduction of val32 for big endian
* Some formatting
v2: * Deduplicate patch_32() definition
* Use u32 for val32
* Remove noinline
---
arch/powerpc/include/asm
flushing when patching data).
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/static_call.c | 2 +-
arch/powerpc/platforms/powermac/smp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/static_call.c
b/arch/powerpc/kernel/static_call.c
index
:
* Addressed the v1 review actions
* Removed noinline (for now)
v2:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20231016050147.115686-1-bg...@linux.ibm.com/
v1:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230207015643.590684-1-bg...@linux.ibm.com/
Benjamin Gray (5
The new data patching still needs to be aligned within a
cacheline too for the flushes to work correctly. To simplify
this requirement, we just say data patches must be aligned.
Detect when data patching is not aligned, returning an invalid
argument error.
Signed-off-by: Benjamin Gray
---
v3
ink: https://lore.kernel.org/all/20230203004649.1f59dbd4@yea/
Signed-off-by: Benjamin Gray
---
v2: * Added the fixes tag, it seems appropriate even if the subject does
mention a more robust solution being required.
patch_u64() should be more efficient, but judging from the bug report
it doesn't
-by: Benjamin Gray
---
v1: https://lore.kernel.org/all/20240315025736.404867-1-bg...@linux.ibm.com/
v2: * Shrink the code array to reduce frame size. It still
crosses a page, and 32 vs 256 words is unlikely to
make a difference in test coverage otherwise.
---
arch/powerpc/lib/test-code
does.
Signed-off-by: Benjamin Gray
---
v2: * Fix typo in EAA (from EEA)
* Fix references to quadrant number (0, not 1)
* Use copy_to_kernel_nofault() over custom memcpy
* Drop custom memcpy optimisation patch
---
arch/powerpc/lib/code-patching.c | 31
says
they are inserted for Power8 or higher).
Signed-off-by: Benjamin Gray
---
arch/powerpc/Makefile | 3 +++
arch/powerpc/platforms/Kconfig.cputype | 12
2 files changed, 15 insertions(+)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index
-by: Benjamin Gray
---
This patch is probably incompatible with the
per-task DEXCR tracking in the userspace DEXCR
series, but I'll fix up whichever one lands last.
I tested on a Power10 (TCG and KVM) and Power9.
I also tried enabling ftrace; no apparent issues,
and the trace probes were definitely
User-Agent: Evolution 3.50.4 (3.50.4-1.fc39)
X-Trend-IP-HD:
ip=[9.192.253.14]helo={ozlabs.au.ibm.com}sender=(bg...@linux.ibm.com)recipient=
On Mon, 2024-03-18 at 08:38 +1100, Benjamin Gray wrote:
> On Fri, 2024-03-15 at 07:14 +, Christophe Leroy wrote:
> >=20
> >=20
>
On Mon, 2024-03-18 at 08:38 +1100, Benjamin Gray wrote:
> On Fri, 2024-03-15 at 07:14 +, Christophe Leroy wrote:
> >
> >
> > Le 15/03/2024 à 03:57, Benjamin Gray a écrit :
> > > patch_instructions() introduces new behaviour with a couple of
&g
On Fri, 2024-03-15 at 06:39 +, Christophe Leroy wrote:
>
>
> Le 15/03/2024 à 03:57, Benjamin Gray a écrit :
> > As we are patching instructions, we can assume the length is a
> > multiple
> > of 4 and the destination address is aligned.
> >
> > Atomi
On Fri, 2024-03-15 at 06:36 +, Christophe Leroy wrote:
>
>
> Le 15/03/2024 à 03:57, Benjamin Gray a écrit :
> > The patching page set up as a writable alias may be in quadrant 1
> > (userspace) if the temporary mm path is used. This causes sanitiser
> > failure
On Fri, 2024-03-15 at 07:14 +, Christophe Leroy wrote:
>
>
> Le 15/03/2024 à 03:57, Benjamin Gray a écrit :
> > patch_instructions() introduces new behaviour with a couple of
> > variations. Test each case of
> >
> > * a repeated 32-bit instruction,
>
On Sat, 2024-03-16 at 10:10 +, Christophe Leroy wrote:
>
>
> Le 15/03/2024 à 09:38, Christophe Leroy a écrit :
> >
> >
> > Le 15/03/2024 à 03:59, Benjamin Gray a écrit :
> > > The existing patching alias page setup and teardown sections can
> > &g
Also supersedes
https://lore.kernel.org/all/20240213043638.168048-1-bg...@linux.ibm.com/
and flushing beyond the changes they make in the
patching window.
Signed-off-by: Benjamin Gray
---
arch/powerpc/lib/code-patching.c | 180 +++
1 file changed, 16 insertions(+), 164 deletions(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code
-by: Benjamin Gray
---
This design can be readily extended to remap the writable page to
another physical page without incurring all of the entry and exit
overhead. But that might have problems with spending too long in
an interrupts disabled context, so I've left it out for now.
---
arch/powerpc/lib/code
As we are patching instructions, we can assume the length is a multiple
of 4 and the destination address is aligned.
Atomicity of patching a prefixed instruction is not a concern, as the
original implementation doesn't provide it anyway.
Signed-off-by: Benjamin Gray
---
arch/powerpc/lib/code
does.
Signed-off-by: Benjamin Gray
---
The patch_memcpy() can be optimised to 4 bytes at a time assuming the
same requirements as regular instruction patching are being followed
for the 'copy sequence of instructions' mode (i.e., they actually are
instructions following instruction alignment
-by: Benjamin Gray
---
arch/powerpc/lib/test-code-patching.c | 92 +++
1 file changed, 92 insertions(+)
diff --git a/arch/powerpc/lib/test-code-patching.c
b/arch/powerpc/lib/test-code-patching.c
index c44823292f73..35a3756272df 100644
--- a/arch/powerpc/lib/test-code-patching.c
On Wed, 2024-01-31 at 11:46 +, Christophe Leroy wrote:
> Hi,
>
> Got the following BUG while loading module test_bpf.ko
>
> No time to investigate for now.
>
> root@vgoip:~# insmod test_bpf.ko
> [ 263.409030]
> ==
> [
mlinux.lds.S
> b/arch/powerpc/kernel/vmlinux.lds.S
> index 1c5970df3233..9c376ae6857d 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -281,7 +281,9 @@ SECTIONS
> * to deal with references from __bug_table
> */
> .exit.text : AT(ADDR
The memset/memcpy functions are by default instrumented by KASAN, which
complains about user memory access when using a poking page in
userspace.
Using a userspace address is expected though, so don't instrument with
KASAN for this function.
Signed-off-by: Benjamin Gray
---
I tried to replace
a 64-bit KASAN build.
>
> So only increase the stack for KASAN if the stack size is < 32KB.
>
> Link:
> https://lore.kernel.org/linuxppc-dev/bug-207129-206...@https.bugzilla.kernel.org%2F/
> Reported-by: Spoorthy
> Reported-by: Benjamin Gray
> Fixes: 18f14afe28
) of the
kasan_mem_to_shadow() calculation are the same for the real and virtual
addresses, so the actual PTE value is the same in the end. But virtual
addresses are the intended input, so fix it.
Signed-off-by: Benjamin Gray
---
arch/powerpc/mm/kasan/init_book3e_64.c | 2 +-
arch/powerpc/mm
On Thu, 2023-11-30 at 15:55 +0530, Naveen N Rao wrote:
> On Mon, Oct 16, 2023 at 04:01:45PM +1100, Benjamin Gray wrote:
> > patch_instruction() is designed for patching instructions in
> > otherwise
> > readonly memory. Other consumers also sometimes need to patch
> > r
On 17/10/23 5:39 pm, Christophe Leroy wrote:
Le 16/10/2023 à 07:01, Benjamin Gray a écrit :
Currently patch_instruction() bases the write length on the value being
written. If the value looks like a prefixed instruction it writes 8 bytes,
otherwise it writes 4 bytes. This makes it potentially
flushing when patching data).
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/static_call.c | 2 +-
arch/powerpc/platforms/powermac/smp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/static_call.c
b/arch/powerpc/kernel/static_call.c
index
ink: https://lore.kernel.org/all/20230203004649.1f59dbd4@yea/
Signed-off-by: Benjamin Gray
---
v2: * Added the fixes tag, it seems appropriate even if the subject does
mention a more robust solution being required.
patch_u64() should be more efficient, but judging from the bug report
it doesn't
the compiler can const-propagate it
away.
Signed-off-by: Benjamin Gray
---
v2: * Deduplicate patch_32() definition
* Use u32 for val32
* Remove noinline
---
arch/powerpc/include/asm/code-patching.h | 33
arch/powerpc/lib/code-patching.c | 66 ++--
2
:
* Addressed the v1 review actions
* Removed noinline (for now)
v1:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230207015643.590684-1-bg...@linux.ibm.com/
Benjamin Gray (3):
powerpc/code-patching: Add generic memory patching
powerpc/64: Convert patch_instruction
are introduced by this patch.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/book3s/64/pgtable.h| 2 +-
arch/powerpc/include/asm/imc-pmu.h | 16
arch/powerpc/kernel/prom_init.c | 2 +-
arch/powerpc/kexec/core_64.c| 4
Sparse reports endianness mismatches in the KVM shared regs getter and
setter helpers.
This code has dynamic endianness behind a safe interface, so a force is
warranted here to tell sparse this is OK.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/kvm_ppc.h | 8
1 file
ignore it.
Signed-off-by: Benjamin Gray
---
arch/powerpc/platforms/powernv/opal-fadump.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/opal-fadump.h
b/arch/powerpc/platforms/powernv/opal-fadump.h
index 3f715efb0aa6..5eeb794b5eb1 100644
---
Sparse reports dereference of a __user pointer. copy_mc_to_user() takes
a __user pointer, verifies it, then calls the generic copy routine
copy_mc_generic().
As we have verified the pointer, cast out the __user annotation when
passing to copy_mc_generic().
Signed-off-by: Benjamin Gray
---
arch
Sparse reports a warning when casting to an int. There is no need to
cast in the first place, so drop them.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/eeh_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc
Sparse reports dereferencing an __iomem pointer. These routines
are clearly low level handlers for IO memory, so force cast away
the __iomem annotation to tell sparse the dereferences are safe.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/io.c | 12 ++--
1 file changed, 6
-by: Benjamin Gray
---
arch/powerpc/include/asm/opal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index a9b31cc258fc..b66b0c615f4f 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
Sparse reports several function implementations annotated with extern.
This is clearly incorrect, likely just copied from an actual extern
declaration in another file.
Fix the sparse warnings by removing extern.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/iommu.c | 8
Sparse reports several uses of 0 for pointer arguments and comparisons.
Replace with NULL to better convey the intent. Remove entirely if a
comparison to follow the kernel style of implicit boolean conversions.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/setup_64.c| 2 +-
arch
instead of continuing to
sit on it indefinitely.
Benjamin Gray (12):
powerpc/xive: Fix endian conversion size
powerpc/pseries: Restructure hvc_get_chars() endianness
powerpc: Explicitly reverse bytes when checking for byte reversal
powerpc: Use NULL instead of 0 for null pointers
powerpc
: 88ec6b93c8e7 ("powerpc/xive: add OPAL extensions for the XIVE native
exploitation support")
Signed-off-by: Benjamin Gray
---
arch/powerpc/sysdev/xive/native.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/xive/native.c
b/arch/powerpc/sysdev/xive/nati
of the code.
Signed-off-by: Benjamin Gray
---
arch/powerpc/sysdev/mpic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index ba287abcb008..dabbdd356664 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev
with cpu_to_be64() and cast lbuf as an
array of __be64 to match the semantics closer.
Signed-off-by: Benjamin Gray
---
arch/powerpc/platforms/pseries/hvconsole.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c
b/arch/powerpc
: Disable DEXCR SBHE sysctl override
0: Override and set DEXCR[SBHE] aspect to 0
1: Override and set DEXCR[SBHE] aspect to 1
Internally, introduces a mechanism to apply arbitrary system wide
overrides on top of the prctl() config.
Signed-off-by: Benjamin Gray
---
arch/powerpc
. If set, don't
report NPHIE as editable via prctl(), as the prctl() value can never
take effect.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig| 5 +
arch/powerpc/kernel/dexcr.c | 7 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch
Add capability to track a DEXCR value per thread.
Nothing actually changes these values yet, but they are correctly
tracked, propagated, and used to set the hardware register.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/processor.h | 12
arch/powerpc/kernel/process.c
r accessed or exposed to userspace, so there is no breakage.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/cputable.h | 6 +-
arch/powerpc/kernel/prom.c | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/cputable.h
b/arch/power
by the hypervisor via
SPR 455. A bitwise OR of these two SPRs will give the effective
DEXCR aspect state of the process.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/processor.h | 10 +++
arch/powerpc/kernel/Makefile | 1 +
arch/powerpc/kernel/dexcr.c | 128
Adds the definitions and generic handler for prctl control of the
PowerPC Dynamic Execution Control Register (DEXCR).
Signed-off-by: Benjamin Gray
---
include/uapi/linux/prctl.h | 13 +
kernel/sys.c | 16
2 files changed, 29 insertions(+)
diff --git
interface could still handle that.
[1]:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230616034846.311705-1-bg...@linux.ibm.com/
Benjamin Gray (6):
powerpc/dexcr: Make all aspects CPU features
powerpc/dexcr: Add thread specific DEXCR configuration
prctl: Define PowerPC DEXCR
use we are only interested in HASHCHK if it's a user space trap.
Fixes: 5bcba4e6c13f ("powerpc/dexcr: Handle hashchk exception")
Signed-off-by: Benjamin Gray
---
v1: https://lore.kernel.org/all/20230825014910.488822-1-bg...@linux.ibm.com/
v1 -> v2: Changed commit description to mentio
manipulation
CONFIG_PPC_KUAP_DEBUG
Adds some extra KAUP checks around interrupts/context switching
CONFIG_PPC_RFI_SRR_DEBUG
Adds some extra SSR checks around interrupts/syscalls
Signed-off-by: Benjamin Gray
---
arch/powerpc/configs/debug.config | 4
1 file changed, 4 insertions
On 29/8/23 4:34 pm, Benjamin Gray wrote:
When enabling debug config options relating to preemption, several bugs
appear in the kernel log. With this series applied, the breakpoint code
no longer prints bugs when running the powerpc/ptrace selftests.
Benjamin Gray (3):
powerpc/watchpoints
It can be easy to miss that the notifier mechanism invokes the callbacks
in an atomic context, so add some comments to that effect on the two
handlers we register here.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint.c | 9 +
1 file changed, 9 insertions(+)
diff
When enabling debug config options relating to preemption, several bugs
appear in the kernel log. With this series applied, the breakpoint code
no longer prints bugs when running the powerpc/ptrace selftests.
Benjamin Gray (3):
powerpc/watchpoints: Disable preemption in thread_change_pc
because we are
reading the instruction that just triggered the watchpoint trap.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint_constraints.c | 7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/hw_breakpoint_constraints.c
b/arch/powerpc
s_cpu_read() call in thread_change_pc(). However the
existing __this_cpu_read() that runs if a breakpoint does need to be
re-inserted has the same issue.
Signed-off-by: Benjamin Gray
---
There's probably a more idiomatic way to express this. We technically
don't need to disable preemption for
a user space trap.
Fixes: 5bcba4e6c13f ("powerpc/dexcr: Handle hashchk exception")
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/traps.c | 56 -
1 file changed, 36 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/kernel/traps.c b/ar
On 30/5/23 10:54 pm, Miguel Ojeda wrote:
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
I'm not familiar with the kallsyms
PowerPC was the only user of these hooks, and has been refactored to no
longer require them. There is no need to keep them around, so remove
them to reduce complexity.
Signed-off-by: Benjamin Gray
---
include/linux/hw_breakpoint.h | 3 ---
kernel/events/hw_breakpoint.c | 28
Now that ptrace and perf are no longer exclusive, update the
test to exercise interesting interactions.
An assembly file is used for the children to allow precise instruction
choice and addresses, while avoiding any compiler quirks.
Signed-off-by: Benjamin Gray
---
.../testing/selftests
watchpoint is
involved.
Signed-off-by: Benjamin Gray
---
Whether it's a _good_ idea to mix ptrace and perf is another thing
entirely mind... . But they are not inherently incompatible.
---
arch/powerpc/kernel/hw_breakpoint.c | 249 +---
1 file changed, 1 insertion(+), 248
We only remove watchpoints when they have the perf_single_step flag set,
so we can reinsert them during the first iteration.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint.c | 12 +---
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel
The behaviour of the thread_change_pc() function is a bit cryptic
without being more familiar with how the watchpoint logic handles
perf's after-execute semantics.
Expand the comment to explain why we can re-insert the breakpoint and
unset the perf_single_step flag.
Signed-off-by: Benjamin Gray
dabr_instruction() without a way to check
their validity.
This patch moves the tracking of this information to the breakpoint
itself. This means we no longer have to do anything special to clean up.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/hw_breakpoint.h | 1 +
arch/powerpc/include
just use the local bp array to track whether
we are ignoring a breakpoint.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint.c | 60 +++--
1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/arch/powerpc/kernel/hw_breakpoint.c
b/arch/powerpc
. It also simplifies handling of ptrace and
perf breakpoints, making insertion less restrictive.
If merged, it allows several arch hooks that PowerPC was the sole user of
to be removed.
Benjamin Gray (7):
powerpc/watchpoints: Explain thread_change_pc() more
powerpc/watchpoints: Don't t
pid_max_addr() searches for the 'pid_max' symbol in /proc/kallsyms, and
prints an error if it cannot find it. The error message has a typo,
calling it pix_max.
Signed-off-by: Benjamin Gray
---
tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c | 2 +-
1 file changed, 1 insertion(+), 1
(), with appropriate descriptions of why
the test is being skipped. This gives a general idea of why a test is
skipped, which can be looked into further if it doesn't make sense.
Signed-off-by: Benjamin Gray
---
tools/testing/selftests/powerpc/ptrace/child.h | 4 ++--
tools/testing
of the dependency on compiler behaviour.
Signed-off-by: Benjamin Gray
---
.../selftests/powerpc/ptrace/ptrace-hwbreak.c | 24 +--
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
b/tools/testing/selftests/powerpc
The documented ptrace request names are currently wrong/incomplete.
Fix this to improve correctness and searchability.
Signed-off-by: Benjamin Gray
---
Documentation/powerpc/ptrace.rst | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/powerpc/ptrace.rst b
While trying to test changes to the breakpoint implementation in the kernel, I
tried to run the ptrace tests and met many unexplained skips and failures.
This series addresses the pain points of trying to run these tests and learn
what they are doing.
Benjamin Gray (4):
Documentation/powerpc
Signed-off-by: Benjamin Gray
---
The generic makefile has other disabled sanitisers / hooks, but this
patch is just an upstream of fixing a blocking issue for running
syzkaller. The blocker is resolved by this; kernels stop hanging on boot
with KCOV + KASAN.
This works as an alternative to
https
On Thu, 2023-07-06 at 11:08 +1000, Benjamin Gray wrote:
> The issue is pre-existing, but is surfaced by commit 721255b9826b
> ("genirq: Use a maple tree for interrupt descriptor management").
> It's not clear to me why this causes it to surface.
>From the thread chain
1 - 100 of 328 matches
Mail list logo