<feed xmlns='http://www.w3.org/2005/Atom'>
<title>starfive-tech/linux.git/lib, branch visionfive_v1_5.13</title>
<subtitle>StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)</subtitle>
<id>https://git.radix-linux.su/starfive-tech/linux.git/atom?h=visionfive_v1_5.13</id>
<link rel='self' href='https://git.radix-linux.su/starfive-tech/linux.git/atom?h=visionfive_v1_5.13'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/'/>
<updated>2021-08-26T21:07:31+00:00</updated>
<entry>
<title>lib/string: optimized memset</title>
<updated>2021-08-26T21:07:31+00:00</updated>
<author>
<name>Matteo Croce</name>
<email>mcroce@microsoft.com</email>
</author>
<published>2021-07-16T03:45:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=c6e1eb4b5ecb83739dec7d90ca65f8544219995b'/>
<id>urn:sha1:c6e1eb4b5ecb83739dec7d90ca65f8544219995b</id>
<content type='text'>
The generic memset is defined as a byte at time write.  This is always
safe, but it's slower than a 4 byte or even 8 byte write.

Write a generic memset which fills the data one byte at time until the
destination is aligned, then fills using the largest size allowed, and
finally fills the remaining data one byte at time.

On a RISC-V machine the speed goes from 140 Mb/s to 241 Mb/s, and this the
binary size increase according to bloat-o-meter:

Function     old     new   delta
memset        32     148    +116

Link: https://lkml.kernel.org/r/20210702123153.14093-4-mcroce@linux.microsoft.com
Signed-off-by: Matteo Croce &lt;mcroce@microsoft.com&gt;
Cc: Christoph Hellwig &lt;hch@infradead.org&gt;
Cc: David Laight &lt;David.Laight@aculab.com&gt;
Cc: Drew Fustini &lt;drew@beagleboard.org&gt;
Cc: Emil Renner Berthing &lt;kernel@esmil.dk&gt;
Cc: Guo Ren &lt;guoren@kernel.org&gt;
Cc: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
Cc: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Cc: Palmer Dabbelt &lt;palmer@dabbelt.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
</content>
</entry>
<entry>
<title>lib/string: optimized memmove</title>
<updated>2021-08-26T21:07:31+00:00</updated>
<author>
<name>Matteo Croce</name>
<email>mcroce@microsoft.com</email>
</author>
<published>2021-07-16T03:45:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=2096a992d6dd47e02819d1ac1f1a696909262fd2'/>
<id>urn:sha1:2096a992d6dd47e02819d1ac1f1a696909262fd2</id>
<content type='text'>
When the destination buffer is before the source one, or when the buffers
doesn't overlap, it's safe to use memcpy() instead, which is optimized to
use a bigger data size possible.

This "optimization" only covers a common case.  In future, proper code
which does the same thing as memcpy() does but backwards can be done.

Link: https://lkml.kernel.org/r/20210702123153.14093-3-mcroce@linux.microsoft.com
Signed-off-by: Matteo Croce &lt;mcroce@microsoft.com&gt;
Cc: Christoph Hellwig &lt;hch@infradead.org&gt;
Cc: David Laight &lt;David.Laight@aculab.com&gt;
Cc: Drew Fustini &lt;drew@beagleboard.org&gt;
Cc: Emil Renner Berthing &lt;kernel@esmil.dk&gt;
Cc: Guo Ren &lt;guoren@kernel.org&gt;
Cc: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
Cc: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Cc: Palmer Dabbelt &lt;palmer@dabbelt.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
</content>
</entry>
<entry>
<title>lib/string: optimized memcpy</title>
<updated>2021-08-26T21:07:31+00:00</updated>
<author>
<name>Matteo Croce</name>
<email>mcroce@microsoft.com</email>
</author>
<published>2021-07-16T03:45:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=e772b4262196a9a153969d371ce2a4e81e2a3333'/>
<id>urn:sha1:e772b4262196a9a153969d371ce2a4e81e2a3333</id>
<content type='text'>
Patch series "lib/string: optimized mem* functions", v2.

Rewrite the generic mem{cpy,move,set} so that memory is accessed with the
widest size possible, but without doing unaligned accesses.

This was originally posted as C string functions for RISC-V[1], but as
there was no specific RISC-V code, it was proposed for the generic
lib/string.c implementation.

Tested on RISC-V and on x86_64 by undefining __HAVE_ARCH_MEM{CPY,SET,MOVE}
and HAVE_EFFICIENT_UNALIGNED_ACCESS.

These are the performances of memcpy() and memset() of a RISC-V machine on
a 32 mbyte buffer:

memcpy:
original aligned:	 75 Mb/s
original unaligned:	 75 Mb/s
new aligned:		114 Mb/s
new unaligned:		107 Mb/s

memset:
original aligned:	140 Mb/s
original unaligned:	140 Mb/s
new aligned:		241 Mb/s
new unaligned:		241 Mb/s

The size increase is negligible:

$ scripts/bloat-o-meter vmlinux.orig vmlinux
add/remove: 0/0 grow/shrink: 4/1 up/down: 427/-6 (421)
Function                                     old     new   delta
memcpy                                        29     351    +322
memset                                        29     117     +88
strlcat                                       68      78     +10
strlcpy                                       50      57      +7
memmove                                       56      50      -6
Total: Before=8556964, After=8557385, chg +0.00%

These functions will be used for RISC-V initially.

[1] https://lore.kernel.org/linux-riscv/20210617152754.17960-1-mcroce@linux.microsoft.com/

This patch (of 3):

Rewrite the generic memcpy() to copy a word at time, without generating
unaligned accesses.

The procedure is made of three steps: First copy data one byte at time
until the destination buffer is aligned to a long boundary.  Then copy the
data one long at time shifting the current and the next long to compose a
long at every cycle.  Finally, copy the remainder one byte at time.

This is the improvement on RISC-V:

original aligned:	 75 Mb/s
original unaligned:	 75 Mb/s
new aligned:		114 Mb/s
new unaligned:		107 Mb/s

and this the binary size increase according to bloat-o-meter:

Function     old     new   delta
memcpy        36     324    +288

Link: https://lkml.kernel.org/r/20210702123153.14093-1-mcroce@linux.microsoft.com
Link: https://lkml.kernel.org/r/20210702123153.14093-2-mcroce@linux.microsoft.com
Signed-off-by: Matteo Croce &lt;mcroce@microsoft.com&gt;
Cc: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Cc: Guo Ren &lt;guoren@kernel.org&gt;
Cc: Christoph Hellwig &lt;hch@infradead.org&gt;
Cc: David Laight &lt;David.Laight@aculab.com&gt;
Cc: Palmer Dabbelt &lt;palmer@dabbelt.com&gt;
Cc: Emil Renner Berthing &lt;kernel@esmil.dk&gt;
Cc: Drew Fustini &lt;drew@beagleboard.org&gt;
Cc: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
</content>
</entry>
<entry>
<title>lib: use PFN_PHYS() in devmem_is_allowed()</title>
<updated>2021-08-18T07:06:46+00:00</updated>
<author>
<name>Liang Wang</name>
<email>wangliang101@huawei.com</email>
</author>
<published>2021-08-13T23:54:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=95f4fb3ef0b9b7f9b0261f35c029729de0e451da'/>
<id>urn:sha1:95f4fb3ef0b9b7f9b0261f35c029729de0e451da</id>
<content type='text'>
commit 854f32648b8a5e424d682953b1a9f3b7c3322701 upstream.

The physical address may exceed 32 bits on 32-bit systems with more than
32 bits of physcial address.  Use PFN_PHYS() in devmem_is_allowed(), or
the physical address may overflow and be truncated.

We found this bug when mapping a high addresses through devmem tool,
when CONFIG_STRICT_DEVMEM is enabled on the ARM with ARM_LPAE and devmem
is used to map a high address that is not in the iomem address range, an
unexpected error indicating no permission is returned.

This bug was initially introduced from v2.6.37, and the function was
moved to lib in v5.11.

Link: https://lkml.kernel.org/r/20210731025057.78825-1-wangliang101@huawei.com
Fixes: 087aaffcdf9c ("ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem")
Fixes: 527701eda5f1 ("lib: Add a generic version of devmem_is_allowed()")
Signed-off-by: Liang Wang &lt;wangliang101@huawei.com&gt;
Reviewed-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
Cc: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Russell King &lt;linux@armlinux.org.uk&gt;
Cc: Liang Wang &lt;wangliang101@huawei.com&gt;
Cc: Xiaoming Ni &lt;nixiaoming@huawei.com&gt;
Cc: Kefeng Wang &lt;wangkefeng.wang@huawei.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;	[2.6.37+]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>lib/decompress_unlz4.c: correctly handle zero-padding around initrds.</title>
<updated>2021-07-20T14:00:22+00:00</updated>
<author>
<name>Dimitri John Ledkov</name>
<email>dimitri.ledkov@canonical.com</email>
</author>
<published>2021-07-01T01:56:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=67a8dfc86bdb21c8f01bb4a5e5f9c89a063807b0'/>
<id>urn:sha1:67a8dfc86bdb21c8f01bb4a5e5f9c89a063807b0</id>
<content type='text'>
[ Upstream commit 2c484419efc09e7234c667aa72698cb79ba8d8ed ]

lz4 compatible decompressor is simple.  The format is underspecified and
relies on EOF notification to determine when to stop.  Initramfs buffer
format[1] explicitly states that it can have arbitrary number of zero
padding.  Thus when operating without a fill function, be extra careful to
ensure that sizes less than 4, or apperantly empty chunksizes are treated
as EOF.

To test this I have created two cpio initrds, first a normal one,
main.cpio.  And second one with just a single /test-file with content
"second" second.cpio.  Then i compressed both of them with gzip, and with
lz4 -l.  Then I created a padding of 4 bytes (dd if=/dev/zero of=pad4 bs=1
count=4).  To create four testcase initrds:

 1) main.cpio.gzip + extra.cpio.gzip = pad0.gzip
 2) main.cpio.lz4  + extra.cpio.lz4 = pad0.lz4
 3) main.cpio.gzip + pad4 + extra.cpio.gzip = pad4.gzip
 4) main.cpio.lz4  + pad4 + extra.cpio.lz4 = pad4.lz4

The pad4 test-cases replicate the initrd load by grub, as it pads and
aligns every initrd it loads.

All of the above boot, however /test-file was not accessible in the initrd
for the testcase #4, as decoding in lz4 decompressor failed.  Also an
error message printed which usually is harmless.

Whith a patched kernel, all of the above testcases now pass, and
/test-file is accessible.

This fixes lz4 initrd decompress warning on every boot with grub.  And
more importantly this fixes inability to load multiple lz4 compressed
initrds with grub.  This patch has been shipping in Ubuntu kernels since
January 2021.

[1] ./Documentation/driver-api/early-userspace/buffer-format.rst

BugLink: https://bugs.launchpad.net/bugs/1835660
Link: https://lore.kernel.org/lkml/20210114200256.196589-1-xnox@ubuntu.com/ # v0
Link: https://lkml.kernel.org/r/20210513104831.432975-1-dimitri.ledkov@canonical.com
Signed-off-by: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Kyungsik Lee &lt;kyungsik.lee@lge.com&gt;
Cc: Yinghai Lu &lt;yinghai@kernel.org&gt;
Cc: Bongkyu Kim &lt;bongkyu.kim@lge.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Sven Schmidt &lt;4sschmid@informatik.uni-hamburg.de&gt;
Cc: Rajat Asthana &lt;thisisrast7@gmail.com&gt;
Cc: Nick Terrell &lt;terrelln@fb.com&gt;
Cc: Gao Xiang &lt;hsiangkao@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>iov_iter_advance(): use consistent semantics for move past the end</title>
<updated>2021-07-20T14:00:16+00:00</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2021-04-24T02:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=ed8c2cc773811a18f84f9f89e4662183d28177f6'/>
<id>urn:sha1:ed8c2cc773811a18f84f9f89e4662183d28177f6</id>
<content type='text'>
[ Upstream commit 3b3fc051cd2cba42bf736fa62780857d251a1236 ]

asking to advance by more than we have left in the iov_iter should
move to the very end; it should *not* leave negative i-&gt;count and
it should not spew into syslog, etc. - it's a legitimate operation.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>seq_buf: Fix overflow in seq_buf_putmem_hex()</title>
<updated>2021-07-19T08:04:52+00:00</updated>
<author>
<name>Yun Zhou</name>
<email>yun.zhou@windriver.com</email>
</author>
<published>2021-06-26T03:21:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=d57fcab190b60f43046d5836c3c56114b4f50080'/>
<id>urn:sha1:d57fcab190b60f43046d5836c3c56114b4f50080</id>
<content type='text'>
commit d3b16034a24a112bb83aeb669ac5b9b01f744bb7 upstream.

There's two variables being increased in that loop (i and j), and i
follows the raw data, and j follows what is being written into the buffer.
We should compare 'i' to MAX_MEMHEX_BYTES or compare 'j' to HEX_CHARS.
Otherwise, if 'j' goes bigger than HEX_CHARS, it will overflow the
destination buffer.

Link: https://lore.kernel.org/lkml/20210625122453.5e2fe304@oasis.local.home/
Link: https://lkml.kernel.org/r/20210626032156.47889-1-yun.zhou@windriver.com

Cc: stable@vger.kernel.org
Fixes: 5e3ca0ec76fce ("ftrace: introduce the "hex" output method")
Signed-off-by: Yun Zhou &lt;yun.zhou@windriver.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>lib/math/rational.c: fix divide by zero</title>
<updated>2021-07-14T15:07:48+00:00</updated>
<author>
<name>Trent Piepho</name>
<email>tpiepho@gmail.com</email>
</author>
<published>2021-07-01T01:55:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=0ef6f9783957506dd364b98d0de0d8f5f67fa902'/>
<id>urn:sha1:0ef6f9783957506dd364b98d0de0d8f5f67fa902</id>
<content type='text'>
[ Upstream commit 65a0d3c14685663ba111038a35db70f559e39336 ]

If the input is out of the range of the allowed values, either larger than
the largest value or closer to zero than the smallest non-zero allowed
value, then a division by zero would occur.

In the case of input too large, the division by zero will occur on the
first iteration.  The best result (largest allowed value) will be found by
always choosing the semi-convergent and excluding the denominator based
limit when finding it.

In the case of the input too small, the division by zero will occur on the
second iteration.  The numerator based semi-convergent should not be
calculated to avoid the division by zero.  But the semi-convergent vs
previous convergent test is still needed, which effectively chooses
between 0 (the previous convergent) vs the smallest allowed fraction (best
semi-convergent) as the result.

Link: https://lkml.kernel.org/r/20210525144250.214670-1-tpiepho@gmail.com
Fixes: 323dd2c3ed0 ("lib/math/rational.c: fix possible incorrect result from rational fractions helper")
Signed-off-by: Trent Piepho &lt;tpiepho@gmail.com&gt;
Reported-by: Yiyuan Guo &lt;yguoaz@gmail.com&gt;
Reviewed-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Cc: Oskar Schirmer &lt;oskar@scara.com&gt;
Cc: Daniel Latypov &lt;dlatypov@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>kunit: Fix result propagation for parameterised tests</title>
<updated>2021-07-14T15:07:39+00:00</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-06-11T03:57:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=d4ff9e9ed5af7b8f82567e142f3f1b1b37e7cc24'/>
<id>urn:sha1:d4ff9e9ed5af7b8f82567e142f3f1b1b37e7cc24</id>
<content type='text'>
[ Upstream commit 384426bd101cb3cd580b18de19d4891ec5ca5bf9 ]

When one parameter of a parameterised test failed, its failure would be
propagated to the overall test, but not to the suite result (unless it
was the last parameter).

This is because test_case-&gt;success was being reset to the test-&gt;success
result after each parameter was used, so a failing test's result would
be overwritten by a non-failing result. The overall test result was
handled in a third variable, test_result, but this was discarded after
the status line was printed.

Instead, just propagate the result after each parameter run.

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Fixes: fadb08e7c750 ("kunit: Support for Parameterized Testing")
Reviewed-by: Marco Elver &lt;elver@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING</title>
<updated>2021-07-14T15:06:48+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2021-06-17T18:57:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/starfive-tech/linux.git/commit/?id=a2c53d934a91a08e83695574d2ce243917b2b0f4'/>
<id>urn:sha1:a2c53d934a91a08e83695574d2ce243917b2b0f4</id>
<content type='text'>
[ Upstream commit c0c2c0dad6a06e0c05e9a52d65f932bd54364c97 ]

When PROVE_RAW_LOCK_NESTING=y many of the selftests FAILED because
HARDIRQ context is out-of-bounds for spinlocks. Instead make the
default hardware context the threaded hardirq context, which preserves
the old locking rules.

The wait-type specific locking selftests will have a non-threaded
HARDIRQ variant.

Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Tested-by: Joerg Roedel &lt;jroedel@suse.de&gt;
Link: https://lore.kernel.org/r/20210617190313.322096283@infradead.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
