<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/riscv/include, branch linux-6.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-10-10T10:00:59Z</updated>
<entry>
<title>riscv: Fix kernel stack size when KASAN is enabled</title>
<updated>2024-10-10T10:00:59Z</updated>
<author>
<name>Alexandre Ghiti</name>
</author>
<published>2024-09-17T15:03:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1b1ba6d628359e4baa03af92b9b635b706f1d934'/>
<id>urn:sha1:1b1ba6d628359e4baa03af92b9b635b706f1d934</id>
<content type='text'>
commit cfb10de18538e383dbc4f3ce7f477ce49287ff3d upstream.

We use Kconfig to select the kernel stack size, doubling the default
size if KASAN is enabled.

But that actually only works if KASAN is selected from the beginning,
meaning that if KASAN config is added later (for example using
menuconfig), CONFIG_THREAD_SIZE_ORDER won't be updated, keeping the
default size, which is not enough for KASAN as reported in [1].

So fix this by moving the logic to compute the right kernel stack into a
header.

Fixes: a7555f6b62e7 ("riscv: stack: Add config of thread stack size")
Reported-by: syzbot+ba9eac24453387a9d502@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000eb301906222aadc2@google.com/ [1]
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Ghiti &lt;alexghiti@rivosinc.com&gt;
Link: https://lore.kernel.org/r/20240917150328.59831-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Fix to allow hpmcounter31 from the guest</title>
<updated>2024-10-04T14:32:19Z</updated>
<author>
<name>Atish Patra</name>
</author>
<published>2024-08-16T07:08:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=efc9792345820aa7d21efc43106bfc12976c1a88'/>
<id>urn:sha1:efc9792345820aa7d21efc43106bfc12976c1a88</id>
<content type='text'>
[ Upstream commit 5aa09297a3dcc798d038bd7436f8c90f664045a6 ]

The csr_fun defines a count parameter which defines the total number
CSRs emulated in KVM starting from the base. This value should be
equal to total number of counters possible for trap/emulation (32).

Fixes: a9ac6c37521f ("RISC-V: KVM: Implement trap &amp; emulate for hpmcounters")
Signed-off-by: Atish Patra &lt;atishp@rivosinc.com&gt;
Link: https://lore.kernel.org/r/20240816-kvm_pmu_fixes-v1-2-cdfce386dd93@rivosinc.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Allow legacy PMU access from guest</title>
<updated>2024-10-04T14:32:19Z</updated>
<author>
<name>Atish Patra</name>
</author>
<published>2024-08-16T07:08:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=659cd6013527a51be8d588d674a0ce328e713a69'/>
<id>urn:sha1:659cd6013527a51be8d588d674a0ce328e713a69</id>
<content type='text'>
[ Upstream commit 7d1ffc8b087e97dbe1985912c7a2d00e53cea169 ]

Currently, KVM traps &amp; emulates PMU counter access only if SBI PMU
is available as the guest can only configure/read PMU counters via
SBI only. However, if SBI PMU is not enabled in the host, the
guest will fallback to the legacy PMU which will try to access
cycle/instret and result in an illegal instruction trap which
is not desired.

KVM can allow dummy emulation of cycle/instret only for the guest
if SBI PMU is not enabled in the host. The dummy emulation will
still return zero as we don't to expose the host counter values
from a guest using legacy PMU.

Fixes: a9ac6c37521f ("RISC-V: KVM: Implement trap &amp; emulate for hpmcounters")
Signed-off-by: Atish Patra &lt;atishp@rivosinc.com&gt;
Link: https://lore.kernel.org/r/20240816-kvm_pmu_fixes-v1-1-cdfce386dd93@rivosinc.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>riscv: Fix RISCV_ALTERNATIVE_EARLY</title>
<updated>2024-09-12T09:13:12Z</updated>
<author>
<name>Alexandre Ghiti</name>
</author>
<published>2024-08-29T16:50:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=82f134ddd4f5da11c277bd1aa02e2a733179725a'/>
<id>urn:sha1:82f134ddd4f5da11c277bd1aa02e2a733179725a</id>
<content type='text'>
[ Upstream commit 1ff95eb2bebda50c4c5406caaf201e0fcb24cc8f ]

RISCV_ALTERNATIVE_EARLY will issue sbi_ecall() very early in the boot
process, before the first memory mapping is setup so we can't have any
instrumentation happening here.

In addition, when the kernel is relocatable, we must also not issue any
relocation this early since they would have been patched virtually only.

So, instead of disabling instrumentation for the whole kernel/sbi.c file
and compiling it with -fno-pie, simply move __sbi_ecall() and
__sbi_base_ecall() into their own file where this is fixed.

Reported-by: Conor Dooley &lt;conor.dooley@microchip.com&gt;
Closes: https://lore.kernel.org/linux-riscv/20240813-pony-truck-3e7a83e9759e@spud/
Reported-by: syzbot+cfbcb82adf6d7279fd35@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-riscv/00000000000065062c061fcec37b@google.com/
Fixes: 1745cfafebdf ("riscv: don't use global static vars to store alternative data")
Signed-off-by: Alexandre Ghiti &lt;alexghiti@rivosinc.com&gt;
Link: https://lore.kernel.org/r/20240829165048.49756-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>riscv: Improve sbi_ecall() code generation by reordering arguments</title>
<updated>2024-09-12T09:13:12Z</updated>
<author>
<name>Alexandre Ghiti</name>
</author>
<published>2024-03-22T11:26:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bb63fe4f5f31006ba544fd588234ce407ead93be'/>
<id>urn:sha1:bb63fe4f5f31006ba544fd588234ce407ead93be</id>
<content type='text'>
[ Upstream commit 16badacd8af48980c546839626d0329bab32b4c3 ]

The sbi_ecall() function arguments are not in the same order as the
ecall arguments, so we end up re-ordering the registers before the
ecall which is useless and costly.

So simply reorder the arguments in the same way as expected by ecall.
Instead of reordering directly the arguments of sbi_ecall(), use a proxy
macro since the current ordering is more natural.

Before:

Dump of assembler code for function sbi_ecall:
   0xffffffff800085e0 &lt;+0&gt;: add sp,sp,-32
   0xffffffff800085e2 &lt;+2&gt;: sd s0,24(sp)
   0xffffffff800085e4 &lt;+4&gt;: mv t1,a0
   0xffffffff800085e6 &lt;+6&gt;: add s0,sp,32
   0xffffffff800085e8 &lt;+8&gt;: mv t3,a1
   0xffffffff800085ea &lt;+10&gt;: mv a0,a2
   0xffffffff800085ec &lt;+12&gt;: mv a1,a3
   0xffffffff800085ee &lt;+14&gt;: mv a2,a4
   0xffffffff800085f0 &lt;+16&gt;: mv a3,a5
   0xffffffff800085f2 &lt;+18&gt;: mv a4,a6
   0xffffffff800085f4 &lt;+20&gt;: mv a5,a7
   0xffffffff800085f6 &lt;+22&gt;: mv a6,t3
   0xffffffff800085f8 &lt;+24&gt;: mv a7,t1
   0xffffffff800085fa &lt;+26&gt;: ecall
   0xffffffff800085fe &lt;+30&gt;: ld s0,24(sp)
   0xffffffff80008600 &lt;+32&gt;: add sp,sp,32
   0xffffffff80008602 &lt;+34&gt;: ret

After:

Dump of assembler code for function __sbi_ecall:
   0xffffffff8000b6b2 &lt;+0&gt;:	add	sp,sp,-32
   0xffffffff8000b6b4 &lt;+2&gt;:	sd	s0,24(sp)
   0xffffffff8000b6b6 &lt;+4&gt;:	add	s0,sp,32
   0xffffffff8000b6b8 &lt;+6&gt;:	ecall
   0xffffffff8000b6bc &lt;+10&gt;:	ld	s0,24(sp)
   0xffffffff8000b6be &lt;+12&gt;:	add	sp,sp,32
   0xffffffff8000b6c0 &lt;+14&gt;:	ret

Signed-off-by: Alexandre Ghiti &lt;alexghiti@rivosinc.com&gt;
Reviewed-by: Atish Patra &lt;atishp@rivosinc.com&gt;
Reviewed-by: Yunhui Cui &lt;cuiyunhui@bytedance.com&gt;
Link: https://lore.kernel.org/r/20240322112629.68170-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
Stable-dep-of: 1ff95eb2bebd ("riscv: Fix RISCV_ALTERNATIVE_EARLY")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>riscv: Add tracepoints for SBI calls and returns</title>
<updated>2024-09-12T09:13:12Z</updated>
<author>
<name>Samuel Holland</name>
</author>
<published>2024-03-21T23:01:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3445b6ccc792268119a9f415a51c9a21129205bf'/>
<id>urn:sha1:3445b6ccc792268119a9f415a51c9a21129205bf</id>
<content type='text'>
[ Upstream commit 56c1c1a09ab93c7b7c957860f01f8600d6c03143 ]

These are useful for measuring the latency of SBI calls. The SBI HSM
extension is excluded because those functions are called from contexts
such as cpuidle where instrumentation is not allowed.

Reviewed-by: Andrew Jones &lt;ajones@ventanamicro.com&gt;
Signed-off-by: Samuel Holland &lt;samuel.holland@sifive.com&gt;
Link: https://lore.kernel.org/r/20240321230131.1838105-1-samuel.holland@sifive.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
Stable-dep-of: 1ff95eb2bebd ("riscv: Fix RISCV_ALTERNATIVE_EARLY")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>riscv: mm: Do not restrict mmap address based on hint</title>
<updated>2024-09-12T09:13:11Z</updated>
<author>
<name>Charlie Jenkins</name>
</author>
<published>2024-08-26T16:36:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9bf1c67635b53a1f4511e0daa631d94268e83a18'/>
<id>urn:sha1:9bf1c67635b53a1f4511e0daa631d94268e83a18</id>
<content type='text'>
[ Upstream commit 2116988d5372aec51f8c4fb85bf8e305ecda47a0 ]

The hint address should not forcefully restrict the addresses returned
by mmap as this causes mmap to report ENOMEM when there is memory still
available.

Signed-off-by: Charlie Jenkins &lt;charlie@rivosinc.com&gt;
Fixes: b5b4287accd7 ("riscv: mm: Use hint address in mmap if available")
Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57")
Closes: https://lore.kernel.org/linux-kernel/ZbxTNjQPFKBatMq+@ghost/T/#mccb1890466bf5a488c9ce7441e57e42271895765
Link: https://lore.kernel.org/r/20240826-riscv_mmap-v1-3-cd8962afe47f@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: fix vector insn load/store width mask</title>
<updated>2024-06-25T15:47:10Z</updated>
<author>
<name>Jesse Taube</name>
</author>
<published>2024-06-06T18:28:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04a2aef59cfe192aa99020601d922359978cc72a'/>
<id>urn:sha1:04a2aef59cfe192aa99020601d922359978cc72a</id>
<content type='text'>
RVFDQ_FL_FS_WIDTH_MASK should be 3 bits [14-12], shifted down by 12 bits.
Replace GENMASK(3, 0) with GENMASK(2, 0).

Fixes: cd054837243b ("riscv: Allocate user's vector context in the first-use trap")
Signed-off-by: Jesse Taube &lt;jesse@rivosinc.com&gt;
Reviewed-by: Charlie Jenkins &lt;charlie@rivosinc.com&gt;
Link: https://lore.kernel.org/r/20240606182800.415831-1-jesse@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>riscv: Fix fully ordered LR/SC xchg[8|16]() implementations</title>
<updated>2024-05-30T16:43:14Z</updated>
<author>
<name>Alexandre Ghiti</name>
</author>
<published>2024-05-30T14:55:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1d84afaf02524d2558e8ca3ca169be2ef720380b'/>
<id>urn:sha1:1d84afaf02524d2558e8ca3ca169be2ef720380b</id>
<content type='text'>
The fully ordered versions of xchg[8|16]() using LR/SC lack the
necessary memory barriers to guarantee the order.

Fix this by matching what is already implemented in the fully ordered
versions of cmpxchg() using LR/SC.

Suggested-by: Andrea Parri &lt;parri.andrea@gmail.com&gt;
Reported-by: Andrea Parri &lt;parri.andrea@gmail.com&gt;
Closes: https://lore.kernel.org/linux-riscv/ZlYbupL5XgzgA0MX@andrea/T/#u
Fixes: a8ed2b7a2c13 ("riscv/cmpxchg: Implement xchg for variables of size 1 and 2")
Signed-off-by: Alexandre Ghiti &lt;alexghiti@rivosinc.com&gt;
Reviewed-by: Andrea Parri &lt;parri.andrea@gmail.com&gt;
Link: https://lore.kernel.org/r/20240530145546.394248-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'riscv-for-linus-6.10-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux</title>
<updated>2024-05-24T17:46:35Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2024-05-24T17:46:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f1f9984fdc5e37303d7180ff7a85dfecb8e57e85'/>
<id>urn:sha1:f1f9984fdc5e37303d7180ff7a85dfecb8e57e85</id>
<content type='text'>
Pull more RISC-V updates from Palmer Dabbelt:

 - The compression format used for boot images is now configurable at
   build time, and these formats are shown in `make help`

 - access_ok() has been optimized

 - A pair of performance bugs have been fixed in the uaccess handlers

 - Various fixes and cleanups, including one for the IMSIC build failure
   and one for the early-boot ftrace illegal NOPs bug

* tag 'riscv-for-linus-6.10-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: Fix early ftrace nop patching
  irqchip: riscv-imsic: Fixup riscv_ipi_set_virq_range() conflict
  riscv: selftests: Add signal handling vector tests
  riscv: mm: accelerate pagefault when badaccess
  riscv: uaccess: Relax the threshold for fast path
  riscv: uaccess: Allow the last potential unrolled copy
  riscv: typo in comment for get_f64_reg
  Use bool value in set_cpu_online()
  riscv: selftests: Add hwprobe binaries to .gitignore
  riscv: stacktrace: fixed walk_stackframe()
  ftrace: riscv: move from REGS to ARGS
  riscv: do not select MODULE_SECTIONS by default
  riscv: show help string for riscv-specific targets
  riscv: make image compression configurable
  riscv: cpufeature: Fix extension subset checking
  riscv: cpufeature: Fix thead vector hwcap removal
  riscv: rewrite __kernel_map_pages() to fix sleeping in invalid context
  riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled
  riscv: Define TASK_SIZE_MAX for __access_ok()
  riscv: Remove PGDIR_SIZE_L3 and TASK_SIZE_MIN
</content>
</entry>
</feed>
