From: Easwar Hariharan <eahariha@linux.microsoft.com>
To: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
iommu@lists.linux.dev, eahariha@linux.microsoft.com,
kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
mhklinux@outlook.com, decui@microsoft.com,
catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, daniel.lezcano@linaro.org,
joro@8bytes.org, robin.murphy@arm.com, arnd@arndb.de,
jinankjain@linux.microsoft.com, muminulrussell@gmail.com,
skinsburskii@linux.microsoft.com, mukeshrathor@microsoft.com
Subject: Re: [PATCH] hyperv: Add CONFIG_MSHV_ROOT to gate hv_root_partition checks
Date: Tue, 11 Feb 2025 21:47:24 -0800 [thread overview]
Message-ID: <20ba4b7c-bebb-4b1f-8c6c-4cd52a5083b5@linux.microsoft.com> (raw)
In-Reply-To: <1739312515-18848-1-git-send-email-nunodasneves@linux.microsoft.com>
On 2/11/2025 2:21 PM, Nuno Das Neves wrote:
> Introduce CONFIG_MSHV_ROOT as a tristate to enable root partition
> booting and future mshv driver functionality.
>
> Change hv_root_partition into a function which always returns false
> if CONFIG_MSHV_ROOT=n.
>
> Introduce hv_current_partition_type to store the type of partition
> (guest, root, or other kinds in future), and hv_identify_partition_type()
> to it up early in Hyper-V initialization.
...to *set* it up early?
>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
> Depends on
> https://lore.kernel.org/linux-hyperv/1738955002-20821-3-git-send-email-nunodasneves@linux.microsoft.com/
>
> arch/arm64/hyperv/mshyperv.c | 2 ++
> arch/x86/hyperv/hv_init.c | 10 ++++----
> arch/x86/kernel/cpu/mshyperv.c | 24 ++----------------
> drivers/clocksource/hyperv_timer.c | 4 +--
> drivers/hv/Kconfig | 12 +++++++++
> drivers/hv/Makefile | 3 ++-
> drivers/hv/hv.c | 10 ++++----
> drivers/hv/hv_common.c | 32 +++++++++++++++++++-----
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/iommu/hyperv-iommu.c | 4 +--
> include/asm-generic/mshyperv.h | 39 +++++++++++++++++++++++++-----
> 11 files changed, 92 insertions(+), 50 deletions(-)
>
<snip>
> +
> +void hv_identify_partition_type(void)
> +{
> + /*
> + * Check partition creation and cpu management privileges
> + *
> + * Hyper-V should never specify running as root and as a Confidential
> + * VM. But to protect against a compromised/malicious Hyper-V trying
> + * to exploit root behavior to expose Confidential VM memory, ignore
> + * the root partition setting if also a Confidential VM.
> + */
> + if ((ms_hyperv.priv_high & HV_CREATE_PARTITIONS) &&
> + (ms_hyperv.priv_high & HV_CPU_MANAGEMENT) &&
> + !(ms_hyperv.priv_high & HV_ISOLATION)) {
> + hv_current_partition_type = HV_PARTITION_TYPE_ROOT;
> + pr_info("Hyper-V: running as root partition\n");
> + } else {
> + hv_current_partition_type = HV_PARTITION_TYPE_GUEST;
> + }
> +}
This should assume GUEST as default and modify to ROOT if all the checks pass.
<snip>
> +static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
> +{
> + return hv_result(U64_MAX);
> +}
Is there value in perhaps #defining hv_result_<whatever this is> as U64_MAX and returning that for documentation?
For e.g. assuming this is something like EOPNOTSUPP
#define HV_RESULT_NOT_SUPP U64_MAX
static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
{ return hv_result(HV_RESULT_NOT_SUPP); }
<snip>
Thanks,
Easwar (he/him)
next prev parent reply other threads:[~2025-02-12 5:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 22:21 [PATCH] hyperv: Add CONFIG_MSHV_ROOT to gate hv_root_partition checks Nuno Das Neves
2025-02-12 5:47 ` Easwar Hariharan [this message]
2025-02-12 23:01 ` Nuno Das Neves
2025-02-12 23:25 ` Easwar Hariharan
2025-02-12 23:30 ` Nuno Das Neves
2025-02-19 19:46 ` Michael Kelley
2025-02-19 23:52 ` Nuno Das Neves
2025-02-20 2:07 ` Michael Kelley
2025-02-20 2:40 ` Nuno Das Neves
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=20ba4b7c-bebb-4b1f-8c6c-4cd52a5083b5@linux.microsoft.com \
--to=eahariha@linux.microsoft.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux.dev \
--cc=jinankjain@linux.microsoft.com \
--cc=joro@8bytes.org \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=mukeshrathor@microsoft.com \
--cc=muminulrussell@gmail.com \
--cc=nunodasneves@linux.microsoft.com \
--cc=robin.murphy@arm.com \
--cc=skinsburskii@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
--cc=x86@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 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.