Re: [PATCH] tools/ocaml: fill arch_config for ARM in domain_getinfolist

Andrew Cooper <[email protected]>
Newsgroups org.xenproject.lists.xen-devel
Message-ID <[email protected]>
On 27/07/2026 10:11 am, Julian Vetter wrote:
> In the function alloc_domaininfo() the arch_config field in domaininfo
> is only filled inside #if defined(__i386__) || defined(__x86_64__). On
> ARM the field is left unpopulated. caml_alloc_tuple() does not zero new
> blocks, so di.Xenctrl.arch_config on ARM is uninitialised garbage for
> every caller of Xenctrl.domain_getinfolist/domain_getinfo. Any toolstack
> dereferencing that value, segfaults once a VM is enumerated in a domain
> scan.
>
> Add the missing ARM equivalent, populating xen_arm_arch_domainconfig
> from the raw xc_domaininfo_t the same way the x86 branch does for
> xen_x86_arch_domainconfig.
>
> Signed-off-by: Julian Vetter <[email protected]>
> ---
>  tools/ocaml/libs/xc/xenctrl_stubs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
> index 7f6381cdd2..b60ea9f12e 100644
> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
> @@ -415,6 +415,7 @@ static value alloc_domaininfo(xc_domaininfo_t * info)
>  {
>  	CAMLparam0();
>  	CAMLlocal5(result, tmp, arch_config, x86_arch_config, emul_list);
> +	CAMLlocal1(arm_arch_config);
>  	int i;
>  
>  	result = caml_alloc_tuple(17);
> @@ -460,6 +461,19 @@ static value alloc_domaininfo(xc_domaininfo_t * info)
>  
>  	Store_field(arch_config, 0, x86_arch_config);
>  
> +	Store_field(result, 16, arch_config);
> +#elif defined(__arm__) || defined(__aarch64__)
> +	/* xen_arm_arch_domainconfig */
> +	arm_arch_config = caml_alloc_tuple(3);
> +	Store_field(arm_arch_config, 0, Val_int(info->arch_config.gic_version));
> +	Store_field(arm_arch_config, 1, Val_int(info->arch_config.nr_spis));
> +	Store_field(arm_arch_config, 2, caml_copy_int32(info->arch_config.clock_frequency));
> +
> +	/* arch_config: arch_domainconfig */
> +	arch_config = caml_alloc_small(1, 0);
> +
> +	Store_field(arch_config, 0, arm_arch_config);
> +
>  	Store_field(result, 16, arch_config);
>  #endif
>  

Oops, this was unintentional, but obvious now you point it out.

While this patch works, it's continuing a bad pattern I accidentally
started.

I'll do a prep cleanup patch, and rebase this one on top.

~Andrew
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.