<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/powerpc/include/asm/uaccess.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-05-12T01:07:39Z</updated>
<entry>
<title>powerpc/uaccess: Fix __get_user() with CONFIG_CC_HAS_ASM_GOTO_OUTPUT</title>
<updated>2021-05-12T01:07:39Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-05-08T09:25:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7315e457d6bc342d06ba0b7ee498221c5237a547'/>
<id>urn:sha1:7315e457d6bc342d06ba0b7ee498221c5237a547</id>
<content type='text'>
Building kernel mainline with GCC 11 leads to following failure
when starting 'init':

  init[1]: bad frame in sys_sigreturn: 7ff5a900 nip 001083cc lr 001083c4
  Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

This is an issue due to a segfault happening in
__unsafe_restore_general_regs() in a loop copying registers from user
to kernel:

  10:	7d 09 03 a6 	mtctr   r8
  14:	80 ca 00 00 	lwz     r6,0(r10)
  18:	80 ea 00 04 	lwz     r7,4(r10)
  1c:	90 c9 00 08 	stw     r6,8(r9)
  20:	90 e9 00 0c 	stw     r7,12(r9)
  24:	39 0a 00 08 	addi    r8,r10,8
  28:	39 29 00 08 	addi    r9,r9,8
  2c:	81 4a 00 08 	lwz     r10,8(r10)  &lt;== r10 is clobbered here
  30:	81 6a 00 0c 	lwz     r11,12(r10)
  34:	91 49 00 08 	stw     r10,8(r9)
  38:	91 69 00 0c 	stw     r11,12(r9)
  3c:	39 48 00 08 	addi    r10,r8,8
  40:	39 29 00 08 	addi    r9,r9,8
  44:	42 00 ff d0 	bdnz    14 &lt;__unsafe_restore_general_regs+0x14&gt;

As shown above, this is due to r10 being re-used by GCC. This didn't
happen with CLANG.

This is fixed by tagging 'x' output as an earlyclobber operand in
__get_user_asm2_goto().

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/cf0a050d124d4f426cdc7a74009d17b01d8d8969.1620465917.git.christophe.leroy@csgroup.eu

</content>
</entry>
<entry>
<title>powerpc: Avoid clang uninitialized warning in __get_user_size_allowed</title>
<updated>2021-04-28T13:34:50Z</updated>
<author>
<name>Nathan Chancellor</name>
</author>
<published>2021-04-26T20:35:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f9cd5f91a897ea0c45d0059ceeb091cee78c6ebe'/>
<id>urn:sha1:f9cd5f91a897ea0c45d0059ceeb091cee78c6ebe</id>
<content type='text'>
Commit 9975f852ce1b ("powerpc/uaccess: Remove calls to __get_user_bad()
and __put_user_bad()") switch to BUILD_BUG() in the default case, which
leaves x uninitialized. This will not be an issue because the build will
be broken in that case but clang does static analysis before it realizes
the default case will be done so it warns about x being uninitialized
(trimmed for brevity):

 In file included from mm/mprotect.c:13:
 In file included from ./include/linux/hugetlb.h:28:
 In file included from ./include/linux/mempolicy.h:16:
 ./include/linux/pagemap.h:772:16: warning: variable '__gu_val' is used
 uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
                 if (unlikely(__get_user(c, uaddr) != 0))
                              ^~~~~~~~~~~~~~~~~~~~
 ./arch/powerpc/include/asm/uaccess.h:266:2: note: expanded from macro '__get_user'
         __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err);      \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ./arch/powerpc/include/asm/uaccess.h:235:2: note: expanded from macro
 '__get_user_size_allowed'
        default: BUILD_BUG();                                   \
        ^~~~~~~

Commit 5cd29b1fd3e8 ("powerpc/uaccess: Use asm goto for get_user when
compiler supports it") added an initialization for x because of the same
reason. Do the same thing here so there is no warning across all
versions of clang.

Signed-off-by: Nathan Chancellor &lt;nathan@kernel.org&gt;
Acked-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://github.com/ClangBuiltLinux/linux/issues/1359
Link: https://lore.kernel.org/r/20210426203518.981550-1-nathan@kernel.org

</content>
</entry>
<entry>
<title>powerpc/uaccess: Also perform 64 bits copies in unsafe_copy_from_user() on ppc32</title>
<updated>2021-04-03T10:22:18Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-19T11:06:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c1cc1570bc8d94f288060f262f11be8f7672578c'/>
<id>urn:sha1:c1cc1570bc8d94f288060f262f11be8f7672578c</id>
<content type='text'>
Similarly to commit 5cf773fc8f37 ("powerpc/uaccess: Also perform
64 bits copies in unsafe_copy_to_user() on ppc32")

ppc32 has an efficiant 64 bits unsafe_get_user(), so also use it in
order to unroll loops more.

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/308e65d9237a14e8c0e3b22919fcf0b5e5592608.1616151715.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Use asm goto for get_user when compiler supports it</title>
<updated>2021-04-03T10:22:16Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5cd29b1fd3e8f2b45fe6d011588d832417defe31'/>
<id>urn:sha1:5cd29b1fd3e8f2b45fe6d011588d832417defe31</id>
<content type='text'>
clang 11 and future GCC are supporting asm goto with outputs.

Use it to implement get_user in order to get better generated code.

Note that clang requires to set x in the default branch of
__get_user_size_goto() otherwise is compliant about x not being
initialised :puzzled:

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/403745b5aaa1b315bb4e8e46c1ba949e77eecec0.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Introduce __get_user_size_goto()</title>
<updated>2021-04-03T10:22:13Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=035785ab2826beb43cfa65a2df37d60074915a4d'/>
<id>urn:sha1:035785ab2826beb43cfa65a2df37d60074915a4d</id>
<content type='text'>
We have got two places doing a goto based on the result
of __get_user_size_allowed().

Refactor that into __get_user_size_goto().

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/def8a39289e02653cfb1583b3b19837de9efed3a.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Refactor get/put_user() and __get/put_user()</title>
<updated>2021-04-03T10:22:10Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e72fcdb26cde72985c418b39f72ecaa222e1f4d5'/>
<id>urn:sha1:e72fcdb26cde72985c418b39f72ecaa222e1f4d5</id>
<content type='text'>
Make get_user() do the access_ok() check then call __get_user().
Make put_user() do the access_ok() check then call __put_user().

Then embed  __get_user_size() and __put_user_size() in
__get_user() and __put_user().

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/eebc554f6a81f570c46ea3551000ff5b886e4faa.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Rename __get/put_user_check/nocheck</title>
<updated>2021-04-03T10:22:08Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=17f8c0bc21bbb7d1fe729c7f656924a6ea72079b'/>
<id>urn:sha1:17f8c0bc21bbb7d1fe729c7f656924a6ea72079b</id>
<content type='text'>
__get_user_check() becomes get_user()
__put_user_check() becomes put_user()
__get_user_nocheck() becomes __get_user()
__put_user_nocheck() becomes __put_user()

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/41d7e45f4733f0e61e63824e4865b4e049db74d6.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Split out __get_user_nocheck()</title>
<updated>2021-04-03T10:22:05Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f904c22f2a9fb09fe705efdedbe4af9a30bdf633'/>
<id>urn:sha1:f904c22f2a9fb09fe705efdedbe4af9a30bdf633</id>
<content type='text'>
One part of __get_user_nocheck() is used for __get_user(),
the other part for unsafe_get_user().

Move the part dedicated to unsafe_get_user() in it.

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/618fe2e0626b308a5a063d5baac827b968e85c32.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Remove calls to __get_user_bad() and __put_user_bad()</title>
<updated>2021-04-03T10:22:02Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9975f852ce1bf041a1a81bf882e29ee7a3b78ca6'/>
<id>urn:sha1:9975f852ce1bf041a1a81bf882e29ee7a3b78ca6</id>
<content type='text'>
__get_user_bad() and __put_user_bad() are functions that are
declared but not defined, in order to make the link fail in
case they are called.

Nowadays, we have BUILD_BUG() and BUILD_BUG_ON() for that, and
they have the advantage to break the build earlier as it breaks
it at compile time instead of link time.

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/d7d839e994f49fae4ff7b70fac72bd951272436b.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
<entry>
<title>powerpc/uaccess: Remove __chk_user_ptr() in __get/put_user</title>
<updated>2021-04-03T10:21:59Z</updated>
<author>
<name>Christophe Leroy</name>
</author>
<published>2021-03-10T17:46:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=028e15616857add3ba4951f989027675370b0e82'/>
<id>urn:sha1:028e15616857add3ba4951f989027675370b0e82</id>
<content type='text'>
Commit d02f6b7dab82 ("powerpc/uaccess: Evaluate macro arguments once,
before user access is allowed") changed the __chk_user_ptr()
argument from the passed ptr pointer to the locally
declared __gu_addr. But __gu_addr is locally defined as __user
so the check is pointless.

During kernel build __chk_user_ptr() voids and is only evaluated
during sparse checks so it should have been armless to leave the
original pointer check there.

Nevertheless, this check is indeed redundant with the assignment
above which casts the ptr pointer to the local __user __gu_addr.
In case of mismatch, sparse will detect it there, so the
__check_user_ptr() is not needed anywhere else than in access_ok().

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/69f17d75046733b891ab2e668dbf464787cdf598.1615398265.git.christophe.leroy@csgroup.eu
</content>
</entry>
</feed>
