<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/powerpc/kernel/kprobes.c, branch linux-5.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-08-18T06:59:14Z</updated>
<entry>
<title>powerpc/kprobes: Fix kprobe Oops happens in booke</title>
<updated>2021-08-18T06:59:14Z</updated>
<author>
<name>Pu Lehui</name>
</author>
<published>2021-08-09T02:36:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4acc0d987141f4a5e1e4aee4909f6c10dc34646a'/>
<id>urn:sha1:4acc0d987141f4a5e1e4aee4909f6c10dc34646a</id>
<content type='text'>
[ Upstream commit 43e8f76006592cb1573a959aa287c45421066f9c ]

When using kprobe on powerpc booke series processor, Oops happens
as show bellow:

/ # echo "p:myprobe do_nanosleep" &gt; /sys/kernel/debug/tracing/kprobe_events
/ # echo 1 &gt; /sys/kernel/debug/tracing/events/kprobes/myprobe/enable
/ # sleep 1
[   50.076730] Oops: Exception in kernel mode, sig: 5 [#1]
[   50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500
[   50.077221] Modules linked in:
[   50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21
[   50.077887] NIP:  c0b9c4e0 LR: c00ebecc CTR: 00000000
[   50.078067] REGS: c3883de0 TRAP: 0700   Not tainted (5.14.0-rc4-00022-g251a1524293d)
[   50.078349] MSR:  00029000 &lt;CE,EE,ME&gt;  CR: 24000228  XER: 20000000
[   50.078675]
[   50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 00000001 00000000 c3883ecc 00000001
[   50.078675] GPR08: c100598c c00ea250 00000004 00000000 24000222 102490c2 bff4180c 101e60d4
[   50.078675] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
[   50.078675] GPR24: 00000002 00000000 c3883ea0 00000001 00000000 0000c350 3b9b8d50 00000000
[   50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190
[   50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0
[   50.080638] Call Trace:
[   50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable)
[   50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110
[   50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28
[   50.081541] --- interrupt: c00 at 0x100a4d08
[   50.081749] NIP:  100a4d08 LR: 101b5234 CTR: 00000003
[   50.081931] REGS: c3883f50 TRAP: 0c00   Not tainted (5.14.0-rc4-00022-g251a1524293d)
[   50.082183] MSR:  0002f902 &lt;CE,EE,PR,FP,ME&gt;  CR: 24000222  XER: 00000000
[   50.082457]
[   50.082457] GPR00: 000000a2 bf980040 1024b4d0 bf980084 bf980084 64000000 00555345 fefefeff
[   50.082457] GPR08: 7f7f7f7f 101e0000 00000069 00000003 28000422 102490c2 bff4180c 101e60d4
[   50.082457] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
[   50.082457] GPR24: 00000002 bf9803f4 10240000 00000000 00000000 100039e0 00000000 102444e8
[   50.083789] NIP [100a4d08] 0x100a4d08
[   50.083917] LR [101b5234] 0x101b5234
[   50.084042] --- interrupt: c00
[   50.084238] Instruction dump:
[   50.084483] 4bfffc40 60000000 60000000 60000000 9421fff0 39400402 914200c0 38210010
[   50.084841] 4bfffc20 00000000 00000000 00000000 &lt;7fe00008&gt; 7c0802a6 7c892378 93c10048
[   50.085487] ---[ end trace f6fffe98e2fa8f3e ]---
[   50.085678]
Trace/breakpoint trap

There is no real mode for booke arch and the MMU translation is
always on. The corresponding MSR_IS/MSR_DS bit in booke is used
to switch the address space, but not for real mode judgment.

Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode")
Signed-off-by: Pu Lehui &lt;pulehui@huawei.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/20210809023658.218915-1-pulehui@huawei.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>powerpc/kprobes: Fix validation of prefixed instructions across page boundary</title>
<updated>2021-06-10T11:39:27Z</updated>
<author>
<name>Naveen N. Rao</name>
</author>
<published>2021-05-19T10:47:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5e5e63bacbe8f1ef9688e7804275eb88cf0be51a'/>
<id>urn:sha1:5e5e63bacbe8f1ef9688e7804275eb88cf0be51a</id>
<content type='text'>
commit 82123a3d1d5a306fdf50c968a474cc60fe43a80f upstream.

When checking if the probed instruction is the suffix of a prefixed
instruction, we access the instruction at the previous word. If the
probed instruction is the very first word of a module, we can end up
trying to access an invalid page.

Fix this by skipping the check for all instructions at the beginning of
a page. Prefixed instructions cannot cross a 64-byte boundary and as
such, we don't expect to encounter a suffix as the very first word in a
page for kernel text. Even if there are prefixed instructions crossing
a page boundary (from a module, for instance), the instruction will be
illegal, so preventing probing on the suffix of such prefix instructions
isn't worthwhile.

Fixes: b4657f7650ba ("powerpc/kprobes: Don't allow breakpoints on suffixes")
Cc: stable@vger.kernel.org # v5.8+
Reported-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Naveen N. Rao &lt;naveen.n.rao@linux.vnet.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/0df9a032a05576a2fa8e97d1b769af2ff0eafbd6.1621416666.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>powerpc: kprobes: Use generic kretprobe trampoline handler</title>
<updated>2020-09-08T09:52:34Z</updated>
<author>
<name>Masami Hiramatsu</name>
</author>
<published>2020-08-29T13:01:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b6c5a58dd89e683e66b52a57a6f022fda79a0aab'/>
<id>urn:sha1:b6c5a58dd89e683e66b52a57a6f022fda79a0aab</id>
<content type='text'>
Use the generic kretprobe trampoline handler. Don't use
framepointer verification.

Signed-off-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/159870610825.1229682.2090635992093223399.stgit@devnote2
</content>
</entry>
<entry>
<title>powerpc: Add a ppc_inst_as_str() helper</title>
<updated>2020-07-23T07:41:36Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-06-02T05:27:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=50428fdc53ba48f6936b10dfdc0d644972403908'/>
<id>urn:sha1:50428fdc53ba48f6936b10dfdc0d644972403908</id>
<content type='text'>
There are quite a few places where instructions are printed, this is
done using a '%x' format specifier. With the introduction of prefixed
instructions, this does not work well. Currently in these places,
ppc_inst_val() is used for the value for %x so only the first word of
prefixed instructions are printed.

When the instructions are word instructions, only a single word should
be printed. For prefixed instructions both the prefix and suffix should
be printed. To accommodate both of these situations, instead of a '%x'
specifier use '%s' and introduce a helper, __ppc_inst_as_str() which
returns a char *. The char * __ppc_inst_as_str() returns is buffer that
is passed to it by the caller.

It is cumbersome to require every caller of __ppc_inst_as_str() to now
declare a buffer. To make it more convenient to use __ppc_inst_as_str(),
wrap it in a macro that uses a compound statement to allocate a buffer
on the caller's stack before calling it.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Reviewed-by: Joel Stanley &lt;joel@jms.id.au&gt;
Acked-by: Segher Boessenkool &lt;segher@kernel.crashing.org&gt;
[mpe: Drop 0x prefix to match most existings uses, especially xmon]
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/20200602052728.18227-1-jniethe5@gmail.com
</content>
</entry>
<entry>
<title>maccess: rename probe_kernel_address to get_kernel_nofault</title>
<updated>2020-06-18T18:14:40Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2020-06-17T07:37:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=25f12ae45fc1931a1dce3cc59f9989a9d87834b0'/>
<id>urn:sha1:25f12ae45fc1931a1dce3cc59f9989a9d87834b0</id>
<content type='text'>
Better describe what this helper does, and match the naming of
copy_from_kernel_nofault.

Also switch the argument order around, so that it acts and looks
like get_user().

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>powerpc/kprobes: Use probe_address() to read instructions</title>
<updated>2020-06-02T10:59:08Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2020-02-24T18:02:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9ed5df69b79a22b40b20bc2132ba2495708b19c4'/>
<id>urn:sha1:9ed5df69b79a22b40b20bc2132ba2495708b19c4</id>
<content type='text'>
In order to avoid Oopses, use probe_address() to read the
instruction at the address where the trap happened.

Signed-off-by: Christophe Leroy &lt;christophe.leroy@c-s.fr&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/7f24b5961a6839ff01df792816807f74ff236bf6.1582567319.git.christophe.leroy@c-s.fr
</content>
</entry>
<entry>
<title>powerpc/kprobes: Don't allow breakpoints on suffixes</title>
<updated>2020-05-18T14:11:03Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-05-06T03:40:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b4657f7650babc9bfb41ce875abe41b18604a105'/>
<id>urn:sha1:b4657f7650babc9bfb41ce875abe41b18604a105</id>
<content type='text'>
Do not allow inserting breakpoints on the suffix of a prefix instruction
in kprobes.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/20200506034050.24806-28-jniethe5@gmail.com
</content>
</entry>
<entry>
<title>powerpc: Introduce a function for reporting instruction length</title>
<updated>2020-05-18T14:10:38Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-05-06T03:40:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=622cf6f436a12338bbcfbb3474629755547fd112'/>
<id>urn:sha1:622cf6f436a12338bbcfbb3474629755547fd112</id>
<content type='text'>
Currently all instructions have the same length, but in preparation for
prefixed instructions introduce a function for returning instruction
length.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Reviewed-by: Alistair Popple &lt;alistair@popple.id.au&gt;
Link: https://lore.kernel.org/r/20200506034050.24806-18-jniethe5@gmail.com
</content>
</entry>
<entry>
<title>powerpc/kprobes: Use patch_instruction()</title>
<updated>2020-05-18T14:10:37Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-05-06T03:40:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a8646f43ba5046e7f5c4396125d5136bfcb17b49'/>
<id>urn:sha1:a8646f43ba5046e7f5c4396125d5136bfcb17b49</id>
<content type='text'>
Instead of using memcpy() and flush_icache_range() use
patch_instruction() which not only accomplishes both of these steps but
will also make it easier to add support for prefixed instructions.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Reviewed-by: Alistair Popple &lt;alistair@popple.id.au&gt;
Link: https://lore.kernel.org/r/20200506034050.24806-16-jniethe5@gmail.com
</content>
</entry>
<entry>
<title>powerpc: Use a function for reading instructions</title>
<updated>2020-05-18T14:10:37Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-05-06T03:40:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f8faaffaa7d99028e457ef2d1dcb43a98f736938'/>
<id>urn:sha1:f8faaffaa7d99028e457ef2d1dcb43a98f736938</id>
<content type='text'>
Prefixed instructions will mean there are instructions of different
length. As a result dereferencing a pointer to an instruction will not
necessarily give the desired result. Introduce a function for reading
instructions from memory into the instruction data type.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Reviewed-by: Alistair Popple &lt;alistair@popple.id.au&gt;
Link: https://lore.kernel.org/r/20200506034050.24806-13-jniethe5@gmail.com
</content>
</entry>
</feed>
