From: Emerson Busson <emersonbusson@gmail.com>
To: mhklinux@outlook.com
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-hyperv@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v2 06/14] hv: vmbus: cover all shared-page policy combinations
Date: Wed, 7 Oct 2026 16:07:44 -0300 [thread overview]
Message-ID: <20261007190752.336426-7-emersonbusson@gmail.com> (raw)
In-Reply-To: <20261007190752.336426-1-emersonbusson@gmail.com>
Name the shared-page selection and enumerate all eight combinations of
Hyper-V isolation, independent guest-memory encryption and channel
confidentiality. Either platform visibility signal selects shared
backing; the confidential-channel override keeps private backing. These
are decision tests, not confidential hardware qualification.
Signed-off-by: Emerson Busson <emersonbusson@gmail.com>
---
drivers/hv/channel.c | 16 ++++++++++++++--
drivers/hv/hyperv_vmbus.h | 2 ++
drivers/hv/vmbus_buffer_test.c | 29 +++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 0c025a12808a..8ed155f2669f 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -45,6 +45,13 @@ int vmbus_buffer_round_size(u32 size, u32 *rounded_size)
return 0;
}
+bool
+vmbus_needs_shared_pages(bool hv_isolation, bool guest_mem_encrypted,
+ bool confidential)
+{
+ return !confidential && (hv_isolation || guest_mem_encrypted);
+}
+
unsigned int vmbus_buffer_order(unsigned long remaining,
unsigned int max_order)
{
@@ -837,6 +844,8 @@ static void *__vmbus_alloc_buffer(struct vmbus_channel *channel,
unsigned long nr_pages;
unsigned long remaining;
unsigned long page_idx = 0;
+ bool hv_isolation;
+ bool guest_mem_encrypted;
struct page **chunks = NULL;
struct page **pages = NULL;
unsigned int order = MAX_PAGE_ORDER;
@@ -853,9 +862,12 @@ static void *__vmbus_alloc_buffer(struct vmbus_channel *channel,
nr_pages = rounded_size >> PAGE_SHIFT;
remaining = nr_pages;
+ hv_isolation = hv_is_isolation_supported();
+ guest_mem_encrypted = cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT);
+
/* If the buffer does not need to be decrypted, just use vzalloc() */
- if ((!hv_is_isolation_supported() &&
- !cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) || confidential)
+ if (!vmbus_needs_shared_pages(hv_isolation, guest_mem_encrypted,
+ confidential))
return vzalloc(rounded_size);
/* Worst case: every chunk is a single page. */
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index e08c472041d5..06094000f2f1 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -557,6 +557,8 @@ int hv_remove_ring_sysfs(struct vmbus_channel *channel);
* These are shared with vmbus_buffer_test.c, which is built into the
* hv_vmbus object alongside channel.c. They stay unexported.
*/
+bool vmbus_needs_shared_pages(bool hv_isolation, bool guest_mem_encrypted,
+ bool confidential);
int vmbus_buffer_round_size(u32 size, u32 *rounded_size);
unsigned int vmbus_buffer_order(unsigned long remaining,
unsigned int max_order);
diff --git a/drivers/hv/vmbus_buffer_test.c b/drivers/hv/vmbus_buffer_test.c
index 60fc526af1af..9b401ef2ceea 100644
--- a/drivers/hv/vmbus_buffer_test.c
+++ b/drivers/hv/vmbus_buffer_test.c
@@ -38,6 +38,34 @@ static void vmbus_buffer_size_overflow_test(struct kunit *test)
(u32)(U32_MAX - PAGE_SIZE + 1));
}
+static void vmbus_buffer_private_shared_selection_test(struct kunit *test)
+{
+ static const struct {
+ bool isolation;
+ bool encrypted;
+ bool confidential;
+ bool shared;
+ } cases[] = {
+ { false, false, false, false },
+ { false, false, true, false },
+ { false, true, false, true },
+ { false, true, true, false },
+ { true, false, false, true },
+ { true, false, true, false },
+ { true, true, false, true },
+ { true, true, true, false },
+ };
+ unsigned int i;
+
+ /* Either platform signal requires visibility; confidential stays private. */
+ for (i = 0; i < ARRAY_SIZE(cases); i++)
+ KUNIT_EXPECT_EQ(test,
+ vmbus_needs_shared_pages(cases[i].isolation,
+ cases[i].encrypted,
+ cases[i].confidential),
+ cases[i].shared);
+}
+
static void vmbus_ring_fallback_order_zero_test(struct kunit *test)
{
unsigned int order;
@@ -317,6 +345,7 @@ static void vmbus_buffer_order_zero_allocation_test(struct kunit *test)
static struct kunit_case vmbus_buffer_test_cases[] = {
KUNIT_CASE(vmbus_buffer_size_rounding_test),
KUNIT_CASE(vmbus_buffer_size_overflow_test),
+ KUNIT_CASE(vmbus_buffer_private_shared_selection_test),
KUNIT_CASE(vmbus_ring_fallback_order_zero_test),
KUNIT_CASE(vmbus_buffer_failed_teardown_leaks_test),
KUNIT_CASE(vmbus_buffer_partial_allocation_cleanup_test),
--
2.43.0
next prev parent reply other threads:[~2026-10-07 19:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 19:07 [PATCH v2 0/14] hv: vmbus: make rings and host-visible buffers survive buddy fragmentation Emerson Busson
2026-10-07 19:07 ` [PATCH v2 01/14] hv: vmbus: convert ring backing through the chunk allocator Emerson Busson
2026-10-07 19:07 ` [PATCH v2 02/14] hv: vmbus: validate chunk buffer allocation and cleanup Emerson Busson
2026-10-07 19:07 ` [PATCH v2 03/14] uio: hv_generic: describe buffers for owned allocation Emerson Busson
2026-10-07 19:07 ` [PATCH v2 04/14] hv: vmbus: add KUnit tests for GPADL post failure injection Emerson Busson
2026-10-07 19:07 ` [PATCH v2 05/14] hv: vmbus: add KUnit test for order-zero allocation fallback Emerson Busson
2026-10-07 19:07 ` Emerson Busson [this message]
2026-10-07 19:07 ` [PATCH v2 07/14] hv: vmbus: distinguish host rescind from local channel unload Emerson Busson
2026-10-07 19:07 ` [PATCH v2 08/14] hv: vmbus: retain backing until ownership and references clear Emerson Busson
2026-10-07 19:07 ` [PATCH v2 09/14] hv: use owned VMBus buffers in NetVSC and UIO Emerson Busson
2026-10-07 19:07 ` [PATCH v2 10/14] hv: vmbus: pin buffer pages across UIO mmap to close the reclaim race Emerson Busson
2026-10-08 16:49 ` kernel test robot
2026-10-08 17:02 ` kernel test robot
2026-10-07 19:07 ` [PATCH v2 11/14] hv: vmbus: vmalloc requestor metadata Emerson Busson
2026-10-07 19:07 ` [PATCH v2 12/14] hv: netvsc: allocate RNDIS request descriptors with kvzalloc_obj() Emerson Busson
2026-10-07 19:07 ` [PATCH v2 13/14] hv: netvsc: handle a NULL request address on empty completions Emerson Busson
2026-10-07 19:07 ` [PATCH v2 14/14] hv: netvsc: use kvzalloc for device state Emerson Busson
2026-10-08 16:55 ` [PATCH v2 0/14] hv: vmbus: make rings and host-visible buffers survive buddy fragmentation Easwar Hariharan
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=20261007190752.336426-7-emersonbusson@gmail.com \
--to=emersonbusson@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®