From: sashiko-bot@kernel.org
To: "Kameron Carr" <kameroncarr@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v5 5/6] arm64: hyperv: Route hypercalls through RSI host call in CCA Realms
Date: Sat, 03 Oct 2026 01:34:04 +0000 [thread overview]
Message-ID: <20261003013404.F390F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261002215725.2015959-6-kameroncarr@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] arm64: hyperv: kcalloc fails to guarantee 256-byte alignment for rsi_host_call
- [Medium] arm64: hyperv: missing NULL pointer guard on hv_hostcall_array causes recursive panic
--
commit 2c893995afa956ce0fb20a1d090c6e04fba71575
Author: Kameron Carr <kameroncarr@linux.microsoft.com>
arm64: hyperv: Route hypercalls through RSI host call in CCA Realms
This commit updates the Hyper-V hypercall wrappers to check if the kernel
is running in a CCA Realm. If so, it routes the hypercalls through the RSI
host call interface using the per-CPU hv_hostcall_array.
> diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c
> index e33a9e3c366a1..2f6fc1469c54f 100644
> --- a/arch/arm64/hyperv/hv_core.c
> +++ b/arch/arm64/hyperv/hv_core.c
> @@ -12,11 +12,43 @@
[ ... ]
> +static u64 hv_do_rsi_hypercall(u64 control, u64 input1, u64 input2)
> +{
> + struct rsi_host_call *hostcall;
> + unsigned long flags;
> + u64 ret;
> +
> + if (!hv_hostcall_array)
> + return HV_STATUS_INVALID_HYPERCALL_INPUT;
> +
> + local_irq_save(flags);
> + hostcall = &hv_hostcall_array[smp_processor_id()];
> + memset(hostcall, 0, sizeof(*hostcall));
> + hostcall->gprs[0] = HV_FUNC_ID;
> + hostcall->gprs[1] = control;
> + hostcall->gprs[2] = input1;
> + hostcall->gprs[3] = input2;
> +
> + if (rsi_host_call(virt_to_phys(hostcall)) == RSI_SUCCESS)
[Severity: High]
Does this physical address satisfy the RMM's 256-byte alignment requirement?
If hv_hostcall_array was allocated with kcalloc() (e.g., in hyperv_init()),
the allocation might not guarantee strict 256-byte alignment when SLUB
debugging or KASAN is enabled due to redzone shifts. If the resulting
address is misaligned, could the RMM reject the SMC host call and return an
error that eventually triggers a BUG_ON() and kernel panic?
[ ... ]
> @@ -76,24 +117,44 @@ EXPORT_SYMBOL_GPL(hv_do_fast_hypercall16);
> void hv_set_vpreg(u32 msr, u64 value)
> {
> struct arm_smccc_res res;
> + struct rsi_host_call *hostcall;
> + unsigned long flags;
> + u64 status;
>
> - arm_smccc_1_1_hvc(HV_FUNC_ID,
> - HVCALL_SET_VP_REGISTERS | HV_HYPERCALL_FAST_BIT |
> - HV_HYPERCALL_REP_COMP_1,
> - HV_PARTITION_ID_SELF,
> - HV_VP_INDEX_SELF,
> - msr,
> - 0,
> - value,
> - 0,
> - &res);
> + if (is_realm_world()) {
> + local_irq_save(flags);
> + hostcall = &hv_hostcall_array[smp_processor_id()];
> + memset(hostcall, 0, sizeof(*hostcall));
[Severity: Medium]
Is it safe to access hv_hostcall_array here without a NULL check?
In hv_do_rsi_hypercall() above, there is a check for !hv_hostcall_array. If
Hyper-V initialization fails and sets hv_hostcall_array to NULL, but the
panic notifier remains registered, a later kernel panic could invoke
hyperv_report_panic() which calls hv_set_vpreg(). Without a guard,
this memset() could cause a recursive fault and break the crash handler.
[ ... ]
> @@ -108,29 +169,55 @@ void hv_get_vpreg_128(u32 msr, struct hv_get_vp_registers_output *result)
> {
> struct arm_smccc_1_2_regs args;
> struct arm_smccc_1_2_regs res;
> + struct rsi_host_call *hostcall;
> + unsigned long flags;
> + u64 status;
>
> - args.a0 = HV_FUNC_ID;
> - args.a1 = HVCALL_GET_VP_REGISTERS | HV_HYPERCALL_FAST_BIT |
> - HV_HYPERCALL_REP_COMP_1;
> - args.a2 = HV_PARTITION_ID_SELF;
> - args.a3 = HV_VP_INDEX_SELF;
> - args.a4 = msr;
> + if (is_realm_world()) {
> + local_irq_save(flags);
> + hostcall = &hv_hostcall_array[smp_processor_id()];
> + memset(hostcall, 0, sizeof(*hostcall));
[Severity: Medium]
Could this also cause a NULL pointer dereference if hv_hostcall_array
was freed and set to NULL during an early boot failure?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261002215725.2015959-1-kameroncarr@linux.microsoft.com?part=5
next prev parent reply other threads:[~2026-10-03 1:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 21:57 [PATCH v5 0/6] arm64: hyperv: Add Realm support for Hyper-V Kameron Carr
2026-10-02 21:57 ` [PATCH v5 1/6] arm64: rsi: Add RSI host call structure and helper function Kameron Carr
2026-10-02 21:57 ` [PATCH v5 2/6] firmware: smccc: Detect hypervisor via RSI host call in CCA Realms Kameron Carr
2026-10-02 21:57 ` [PATCH v5 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for " Kameron Carr
2026-10-03 1:34 ` sashiko-bot
2026-10-02 21:57 ` [PATCH v5 4/6] Drivers: hv: Mark shared memory as decrypted " Kameron Carr
2026-10-02 21:57 ` [PATCH v5 5/6] arm64: hyperv: Route hypercalls through RSI host call in " Kameron Carr
2026-10-03 1:34 ` sashiko-bot [this message]
2026-10-02 21:57 ` [PATCH v5 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=20261003013404.F390F1F000FF@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