<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/powerpc/include/asm/inst.h, branch linux-5.13.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-07-20T14:00:18Z</updated>
<entry>
<title>powerpc/inst: Fix sparse detection on get_user_instr()</title>
<updated>2021-07-20T14:00:18Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-05-20T13:50:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c5085c93f641a9def4e790a18d09749021b3066'/>
<id>urn:sha1:0c5085c93f641a9def4e790a18d09749021b3066</id>
<content type='text'>
[ Upstream commit b3a9e523237013477bea914b7fbfbe420428b988 ]

get_user_instr() lacks sparse detection for the __user tag.

This is because __gui_ptr is assigned with a cast.

Fix that by adding a __chk_user_ptr()

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/0320e5b41a794fd456ab8c5993bbfadcf9e1d8b4.1621516826.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>powerpc: Rename probe_kernel_read_inst()</title>
<updated>2021-04-21T12:52:33Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-04-14T13:08:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=41d6cf68b5f611934bcc6a7d4a1a2d9bfd04b420'/>
<id>urn:sha1:41d6cf68b5f611934bcc6a7d4a1a2d9bfd04b420</id>
<content type='text'>
When probe_kernel_read_inst() was created, it was to mimic
probe_kernel_read() function.

Since then, probe_kernel_read() has been renamed
copy_from_kernel_nofault().

Rename probe_kernel_read_inst() into copy_inst_from_kernel_nofault().

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/b783d1f7cdb8914992384a669a2af57051b6bdcf.1618405715.git.christophe.leroy@csgroup.eu

</content>
</entry>
<entry>
<title>powerpc: Make probe_kernel_read_inst() common to PPC32 and PPC64</title>
<updated>2021-04-21T12:52:33Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-04-14T13:08:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6449078d50111c839bb7156c3b99b9def80eed42'/>
<id>urn:sha1:6449078d50111c839bb7156c3b99b9def80eed42</id>
<content type='text'>
We have two independant versions of probe_kernel_read_inst(), one for
PPC32 and one for PPC64.

The PPC32 is identical to the first part of the PPC64 version.
The remaining part of PPC64 version is not relevant for PPC32, but
not contradictory, so we can easily have a common function with
the PPC64 part opted out via a IS_ENABLED(CONFIG_PPC64).

The only need is to add a version of ppc_inst_prefix() for PPC32.

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/f7b9dfddef3b3760182c7e5466356c121a293dc9.1618405715.git.christophe.leroy@csgroup.eu

</content>
</entry>
<entry>
<title>powerpc: Remove probe_user_read_inst()</title>
<updated>2021-04-21T12:52:33Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-04-14T13:08:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6ac7897f08e04b47df3955d7691652e9d12d4068'/>
<id>urn:sha1:6ac7897f08e04b47df3955d7691652e9d12d4068</id>
<content type='text'>
Its name comes from former probe_user_read() function.
That function is now called copy_from_user_nofault().

probe_user_read_inst() uses copy_from_user_nofault() to read only
a few bytes. It is suboptimal.

It does the same as get_user_inst() but in addition disables
page faults.

But on the other hand, it is not used for the time being. So remove it
for now. If one day it is really needed, we can give it a new name
more in line with today's naming, and implement it using get_user_inst()

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/5f6f82572242a59bfee1e19a71194d8f7ef5fca4.1618405715.git.christophe.leroy@csgroup.eu

</content>
</entry>
<entry>
<title>powerpc/inst: ppc_inst_as_u64() becomes ppc_inst_as_ulong()</title>
<updated>2021-04-21T12:52:32Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-04-20T14:02:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=693557ebf407a85ea400a0b501bb97687d8f4856'/>
<id>urn:sha1:693557ebf407a85ea400a0b501bb97687d8f4856</id>
<content type='text'>
In order to simplify use on PPC32, change ppc_inst_as_u64()
into ppc_inst_as_ulong() that returns the 32 bits instruction
on PPC32.

Will be used when porting OPTPROBES to PPC32.

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/22cadf29620664b600b82026d2a72b8b23351777.1618927318.git.christophe.leroy@csgroup.eu

</content>
</entry>
<entry>
<title>powerpc/uaccess: Move get_user_instr helpers in asm/inst.h</title>
<updated>2021-04-03T10:21:45Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=35506a3e2d7c4d93cb564e23471a448cbd98f085'/>
<id>urn:sha1:35506a3e2d7c4d93cb564e23471a448cbd98f085</id>
<content type='text'>
Those helpers use get_user helpers but they don't participate
in their implementation, so they do not belong to asm/uaccess.h

Move them in asm/inst.h

Signed-off-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/2c6e83581b4fa434aa7cf2fa7714c41e98f57007.1615398265.git.christophe.leroy@csgroup.eu
</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>powerpc: Add ppc_inst_as_u64()</title>
<updated>2020-05-26T13:36:57Z</updated>
<author>
<name>Michael Ellerman</name>
</author>
<published>2020-05-26T07:26:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=16ef9767e4dc5cf03a71ae7bc2bc588dbbe7983e'/>
<id>urn:sha1:16ef9767e4dc5cf03a71ae7bc2bc588dbbe7983e</id>
<content type='text'>
The code patching code wants to get the value of a struct ppc_inst as
a u64 when the instruction is prefixed, so we can pass the u64 down to
__put_user_asm() and write it with a single store.

The optprobes code wants to load a struct ppc_inst as an immediate
into a register so it is useful to have it as a u64 to use the
existing helper function.

Currently this is a bit awkward because the value differs based on the
CPU endianness, so add a helper to do the conversion.

This fixes the usage in arch_prepare_optimized_kprobe() which was
previously incorrect on big endian.

Fixes: 650b55b707fd ("powerpc: Add prefixed instructions to instruction data type")
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Tested-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Link: https://lore.kernel.org/r/20200526072630.2487363-1-mpe@ellerman.id.au
</content>
</entry>
<entry>
<title>powerpc: Add ppc_inst_next()</title>
<updated>2020-05-26T13:36:51Z</updated>
<author>
<name>Michael Ellerman</name>
</author>
<published>2020-05-22T13:33:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c5ff46d69c410f7fac173e4fde3eea484b4b4eda'/>
<id>urn:sha1:c5ff46d69c410f7fac173e4fde3eea484b4b4eda</id>
<content type='text'>
In a few places we want to calculate the address of the next
instruction. Previously that was simple, we just added 4 bytes, or if
using a u32 * we incremented that pointer by 1.

But prefixed instructions make it more complicated, we need to advance
by either 4 or 8 bytes depending on the actual instruction. We also
can't do pointer arithmetic using struct ppc_inst, because it is
always 8 bytes in size on 64-bit, even though we might only need to
advance by 4 bytes.

So add a ppc_inst_next() helper which calculates the location of the
next instruction, if the given instruction was located at the given
address. Note the instruction doesn't need to actually be at the
address in memory.

Although it would seem natural for the value to be passed by value,
that makes it too easy to write a loop that will read off the end of a
page, eg:

	for (; src &lt; end; src = ppc_inst_next(src, *src),
			  dest = ppc_inst_next(dest, *dest))

As noticed by Christophe and Jordan, if end is the exact end of a
page, and the next page is not mapped, this will fault, because *dest
will read 8 bytes, 4 bytes into the next page.

So value is passed by reference, so the helper can be careful to use
ppc_inst_read() on it.

Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Reviewed-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Link: https://lore.kernel.org/r/20200522133318.1681406-1-mpe@ellerman.id.au
</content>
</entry>
<entry>
<title>powerpc: Add prefixed instructions to instruction data type</title>
<updated>2020-05-18T14:10:39Z</updated>
<author>
<name>Jordan Niethe</name>
</author>
<published>2020-05-15T02:12:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=650b55b707fdfa764e9f2b81314d3eb4216fb962'/>
<id>urn:sha1:650b55b707fdfa764e9f2b81314d3eb4216fb962</id>
<content type='text'>
For powerpc64, redefine the ppc_inst type so both word and prefixed
instructions can be represented. On powerpc32 the type will remain the
same. Update places which had assumed instructions to be 4 bytes long.

Signed-off-by: Jordan Niethe &lt;jniethe5@gmail.com&gt;
Reviewed-by: Alistair Popple &lt;alistair@popple.id.au&gt;
[mpe: Rework the get_user_inst() macros to be parameterised, and don't
      assign to the dest if an error occurred. Use CONFIG_PPC64 not
      __powerpc64__ in a few places. Address other comments from
      Christophe. Fix some sparse complaints.]
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/20200506034050.24806-24-jniethe5@gmail.com
</content>
</entry>
</feed>
