[PATCH v4 15/17] KVM: arm64: Reject hyp trace descriptors with fewer CPUs than hyp_nr_cpus
Vincent Donnefort <[email protected]> Fri, 31 Jul 2026 15:35:39 +0100
| Newsgroups | dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel |
|---|---|
| Message-ID | <[email protected]> |
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. Reviewed-by: Fuad Tabba <[email protected]> Tested-by: Fuad Tabba <[email protected]> Signed-off-by: Vincent Donnefort <[email protected]> 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.508.g3f0d502094-goog