<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/arch/riscv, branch stable</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/arch/riscv?h=stable</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/arch/riscv?h=stable'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2026-09-15T13:25:51Z</updated>
<entry>
<title>RISC-V: KVM: Fix HSM hart status error propagation</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Tan Chi</name>
<email>tanchi25@mails.ucas.ac.cn</email>
</author>
<published>2026-09-14T03:11:46Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=41e81f7e3ef96594fb840445343c0ee7723aa550'/>
<id>urn:sha1:41e81f7e3ef96594fb840445343c0ee7723aa550</id>
<content type='text'>
kvm_sbi_hsm_vcpu_get_status() returns SBI_ERR_INVALID_PARAM when
the requested hart does not exist. However, the HART_STATUS case
returns from the SBI handler without storing this error in
retdata-&gt;err_val.

As a result, a guest querying the status of a non-existent hart
observes SBI_SUCCESS instead of SBI_ERR_INVALID_PARAM.

Use the common SBI error handling path for HART_STATUS after
saving a valid hart state in retdata-&gt;out_val. This preserves
the returned error when kvm_sbi_hsm_vcpu_get_status() fails.

Fixes: bae0dfd74e01 ("RISC-V: KVM: Modify SBI extension handler to return SBI error code")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Tan Chi &lt;tanchi25@mails.ucas.ac.cn&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260914031146.446157-1-tanchi25@mails.ucas.ac.cn
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Fix perf-backed counter accounting across stop and read</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>SeungJu Cheon</name>
<email>suunj1331@gmail.com</email>
</author>
<published>2026-08-25T08:37:19Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=c7e2cc38c56142cdab25e6f73602a8222bf9479b'/>
<id>urn:sha1:c7e2cc38c56142cdab25e6f73602a8222bf9479b</id>
<content type='text'>
pmu_ctr_read() adds the event count returned by perf_event_read_value()
to counter_val, which can accumulate the same count repeatedly across
reads. kvm_riscv_vcpu_pmu_ctr_stop() also leaves counter_val stale by
not folding the current event count into it.

Make reads of perf-backed counters side-effect free, and use
perf_event_pause() when stopping a counter to fold the current event
count into counter_val while resetting it. This preserves the counter
value across stop/start and lets the snapshot path use counter_val
directly.

Fixes: 0cb74b65d2e5 ("RISC-V: KVM: Implement perf support without sampling")
Signed-off-by: SeungJu Cheon &lt;suunj1331@gmail.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260825083719.643970-4-suunj1331@gmail.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Report snapshot write failure to the guest</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>SeungJu Cheon</name>
<email>suunj1331@gmail.com</email>
</author>
<published>2026-08-25T08:37:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=057dd2639ceae79adced5d8fe52c32d562edcb3a'/>
<id>urn:sha1:057dd2639ceae79adced5d8fe52c32d562edcb3a</id>
<content type='text'>
If kvm_vcpu_write_guest() fails while updating the PMU snapshot area
on counter stop, the guest may receive SBI_SUCCESS without the
snapshot being updated, leaving stale data in shared memory.

Return SBI_ERR_FAILURE when the snapshot write fails.

Fixes: c2f41ddbcdd7 ("RISC-V: KVM: Implement SBI PMU Snapshot feature")
Signed-off-by: SeungJu Cheon &lt;suunj1331@gmail.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260825083719.643970-3-suunj1331@gmail.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Preserve firmware counter value across stop/start</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>SeungJu Cheon</name>
<email>suunj1331@gmail.com</email>
</author>
<published>2026-08-25T08:37:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=8b3fd1a8b305321171602bfa7c41212441cf69e4'/>
<id>urn:sha1:8b3fd1a8b305321171602bfa7c41212441cf69e4</id>
<content type='text'>
Firmware events accumulate in kvpmu-&gt;fw_event[].value while running,
but counter stop only clears fw_event[].started without saving the
value back to pmc-&gt;counter_val. A subsequent counter start without
SBI_PMU_START_FLAG_SET_INIT_VALUE reloads the stale counter_val into
fw_event[].value, losing all events counted so far.

Save fw_event[].value into counter_val when actually stopping a
running counter, and remove the now redundant synchronization from
the snapshot path.

Fixes: badc386869e2c ("RISC-V: KVM: Support firmware events")
Signed-off-by: SeungJu Cheon &lt;suunj1331@gmail.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260825083719.643970-2-suunj1331@gmail.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Fix sdata leak and stale snapshot_addr in snapshot_set_shmem</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Zongmin Zhou</name>
<email>zhouzongmin@kylinos.cn</email>
</author>
<published>2026-08-26T06:41:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=b7749531a9b195f4fd7db92ca3cc49bda1a4dc8d'/>
<id>urn:sha1:b7749531a9b195f4fd7db92ca3cc49bda1a4dc8d</id>
<content type='text'>
A guest may call SBI_PMU_SNAPSHOT_SET_SHMEM repeatedly. Each call
overwrites kvpmu-&gt;sdata without freeing the old buffer (memory leak),
and if a later kvm_vcpu_write_guest() fails, the error path frees
sdata but leaves snapshot_addr stale. A subsequent
SBI_PMU_COUNTER_START then passes the INVALID_GPA check and crashes
the host with a NULL buffer in kvm_vcpu_read_guest().

Fix this by clearing the previously installed snapshot area before
installing a new one, which keeps sdata and snapshot_addr consistent.
The SBI spec suggests a single invocation but defines no error code
for repeated calls, so KVM must tolerate them.

Fixes: c2f41ddbcdd756 ("RISC-V: KVM: Implement SBI PMU Snapshot feature")
Cc: stable@vger.kernel.org
Signed-off-by: Zongmin Zhou &lt;zhouzongmin@kylinos.cn&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260826064117.58029-1-min_halo@163.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>KVM: riscv: Fix NACL hfence entry update order</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Zongmin Zhou</name>
<email>zhouzongmin@kylinos.cn</email>
</author>
<published>2026-08-26T07:50:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=b3d346838ec65fac7fd83f5dbcedd13cadfffddb'/>
<id>urn:sha1:b3d346838ec65fac7fd83f5dbcedd13cadfffddb</id>
<content type='text'>
The SBI v3.0 specification (section 15.1.2) requires a nested HFENCE
entry to be populated as follows:
1) find an unused entry with Config.Pending == 0
2) update the Page_Number and Page_Count words
3) update the Config word with Config.Pending set

__kvm_riscv_nacl_hfence() writes the Config word first, so the SBI
implementation (or NACL hardware) can observe a pending entry with
pnum/pcount values left over from the previous use of that entry,
resulting in incorrect TLB flush ranges.

Write pnum and pcount first and the Config word last. Since the
consumer is an external agent on coherent shared memory, use
WRITE_ONCE() to stop the compiler from reordering the stores and
smp_wmb() to make the parameter words globally visible before the
Pending bit is set.

Fixes: d466c19cead5 ("RISC-V: KVM: Add common nested acceleration support")
Signed-off-by: Zongmin Zhou &lt;zhouzongmin@kylinos.cn&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260826075009.68952-1-min_halo@163.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Propagate interrupted G-stage faults</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Xie Bo</name>
<email>xb@ultrarisc.com</email>
</author>
<published>2026-08-10T05:15:44Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=f41fb17143df890855d3de980f8eb92dfd595817'/>
<id>urn:sha1:f41fb17143df890855d3de980f8eb92dfd595817</id>
<content type='text'>
__kvm_faultin_pfn() reports an interrupted host page fault with
KVM_PFN_ERR_SIGPENDING. RISC-V currently handles it as a generic
error PFN and returns -EFAULT.

Return -EINTR for the signal-pending sentinel so callers can distinguish
an interrupted fault from an invalid userspace mapping. Do not log the
expected interruption as a vCPU exit error.

Fixes: 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page table programming")
Cc: stable@vger.kernel.org
Signed-off-by: Xie Bo &lt;xb@ultrarisc.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260810051544.3953925-3-xb@ultrarisc.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Release unused page after MMU invalidation</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Xie Bo</name>
<email>xb@ultrarisc.com</email>
</author>
<published>2026-08-10T05:15:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=ed54fdb460a6e81d5f8f38388d1f10b385dd4a58'/>
<id>urn:sha1:ed54fdb460a6e81d5f8f38388d1f10b385dd4a58</id>
<content type='text'>
If an MMU invalidation races with a G-stage fault, the fault handler skips
installing the page but leaves ret set to zero. As a result,
kvm_release_faultin_page() treats the page as used and can unnecessarily
mark it dirty.

Track the invalidation retry separately and release the page as unused,
while preserving the existing return value so that the vCPU retries the
fault.

Fixes: 2ed90cb0938a ("KVM: RISC-V: Retry fault if vma_lookup() results become invalid")
Cc: stable@vger.kernel.org
Signed-off-by: Xie Bo &lt;xb@ultrarisc.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260810051544.3953925-2-xb@ultrarisc.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Serialize IMSIC attributes with vCPU migration</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Xie Bo</name>
<email>xb@ultrarisc.com</email>
</author>
<published>2026-08-10T01:21:15Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=8ae12ccaec6ec74945d8c1ef39f2c1b8df779abc'/>
<id>urn:sha1:8ae12ccaec6ec74945d8c1ef39f2c1b8df779abc</id>
<content type='text'>
KVM device ioctls are not serialized against KVM_RUN. As a result,
kvm_riscv_aia_imsic_rw_attr() can snapshot the physical CPU and HGEI of
an IMSIC VS-file before a concurrent vCPU migration releases it.

The HGEI can then be allocated to another vCPU before imsic_vsfile_rw()
uses the stale tuple. A GET or SET attribute may consequently access the
new owner's interrupt file.

Serialize the entire IMSIC attribute operation with the target vCPU
mutex. This prevents the VS-file from being migrated and recycled until
the attribute access completes. Acquire the mutex killably so that the
device ioctl remains interruptible while waiting for KVM_RUN to finish.

Fixes: db8b7e97d613 ("RISC-V: KVM: Add in-kernel virtualization of AIA IMSIC")
Cc: stable@vger.kernel.org
Signed-off-by: Xie Bo &lt;xb@ultrarisc.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260810-imsic-attr-race-v2-1-00ed95ad321e@ultrarisc.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Fix the conversion between vsip and hvip</title>
<updated>2026-09-15T13:25:51Z</updated>
<author>
<name>Yicong Yang</name>
<email>yang.yicong@picoheart.com</email>
</author>
<published>2026-08-04T13:40:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=52c6b7d20d3e791a9e75aa2be2a467990154c7cd'/>
<id>urn:sha1:52c6b7d20d3e791a9e75aa2be2a467990154c7cd</id>
<content type='text'>
Per AIA spec 1.0 Section 6.3.2, the interrupt numbers 13-63
shares same bit position between related VS shadow CSRs and
hypervisor CSRs. So there's a shift only for SSI, STI and
SEI interrupt.

Currently the KVM always does a shift for all the interrupts
(include LCOFI with number 13) when doing the conversion
between vsip and hvip. Fix this by only doing shift the SSI,
STI and SEI. Add wrappers for doing the conversion between
vsip and hvip.

Fixes: 16b0bde9a37c ("RISC-V: KVM: Add perf sampling support for guests")
Signed-off-by: Yicong Yang &lt;yang.yicong@picoheart.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260804134018.85497-1-yang.yicong@picoheart.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
</feed>
