From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (mta1.migadu.com [37.59.57.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FCEF37DE84 for ; Tue, 11 Aug 2026 06:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.59.57.117 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786428192; cv=none; b=WRYWwGIZ5AJcYW0Zg93lmadjJYOHFBf4FOVGp5V/lXcrhmG5lNGgpiMOvmQw6EdXD97cz4X2e90lgWVirZ3D6BOMdKWiaS3na//oh8aOcFE/QFsim91QxbThJt1qZu3w28A3oXPT6PGr+kptSmihCVazo+x8Uat4GgJGClKkxZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786428192; c=relaxed/simple; bh=bMHq+iTrEIOj6rLzHjU0abNJ0o/E5StGKA6mMJ0Agdw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lWT/6hPl3Gxg7yLLWeiIQEGy2bTha4dRcnRCX9nuITIOsqCZgWlmnPRHczvc9R5ngQ++aBXXu+ZtD9tvC9LMTq7he+OZbU6EUkB+8wvLj5gjuVLp0JPYcBLEtWOxQaBWrIUv8MYv4vTYpmWzspMIzIuHx9t2YAaIs0tBhnZKgLM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=dwjLWgXd; arc=none smtp.client-ip=37.59.57.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="dwjLWgXd" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786428188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uJJi6fAW87uNl1GyGL1wWoOrHzVefNmtF4hW3yne+6I=; b=dwjLWgXdHe5FfZ1oqSdC5E94o5zj3BhveFwy74U09yRS/yiWF1lpeL4LKHeXP014CFeVuE FbOF9kg0dHZM8ev5G/lEvQawQzZTB8FLEXCnKObwDBhKQEeNa0arBDVIP93lrI3s/2xEpX 4urR/cDI4SEFBtZrnpKwrvOAxjQdw4U= From: Jinyu Tang To: Anup Patel , Anup Patel , Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Andrew Jones , Conor Dooley , Yong-Xuan Wang , Nutty Liu , Jinyu Tang , Jinyu Tang Subject: [PATCH 3/3] KVM: selftests: Enable pre_fault_memory_test for RISC-V Date: Tue, 11 Aug 2026 14:01:34 +0800 Message-ID: <20260811060134.106973-4-jinyu.tang@linux.dev> In-Reply-To: <20260811060134.106973-1-jinyu.tang@linux.dev> References: <20260811060134.106973-1-jinyu.tang@linux.dev> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT RISC-V now supports KVM_PRE_FAULT_MEMORY, so include the generic pre_fault_memory_test in the RISC-V KVM selftest build. The test uses PAGE_SIZE from the architecture processor header. Define the normal 4K RISC-V selftest page size so the generic test can build for RISC-V. RISC-V selects VM_MODE_DEFAULT at runtime. Initialize the supported guest modes before creating the VM so the generic test can run on RISC-V hosts where the default mode is discovered from KVM capabilities. Signed-off-by: Jinyu Tang --- tools/testing/selftests/kvm/Makefile.kvm | 1 + tools/testing/selftests/kvm/include/riscv/processor.h | 3 +++ tools/testing/selftests/kvm/pre_fault_memory_test.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm index 6fc34e9bf8e1..ac64ac92fd4b 100644 --- a/tools/testing/selftests/kvm/Makefile.kvm +++ b/tools/testing/selftests/kvm/Makefile.kvm @@ -225,6 +225,7 @@ TEST_GEN_PROGS_riscv += coalesced_io_test TEST_GEN_PROGS_riscv += dirty_log_perf_test TEST_GEN_PROGS_riscv += get-reg-list TEST_GEN_PROGS_riscv += mmu_stress_test +TEST_GEN_PROGS_riscv += pre_fault_memory_test TEST_GEN_PROGS_riscv += rseq_test TEST_GEN_PROGS_riscv += steal_time diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index abde3c71c891..70487c8ed155 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -12,6 +12,9 @@ #include #include "kvm_util.h" +#define PAGE_SHIFT 12 +#define PAGE_SIZE BIT_ULL(PAGE_SHIFT) + #define INSN_OPCODE_MASK 0x007c #define INSN_OPCODE_SHIFT 2 #define INSN_OPCODE_SYSTEM 28 diff --git a/tools/testing/selftests/kvm/pre_fault_memory_test.c b/tools/testing/selftests/kvm/pre_fault_memory_test.c index a0fcae3cb7a8..6eebf0524673 100644 --- a/tools/testing/selftests/kvm/pre_fault_memory_test.c +++ b/tools/testing/selftests/kvm/pre_fault_memory_test.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -219,6 +220,8 @@ static void test_pre_fault_memory(unsigned long vm_type, bool private) int main(int argc, char *argv[]) { + guest_modes_append_default(); + TEST_REQUIRE(kvm_check_cap(KVM_CAP_PRE_FAULT_MEMORY)); test_pre_fault_memory(0, false); -- 2.43.0