From: Sriram Nambakam <snambakam@linux.microsoft.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 2/4] KVM: x86: exit VM-plane config/activate hypercalls to userspace
Date: Mon, 10 Aug 2026 17:31:12 -0700 [thread overview]
Message-ID: <20260811003114.30107-3-snambakam@linux.microsoft.com> (raw)
In-Reply-To: <20260811003114.30107-1-snambakam@linux.microsoft.com>
Handle the guest's plane-setup hypercalls by exiting to the VMM:
KVM_HC_VM_PLANES_CONFIG - allocate plane memory
KVM_HC_VM_PLANES_ACTIVATE - create and activate the plane vCPU
Both exit via KVM_EXIT_HYPERCALL (gated by KVM_CAP_EXIT_HYPERCALL, hence
added to KVM_EXIT_HYPERCALL_VALID_MASK) and are completed by userspace.
This is what brings a secure plane and its vCPU into existence; the
in-kernel VBS plane-switch handlers are added separately.
---
arch/x86/kvm/x86.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0ace79c957bb..3b21c72fc9e0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -119,7 +119,10 @@ u64 __read_mostly efer_reserved_bits = ~((u64)(EFER_SCE | EFER_LME | EFER_LMA));
static u64 __read_mostly efer_reserved_bits = ~((u64)EFER_SCE);
#endif
-#define KVM_EXIT_HYPERCALL_VALID_MASK (1 << KVM_HC_MAP_GPA_RANGE)
+#define KVM_EXIT_HYPERCALL_VALID_MASK \
+ ((1 << KVM_HC_MAP_GPA_RANGE) | \
+ (1 << KVM_HC_VM_PLANES_CONFIG) | \
+ (1 << KVM_HC_VM_PLANES_ACTIVATE))
#define KVM_CAP_PMU_VALID_MASK KVM_PMU_CAP_DISABLE
@@ -10559,6 +10562,30 @@ int ____kvm_emulate_hypercall(struct kvm_vcpu *vcpu, int cpl,
vcpu->arch.complete_userspace_io = complete_hypercall;
return 0;
}
+ case KVM_HC_VM_PLANES_CONFIG:
+ case KVM_HC_VM_PLANES_ACTIVATE:
+ /*
+ * VM plane setup: hand off to the VMM, which allocates plane
+ * memory (CONFIG) and creates + activates the plane vCPU
+ * (ACTIVATE). Serviced entirely in userspace.
+ */
+ if (!user_exit_on_hypercall(vcpu->kvm, nr))
+ break;
+
+ vcpu->run->exit_reason = KVM_EXIT_HYPERCALL;
+ vcpu->run->hypercall.nr = nr;
+ vcpu->run->hypercall.ret = 0;
+ vcpu->run->hypercall.args[0] = a0;
+ vcpu->run->hypercall.args[1] = a1;
+ vcpu->run->hypercall.args[2] = a2;
+ vcpu->run->hypercall.args[3] = a3;
+ vcpu->run->hypercall.flags = 0;
+ if (op_64_bit)
+ vcpu->run->hypercall.flags |= KVM_EXIT_HYPERCALL_LONG_MODE;
+
+ WARN_ON_ONCE(vcpu->run->hypercall.flags & KVM_EXIT_HYPERCALL_MBZ);
+ vcpu->arch.complete_userspace_io = complete_hypercall;
+ return 0;
default:
ret = -KVM_ENOSYS;
break;
--
2.55.0
next prev parent reply other threads:[~2026-08-11 0:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 0:31 [RFC PATCH v2 0/4] KVM: VM Planes host support for VBS Sriram Nambakam
2026-08-11 0:31 ` [RFC PATCH v2 1/4] kvm: uapi: reserve VM-plane and VBS hypercall numbers Sriram Nambakam
2026-08-11 0:31 ` Sriram Nambakam [this message]
2026-08-11 0:31 ` [RFC PATCH v2 3/4] KVM: x86: add VTL-call state to struct kvm_vcpu_common Sriram Nambakam
2026-08-11 0:31 ` [RFC PATCH v2 4/4] KVM: x86: handle VBS VTL call/return via in-kernel plane switch Sriram Nambakam
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=20260811003114.30107-3-snambakam@linux.microsoft.com \
--to=snambakam@linux.microsoft.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.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