[PATCH v2 17/18] KVM: arm64: Reject hyp trace descriptors with fewer CPUs than hyp_nr_cpus

Fuad Tabba fuad.tabba at linux.dev
Wed Jul 15 06:54:16 PDT 2026


On Mon, 6 Jul 2026 at 18:54, Vincent Donnefort <vdonnefort at google.com> wrote:
>
> While a trace descriptor with fewer CPUs than hyp_nr_cpus currently
> causes no functional issue, such a configuration is invalid and would
> cause the hypervisor to skip ring buffer initialization when allocating
> backing pages in EL2.
>
> Enforce nr_cpus == hyp_nr_cpus during trace descriptor validation to
> guarantee that every possible CPU has a valid ring buffer descriptor.
>
> Signed-off-by: Vincent Donnefort <vdonnefort at google.com>

Reviewed-by: Fuad Tabba <fuad.tabba at linux.dev>

Cheers,
/fuad

>
> diff --git a/arch/arm64/kvm/hyp/nvhe/trace.c b/arch/arm64/kvm/hyp/nvhe/trace.c
> index e7e150ab265f..6e716295247a 100644
> --- a/arch/arm64/kvm/hyp/nvhe/trace.c
> +++ b/arch/arm64/kvm/hyp/nvhe/trace.c
> @@ -181,6 +181,9 @@ static bool hyp_trace_desc_is_valid(struct hyp_trace_desc *desc, size_t desc_siz
>         desc_end = (void *)desc + desc_size;
>         nr_bpages = desc->bpages_backing_size / sizeof(struct simple_buffer_page);
>
> +       if (desc->trace_buffer_desc.nr_cpus != hyp_nr_cpus)
> +               return false;
> +
>         for_each_ring_buffer_desc(rb_desc, cpu, &desc->trace_buffer_desc) {
>                 /* Can we read nr_page_va? */
>                 if ((void *)rb_desc + struct_size(rb_desc, page_va, 0) > desc_end)
> --
> 2.55.0.rc2.803.g1fd1e6609c-goog
>



More information about the linux-arm-kernel mailing list