<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/arch/riscv/lib/uaccess.S, branch linus/master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/arch/riscv/lib/uaccess.S?h=linus%2Fmaster</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/arch/riscv/lib/uaccess.S?h=linus%2Fmaster'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-01-06T01:52:47Z</updated>
<entry>
<title>riscv: extable: consolidate definitions</title>
<updated>2022-01-06T01:52:47Z</updated>
<author>
<name>Jisheng Zhang</name>
<email>jszhang@kernel.org</email>
</author>
<published>2021-11-18T11:25:45Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=6dd10d9166a0c06260e0ac6b1fac454117c8024a'/>
<id>urn:sha1:6dd10d9166a0c06260e0ac6b1fac454117c8024a</id>
<content type='text'>
This is a riscv port of commit 819771cc2892 ("arm64: extable:
consolidate definitions").

Signed-off-by: Jisheng Zhang &lt;jszhang@kernel.org&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>riscv: lib: uaccess: fold fixups into body</title>
<updated>2022-01-06T01:52:39Z</updated>
<author>
<name>Jisheng Zhang</name>
<email>jszhang@kernel.org</email>
</author>
<published>2021-11-18T11:25:14Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=9d504f9aa5c1b76673018da9503e76b351a24b8c'/>
<id>urn:sha1:9d504f9aa5c1b76673018da9503e76b351a24b8c</id>
<content type='text'>
uaccess functions such __asm_copy_to_user(),  __arch_copy_from_user()
and __clear_user() place their exception fixups in the `.fixup` section
without any clear association with themselves. If we backtrace the
fixup code, it will be symbolized as an offset from the nearest prior
symbol.

Similar as arm64 does, we must move fixups into the body of the
functions themselves, after the usual fast-path returns.

Signed-off-by: Jisheng Zhang &lt;jszhang@kernel.org&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>riscv: switch to relative exception tables</title>
<updated>2022-01-06T01:52:20Z</updated>
<author>
<name>Jisheng Zhang</name>
<email>jszhang@kernel.org</email>
</author>
<published>2021-11-18T11:22:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=bb1f85d6046f0db757ac52ed60a5eba5df394819'/>
<id>urn:sha1:bb1f85d6046f0db757ac52ed60a5eba5df394819</id>
<content type='text'>
Similar as other architectures such as arm64, x86 and so on, use
offsets relative to the exception table entry values rather than
absolute addresses for both the exception locationand the fixup.

However, RISCV label difference will actually produce two relocations,
a pair of R_RISCV_ADD32 and R_RISCV_SUB32. Take below simple code for
example:

$ cat test.S
.section .text
1:
        nop
.section __ex_table,"a"
        .balign 4
        .long (1b - .)
.previous

$ riscv64-linux-gnu-gcc -c test.S
$ riscv64-linux-gnu-readelf -r test.o
Relocation section '.rela__ex_table' at offset 0x100 contains 2 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  000600000023 R_RISCV_ADD32     0000000000000000 .L1^B1 + 0
000000000000  000500000027 R_RISCV_SUB32     0000000000000000 .L0  + 0

The modpost will complain the R_RISCV_SUB32 relocation, so we need to
patch modpost.c to skip this relocation for .rela__ex_table section.

After this patch, the __ex_table section size of defconfig vmlinux is
reduced from 7072 Bytes to 3536 Bytes.

Signed-off-by: Jisheng Zhang &lt;jszhang@kernel.org&gt;
Reviewed-by: Kefeng Wang &lt;wangkefeng.wang@huawei.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>riscv: __asm_copy_to-from_user: Fix: Typos in comments</title>
<updated>2021-07-24T00:49:12Z</updated>
<author>
<name>Akira Tsukamoto</name>
<email>akira.tsukamoto@gmail.com</email>
</author>
<published>2021-07-20T08:53:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=ea196c548c0ac407afd31d142712b6da8bd00244'/>
<id>urn:sha1:ea196c548c0ac407afd31d142712b6da8bd00244</id>
<content type='text'>
Fixing typos and grammar mistakes and using more intuitive label
name.

Signed-off-by: Akira Tsukamoto &lt;akira.tsukamoto@gmail.com&gt;
Fixes: ca6eaaa210de ("riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall")
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: __asm_copy_to-from_user: Remove unnecessary size check</title>
<updated>2021-07-24T00:49:07Z</updated>
<author>
<name>Akira Tsukamoto</name>
<email>akira.tsukamoto@gmail.com</email>
</author>
<published>2021-07-20T08:52:36Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=d4b3e0105e3c2411af666a50b1bf2d25656a5e83'/>
<id>urn:sha1:d4b3e0105e3c2411af666a50b1bf2d25656a5e83</id>
<content type='text'>
Clean up:

The size of 0 will be evaluated in the next step. Not
required here.

Signed-off-by: Akira Tsukamoto &lt;akira.tsukamoto@gmail.com&gt;
Fixes: ca6eaaa210de ("riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall")
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: __asm_copy_to-from_user: Fix: fail on RV32</title>
<updated>2021-07-24T00:49:01Z</updated>
<author>
<name>Akira Tsukamoto</name>
<email>akira.tsukamoto@gmail.com</email>
</author>
<published>2021-07-20T08:51:45Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=22b5f16ffeff38938ad7420a2bfa3c281c36fd17'/>
<id>urn:sha1:22b5f16ffeff38938ad7420a2bfa3c281c36fd17</id>
<content type='text'>
Had a bug when converting bytes to bits when the cpu was rv32.

The a3 contains the number of bytes and multiple of 8
would be the bits. The LGREG is holding 2 for RV32 and 3 for
RV32, so to achieve multiple of 8 it must always be constant 3.
The 2 was mistakenly used for rv32.

Signed-off-by: Akira Tsukamoto &lt;akira.tsukamoto@gmail.com&gt;
Fixes: ca6eaaa210de ("riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall")
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: __asm_copy_to-from_user: Fix: overrun copy</title>
<updated>2021-07-24T00:48:52Z</updated>
<author>
<name>Akira Tsukamoto</name>
<email>akira.tsukamoto@gmail.com</email>
</author>
<published>2021-07-20T08:50:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=6010d300f9f7e16d1bf327b4730bcd0c0886d9e6'/>
<id>urn:sha1:6010d300f9f7e16d1bf327b4730bcd0c0886d9e6</id>
<content type='text'>
There were two causes for the overrun memory access.

The threshold size was too small.
The aligning dst require one SZREG and unrolling word copy requires
8*SZREG, total have to be at least 9*SZREG.

Inside the unrolling copy, the subtracting -(8*SZREG-1) would make
iteration happening one extra loop. Proper value is -(8*SZREG).

Signed-off-by: Akira Tsukamoto &lt;akira.tsukamoto@gmail.com&gt;
Fixes: ca6eaaa210de ("riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall")
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall</title>
<updated>2021-07-06T22:09:48Z</updated>
<author>
<name>Akira Tsukamoto</name>
<email>akira.tsukamoto@gmail.com</email>
</author>
<published>2021-06-23T12:40:39Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=ca6eaaa210deec0e41cbfc380bf89cf079203569'/>
<id>urn:sha1:ca6eaaa210deec0e41cbfc380bf89cf079203569</id>
<content type='text'>
This patch will reduce cpu usage dramatically in kernel space especially
for application which use sys-call with large buffer size, such as
network applications. The main reason behind this is that every
unaligned memory access will raise exceptions and switch between s-mode
and m-mode causing large overhead.

First copy in bytes until reaches the first word aligned boundary in
destination memory address. This is the preparation before the bulk
aligned word copy.

The destination address is aligned now, but oftentimes the source
address is not in an aligned boundary. To reduce the unaligned memory
access, it reads the data from source in aligned boundaries, which will
cause the data to have an offset, and then combines the data in the next
iteration by fixing offset with shifting before writing to destination.
The majority of the improving copy speed comes from this shift copy.

In the lucky situation that the both source and destination address are
on the aligned boundary, perform load and store with register size to
copy the data. Without the unrolling, it will reduce the speed since the
next store instruction for the same register using from the load will
stall the pipeline.

At last, copying the remainder in one byte at a time.

Signed-off-by: Akira Tsukamoto &lt;akira.tsukamoto@gmail.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>RISC-V: Stop using LOCAL for the uaccess fixups</title>
<updated>2020-03-03T18:45:14Z</updated>
<author>
<name>Palmer Dabbelt</name>
<email>palmerdabbelt@google.com</email>
</author>
<published>2020-02-27T19:16:28Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=abc71bf0a70311ab294f97a7f16e8de03718c05a'/>
<id>urn:sha1:abc71bf0a70311ab294f97a7f16e8de03718c05a</id>
<content type='text'>
LLVM's integrated assembler doesn't support the LOCAL directive, which we're
using when generating our uaccess fixup tables.  Luckily the table fragment is
small enough that there's only one internal symbol, so using a relative symbol
reference doesn't really complicate anything.

Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: fix compile failure with EXPORT_SYMBOL() &amp; !MMU</title>
<updated>2019-12-28T05:44:36Z</updated>
<author>
<name>Luc Van Oostenryck</name>
<email>luc.vanoostenryck@gmail.com</email>
</author>
<published>2019-12-22T09:26:04Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4d47ce158efb7b145c680e79cd33e3c6fd773de4'/>
<id>urn:sha1:4d47ce158efb7b145c680e79cd33e3c6fd773de4</id>
<content type='text'>
When support for !MMU was added, the declaration of
__asm_copy_to_user() &amp; __asm_copy_from_user() were #ifdefed
out hence their EXPORT_SYMBOL() give an error message like:
  .../riscv_ksyms.c:13:15: error: '__asm_copy_to_user' undeclared here
  .../riscv_ksyms.c:14:15: error: '__asm_copy_from_user' undeclared here

Since these symbols are not defined with !MMU it's wrong to export them.
Same for __clear_user() (even though this one is also declared in
include/asm-generic/uaccess.h and thus doesn't give an error message).

Fix this by doing the EXPORT_SYMBOL() directly where these symbols
are defined: inside lib/uaccess.S itself.

Fixes: 6bd33e1ece52 ("riscv: fix compile failure with EXPORT_SYMBOL() &amp; !MMU")
Reported-by: kbuild test robot &lt;lkp@intel.com&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: Palmer Dabbelt &lt;palmer@dabbelt.com&gt;
Cc: Paul Walmsley &lt;paul.walmsley@sifive.com&gt;
Signed-off-by: Luc Van Oostenryck &lt;luc.vanoostenryck@gmail.com&gt;
Signed-off-by: Paul Walmsley &lt;paul.walmsley@sifive.com&gt;</content>
</entry>
</feed>
