From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-115.mta1.migadu.com [95.215.58.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7B293DBD49 for ; Sat, 15 Aug 2026 10:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789728; cv=none; b=l1dXRoAaXmlpyt1HM9j6jsGFrx6lHEGnd6cNyRQGKF7w6j15szLKUgMFfL3/npGpeK7WH37OpAF+sdbgrHBhK50UNIFX6HejJ6AxkTuIVMNgcrs1ZA4mddrS/8rBFX3ZETcforx63dNNrfgF6Qjq71zNtXPoEZQ4sNBiE3OE4w0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789728; c=relaxed/simple; bh=0xdUqTsvy+qUrlfku4ZIUWyJOcx0knAT5Kmtq4e0nOA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Di2/t23nCKgwHHGEpXYsnNj//fgtdcAOhtxBFlYYNLzPKYLxRzE9JuvoQvopCME9aJxqyyar9Iac/UFt3xPJ/DfZZ6JdUrmWnjv6FF4NBo88KW/5mLIzIHQ2xhQxmYAlw8sUYCRFQEo/sdKf+ZQ69Kd3oBt5PAA63+AfLJ0GELo= 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=YOZ4afsK; arc=none smtp.client-ip=95.215.58.115 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="YOZ4afsK" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=0xdUqTsvy+qUrlfku4ZIUWyJOcx0knAT5Kmtq4e0nOA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786789723; v=1; x=1787394523; b=YOZ4afsKxPNe1ujmq2/i6/adGvcyUtsaGstg3n8JaOrrb78iACU7oo1ti8IfQhhAT9tyaWXo 6VKYs380HDYMKd2qQBW0ozRcEBlV9PglYBuxM4/keVo5fxDN4yyJumn4yv2i8c2SwkIpxXwq3Z/ A0EDz74MA9CF5y519RWqDY+8= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost.localdomain (2408:823d:2011:2c0:e810:54f9:f0a3:99d) by smtp.migadu.com with ESMTPS id 18de2c252fa19764; Sat, 15 Aug 2026 10:28:43 +0000 X-Migadu-Flow: FLOW_OUT From: Jinyu Tang To: Anup Patel , Anup Patel , Atish Patra 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, Paolo Bonzini , Sean Christopherson , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Andrew Jones , Conor Dooley , Yong-Xuan Wang , Nutty Liu , Jinyu Tang , Jinyu Tang Subject: [PATCH v4 RESEND 0/5] KVM: riscv: Add KVM_PRE_FAULT_MEMORY support Date: Sat, 15 Aug 2026 06:28:28 -0400 Message-ID: <20260815102833.864330-1-jinyu.tang@linux.dev> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add RISC-V support for the generic KVM_PRE_FAULT_MEMORY ioctl. Patch 1 and patch 2 fix existing G-stage huge-page corner cases. They are included first because the prefault hook relies on the map path reporting the mapping that actually covers the requested GPA. Patch 3 adds the RISC-V arch hook for KVM_PRE_FAULT_MEMORY. Patch 4 adds Sv57 indexing support to the RISC-V KVM selftest helpers, and patch 5 enables the generic pre_fault_memory_test for RISC-V. Patch 1 folds the previously posted standalone G-stage table overwrite fix into this series: https://lore.kernel.org/kvm-riscv/20260814105752.565325-1-jinyu.tang@linux.dev/T/#u Changes in v4 resend: - Resend the full series because the previous v4 send was interrupted and the kvm-riscv list archive did not show a complete thread. No code changes. Changes in v4: - Fold the standalone G-stage non-leaf overwrite fix into this series. - Avoid THP adjustment when the original faulting GPA already has an existing 4K G-stage leaf. - Return an error for HWPOISON instead of reporting success without a visible G-stage mapping. (Sashiko) Changes in v3: - Retry internally when the map path returns success without a visible G-stage mapping, instead of exposing -EAGAIN. (Sashiko) Changes in v2: - Drop the per-test guest_modes_append_default() call from pre_fault_memory_test.c. (Sean) Jinyu Tang (5): KVM: riscv: Avoid overwriting G-stage tables with huge leaves KVM: riscv: Avoid THP adjustment for existing 4K G-stage leaves KVM: riscv: Implement KVM_PRE_FAULT_MEMORY KVM: selftests: Add RISC-V Sv57 page table indexing KVM: selftests: Enable pre_fault_memory_test for RISC-V arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/gstage.c | 9 ++ arch/riscv/kvm/mmu.c | 83 ++++++++++++++++++- arch/riscv/kvm/vm.c | 1 + tools/testing/selftests/kvm/Makefile.kvm | 1 + .../selftests/kvm/include/riscv/processor.h | 6 ++ .../selftests/kvm/lib/riscv/processor.c | 2 + 7 files changed, 100 insertions(+), 3 deletions(-) -- 2.43.0