From: Mukesh R <mrathor@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
mhkelley58@gmail.com, kameroncarr@linux.microsoft.com
Subject: [PATCH V1 1/2] Drivers: hv: Add new function hv_isolation_type_hw()
Date: Fri, 13 Nov 2026 18:53:12 -0800 [thread overview]
Message-ID: <20261114025313.1257042-2-mrathor@linux.microsoft.com> (raw)
In-Reply-To: <20261114025313.1257042-1-mrathor@linux.microsoft.com>
Add a new function hv_isolation_type_hw() for convenient check of
whether a VM is running in HW confidential mode, ie, TDX or SNP on x86
or RME on ARM.
Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
---
arch/x86/hyperv/ivm.c | 5 +++++
drivers/hv/hv_common.c | 9 +++++++--
include/asm-generic/mshyperv.h | 7 +++++++
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index 2ce4dfe53472..26e570cf77be 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -944,3 +944,8 @@ bool hv_isolation_type_tdx(void)
{
return static_branch_unlikely(&isolation_type_tdx);
}
+
+bool hv_isolation_type_hw(void)
+{
+ return hv_isolation_type_snp() || hv_isolation_type_tdx();
+}
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 27b9b79d4f4c..b537cafdc2a2 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -528,8 +528,7 @@ int hv_common_cpu_init(unsigned int cpu)
*outputarg = (char *)mem + HV_HYP_PAGE_SIZE;
}
- if (!ms_hyperv.paravisor_present &&
- (hv_isolation_type_snp() || hv_isolation_type_tdx())) {
+ if (!ms_hyperv.paravisor_present && hv_isolation_type_hw()) {
ret = set_memory_decrypted((unsigned long)mem, pgcount);
if (ret) {
/* It may be unsafe to free 'mem' */
@@ -696,6 +695,12 @@ bool __weak hv_isolation_type_tdx(void)
}
EXPORT_SYMBOL_GPL(hv_isolation_type_tdx);
+bool __weak hv_isolation_type_hw(void)
+{
+ return false;
+}
+EXPORT_SYMBOL_GPL(hv_isolation_type_hw);
+
void __weak hv_setup_vmbus_handler(void (*handler)(void))
{
}
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index 4c9f3353074a..396bcb3db0bc 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -84,6 +84,13 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);
bool hv_isolation_type_snp(void);
bool hv_isolation_type_tdx(void);
+/* This needs to be before hv_do_rep_hypercall() below */
+#if IS_ENABLED(CONFIG_HYPERV)
+bool hv_isolation_type_hw(void);
+#else
+static inline bool hv_isolation_type_hw(void) { return false; }
+#endif
+
/*
* On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
* it doesn't provide a recommendation flag and AEOI must be disabled.
--
2.51.2.vfs.0.1
next prev parent reply other threads:[~2026-11-14 2:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 2:53 [PATCH V1 0/2] Hyper-V: Fix bugs and issues around repeat hypercall Mukesh R
2026-11-14 2:53 ` Mukesh R [this message]
2026-11-14 2:53 ` [PATCH V1 2/2] Drivers: hv: " Mukesh R
2026-11-14 3:18 ` 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=20261114025313.1257042-2-mrathor@linux.microsoft.com \
--to=mrathor@linux.microsoft.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kameroncarr@linux.microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhkelley58@gmail.com \
--cc=wei.liu@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.