From: sashiko-bot@kernel.org
To: "Thara Gopinath" <tgopinath@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [RFC PATCH 06/12] drivers: hv: Add VSM boot driver and enable VTL1 at the partition level
Date: Tue, 01 Sep 2026 17:24:42 +0000 [thread overview]
Message-ID: <20260901172442.995301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901165647.3160413-7-tgopinath@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Incorrect validation of the MBEC enablement bitmask allows silent failure of VTL1 security configuration.
- [High] Missing MBEC validation when VTL1 is found to be already enabled, allowing acceptance of insecure pre-configured VTL1 states.
- [Medium] hv_vsm_boot_init pins initialization to cpumask_first(cpu_online_mask), which is incorrect for kexec/kdump where the boot CPU may not be CPU 0.
--
commit cce0c5216b1bbddd78ce31614c3d1587f8bcd4ea
Author: Thara Gopinath <tgopinath@linux.microsoft.com>
drivers: hv: Add VSM boot driver and enable VTL1 at the partition level
This commit introduces a driver to bring up Linux VBS (LVBS) using Hyper-V's
Virtual Secure Mode. It provides the initial sequence to probe privileges, pin
execution to the VTL0 boot CPU, and enable VTL1 at the partition level with
MBEC.
> diff --git a/drivers/hv/hv_vsm_boot.c b/drivers/hv/hv_vsm_boot.c
> new file mode 100644
> index 0000000000000..99e4dc8695837
> --- /dev/null
> +++ b/drivers/hv/hv_vsm_boot.c
[ ... ]
> +static int __init hv_vsm_bootstrap_vtl(void)
> +{
> + u16 partition_enabled_vtl_set = 0, partition_mbec_enabled_vtl_set = 0;
> + u8 partition_max_vtl;
> + int ret;
> +
> + /* Check and enable VTL1 at the partition level */
> + ret = hv_vsm_get_partition_status(&partition_enabled_vtl_set, &partition_max_vtl,
> + &partition_mbec_enabled_vtl_set);
> + if (ret)
> + return ret;
> +
> + if (partition_max_vtl < HV_VTL_SECURE) {
> + pr_err("VTL1 is not supported by the partition\n");
> + return -EINVAL;
> + }
> +
> + if (partition_enabled_vtl_set & HV_VTL1_ENABLE_BIT) {
> + pr_info("Partition VTL1 is already enabled\n");
> + } else {
[Severity: High]
Does this code skip verifying MBEC when VTL1 is already enabled?
If an attacker or previous boot stage races to enable VTL1 but omits
enabling MBEC, checking partition_enabled_vtl_set here finds VTL1 enabled
and skips further configuration without validating
partition_mbec_enabled_vtl_set. Could this allow acceptance of insecure
pre-configured VTL1 states?
> + ret = hv_vsm_enable_partition_vtl();
> + if (ret) {
> + pr_err("Enabling Partition VTL1 failed with status 0x%x\n",
> + ret);
> + return -EINVAL;
> + }
> + ret = hv_vsm_get_partition_status(&partition_enabled_vtl_set, &partition_max_vtl,
> + &partition_mbec_enabled_vtl_set);
> + if (ret)
> + return ret;
> + if (!(partition_enabled_vtl_set & HV_VTL1_ENABLE_BIT)) {
> + pr_err("Tried Enabling Partition VTL 1 and still failed\n");
> + return -EINVAL;
> + }
> + if (!partition_mbec_enabled_vtl_set) {
[Severity: High]
Since partition_mbec_enabled_vtl_set is a bitmask of all VTLs with MBEC,
does this validation only check if the mask is completely empty?
If VTL0 already has MBEC enabled (bit 0 is 1), the mask is non-zero, causing
this check to falsely pass even if the hypervisor failed to enable MBEC for
VTL1. Should this instead isolate the VTL1 bit, for example:
!(partition_mbec_enabled_vtl_set & HV_VTL1_ENABLE_BIT) ?
> + pr_err("Tried Enabling Partition MBEC and failed\n");
> + return -EINVAL;
> + }
> + }
> + return 0;
> +}
[ ... ]
> +static int __init hv_vsm_boot_init(void)
> +{
> + cpumask_var_t mask;
> + unsigned int boot_cpu;
> + int ret;
> +
> + if (!vsm_arch_has_vsm_access())
> + return 0;
> +
> + /*
> + * Copy the current cpu mask and pin rest of the running code to boot cpu.
> + * Important since we want boot cpu of VTL0 to be the boot cpu for VTL1.
> + * ToDo: Check if copying and restoring current->cpus_mask is enough
> + * ToDo: Verify the assumption that cpumask_first(cpu_online_mask) is
> + * the boot cpu
> + */
> + if (!alloc_cpumask_var(&mask, GFP_KERNEL))
> + panic("Could not allocate cpumask");
> +
> + cpumask_copy(mask, ¤t->cpus_mask);
> + boot_cpu = cpumask_first(cpu_online_mask);
> + set_cpus_allowed_ptr(current, cpumask_of(boot_cpu));
[Severity: Medium]
Will this incorrectly pin the task to the lowest-numbered online CPU rather
than the actual boot CPU during a kexec or kdump?
If the kernel is booted via kexec or kdump on a non-zero CPU, lower-numbered
CPUs might be brought online during SMP initialization. In this scenario,
cpumask_first(cpu_online_mask) returns the lowest numbered online CPU, which
is not necessarily the Bootstrap Processor (BSP). Is get_boot_cpu_id() the
proper API to use here?
> +
> + ret = hv_vsm_bootstrap_vtl();
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901165647.3160413-1-tgopinath@linux.microsoft.com?part=6
next prev parent reply other threads:[~2026-09-01 17:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 16:55 [RFC PATCH 00/12] Introduce LVBS support for Hyper-V guests Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 01/12] drivers: hv: Add HYPERV_VSM kconfig option Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 02/12] drivers: hv: hv_common: Allocate Hyper-V output arg page when VSM is enabled Thara Gopinath
2026-09-01 17:12 ` sashiko-bot
2026-09-01 22:56 ` Wei Liu
2026-09-01 16:55 ` [RFC PATCH 03/12] drivers: hv: Reserve memory for VSM secure kernel during early boot Thara Gopinath
2026-09-01 17:10 ` sashiko-bot
2026-09-02 0:59 ` Wei Liu
2026-09-02 13:38 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 04/12] firmware: efi: libstub: x86-stub: Enable VSM awareness in efi os indications variable Thara Gopinath
2026-09-01 17:09 ` sashiko-bot
2026-09-02 1:09 ` Wei Liu
2026-09-02 14:23 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 05/12] include: hyperv: hvgdk_mini.h: Add VTL-specific structures and bits Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 06/12] drivers: hv: Add VSM boot driver and enable VTL1 at the partition level Thara Gopinath
2026-09-01 17:24 ` sashiko-bot [this message]
2026-09-02 1:16 ` Wei Liu
2026-09-02 14:28 ` Thara Gopinath
2026-09-02 4:43 ` Wei Liu
2026-09-04 13:23 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 07/12] drivers: hv: hv_vsm_boot: load secure kernel image from firmware Thara Gopinath
2026-09-01 17:20 ` sashiko-bot
2026-09-02 4:37 ` Wei Liu
2026-09-02 16:22 ` Thara Gopinath
2026-09-02 22:58 ` Wei Liu
2026-09-01 16:55 ` [RFC PATCH 08/12] arch: x86: hyperv: Build initial vCPU context for VTL1 secure kernel Thara Gopinath
2026-09-01 17:25 ` sashiko-bot
2026-09-01 16:55 ` [RFC PATCH 09/12] drivers: hv: hv_vsm_boot: Enable VTL1 on the boot processor Thara Gopinath
2026-09-01 17:36 ` sashiko-bot
2026-09-01 16:55 ` [RFC PATCH 10/12] arch: x86: hyperv: hv_vtl_vsm: Introduce vtlcall Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 11/12] drivers: hv: hv_vsm_boot: Boot primary processor in VTL1 Thara Gopinath
2026-09-01 17:35 ` sashiko-bot
2026-09-01 16:55 ` [RFC PATCH 12/12] drivers: hv: hv_vsm_boot: Boot secondary processors " Thara Gopinath
2026-09-01 17:44 ` sashiko-bot
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=20260901172442.995301F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tgopinath@linux.microsoft.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.