Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kameron Carr" <kameroncarr@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v4 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms
Date: Fri, 02 Oct 2026 09:13:54 +0000	[thread overview]
Message-ID: <20261002091354.9D9F41F00893@smtp.kernel.org> (raw)
In-Reply-To: <20261001220552.1793471-4-kameroncarr@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] arm64: hyperv: kcalloc does not guarantee 256-byte alignment for rsi_host_call
- [Low] arm64: hyperv: unnecessary early boot memory allocation error handling
--

commit ef58d4d121fbefca0e2e24ac57c717abd6fc93ba
Author: Kameron Carr <kameroncarr@linux.microsoft.com>
arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms

This commit allocates a per-CPU array of rsi_host_call structures in
hyperv_init() for Realm guests. The array is used to route hypercalls
through the RSI_HOST_CALL interface since Arm CCA Realms cannot issue
Hyper-V hypercalls via HVC.

> diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c
> index 4fdc26ade1d74..b1657cfabd7d1 100644
> --- a/arch/arm64/hyperv/mshyperv.c
> +++ b/arch/arm64/hyperv/mshyperv.c

[ ... ]

> @@ -85,6 +90,20 @@ static int __init hyperv_init(void)
>  	if (!hyperv_detect_via_acpi() && !hyperv_detect_via_smccc())
>  		return 0;
>  
> +	/*
> +	 * The RSI host-call buffers are only ever used when
> +	 * is_realm_world() is true. Skip the allocation on non-Realm
> +	 * guests. A single contiguous array of nr_cpu_ids entries is
> +	 * allocated; each CPU indexes into it by its processor ID.
> +	 */
> +	if (is_realm_world()) {
> +		hv_hostcall_array = kcalloc(nr_cpu_ids,
> +					    sizeof(struct rsi_host_call),
> +					    GFP_KERNEL);

[Severity: High]
Does kcalloc guarantee the 256-byte alignment required by the RMM ABI for
the RSI_HOST_CALL structure?

When hv_do_rsi_hypercall() passes
virt_to_phys(&hv_hostcall_array[smp_processor_id()]) to rsi_host_call(),
the RMM might reject the hypercall if the physical address is unaligned,
which would break Realm guest booting.

The kcalloc API only guarantees ARCH_KMALLOC_MINALIGN (e.g., 8 or 16 bytes)
and does not respect the __aligned(256) attribute of the type. Furthermore,
when CONFIG_SLUB_DEBUG is enabled, redzones will shift the object pointer
away from natural alignment, ensuring that the 256-byte alignment
requirement is violated.

> +		if (!hv_hostcall_array)
> +			return -ENOMEM;

[Severity: Low]
Is returning -ENOMEM here necessary?

Because hyperv_init() is executed via early_initcall, physical memory
should be available. Complex error handling, cleanup logic, or returning
-ENOMEM in these early boot functions is often unnecessary dead code,
as an allocation failure typically means the system cannot boot anyway.

> +	}
>  
>  	/* Setup the guest ID */
>  	guest_id = hv_generate_guest_id(LINUX_VERSION_CODE);

[ ... ]

> @@ -125,6 +144,11 @@ static int __init hyperv_init(void)
>  
>  	hyperv_initialized = true;
>  	return 0;
> +
> +free_hostcall_mem:
> +	kfree(hv_hostcall_array);
> +	hv_hostcall_array = NULL;
> +	return ret;

[Severity: Low]
Can we omit this explicit cleanup path?

As noted above, executing cleanup logic for failures that are fatal
during early boot adds unnecessary code complexity.

>  }
>  
>  early_initcall(hyperv_init);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261001220552.1793471-1-kameroncarr@linux.microsoft.com?part=3

  reply	other threads:[~2026-10-02  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 22:05 [PATCH v4 0/6] arm64: hyperv: Add Realm support for Hyper-V Kameron Carr
2026-10-01 22:05 ` [PATCH v4 1/6] arm64: rsi: Add RSI host call structure and helper function Kameron Carr
2026-10-02  9:13   ` sashiko-bot
2026-10-01 22:05 ` [PATCH v4 2/6] firmware: smccc: Detect hypervisor via RSI host call in CCA Realms Kameron Carr
2026-10-02  9:13   ` sashiko-bot
2026-10-01 22:05 ` [PATCH v4 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for " Kameron Carr
2026-10-02  9:13   ` sashiko-bot [this message]
2026-10-01 22:05 ` [PATCH v4 4/6] Drivers: hv: Mark shared memory as decrypted " Kameron Carr
2026-10-01 22:05 ` [PATCH v4 5/6] arm64: hyperv: Route hypercalls through RSI host call in " Kameron Carr
2026-10-02  9:13   ` sashiko-bot
2026-10-01 22:05 ` [PATCH v4 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=20261002091354.9D9F41F00893@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