VBS/VSM-on-KVM: guest support using VM Planes
Subsystems (4)
v2 cover VBS/VSM-on-KVM: guest support using VM Planes
This RFC adds guest-side Virtualization-Based Security (VBS) support using KVM VM Planes. Plane 0 runs the normal guest kernel and plane 1 runs a higher-trust secure kernel that receives VTL calls through the KVM hypercall-mediated plane switch.
The series enables a second software plane by default, introduces the VBS core and KVM backend, bootstraps the secure plane, and adds the secure-side monitor and park/dispatch handshake.
This is v2 of the series. Based on feedback from maintainers, the KVM host, guest, and QEMU changes are now being posted as three separate, layered RFCs to make it easier to understand the context of these changes as they pertain to the KVM host, guest, and QEMU. This patchset does not yet include memory protection between planes; that will be added in a future version.
This series is based on the KVM VM Planes prerequisite patchset obtained from Joerg Roedel's tree (kvm-planes-v7.1):
https://github.com/joergroedel/linux/tree/kvm-planes-v7.1
This series depends on the separately posted four-patch KVM host RFC ending at commit 6cbd0b038cb3 ("KVM: x86: handle VBS VTL call/return via in-kernel plane switch"):
https://lore.kernel.org/kvm/[email protected]/
This remains prototype code and is not intended for production use.
The implementation and integration tooling are available at:
Linux and KVM support:
https://github.com/safe-tee/linux/tree/vm-planes-layered
QEMU support:
https://github.com/safe-tee/qemu/tree/vm-planes-layered
Build, test, and integration tooling:
https://github.com/safe-tee/lvbs/tree/vm-planes-layered
Acknowledgments
===============
This work stands on top of, and is indebted to, several prior efforts:
- Joerg Roedel, whose QEMU and KVM VM Planes work provides the infrastructure that the VBS/VSM secure plane relies on.
- Paolo Bonzini, whose "[RFC PATCH 00/29] KVM: VM planes" introduced the VM Plane concept to KVM as a common in-kernel model for AMD VMPLs, Intel TDX partitions, Hyper-V VTLs, and Arm CCA planes.
https://lwn.net/Articles/1016113/
- James Bottomley and James Morris, for their ongoing VSM-on-KVM work, which informed the design and direction of this series.
Feedback on the VBS framework, guest bootstrap, backend interface, and normal-plane/secure-plane division is welcome.
Sriram Nambakam (8):
KVM: x86: raise the default maximum planes to two security/vbs: introduce core VBS framework security/vbs: add platform probe and backend registration security/vbs: add KVM software planes backend security/vbs: enable the backend after driver init
vm_planes: add hypervisor-assisted plane bootstrap security/vbs: bootstrap the plane from the enable path drivers/virt: add KVM VM-planes secure-plane monitor
arch/x86/kernel/cpu/common.c | 64 ++++ arch/x86/kvm/x86.c | 3 +- arch/x86/realmode/init.c | 21 ++ drivers/virt/Kconfig | 15 + drivers/virt/Makefile | 1 + drivers/virt/secure_monitor.c | 141 ++++++++ include/linux/vbs.h | 74 ++++ include/linux/vm_planes.h | 46 +++ init/Kconfig | 18 + init/Makefile | 4 + init/vm_planes.c | 636 ++++++++++++++++++++++++++++++++++ security/Kconfig | 2 + security/Makefile | 1 + security/vbs/Kconfig | 32 ++ security/vbs/Makefile | 7 + security/vbs/core.c | 182 ++++++++++ security/vbs/internal.h | 20 ++ security/vbs/kvm_planes.c | 177 ++++++++++ security/vbs/probe.c | 61 ++++ 19 files changed, 1504 insertions(+), 1 deletion(-) create mode 100644 drivers/virt/secure_monitor.c create mode 100644 include/linux/vbs.h create mode 100644 include/linux/vm_planes.h create mode 100644 init/vm_planes.c create mode 100644 security/vbs/Kconfig create mode 100644 security/vbs/Makefile create mode 100644 security/vbs/core.c create mode 100644 security/vbs/internal.h create mode 100644 security/vbs/kvm_planes.c create mode 100644 security/vbs/probe.c
base-commit: 6cbd0b038cb31db2f06fe6516f5982d5bdb50174
Signature · 1 line
2.55.0
RFC PATCH v2 1/8 KVM: x86: raise the default maximum planes to two
The default max-planes callback returns 1, which limits KVM_CAP_PLANES to a single plane on VMX (and on SVM for non-SEV-SNP guests). VBS needs a normal plane (0) and one secure plane (1), so return 2 by default. This is still gated by irqchip=split in kvm_arch_max_planes().
--- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +2 -1
@@ -478,7 +478,8 @@ static unsigned int num_msr_based_features;unsigned kvm_x86_default_max_planes (struct kvm *kvm) { -return 1 ; +/* Support a normal plane (0) and one secure plane (1) for VBS. */ +return 2 ; }EXPORT_SYMBOL_FOR_KVM_INTERNAL (kvm_x86_default_max_planes);
Signature · 1 line
2.55.0
RFC PATCH v2 2/8 security/vbs: introduce core VBS framework
In reply to Sriram NambakamAdd the transport-agnostic Virtualization-Based Security (VBS) core: a small dispatch layer between the guest OS (plane-0) and a secure kernel running in a higher-privileged plane-1.
Backends register a struct vbs_ops via vbs_register_backend(); the core exposes vbs_available() and a generic vbs_vtl_call() that forwards to the active backend. No backend is registered yet.
Gated by CONFIG_VBS (off by default).
--- include/linux/vbs.h | 74 +++++++++++++++++++++++++++++++++++++++++++ security/Kconfig | 2 ++ security/Makefile | 1 + security/vbs/Kconfig | 16 ++++++++++ security/vbs/Makefile | 3 ++ security/vbs/core.c | 56 ++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+) create mode 100644 include/linux/vbs.h create mode 100644 security/vbs/Kconfig create mode 100644 security/vbs/Makefile create mode 100644 security/vbs/core.c
include/linux/vbs.h new file +74 -0
@@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* VBS — Virtualization-Based Security +* +* Transport-agnostic interface between the guest OS (plane-0) and a secure +* kernel running in a higher-privileged plane-1. The guest kernel calls the +* vbs_*() functions; the active backend translates them into the appropriate +* transport (e.g. a KVM paravirt hypercall). +* +* This is the core framework only. VBS is software-only: backends are +* software/hypervisor planes (KVM software planes now, Hyper-V VSM later). +* Backends register via vbs_register_backend(). +*/ + +#ifndef _LINUX_VBS_H +#define _LINUX_VBS_H + +#include <linux/types.h> +#include <linux/errno.h> + +/* VTL-call request codes (plane-0 -> plane-1 direction). */ +enum vbs_call_id { +VBS_CALL_INIT =0x0001 ,/* plane-0 boot complete: load plane */ +VBS_CALL_SHUTDOWN =0x0002 ,/* plane-0 shutting down: unload */ +}; + +/** +* struct vbs_ops - operations provided by a VBS backend +* @name: backend name, e.g. "kvm-planes" +* @init: load/connect the secure plane; called once after drivers init +* @shutdown: unload the secure plane; called on reboot/halt +* @vtl_call: send an arbitrary request to the secure kernel and wait for a +* response. Returns 0 on success, negative errno on failure. +* +* Callbacks run from process context with preemption enabled. +*/ +struct vbs_ops { +const char *name; + +int (*init)(void ); +void (*shutdown)(void ); + +int (*vtl_call)(enum vbs_call_id id, +const void *arg,size_t arg_size, +void *resp,size_t resp_size); +}; + +#ifdef CONFIG_VBS + +/** +* vbs_register_backend() - register the platform-specific backend. +* +* Called once during boot by the platform detection code. Only one backend +* can be active at a time. +*/ +int vbs_register_backend (const struct vbs_ops *ops); + +/** vbs_available() - true if a backend is registered. */ +bool vbs_available (void ); + +/** vbs_vtl_call() - dispatch a raw VTL call through the active backend. */ +int vbs_vtl_call (enum vbs_call_id id, +const void *arg,size_t arg_size, +void *resp,size_t resp_size); + +#else /* !CONFIG_VBS */ + +static inline bool vbs_available (void ) {return false; } +static inline int vbs_vtl_call (enum vbs_call_id id, +const void *arg,size_t arg_size, +void *resp,size_t resp_size) {return -ENOSYS ; } + +#endif /* CONFIG_VBS */ +#endif /* _LINUX_VBS_H */
security/Kconfig +2 -0
@@ -299,6 +299,8 @@ config SECURITY_COMMONCAP_KUNIT_TEST If unsure, say N. +source "security/vbs/Kconfig" + source "security/Kconfig.hardening" endmenu
security/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_CGROUPS) += device_cgroup.o obj-$(CONFIG_BPF_LSM) += bpf/ obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/ obj-$(CONFIG_SECURITY_IPE) += ipe/ +obj-$(CONFIG_VBS) += vbs/ # Object integrity file lists obj-$(CONFIG_INTEGRITY) += integrity/
security/vbs/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config VBS + bool "Virtualization-Based Security (VBS) support" + depends on X86_64 + help + Enable a transport-agnostic interface between the guest OS + (plane-0) and a secure kernel running in a higher-privileged + plane-1. + + The core VBS layer dispatches calls from kernel subsystems to a + platform-specific backend. VBS is software-only: backends are + software/hypervisor planes (KVM software planes now, Hyper-V VSM + later). Hardware confidential-compute is out of scope. + + If unsure, say N.
security/vbs/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_VBS) += vbs.o +vbs-y := core.o
security/vbs/core.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.55.0
RFC PATCH v2 3/8 security/vbs: add platform probe and backend registration
In reply to Sriram NambakamAdd a single rootfs_initcall that walks a probe table and registers the first backend whose detect() succeeds. The table currently holds only the KVM software-planes entry; when that backend is not configured a local stub keeps the probe self-contained and buildable.
Registration only records the backend at this stage.
--- security/vbs/Makefile | 4 ++- security/vbs/internal.h | 20 ++++++++++++++ security/vbs/probe.c | 61 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 security/vbs/internal.h create mode 100644 security/vbs/probe.c
security/vbs/Makefile +3 -1
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VBS) += vbs.o -vbs-y := core.o +# probe.o links before core.o so the backend is registered (vbs_probe_init) +# early in the rootfs_initcall level. +vbs-y := probe.o core.o
security/vbs/internal.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* VBS internal header — shared between probe.c and backend implementations. +*/ +#ifndef _SECURITY_VBS_INTERNAL_H +#define _SECURITY_VBS_INTERNAL_H + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/printk.h> +#include <linux/vbs.h> + +/* Each backend exports a detect + get_ops pair for the centralized probe. */ + +#ifdef CONFIG_VBS_KVM_PLANES +bool __init vbs_kvm_planes_detect (void ); +const struct vbs_ops *vbs_kvm_planes_get_ops (void ); +#endif + +#endif /* _SECURITY_VBS_INTERNAL_H */
security/vbs/probe.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.55.0
RFC PATCH v2 4/8 security/vbs: add KVM software planes backend
In reply to Sriram NambakamAdd the KVM software-planes VBS backend. It uses a synchronous shared-memory calling area and the KVM_HC_VBS_VTL_CALL paravirt hypercall (handled by the host) to reach plane-1.
Only the plane lifecycle is implemented: init() allocates the calling area and issues VBS_CALL_INIT to load (connect to) the secure plane; shutdown() issues VBS_CALL_SHUTDOWN to unload it. The BSP-pinned work_on_cpu() ensures the plane switch always lands on CPU0.
Gated by CONFIG_VBS_KVM_PLANES.
--- security/vbs/Kconfig | 15 ++++ security/vbs/Makefile | 2 + security/vbs/kvm_planes.c | 177 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 security/vbs/kvm_planes.c
security/vbs/Kconfig +15 -0
@@ -14,3 +14,18 @@ config VBS later). Hardware confidential-compute is out of scope. If unsure, say N. + +config VBS_KVM_PLANES + bool "VBS backend: KVM software planes" + depends on VBS && KVM_GUEST + help + VBS backend that uses a KVM paravirt hypercall to communicate + between plane-0 (the normal guest kernel) and plane-1 (a secure + kernel running in a separate KVM VM plane managed by QEMU). + + This minimal backend supports loading (connecting to) and + unloading the secure plane via a shared-memory calling area. + + Select this if you are running under KVM with VM planes support. + + If unsure, say N.
security/vbs/Makefile +2 -0
@@ -3,3 +3,5 @@ obj-$(CONFIG_VBS) += vbs.o # probe.o links before core.o so the backend is registered (vbs_probe_init) # early in the rootfs_initcall level. vbs-y := probe.o core.o + +obj-$(CONFIG_VBS_KVM_PLANES) += kvm_planes.o
security/vbs/kvm_planes.c new file +177 -0
177 lines not on this page · raw message
Signature · 1 line
2.55.0
RFC PATCH v2 5/8 security/vbs: enable the backend after driver init
In reply to Sriram NambakamActivate a registered VBS backend from a late_initcall, once plane-0 is otherwise up. Enabling is opt-in and requires two conditions:
1. the operator passes enable-kvm-planes=1 on the kernel command line, and
2. the boot image advertises a provisioned secure plane via /etc/Kconfig.kvm-planes containing CONFIG_VM_PLANES=y.
When both hold, call the backend's init() to load the secure plane and register a reboot notifier that invokes shutdown() to unload it.
--- security/vbs/core.c | 114 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
security/vbs/core.c +114 -0
@@ -8,8 +8,15 @@#include <linux/vbs.h> #include <linux/export.h> +#include <linux/init.h> +#include <linux/kernel_read_file.h> +#include <linux/kstrtox.h> #include <linux/mutex.h> #include <linux/printk.h> +#include <linux/reboot.h> +#include <linux/sizes.h> +#include <linux/string.h> +#include <linux/vmalloc.h> static const struct vbs_ops *vbs_backend;static DEFINE_MUTEX (vbs_lock);
@@ -54,3 +61,110 @@ int vbs_vtl_call(enum vbs_call_id id,return ops->vtl_call (id, arg, arg_size, resp, resp_size); }EXPORT_SYMBOL_GPL (vbs_vtl_call); + +/* ── enable after driver init ────────────────────────────────── */ + +/* +* A registered backend is only activated when two conditions hold: +* 1. the operator opts in on the kernel command line (enable-kvm-planes=1), +* and +* 2. the boot image advertises a provisioned secure plane via a plane +* configuration file that enables the expected option. +*/ +#define VBS_KCONFIG_PATH "/etc/Kconfig.kvm-planes" +#define VBS_KCONFIG_TOKEN "CONFIG_VM_PLANES=y" + +static bool vbs_enable_requested; + +static int __init vbs_parse_enable_kvm_planes (char *str) +{ +bool val; + +/* Bare "enable-kvm-planes" (no value) means enabled. */ +if (!str || !*str) + vbs_enable_requested = true; +else if (!kstrtobool (str, &val)) + vbs_enable_requested = val; +return 0 ; +} +early_param ("enable-kvm-planes" , vbs_parse_enable_kvm_planes); + +static int vbs_reboot_notify (struct notifier_block *nb,unsigned long action, +void *data) +{ +const struct vbs_ops *ops =READ_ONCE (vbs_backend); + +if (ops && ops->shutdown) + ops->shutdown (); +return NOTIFY_DONE ; +} + +static struct notifier_block vbs_reboot_nb = { + .notifier_call = vbs_reboot_notify, +}; + +/* Return true if VBS_KCONFIG_PATH exists and enables the plane config. */ +static bool __init vbs_plane_config_present (void ) +{ +void *buf =NULL ; +size_t sz =0 ; +bool ok = false; +int ret; + + ret =kernel_read_file_from_path (VBS_KCONFIG_PATH ,0 , &buf,SZ_1M , &sz, +READING_UNKNOWN ); +if (ret <0 ) { +pr_info ("vbs: %s unavailable (%d); backend left idle\n" , +VBS_KCONFIG_PATH , ret); +return false; + } + +if (buf && sz) + ok =strnstr (buf,VBS_KCONFIG_TOKEN , sz) !=NULL ; +vfree (buf); + +if (!ok) +pr_info ("vbs: %s present but %s not set; backend left idle\n" , +VBS_KCONFIG_PATH ,VBS_KCONFIG_TOKEN ); +return ok; +} + +/* +* Enable the registered backend after device drivers have initialised. +* Runs at late_initcall so the plane is loaded only once the plane-0 kernel +* is otherwise up, the operator requested it (enable-kvm-planes=1), and the +* boot image advertises a plane config. +*/ +static int __init vbs_enable (void ) +{ +const struct vbs_ops *ops =READ_ONCE (vbs_backend); +int ret; + +if (!ops) { +pr_debug ("vbs: no backend registered; nothing to enable\n" ); +return 0 ; + } + +if (!vbs_enable_requested) { +pr_info ("vbs: enable-kvm-planes not set; backend \"%s\" left idle\n" , + ops->name); +return 0 ; + } + +if (!vbs_plane_config_present ()) +return 0 ; + +if (ops->init) { + ret = ops->init (); +if (ret) { +pr_warn ("vbs: backend \"%s\" init failed (%d)\n" , + ops->name, ret); +return 0 ; + } + } + +register_reboot_notifier (&vbs_reboot_nb); +pr_info ("vbs: enabled backend \"%s\"\n" , ops->name); +return 0 ; +} +late_initcall (vbs_enable);
Signature · 1 line
2.55.0
RFC PATCH v2 6/8 vm_planes: add hypervisor-assisted plane bootstrap
In reply to Sriram NambakamAdd the guest-side VM-planes bootstrap under CONFIG_VM_PLANES. It reads the per-plane configuration (config-vm-planes) and the plane kernel images from the initramfs, allocates plane memory and creates the planes via the KVM_HC_VM_PLANES_CONFIG / KVM_HC_VM_PLANES_ACTIVATE paravirt hypercalls, and loads RAW or ELF plane kernels into plane memory.
The orchestration is exposed as vm_planes_bootstrap() so a consumer can drive it at the right point in boot; the x86 hypercall wrappers alloc_vm_planes() / activate_vm_planes() live in cpu/common.c.
Only software planes are supported; there is no memory protection or sealing here.
--- arch/x86/kernel/cpu/common.c | 64 ++++ include/linux/vm_planes.h | 46 +++ init/Kconfig | 18 + init/Makefile | 4 + init/vm_planes.c | 636 +++++++++++++++++++++++++++++++++++ 5 files changed, 768 insertions(+) create mode 100644 include/linux/vm_planes.h create mode 100644 init/vm_planes.c
arch/x86/kernel/cpu/common.c +64 -0
@@ -28,8 +28,11 @@#include <linux/stackprotector.h> #include <linux/utsname.h> #include <linux/efi.h> +#include <linux/kvm_para.h> +#include <linux/vm_planes.h> #include <asm/alternative.h> +#include <asm/kvm_para.h> #include <asm/cmdline.h> #include <asm/cpuid/api.h> #include <asm/perf_event.h>
@@ -2664,3 +2667,64 @@ void __init arch_cpu_finalize_init(void)*/ mem_encrypt_init (); } + +#ifdef CONFIG_VM_PLANES +int __init alloc_vm_planes (unsigned int plane_count, +struct vm_plane_config *plane_cfg) +{ +phys_addr_t phys; +long ret; + +if (!plane_count || !plane_cfg) +return -EINVAL ; + +if (!kvm_para_available ()) { +pr_warn ("vm_planes: hypercall interface unavailable\n" ); +return -ENODEV ; + } + + phys =virt_to_phys ((void *)plane_cfg); + +if (sizeof (unsigned long ) <sizeof (phys_addr_t) && phys >ULONG_MAX ) { +pr_warn ("vm_planes: shared config address exceeds hypercall register width\n" ); +return -EOVERFLOW ; + } + + ret =kvm_hypercall2 (KVM_HC_VM_PLANES_CONFIG , + (unsigned long )phys, + plane_count); +if (ret <0 ) { +pr_warn ("vm_planes: hypercall failed: %ld\n" , ret); +return (int )ret; + } + +return 0 ; +} + +int __init activate_vm_planes (unsigned int plane_count, +struct vm_plane_config *plane_cfg) +{ +phys_addr_t phys; +long ret; + +if (!plane_count || !plane_cfg) +return -EINVAL ; + +if (!kvm_para_available ()) { +pr_warn ("vm_planes: hypercall interface unavailable\n" ); +return -ENODEV ; + } + + phys =virt_to_phys ((void *)plane_cfg); + + ret =kvm_hypercall2 (KVM_HC_VM_PLANES_ACTIVATE , + (unsigned long )phys, + plane_count); +if (ret <0 ) { +pr_warn ("vm_planes: activate hypercall failed: %ld\n" , ret); +return (int )ret; + } + +return 0 ; +} +#endif /* CONFIG_VM_PLANES */
include/linux/vm_planes.h new file +46 -0
46 lines not on this page · raw message
init/Kconfig +18 -0
@@ -2259,6 +2259,24 @@ source "kernel/Kconfig.kexec" source "kernel/liveupdate/Kconfig" +config VM_PLANES + bool "Enable VM planes early boot support" if EXPERT + depends on KVM_GUEST + default n + help + Enable hypervisor-assisted multi-kernel (VM planes) support. + + When enabled, and when the VBS backend requests it, the kernel sets + up the configured planes from the VBS enable path (late_initcall, + after device drivers and before userspace). The plane configuration + and per-plane kernel images are read from the initramfs. + + The initrd config-vm-planes file is expected to provide per-plane + entries for PLANE_<id>_KERNEL, PLANE_<id>_LOAD_OFFSET, and + PLANE_<id>_MEMORY_SIZE. + + If unsure, say N. + endmenu # General setup source "arch/Kconfig"
init/Makefile +4 -0
@@ -14,6 +14,10 @@ endif obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o obj-$(CONFIG_INITRAMFS_TEST) += initramfs_test.o +# vm_planes.o must link AFTER initramfs.o so that it reads the plane config +# and kernels from the populated rootfs. +obj-$(CONFIG_VM_PLANES) += vm_planes.o + obj-y += init_task.o mounts-y := do_mounts.o
init/vm_planes.c new file +636 -0
636 lines not on this page · raw message
Signature · 1 line
2.55.0
RFC PATCH v2 7/8 security/vbs: bootstrap the plane from the enable path
In reply to Sriram NambakamWhen the KVM software-planes backend is enabled, create and activate the secure plane before the backend issues its first VTL call. vbs_enable() runs at late_initcall -- after device drivers have initialised and before userspace starts -- which is where vm_planes_bootstrap() now runs.
Select VM_PLANES from VBS_KVM_PLANES so the plane bootstrap is built in whenever the backend is.
--- security/vbs/Kconfig | 1 + security/vbs/core.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
security/vbs/Kconfig +1 -0
@@ -18,6 +18,7 @@ config VBS config VBS_KVM_PLANES bool "VBS backend: KVM software planes" depends on VBS && KVM_GUEST + select VM_PLANES help VBS backend that uses a KVM paravirt hypercall to communicate between plane-0 (the normal guest kernel) and plane-1 (a secure
security/vbs/core.c +12 -0
@@ -16,6 +16,7 @@#include <linux/reboot.h> #include <linux/sizes.h> #include <linux/string.h> +#include <linux/vm_planes.h> #include <linux/vmalloc.h> static const struct vbs_ops *vbs_backend;
@@ -154,6 +155,17 @@ static int __init vbs_enable(void)if (!vbs_plane_config_present ())return 0 ; +/* +* Create and activate the secure plane before the backend issues its +* first VTL call. A failure here leaves the backend idle. +*/ + ret =vm_planes_bootstrap (); +if (ret) { +pr_warn ("vbs: plane bootstrap failed (%d); backend \"%s\" left idle\n" , + ret, ops->name); +return 0 ; + } +if (ops->init) { ret = ops->init ();if (ret) {
Signature · 1 line
2.55.0
RFC PATCH v2 8/8 drivers/virt: add KVM VM-planes secure-plane monitor
In reply to Sriram NambakamAdd the secure-plane (plane >0) side of the VM-planes park/dispatch handshake, so an otherwise ordinary kernel can act as the secure plane without the full VBS stack. Activated by the "secure_monitor" kernel command-line option, a late_initcall kthread hands control back to the normal plane via KVM_HC_VBS_VTL_RETURN and then services VTL calls from the shared calling area (matching struct vbs_kvm_ca in security/vbs).
Calls are acknowledged as no-ops for now; real per-call handlers are added incrementally. The same option also skips the sub-1M real-mode trampoline (arch/x86/realmode/init.c), which the secure plane neither has memory for nor uses.
Gated by CONFIG_VBS_SECURE_MONITOR.
--- arch/x86/realmode/init.c | 21 +++++ drivers/virt/Kconfig | 15 ++++ drivers/virt/Makefile | 1 + drivers/virt/secure_monitor.c | 141 ++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 drivers/virt/secure_monitor.c
arch/x86/realmode/init.c +21 -0
@@ -44,6 +44,27 @@ void load_trampoline_pgtable(void)__flush_tlb_all (); } +#ifdef CONFIG_VBS_SECURE_MONITOR +/* +* A KVM VM-planes secure plane (plane > 0) is entered directly in 64-bit long +* mode and boots from a single carved-out high-memory region that contains no +* RAM below 1 MiB. It runs with no firmware, ACPI sleep, or hibernation, so +* the 16-bit real-mode trampoline can neither be allocated (there is no +* sub-1M memory) nor is it ever used. Disable the real-mode setup from an +* early_param so it takes effect before setup_arch() calls +* x86_platform.realmode_reserve(); triggered by the "secure_monitor" option, +* the same switch that activates the in-kernel secure-plane monitor. +*/ +static int __init secure_plane_no_real_mode (char *arg) +{ + x86_platform.realmode_reserve = x86_init_noop; + x86_platform.realmode_init = x86_init_noop; +pr_info ("realmode: secure plane: skipping sub-1M trampoline\n" ); +return 0 ; +} +early_param ("secure_monitor" , secure_plane_no_real_mode); +#endif /* CONFIG_VBS_SECURE_MONITOR */ +void __init reserve_real_mode (void ) {phys_addr_t mem, limit = x86_init.resources.realmode_limit;
drivers/virt/Kconfig +15 -0
@@ -13,6 +13,21 @@ menuconfig VIRT_DRIVERS if VIRT_DRIVERS +config VBS_SECURE_MONITOR + bool "KVM VM-planes secure-plane monitor" + depends on X86 && KVM_GUEST + help + In-kernel monitor for the secure plane (plane >0) of a KVM VM-planes + guest. When enabled and the "secure_monitor" kernel command-line + option is present, a kernel thread hands control back to the normal + plane via the KVM_HC_VBS_VTL_RETURN hypercall and then services VTL + calls from a shared calling area. + + This is independent of the full VBS stack (CONFIG_VBS) so that any + secure kernel can act as plane 1. Per-call handlers are plumbed in + incrementally; until then calls are acknowledged as no-ops. Say N + unless this kernel is used as a VM-planes secure plane. + config VMGENID tristate "Virtual Machine Generation ID driver" default y
drivers/virt/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o obj-$(CONFIG_VMGENID) += vmgenid.o +obj-$(CONFIG_VBS_SECURE_MONITOR) += secure_monitor.o obj-y += vboxguest/ obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
drivers/virt/secure_monitor.c new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
2.55.0