<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/arch/riscv/kernel/Makefile, branch v5.14</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>riscv: kexec: do not add '-mno-relax' flag if compiler doesn't support it</title>
<updated>2021-08-12T14:16:52+00:00</updated>
<author>
<name>Changbin Du</name>
<email>changbin.du@gmail.com</email>
</author>
<published>2021-07-22T02:17:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=030d6dbf0c2e5fdf23ad29557f0c87a882993e26'/>
<id>030d6dbf0c2e5fdf23ad29557f0c87a882993e26</id>
<content type='text'>
The RISC-V special option '-mno-relax' which to disable linker relaxations
is supported by GCC8+. For GCC7 and lower versions do not support this
option.

Fixes: fba8a8674f68 ("RISC-V: Add kexec support")
Signed-off-by: Changbin Du &lt;changbin.du@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The RISC-V special option '-mno-relax' which to disable linker relaxations
is supported by GCC8+. For GCC7 and lower versions do not support this
option.

Fixes: fba8a8674f68 ("RISC-V: Add kexec support")
Signed-off-by: Changbin Du &lt;changbin.du@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux</title>
<updated>2021-05-06T16:24:18+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-05-06T16:24:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=939b7cbc00906b02c6eae6a380ad6c24c7a1e043'/>
<id>939b7cbc00906b02c6eae6a380ad6c24c7a1e043</id>
<content type='text'>
Pull RISC-V updates from Palmer Dabbelt:

 - Support for the memtest= kernel command-line argument.

 - Support for building the kernel with FORTIFY_SOURCE.

 - Support for generic clockevent broadcasts.

 - Support for the buildtar build target.

 - Some build system cleanups to pass more LLVM-friendly arguments.

 - Support for kprobes.

 - A rearranged kernel memory map, the first part of supporting sv48
   systems.

 - Improvements to kexec, along with support for kdump and crash
   kernels.

 - An alternatives-based errata framework, along with support for
   handling a pair of errata that manifest on some SiFive designs
   (including the HiFive Unmatched).

 - Support for XIP.

 - A device tree for the Microchip PolarFire ICICLE SoC and associated
   dev board.

... along with a bunch of cleanups.  There are already a handful of fixes
on the list so there will likely be a part 2.

* tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (45 commits)
  RISC-V: Always define XIP_FIXUP
  riscv: Remove 32b kernel mapping from page table dump
  riscv: Fix 32b kernel build with CONFIG_DEBUG_VIRTUAL=y
  RISC-V: Fix error code returned by riscv_hartid_to_cpuid()
  RISC-V: Enable Microchip PolarFire ICICLE SoC
  RISC-V: Initial DTS for Microchip ICICLE board
  dt-bindings: riscv: microchip: Add YAML documentation for the PolarFire SoC
  RISC-V: Add Microchip PolarFire SoC kconfig option
  RISC-V: enable XIP
  RISC-V: Add crash kernel support
  RISC-V: Add kdump support
  RISC-V: Improve init_resources()
  RISC-V: Add kexec support
  RISC-V: Add EM_RISCV to kexec UAPI header
  riscv: vdso: fix and clean-up Makefile
  riscv/mm: Use BUG_ON instead of if condition followed by BUG.
  riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe
  riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU
  riscv: module: Create module allocations without exec permissions
  riscv: bpf: Avoid breaking W^X
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull RISC-V updates from Palmer Dabbelt:

 - Support for the memtest= kernel command-line argument.

 - Support for building the kernel with FORTIFY_SOURCE.

 - Support for generic clockevent broadcasts.

 - Support for the buildtar build target.

 - Some build system cleanups to pass more LLVM-friendly arguments.

 - Support for kprobes.

 - A rearranged kernel memory map, the first part of supporting sv48
   systems.

 - Improvements to kexec, along with support for kdump and crash
   kernels.

 - An alternatives-based errata framework, along with support for
   handling a pair of errata that manifest on some SiFive designs
   (including the HiFive Unmatched).

 - Support for XIP.

 - A device tree for the Microchip PolarFire ICICLE SoC and associated
   dev board.

... along with a bunch of cleanups.  There are already a handful of fixes
on the list so there will likely be a part 2.

* tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (45 commits)
  RISC-V: Always define XIP_FIXUP
  riscv: Remove 32b kernel mapping from page table dump
  riscv: Fix 32b kernel build with CONFIG_DEBUG_VIRTUAL=y
  RISC-V: Fix error code returned by riscv_hartid_to_cpuid()
  RISC-V: Enable Microchip PolarFire ICICLE SoC
  RISC-V: Initial DTS for Microchip ICICLE board
  dt-bindings: riscv: microchip: Add YAML documentation for the PolarFire SoC
  RISC-V: Add Microchip PolarFire SoC kconfig option
  RISC-V: enable XIP
  RISC-V: Add crash kernel support
  RISC-V: Add kdump support
  RISC-V: Improve init_resources()
  RISC-V: Add kexec support
  RISC-V: Add EM_RISCV to kexec UAPI header
  riscv: vdso: fix and clean-up Makefile
  riscv/mm: Use BUG_ON instead of if condition followed by BUG.
  riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe
  riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU
  riscv: module: Create module allocations without exec permissions
  riscv: bpf: Avoid breaking W^X
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>RISC-V: Add crash kernel support</title>
<updated>2021-04-26T15:25:24+00:00</updated>
<author>
<name>Nick Kossifidis</name>
<email>mick@ics.forth.gr</email>
</author>
<published>2021-04-19T00:55:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=5640975003d0234da08559677e22ec25b9cb3267'/>
<id>5640975003d0234da08559677e22ec25b9cb3267</id>
<content type='text'>
This patch allows Linux to act as a crash kernel for use with
kdump. Userspace will let the crash kernel know about the
memory region it can use through linux,usable-memory property
on the /memory node (overriding its reg property), and about the
memory region where the elf core header of the previous kernel
is saved, through a reserved-memory node with a compatible string
of "linux,elfcorehdr". This approach is the least invasive and
re-uses functionality already present.

I tested this on riscv64 qemu and it works as expected, you
may test it by retrieving the dmesg of the previous kernel
through /proc/vmcore, using the vmcore-dmesg utility from
kexec-tools.

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch allows Linux to act as a crash kernel for use with
kdump. Userspace will let the crash kernel know about the
memory region it can use through linux,usable-memory property
on the /memory node (overriding its reg property), and about the
memory region where the elf core header of the previous kernel
is saved, through a reserved-memory node with a compatible string
of "linux,elfcorehdr". This approach is the least invasive and
re-uses functionality already present.

I tested this on riscv64 qemu and it works as expected, you
may test it by retrieving the dmesg of the previous kernel
through /proc/vmcore, using the vmcore-dmesg utility from
kexec-tools.

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>RISC-V: Add kdump support</title>
<updated>2021-04-26T15:25:23+00:00</updated>
<author>
<name>Nick Kossifidis</name>
<email>mick@ics.forth.gr</email>
</author>
<published>2021-04-19T00:55:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e53d28180d4d0fd12b6d2bde49cb87aa775b6ba8'/>
<id>e53d28180d4d0fd12b6d2bde49cb87aa775b6ba8</id>
<content type='text'>
This patch adds support for kdump, the kernel will reserve a
region for the crash kernel and jump there on panic. In order
for userspace tools (kexec-tools) to prepare the crash kernel
kexec image, we also need to expose some information on
/proc/iomem for the memory regions used by the kernel and for
the region reserved for crash kernel. Note that on userspace
the device tree is used to determine the system's memory
layout so the "System RAM" on /proc/iomem is ignored.

I tested this on riscv64 qemu and works as expected, you may
test it by triggering a crash through /proc/sysrq_trigger:

echo c &gt; /proc/sysrq_trigger

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds support for kdump, the kernel will reserve a
region for the crash kernel and jump there on panic. In order
for userspace tools (kexec-tools) to prepare the crash kernel
kexec image, we also need to expose some information on
/proc/iomem for the memory regions used by the kernel and for
the region reserved for crash kernel. Note that on userspace
the device tree is used to determine the system's memory
layout so the "System RAM" on /proc/iomem is ignored.

I tested this on riscv64 qemu and works as expected, you may
test it by triggering a crash through /proc/sysrq_trigger:

echo c &gt; /proc/sysrq_trigger

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>RISC-V: Add kexec support</title>
<updated>2021-04-26T15:25:21+00:00</updated>
<author>
<name>Nick Kossifidis</name>
<email>mick@ics.forth.gr</email>
</author>
<published>2021-04-19T00:55:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=fba8a8674f68a0628abae470dfcfbcb4a0d7a79e'/>
<id>fba8a8674f68a0628abae470dfcfbcb4a0d7a79e</id>
<content type='text'>
This patch adds support for kexec on RISC-V. On SMP systems it depends
on HOTPLUG_CPU in order to be able to bring up all harts after kexec.
It also needs a recent OpenSBI version that supports the HSM extension.
I tested it on riscv64 QEMU on both an smp and a non-smp system.

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds support for kexec on RISC-V. On SMP systems it depends
on HOTPLUG_CPU in order to be able to bring up all harts after kexec.
It also needs a recent OpenSBI version that supports the HSM extension.
I tested it on riscv64 QEMU on both an smp and a non-smp system.

Signed-off-by: Nick Kossifidis &lt;mick@ics.forth.gr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv: syscall_table: Reduce W=1 compilation warnings noise</title>
<updated>2021-03-10T04:46:04+00:00</updated>
<author>
<name>Nanyong Sun</name>
<email>sunnanyong@huawei.com</email>
</author>
<published>2021-03-05T11:33:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a6a58ecf98c3f6d95123ee3e66ccb6f7672c6e68'/>
<id>a6a58ecf98c3f6d95123ee3e66ccb6f7672c6e68</id>
<content type='text'>
Building riscv syscall table with W=1 throws the warning as
following pattern:
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
   14 | #define __SYSCALL(nr, call) [nr] = (call),
      |                                    ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
   29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
      |                                     ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
   34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
      | ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for ‘sys_call_table[0]’)
   14 | #define __SYSCALL(nr, call) [nr] = (call),
      |                                    ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
   29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
      |                                     ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
   34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
      | ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
...

Since we intentionally build the syscall tables this way,ignore the warning.

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Nanyong Sun &lt;sunnanyong@huawei.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Building riscv syscall table with W=1 throws the warning as
following pattern:
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
   14 | #define __SYSCALL(nr, call) [nr] = (call),
      |                                    ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
   29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
      |                                     ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
   34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
      | ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for ‘sys_call_table[0]’)
   14 | #define __SYSCALL(nr, call) [nr] = (call),
      |                                    ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
   29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
      |                                     ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
   34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
      | ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
...

Since we intentionally build the syscall tables this way,ignore the warning.

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Nanyong Sun &lt;sunnanyong@huawei.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv: Add kprobes supported</title>
<updated>2021-01-14T23:09:06+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:01:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c22b0bcb1dd024cb9caad9230e3a387d8b061df5'/>
<id>c22b0bcb1dd024cb9caad9230e3a387d8b061df5</id>
<content type='text'>
This patch enables "kprobe &amp; kretprobe" to work with ftrace
interface. It utilized software breakpoint as single-step
mechanism.

Some instructions which can't be single-step executed must be
simulated in kernel execution slot, such as: branch, jal, auipc,
la ...

Some instructions should be rejected for probing and we use a
blacklist to filter, such as: ecall, ebreak, ...

We use ebreak &amp; c.ebreak to replace origin instruction and the
kprobe handler prepares an executable memory slot for out-of-line
execution with a copy of the original instruction being probed.
In execution slot we add ebreak behind original instruction to
simulate a single-setp mechanism.

The patch is based on packi's work [1] and csky's work [2].
 - The kprobes_trampoline.S is all from packi's patch
 - The single-step mechanism is new designed for riscv without hw
   single-step trap
 - The simulation codes are from csky
 - Frankly, all codes refer to other archs' implementation

 [1] https://lore.kernel.org/linux-riscv/20181113195804.22825-1-me@packi.ch/
 [2] https://lore.kernel.org/linux-csky/20200403044150.20562-9-guoren@kernel.org/

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Co-developed-by: Patrick Stählin &lt;me@packi.ch&gt;
Signed-off-by: Patrick Stählin &lt;me@packi.ch&gt;
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Tested-by: Zong Li &lt;zong.li@sifive.com&gt;
Reviewed-by: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: Patrick Stählin &lt;me@packi.ch&gt;
Cc: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
Cc: Björn Töpel &lt;bjorn.topel@gmail.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch enables "kprobe &amp; kretprobe" to work with ftrace
interface. It utilized software breakpoint as single-step
mechanism.

Some instructions which can't be single-step executed must be
simulated in kernel execution slot, such as: branch, jal, auipc,
la ...

Some instructions should be rejected for probing and we use a
blacklist to filter, such as: ecall, ebreak, ...

We use ebreak &amp; c.ebreak to replace origin instruction and the
kprobe handler prepares an executable memory slot for out-of-line
execution with a copy of the original instruction being probed.
In execution slot we add ebreak behind original instruction to
simulate a single-setp mechanism.

The patch is based on packi's work [1] and csky's work [2].
 - The kprobes_trampoline.S is all from packi's patch
 - The single-step mechanism is new designed for riscv without hw
   single-step trap
 - The simulation codes are from csky
 - Frankly, all codes refer to other archs' implementation

 [1] https://lore.kernel.org/linux-riscv/20181113195804.22825-1-me@packi.ch/
 [2] https://lore.kernel.org/linux-csky/20200403044150.20562-9-guoren@kernel.org/

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Co-developed-by: Patrick Stählin &lt;me@packi.ch&gt;
Signed-off-by: Patrick Stählin &lt;me@packi.ch&gt;
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Tested-by: Zong Li &lt;zong.li@sifive.com&gt;
Reviewed-by: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: Patrick Stählin &lt;me@packi.ch&gt;
Cc: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
Cc: Björn Töpel &lt;bjorn.topel@gmail.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv: Fixup patch_text panic in ftrace</title>
<updated>2021-01-14T23:09:04+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:01:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=5ad84adf5456313e285734102367c861c436c5ed'/>
<id>5ad84adf5456313e285734102367c861c436c5ed</id>
<content type='text'>
Just like arm64, we can't trace the function in the patch_text path.

Here is the bug log:

[   45.234334] Unable to handle kernel paging request at virtual address ffffffd38ae80900
[   45.242313] Oops [#1]
[   45.244600] Modules linked in:
[   45.247678] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-00025-g9b7db83-dirty #215
[   45.255797] epc: ffffffe00021689a ra : ffffffe00021718e sp : ffffffe01afabb58
[   45.262955]  gp : ffffffe00136afa0 tp : ffffffe01af94d00 t0 : 0000000000000002
[   45.270200]  t1 : 0000000000000000 t2 : 0000000000000001 s0 : ffffffe01afabc08
[   45.277443]  s1 : ffffffe0013718a8 a0 : 0000000000000000 a1 : ffffffe01afabba8
[   45.284686]  a2 : 0000000000000000 a3 : 0000000000000000 a4 : c4c16ad38ae80900
[   45.291929]  a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000052464e43
[   45.299173]  s2 : 0000000000000001 s3 : ffffffe000206a60 s4 : ffffffe000206a60
[   45.306415]  s5 : 00000000000009ec s6 : ffffffe0013718a8 s7 : c4c16ad38ae80900
[   45.313658]  s8 : 0000000000000004 s9 : 0000000000000001 s10: 0000000000000001
[   45.320902]  s11: 0000000000000003 t3 : 0000000000000001 t4 : ffffffffd192fe79
[   45.328144]  t5 : ffffffffb8f80000 t6 : 0000000000040000
[   45.333472] status: 0000000200000100 badaddr: ffffffd38ae80900 cause: 000000000000000f
[   45.341514] ---[ end trace d95102172248fdcf ]---
[   45.346176] note: migration/0[11] exited with preempt_count 1

(gdb) x /2i $pc
=&gt; 0xffffffe00021689a &lt;__do_proc_dointvec+196&gt;: sd      zero,0(s7)
   0xffffffe00021689e &lt;__do_proc_dointvec+200&gt;: li      s11,0

(gdb) bt
0  __do_proc_dointvec (tbl_data=0x0, table=0xffffffe01afabba8,
write=0, buffer=0x0, lenp=0x7bf897061f9a0800, ppos=0x4, conv=0x0,
data=0x52464e43) at kernel/sysctl.c:581
1  0xffffffe00021718e in do_proc_dointvec (data=&lt;optimized out&gt;,
conv=&lt;optimized out&gt;, ppos=&lt;optimized out&gt;, lenp=&lt;optimized out&gt;,
buffer=&lt;optimized out&gt;, write=&lt;optimized out&gt;, table=&lt;optimized out&gt;)
at kernel/sysctl.c:964
2  proc_dointvec_minmax (ppos=&lt;optimized out&gt;, lenp=&lt;optimized out&gt;,
buffer=&lt;optimized out&gt;, write=&lt;optimized out&gt;, table=&lt;optimized out&gt;)
at kernel/sysctl.c:964
3  proc_do_static_key (table=&lt;optimized out&gt;, write=1, buffer=0x0,
lenp=0x0, ppos=0x7bf897061f9a0800) at kernel/sysctl.c:1643
4  0xffffffe000206792 in ftrace_make_call (rec=&lt;optimized out&gt;,
addr=&lt;optimized out&gt;) at arch/riscv/kernel/ftrace.c:109
5  0xffffffe0002c9c04 in __ftrace_replace_code
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
6  0xffffffe0002ca0b2 in ftrace_replace_code (mod_flags=&lt;optimized
out&gt;) at kernel/trace/ftrace.c:2530
7  0xffffffe0002ca26a in ftrace_modify_all_code (command=5) at
kernel/trace/ftrace.c:2677
8  0xffffffe0002ca30e in __ftrace_modify_code (data=&lt;optimized out&gt;)
at kernel/trace/ftrace.c:2703
9  0xffffffe0002c13b0 in multi_cpu_stop (data=0x0) at kernel/stop_machine.c:224
10 0xffffffe0002c0fde in cpu_stopper_thread (cpu=&lt;optimized out&gt;) at
kernel/stop_machine.c:491
11 0xffffffe0002343de in smpboot_thread_fn (data=0x0) at kernel/smpboot.c:165
12 0xffffffe00022f8b4 in kthread (_create=0xffffffe01af0c040) at
kernel/kthread.c:292
13 0xffffffe000201fac in handle_exception () at arch/riscv/kernel/entry.S:236

   0xffffffe00020678a &lt;+114&gt;:   auipc   ra,0xffffe
   0xffffffe00020678e &lt;+118&gt;:   jalr    -118(ra) # 0xffffffe000204714 &lt;patch_text_nosync&gt;
   0xffffffe000206792 &lt;+122&gt;:   snez    a0,a0

(gdb) disassemble patch_text_nosync
Dump of assembler code for function patch_text_nosync:
   0xffffffe000204714 &lt;+0&gt;:     addi    sp,sp,-32
   0xffffffe000204716 &lt;+2&gt;:     sd      s0,16(sp)
   0xffffffe000204718 &lt;+4&gt;:     sd      ra,24(sp)
   0xffffffe00020471a &lt;+6&gt;:     addi    s0,sp,32
   0xffffffe00020471c &lt;+8&gt;:     auipc   ra,0x0
   0xffffffe000204720 &lt;+12&gt;:    jalr    -384(ra) # 0xffffffe00020459c &lt;patch_insn_write&gt;
   0xffffffe000204724 &lt;+16&gt;:    beqz    a0,0xffffffe00020472e &lt;patch_text_nosync+26&gt;
   0xffffffe000204726 &lt;+18&gt;:    ld      ra,24(sp)
   0xffffffe000204728 &lt;+20&gt;:    ld      s0,16(sp)
   0xffffffe00020472a &lt;+22&gt;:    addi    sp,sp,32
   0xffffffe00020472c &lt;+24&gt;:    ret
   0xffffffe00020472e &lt;+26&gt;:    sd      a0,-24(s0)
   0xffffffe000204732 &lt;+30&gt;:    auipc   ra,0x4
   0xffffffe000204736 &lt;+34&gt;:    jalr    -1464(ra) # 0xffffffe00020817a &lt;flush_icache_all&gt;
   0xffffffe00020473a &lt;+38&gt;:    ld      a0,-24(s0)
   0xffffffe00020473e &lt;+42&gt;:    ld      ra,24(sp)
   0xffffffe000204740 &lt;+44&gt;:    ld      s0,16(sp)
   0xffffffe000204742 &lt;+46&gt;:    addi    sp,sp,32
   0xffffffe000204744 &lt;+48&gt;:    ret

(gdb) disassemble flush_icache_all-4
Dump of assembler code for function flush_icache_all:
   0xffffffe00020817a &lt;+0&gt;:     addi    sp,sp,-8
   0xffffffe00020817c &lt;+2&gt;:     sd      ra,0(sp)
   0xffffffe00020817e &lt;+4&gt;:     auipc   ra,0xfffff
   0xffffffe000208182 &lt;+8&gt;:     jalr    -1822(ra) # 0xffffffe000206a60 &lt;ftrace_caller&gt;
   0xffffffe000208186 &lt;+12&gt;:    ld      ra,0(sp)
   0xffffffe000208188 &lt;+14&gt;:    addi    sp,sp,8
   0xffffffe00020818a &lt;+0&gt;:     addi    sp,sp,-16
   0xffffffe00020818c &lt;+2&gt;:     sd      s0,0(sp)
   0xffffffe00020818e &lt;+4&gt;:     sd      ra,8(sp)
   0xffffffe000208190 &lt;+6&gt;:     addi    s0,sp,16
   0xffffffe000208192 &lt;+8&gt;:     li      a0,0
   0xffffffe000208194 &lt;+10&gt;:    auipc   ra,0xfffff
   0xffffffe000208198 &lt;+14&gt;:    jalr    -410(ra) # 0xffffffe000206ffa &lt;sbi_remote_fence_i&gt;
   0xffffffe00020819c &lt;+18&gt;:    ld      s0,0(sp)
   0xffffffe00020819e &lt;+20&gt;:    ld      ra,8(sp)
   0xffffffe0002081a0 &lt;+22&gt;:    addi    sp,sp,16
   0xffffffe0002081a2 &lt;+24&gt;:    ret

(gdb) frame 5
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
2503                    return ftrace_make_call(rec, ftrace_addr);
(gdb) p /x rec-&gt;ip
$2 = 0xffffffe00020817a -&gt; flush_icache_all !

When we modified flush_icache_all's patchable-entry with ftrace_caller:
 - Insert ftrace_caller at flush_icache_all prologue.
 - Call flush_icache_all to sync I/Dcache, but flush_icache_all is
just we modified by half.

Link: https://lore.kernel.org/linux-riscv/CAJF2gTT=oDWesWe0JVWvTpGi60-gpbNhYLdFWN_5EbyeqoEDdw@mail.gmail.com/T/#t
Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Reviewed-by: Atish Patra &lt;atish.patra@wdc.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Just like arm64, we can't trace the function in the patch_text path.

Here is the bug log:

[   45.234334] Unable to handle kernel paging request at virtual address ffffffd38ae80900
[   45.242313] Oops [#1]
[   45.244600] Modules linked in:
[   45.247678] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-00025-g9b7db83-dirty #215
[   45.255797] epc: ffffffe00021689a ra : ffffffe00021718e sp : ffffffe01afabb58
[   45.262955]  gp : ffffffe00136afa0 tp : ffffffe01af94d00 t0 : 0000000000000002
[   45.270200]  t1 : 0000000000000000 t2 : 0000000000000001 s0 : ffffffe01afabc08
[   45.277443]  s1 : ffffffe0013718a8 a0 : 0000000000000000 a1 : ffffffe01afabba8
[   45.284686]  a2 : 0000000000000000 a3 : 0000000000000000 a4 : c4c16ad38ae80900
[   45.291929]  a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000052464e43
[   45.299173]  s2 : 0000000000000001 s3 : ffffffe000206a60 s4 : ffffffe000206a60
[   45.306415]  s5 : 00000000000009ec s6 : ffffffe0013718a8 s7 : c4c16ad38ae80900
[   45.313658]  s8 : 0000000000000004 s9 : 0000000000000001 s10: 0000000000000001
[   45.320902]  s11: 0000000000000003 t3 : 0000000000000001 t4 : ffffffffd192fe79
[   45.328144]  t5 : ffffffffb8f80000 t6 : 0000000000040000
[   45.333472] status: 0000000200000100 badaddr: ffffffd38ae80900 cause: 000000000000000f
[   45.341514] ---[ end trace d95102172248fdcf ]---
[   45.346176] note: migration/0[11] exited with preempt_count 1

(gdb) x /2i $pc
=&gt; 0xffffffe00021689a &lt;__do_proc_dointvec+196&gt;: sd      zero,0(s7)
   0xffffffe00021689e &lt;__do_proc_dointvec+200&gt;: li      s11,0

(gdb) bt
0  __do_proc_dointvec (tbl_data=0x0, table=0xffffffe01afabba8,
write=0, buffer=0x0, lenp=0x7bf897061f9a0800, ppos=0x4, conv=0x0,
data=0x52464e43) at kernel/sysctl.c:581
1  0xffffffe00021718e in do_proc_dointvec (data=&lt;optimized out&gt;,
conv=&lt;optimized out&gt;, ppos=&lt;optimized out&gt;, lenp=&lt;optimized out&gt;,
buffer=&lt;optimized out&gt;, write=&lt;optimized out&gt;, table=&lt;optimized out&gt;)
at kernel/sysctl.c:964
2  proc_dointvec_minmax (ppos=&lt;optimized out&gt;, lenp=&lt;optimized out&gt;,
buffer=&lt;optimized out&gt;, write=&lt;optimized out&gt;, table=&lt;optimized out&gt;)
at kernel/sysctl.c:964
3  proc_do_static_key (table=&lt;optimized out&gt;, write=1, buffer=0x0,
lenp=0x0, ppos=0x7bf897061f9a0800) at kernel/sysctl.c:1643
4  0xffffffe000206792 in ftrace_make_call (rec=&lt;optimized out&gt;,
addr=&lt;optimized out&gt;) at arch/riscv/kernel/ftrace.c:109
5  0xffffffe0002c9c04 in __ftrace_replace_code
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
6  0xffffffe0002ca0b2 in ftrace_replace_code (mod_flags=&lt;optimized
out&gt;) at kernel/trace/ftrace.c:2530
7  0xffffffe0002ca26a in ftrace_modify_all_code (command=5) at
kernel/trace/ftrace.c:2677
8  0xffffffe0002ca30e in __ftrace_modify_code (data=&lt;optimized out&gt;)
at kernel/trace/ftrace.c:2703
9  0xffffffe0002c13b0 in multi_cpu_stop (data=0x0) at kernel/stop_machine.c:224
10 0xffffffe0002c0fde in cpu_stopper_thread (cpu=&lt;optimized out&gt;) at
kernel/stop_machine.c:491
11 0xffffffe0002343de in smpboot_thread_fn (data=0x0) at kernel/smpboot.c:165
12 0xffffffe00022f8b4 in kthread (_create=0xffffffe01af0c040) at
kernel/kthread.c:292
13 0xffffffe000201fac in handle_exception () at arch/riscv/kernel/entry.S:236

   0xffffffe00020678a &lt;+114&gt;:   auipc   ra,0xffffe
   0xffffffe00020678e &lt;+118&gt;:   jalr    -118(ra) # 0xffffffe000204714 &lt;patch_text_nosync&gt;
   0xffffffe000206792 &lt;+122&gt;:   snez    a0,a0

(gdb) disassemble patch_text_nosync
Dump of assembler code for function patch_text_nosync:
   0xffffffe000204714 &lt;+0&gt;:     addi    sp,sp,-32
   0xffffffe000204716 &lt;+2&gt;:     sd      s0,16(sp)
   0xffffffe000204718 &lt;+4&gt;:     sd      ra,24(sp)
   0xffffffe00020471a &lt;+6&gt;:     addi    s0,sp,32
   0xffffffe00020471c &lt;+8&gt;:     auipc   ra,0x0
   0xffffffe000204720 &lt;+12&gt;:    jalr    -384(ra) # 0xffffffe00020459c &lt;patch_insn_write&gt;
   0xffffffe000204724 &lt;+16&gt;:    beqz    a0,0xffffffe00020472e &lt;patch_text_nosync+26&gt;
   0xffffffe000204726 &lt;+18&gt;:    ld      ra,24(sp)
   0xffffffe000204728 &lt;+20&gt;:    ld      s0,16(sp)
   0xffffffe00020472a &lt;+22&gt;:    addi    sp,sp,32
   0xffffffe00020472c &lt;+24&gt;:    ret
   0xffffffe00020472e &lt;+26&gt;:    sd      a0,-24(s0)
   0xffffffe000204732 &lt;+30&gt;:    auipc   ra,0x4
   0xffffffe000204736 &lt;+34&gt;:    jalr    -1464(ra) # 0xffffffe00020817a &lt;flush_icache_all&gt;
   0xffffffe00020473a &lt;+38&gt;:    ld      a0,-24(s0)
   0xffffffe00020473e &lt;+42&gt;:    ld      ra,24(sp)
   0xffffffe000204740 &lt;+44&gt;:    ld      s0,16(sp)
   0xffffffe000204742 &lt;+46&gt;:    addi    sp,sp,32
   0xffffffe000204744 &lt;+48&gt;:    ret

(gdb) disassemble flush_icache_all-4
Dump of assembler code for function flush_icache_all:
   0xffffffe00020817a &lt;+0&gt;:     addi    sp,sp,-8
   0xffffffe00020817c &lt;+2&gt;:     sd      ra,0(sp)
   0xffffffe00020817e &lt;+4&gt;:     auipc   ra,0xfffff
   0xffffffe000208182 &lt;+8&gt;:     jalr    -1822(ra) # 0xffffffe000206a60 &lt;ftrace_caller&gt;
   0xffffffe000208186 &lt;+12&gt;:    ld      ra,0(sp)
   0xffffffe000208188 &lt;+14&gt;:    addi    sp,sp,8
   0xffffffe00020818a &lt;+0&gt;:     addi    sp,sp,-16
   0xffffffe00020818c &lt;+2&gt;:     sd      s0,0(sp)
   0xffffffe00020818e &lt;+4&gt;:     sd      ra,8(sp)
   0xffffffe000208190 &lt;+6&gt;:     addi    s0,sp,16
   0xffffffe000208192 &lt;+8&gt;:     li      a0,0
   0xffffffe000208194 &lt;+10&gt;:    auipc   ra,0xfffff
   0xffffffe000208198 &lt;+14&gt;:    jalr    -410(ra) # 0xffffffe000206ffa &lt;sbi_remote_fence_i&gt;
   0xffffffe00020819c &lt;+18&gt;:    ld      s0,0(sp)
   0xffffffe00020819e &lt;+20&gt;:    ld      ra,8(sp)
   0xffffffe0002081a0 &lt;+22&gt;:    addi    sp,sp,16
   0xffffffe0002081a2 &lt;+24&gt;:    ret

(gdb) frame 5
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
2503                    return ftrace_make_call(rec, ftrace_addr);
(gdb) p /x rec-&gt;ip
$2 = 0xffffffe00020817a -&gt; flush_icache_all !

When we modified flush_icache_all's patchable-entry with ftrace_caller:
 - Insert ftrace_caller at flush_icache_all prologue.
 - Call flush_icache_all to sync I/Dcache, but flush_icache_all is
just we modified by half.

Link: https://lore.kernel.org/linux-riscv/CAJF2gTT=oDWesWe0JVWvTpGi60-gpbNhYLdFWN_5EbyeqoEDdw@mail.gmail.com/T/#t
Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Reviewed-by: Atish Patra &lt;atish.patra@wdc.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv: Fixup wrong ftrace remove cflag</title>
<updated>2021-01-14T23:09:03+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:01:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=67d945778099b14324811fe67c5aff2cda7a7ad5'/>
<id>67d945778099b14324811fe67c5aff2cda7a7ad5</id>
<content type='text'>
We must use $(CC_FLAGS_FTRACE) instead of directly using -pg. It
will cause -fpatchable-function-entry error.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We must use $(CC_FLAGS_FTRACE) instead of directly using -pg. It
will cause -fpatchable-function-entry error.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv: kernel: Drop unused clean rule</title>
<updated>2020-12-11T01:42:34+00:00</updated>
<author>
<name>Kefeng Wang</name>
<email>wangkefeng.wang@huawei.com</email>
</author>
<published>2020-11-21T10:15:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=772e1b7c426762159e5150ecff5268e6e1f361d3'/>
<id>772e1b7c426762159e5150ecff5268e6e1f361d3</id>
<content type='text'>
Signed-off-by: Kefeng Wang &lt;wangkefeng.wang@huawei.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Kefeng Wang &lt;wangkefeng.wang@huawei.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
