From: sashiko-bot@kernel.org
To: "Kameron Carr" <kameroncarr@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v3 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Date: Tue, 21 Jul 2026 20:24:30 +0000 [thread overview]
Message-ID: <20260721202431.35E0E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721201148.1441143-5-kameroncarr@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Using `kmalloc()` for memory passed to `set_memory_decrypted()` causes silent memory corruption on x86 and initialization failures on ARM64 due to a lack of strict page alignment and KASAN/MTE pointer tagging.
--
--- Patch [4]: [PATCH v3 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms ---
commit 21b5c4cec77eb56971c17ededee7133820fad287
Author: Kameron Carr <kameroncarr@linux.microsoft.com>
Drivers: hv: Mark shared memory as decrypted for CCA Realms
This patch extends confidential VM isolation memory decryption to Arm CCA Realm
guests during hypercall memory initialization. It introduces a helper for CCA
isolation and updates the hypercall buffer allocation path to use it.
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 6b67ac6167891..0f9412fcb9571 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
[ ... ]
> @@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)
> * online and then taken offline
> */
> if (!*inputarg) {
> - mem = kmalloc_array(pgcount, HV_HYP_PAGE_SIZE, flags);
> + mem = kmalloc(alloc_size, flags);
> if (!mem)
> return -ENOMEM;
>
> @@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu)
> }
>
> if (!ms_hyperv.paravisor_present &&
> - (hv_isolation_type_snp() || hv_isolation_type_tdx())) {
> - ret = set_memory_decrypted((unsigned long)mem, pgcount);
> + (hv_isolation_type_snp() || hv_isolation_type_tdx() ||
> + hv_isolation_type_cca())) {
> + ret = set_memory_decrypted((unsigned long)mem,
> + alloc_size >> PAGE_SHIFT);
[Severity: High]
This isn't a bug introduced by this patch, but is it safe to pass memory
allocated by kmalloc to set_memory_decrypted() in hv_common_cpu_init()?
When kmalloc is used with SLUB_DEBUG, the returned pointer is not strictly
page-aligned. Because set_memory_decrypted() operates on page frames and
rounds down to the page boundary, this could silently decrypt adjacent slab
objects or metadata on x86 architectures.
Additionally, on arm64 systems with MTE enabled, kmalloc returns a tagged
pointer. Passing a tagged pointer to set_memory_decrypted() causes its
internal __is_lm_address() check to fail, leading to initialization failures
during boot or CPU hotplug for CCA guests.
Would it be better to allocate this memory using the page allocator, such as
with __get_free_pages(), to ensure the address is strictly page-aligned and
untagged?
> if (ret) {
> /* It may be unsafe to free 'mem' */
> return ret;
> }
>
> - memset(mem, 0x00, pgcount * HV_HYP_PAGE_SIZE);
> + memset(mem, 0x00, alloc_size);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721201148.1441143-1-kameroncarr@linux.microsoft.com?part=4
next prev parent reply other threads:[~2026-07-21 20:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 20:11 [PATCH v3 0/6] arm64: hyperv: Add Realm support for Hyper-V Kameron Carr
2026-07-21 20:11 ` [PATCH v3 1/6] arm64: rsi: Add RSI host call structure and helper function Kameron Carr
2026-07-21 20:22 ` sashiko-bot
2026-07-21 20:11 ` [PATCH v3 2/6] firmware: smccc: Detect hypervisor via RSI host call in CCA Realms Kameron Carr
2026-07-21 20:24 ` sashiko-bot
2026-07-21 20:11 ` [PATCH v3 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for " Kameron Carr
2026-07-21 20:25 ` sashiko-bot
2026-07-21 20:11 ` [PATCH v3 4/6] Drivers: hv: Mark shared memory as decrypted " Kameron Carr
2026-07-21 20:24 ` sashiko-bot [this message]
2026-07-21 20:11 ` [PATCH v3 5/6] arm64: hyperv: Route hypercalls through RSI host call in " Kameron Carr
2026-07-21 20:27 ` sashiko-bot
2026-07-21 20:11 ` [PATCH v3 6/6] arm64: hyperv: Implement hv_is_isolation_supported() for " Kameron Carr
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=20260721202431.35E0E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kameroncarr@linux.microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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