Skip to contentSkip to conversation

KVM: riscv: selftests: Enable supported test cases

PATCH Superseded [email protected] 2 participants 8 messages Aug 7, 2025 – Aug 19, 2025

Subsystems (5)
KVM Kselftest RISC-V KVM RISC-V +1 more subsystems

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover KVM: riscv: selftests: Enable supported test cases

From: Dong Yang <[email protected]>

Add supported KVM test cases and fix the compilation dependencies.
---
Changes in v2:
- Delete some repeat KVM test cases on riscv
- Add missing headers to fix the build for new RISC-V KVM selftests

Dong Yang (1):
KVM: riscv: selftests: Add missing headers for new testcases

Quan Zhou (2):
KVM: riscv: selftests: Add common supported test cases
KVM: riscv: selftests: Use the existing RISCV_FENCE macro in

    `rseq-riscv.h`
 tools/testing/selftests/kvm/Makefile.kvm              | 6 ++++++
 tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++
 tools/testing/selftests/rseq/rseq-riscv.h             | 3 +--
 3 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 KVM: riscv: selftests: Add common supported test cases

From: Quan Zhou <[email protected]>

Some common KVM test cases are supported on riscv now as following:

access_tracking_perf_test
dirty_log_perf_test
memslot_modification_stress_test
memslot_perf_test
mmu_stress_test
rseq_test

---
 tools/testing/selftests/kvm/Makefile.kvm | 6 ++++++
 1 file changed, 6 insertions(+)
tools/testing/selftests/kvm/Makefile.kvm +6 -0
index 38b95998e..3a7186551 100644
@@ -197,6 +197,12 @@ TEST_GEN_PROGS_riscv += arch_timer
 TEST_GEN_PROGS_riscv += coalesced_io_test
 TEST_GEN_PROGS_riscv += get-reg-list
 TEST_GEN_PROGS_riscv += steal_time
+TEST_GEN_PROGS_riscv += access_tracking_perf_test
+TEST_GEN_PROGS_riscv += dirty_log_perf_test
+TEST_GEN_PROGS_riscv += memslot_modification_stress_test
+TEST_GEN_PROGS_riscv += memslot_perf_test
+TEST_GEN_PROGS_riscv += mmu_stress_test
+TEST_GEN_PROGS_riscv += rseq_test
 
 TEST_GEN_PROGS_loongarch += coalesced_io_test
 TEST_GEN_PROGS_loongarch += demand_paging_test
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/3] KVM: riscv: selftests: Add common supported test cases

Quoted 10 lines · On Thu, Aug 07, 2025 at 10:59:28PM +0800, [email protected] wrote:

From: Quan Zhou <[email protected]>

Some common KVM test cases are supported on riscv now as following:

access_tracking_perf_test
dirty_log_perf_test
memslot_modification_stress_test
memslot_perf_test
mmu_stress_test
rseq_test

I gave these a light testing after pulling together an appropriate config (we should probably better document needed config symbols...) The tests seemed to mostly work for me, so ack for including them.

Quoted 12 lines
---
 tools/testing/selftests/kvm/Makefile.kvm | 6 ++++++
 1 file changed, 6 insertions(+)
tools/testing/selftests/kvm/Makefile.kvm +0 -0
index 38b95998e..3a7186551 100644

tools/testing/selftests/kvm/Makefile.kvm TEST_GEN_PROGS_riscv += arch_timer · line 205

Quoted 9 lines
tools/testing/selftests/kvm/Makefile.kvm +6 -0
@@ -197,6 +197,12 @@ TEST_GEN_PROGS_riscv += arch_timer
 TEST_GEN_PROGS_riscv += coalesced_io_test
 TEST_GEN_PROGS_riscv += get-reg-list
 TEST_GEN_PROGS_riscv += steal_time
+TEST_GEN_PROGS_riscv += access_tracking_perf_test
+TEST_GEN_PROGS_riscv += dirty_log_perf_test
+TEST_GEN_PROGS_riscv += memslot_modification_stress_test
+TEST_GEN_PROGS_riscv += memslot_perf_test
+TEST_GEN_PROGS_riscv += mmu_stress_test
+TEST_GEN_PROGS_riscv += rseq_test

Please integrate into the current list in alphabetical order.

Thanks,
drew

Quoted 11 lines
tools/testing/selftests/kvm/Makefile.kvm +0 -0
 TEST_GEN_PROGS_loongarch += coalesced_io_test
 TEST_GEN_PROGS_loongarch += demand_paging_test
Signature · 7 lines
2.34.1


-- 
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv
#3 lore raw

PATCH v2 2/3 KVM: riscv: selftests: Use the existing RISCV_FENCE macro in `rseq-riscv.h`

In reply to [email protected]

From: Quan Zhou <[email protected]>

To avoid redefinition issues with RISCV_FENCE,
directly reference the existing macro in rseq-riscv.h.

---
 tools/testing/selftests/rseq/rseq-riscv.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/rseq/rseq-riscv.h +1 -2
index 67d544aaa..06c840e81 100644
@@ -8,6 +8,7 @@
  * exception when executed in all modes.
  */
 #include <endian.h>
+#include <asm/fence.h>
 
 #if defined(__BYTE_ORDER) ? (__BYTE_ORDER == __LITTLE_ENDIAN) : defined(__LITTLE_ENDIAN)
 #define RSEQ_SIG   0xf1401073  /* csrr mhartid, x0 */
@@ -24,8 +25,6 @@
 #define REG_L	__REG_SEL("ld ", "lw ")
 #define REG_S	__REG_SEL("sd ", "sw ")
 
-#define RISCV_FENCE(p, s) \
-	__asm__ __volatile__ ("fence " #p "," #s : : : "memory")
 #define rseq_smp_mb()	RISCV_FENCE(rw, rw)
 #define rseq_smp_rmb()	RISCV_FENCE(r, r)
 #define rseq_smp_wmb()	RISCV_FENCE(w, w)
Signature · 1 line
2.34.1
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] KVM: riscv: selftests: Use the existing RISCV_FENCE macro in `rseq-riscv.h`

Quoted 35 lines · On Thu, Aug 07, 2025 at 10:59:29PM +0800, [email protected] wrote:

From: Quan Zhou <[email protected]>

To avoid redefinition issues with RISCV_FENCE,
directly reference the existing macro in rseq-riscv.h.

---
 tools/testing/selftests/rseq/rseq-riscv.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/rseq/rseq-riscv.h +1 -2
index 67d544aaa..06c840e81 100644
@@ -8,6 +8,7 @@
  * exception when executed in all modes.
  */
 #include <endian.h>
+#include <asm/fence.h>
 
 #if defined(__BYTE_ORDER) ? (__BYTE_ORDER == __LITTLE_ENDIAN) : defined(__LITTLE_ENDIAN)
 #define RSEQ_SIG   0xf1401073  /* csrr mhartid, x0 */
@@ -24,8 +25,6 @@
 #define REG_L	__REG_SEL("ld ", "lw ")
 #define REG_S	__REG_SEL("sd ", "sw ")
 
-#define RISCV_FENCE(p, s) \
-	__asm__ __volatile__ ("fence " #p "," #s : : : "memory")
 #define rseq_smp_mb()	RISCV_FENCE(rw, rw)
 #define rseq_smp_rmb()	RISCV_FENCE(r, r)
 #define rseq_smp_wmb()	RISCV_FENCE(w, w)
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 3/3 KVM: riscv: selftests: Add missing headers for new testcases

In reply to [email protected]

From: Dong Yang <[email protected]>

Add missing headers to fix the build for new RISC-V KVM selftests.

---
 tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/kvm/include/riscv/processor.h +2 -0
index 162f303d9..4cf5ae117 100644
@@ -9,7 +9,9 @@
 
 #include <linux/stringify.h>
 #include <asm/csr.h>
+#include <asm/vdso/processor.h>
 #include "kvm_util.h"
+#include "ucall_common.h"
 
 #define INSN_OPCODE_MASK	0x007c
 #define INSN_OPCODE_SHIFT	2
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH v2 3/3] KVM: riscv: selftests: Add missing headers for new testcases

Quoted 15 lines · On Thu, Aug 07, 2025 at 10:59:30PM +0800, [email protected] wrote:

From: Dong Yang <[email protected]>

Add missing headers to fix the build for new RISC-V KVM selftests.

---
 tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/kvm/include/riscv/processor.h +0 -0
index 162f303d9..4cf5ae117 100644

tools/testing/selftests/kvm/include/riscv/processor.h line 12

Quoted 4 lines
tools/testing/selftests/kvm/include/riscv/processor.h +1 -0
@@ -9,7 +9,9 @@
 
 #include <linux/stringify.h>
 #include <asm/csr.h>
+#include <asm/vdso/processor.h>

This is fine, but...

tools/testing/selftests/kvm/include/riscv/processor.h line 14

Quoted 2 lines
tools/testing/selftests/kvm/include/riscv/processor.h +1 -0
 #include "kvm_util.h"
+#include "ucall_common.h"

...this isn't correct. We should instead add this include line to all the source files that need it:

access_tracking_perf_test.c
memslot_modification_stress_test.c
memslot_perf_test.c

Thanks,
drew

Quoted 11 lines
tools/testing/selftests/kvm/include/riscv/processor.h +0 -0
 #define INSN_OPCODE_MASK	0x007c
 #define INSN_OPCODE_SHIFT	2
Signature · 7 lines
2.34.1


-- 
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv
#7 lore raw
In reply to [email protected]
Quoted 14 lines · On Thu, Aug 07, 2025 at 10:59:27PM +0800, [email protected] wrote:

From: Dong Yang <[email protected]>

Add supported KVM test cases and fix the compilation dependencies.
---
Changes in v2:
- Delete some repeat KVM test cases on riscv
- Add missing headers to fix the build for new RISC-V KVM selftests

Dong Yang (1):
KVM: riscv: selftests: Add missing headers for new testcases

Quan Zhou (2):
KVM: riscv: selftests: Add common supported test cases
KVM: riscv: selftests: Use the existing RISCV_FENCE macro in

Quoted 7 lines
    `rseq-riscv.h`
 tools/testing/selftests/kvm/Makefile.kvm              | 6 ++++++
 tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++
 tools/testing/selftests/rseq/rseq-riscv.h             | 3 +--
 3 files changed, 9 insertions(+), 2 deletions(-)

The two fix patches need to come before the Makefile patch in order to avoid breaking the build.

Thanks,
drew