mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>, Anup Patel <anup@brainfault.org>
Cc: Mark Brown <broonie@kernel.org>, Lorenzo Stoakes <ljs@kernel.org>,
	Marc Zyngier <maz@kernel.org>, Jinyu Tang <jinyu.tang@linux.dev>,
	Atish Patra <atish.patra@linux.dev>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <pjw@kernel.org>, Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	linux-riscv@lists.infradead.org, linux-next@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: riscv: Implement kvm_arch_pre_fault_allowed()
Date: Thu, 22 Oct 2026 10:42:16 -0400	[thread overview]
Message-ID: <36adc119db9b30984c0df4d1846c0f29e4e46c07.1792679974.git.sashal@kernel.org> (raw)
In-Reply-To: <CABgObfaH4-Ud4VR=GC8giDmWGJWS-tvYSmPOs4TtWg2hm4ocqw@mail.gmail.com>

Commit caa63620f9e3 ("KVM: Allow architectures to disallow pre-fault")
requires every architecture that selects KVM_GENERIC_PRE_FAULT_MEMORY to
implement kvm_arch_pre_fault_allowed(), and there is no generic default.

Commit e8b32e377951 ("KVM: riscv: Implement KVM_PRE_FAULT_MEMORY") was
written before that hook existed, so it selects the option without
implementing the hook. With both commits in the same tree, riscv builds
with KVM enabled fail to link:

  ld.lld: error: undefined symbol: kvm_arch_pre_fault_allowed
  >>> referenced by kvm_main.c
  >>>               virt/kvm/kvm_main.o:(kvm_vcpu_pre_fault_memory) in archive vmlinux.a

The riscv implementation does not refuse pre-faulting in any state, so
return 0 to keep its current behaviour.

Fixes: e8b32e377951 ("KVM: riscv: Implement KVM_PRE_FAULT_MEMORY")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Paolo, this is needed when kvm-riscv-7.4-1 is merged into kvm/next.
Feel free to squash it into the merge instead.

Mark, next-20261022 already fails to link, so linux-next needs this on
top of the kvm-riscv merge.

Build-tested with a riscv tinyconfig plus KVM=y on next-20261022 and on
kvm/next with kvm-riscv-7.4-1 merged. Not runtime tested.

 arch/riscv/kvm/mmu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
index e8673cfa69668..738d9ee1eac9d 100644
--- a/arch/riscv/kvm/mmu.c
+++ b/arch/riscv/kvm/mmu.c
@@ -754,6 +754,11 @@ int kvm_riscv_mmu_map(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
 	return ret;
 }
 
+int kvm_arch_pre_fault_allowed(struct kvm_vcpu *vcpu)
+{
+	return 0;
+}
+
 long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
 				    struct kvm_pre_fault_memory *range)
 {
-- 
2.53.0


       reply	other threads:[~2026-10-22 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABgObfaH4-Ud4VR=GC8giDmWGJWS-tvYSmPOs4TtWg2hm4ocqw@mail.gmail.com>
2026-10-22 14:42 ` Sasha Levin [this message]
2026-10-22 14:51   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36adc119db9b30984c0df4d1846c0f29e4e46c07.1792679974.git.sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=broonie@kernel.org \
    --cc=jinyu.tang@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=ljs@kernel.org \
    --cc=maz@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®