Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] arm64: hyperv: kcalloc() violates RSI host call 256-byte alignment
--

commit 15aadbf7702767ee71f473eab885a0900dbd0a76
Author: Kameron Carr <[email protected]>

arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms

This commit adds a dynamically allocated array of per-CPU `struct
rsi_host_call` structures for ARM CCA Realms. The memory is allocated using
kcalloc() during hyperv_init() to avoid paying the memory cost on non-Realm
guests.

> 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() satisfy the __aligned(256) requirement of struct rsi_host_call
when SLUB debugging or KASAN is enabled?

The struct definition explicitly demands 256-byte alignment:

include/linux/arm-smccc-rsi.h:
struct rsi_host_call {
        u16 immediate;
        u8 _padding[6];
        u64 gprs[31];
} __aligned(256);

kcalloc() only receives the size of the structure, not the alignment
constraint. When SLUB debugging is enabled, redzoning metadata is prepended to
the object, shifting the base pointer off the 256-byte boundary. A misaligned
Intermediate Physical Address (IPA) might lead to hardware rejection of the
hypercall by the Realm Management Monitor (RMM).

Additionally, since this allocates a single contiguous array for all CPUs,
does it bypass NUMA locality? Using alloc_percpu() would satisfy the alignment
constraint natively and allocate memory on local nodes.

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

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to