[PATCH 0/2] tools/ocaml: bindings needed to build ARM domains

Julian Vetter posted 2 patches 1 month ago
Only 0 patches received!
There is a newer version of this series
tools/ocaml/libs/xc/xenctrl.ml      |  7 +++++
tools/ocaml/libs/xc/xenctrl.mli     |  6 +++++
tools/ocaml/libs/xc/xenctrl_stubs.c | 40 ++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 1 deletion(-)
[PATCH 0/2] tools/ocaml: bindings needed to build ARM domains
Posted by Julian Vetter 1 month ago
Hello,
this series adds two bindings that are still missing for an OCaml
toolstack, to create and build ARM domains.

Patch 1 exposes the XEN_SYSCTL_PHYSCAP_ARM_GIC_V2/V3 bits of
XEN_SYSCTL_physinfo in arm_physinfo_caps. Since
XEN_DOMCTL_CONFIG_GIC_NATIVE was removed, the toolstack has to pick a
concrete GIC version itself. The OCaml physinfo stub only reports the
SVE vector length on ARM, so OCaml toolstacks currently can't select a
GIC version.

Patch 2 adds bindings for XEN_DOMCTL_{get,set}_paging_mempool_size. The
existing shadow_allocation_{get,set} bindings use
XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION, which are x86-only and fail
with -ENOSYS on ARM, so there is no way to size the P2M pool of an ARM
domain from OCaml, as libxl does.

Even though I'm sending these patches as a series, they are somewhat
independent from each other. But together with the patch I sent earlier
today "tools/ocaml: implement stub_xc_domain_create() for ARM", they are
what xenopsd needs to create ARM domains.

Signed-off-by: Julian Vetter <julian.vetter@vates.tech>

Julian Vetter (2):
  tools/ocaml: expose the supported guest GIC versions in physinfo
  tools/ocaml: add bindings for the paging mempool size

 tools/ocaml/libs/xc/xenctrl.ml      |  7 +++++
 tools/ocaml/libs/xc/xenctrl.mli     |  6 +++++
 tools/ocaml/libs/xc/xenctrl_stubs.c | 40 ++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 1 deletion(-)

-- 
2.53.0



-- 
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
[PATCH 0/2] tools/ocaml: bindings needed to build ARM domains
Posted by Julian Vetter 1 month ago
Hello,
this series adds two OCaml bindings that are still missing for an OCaml
toolstack, such as xenopsd, to create and build ARM domains.

Patch 1 exposes the XEN_SYSCTL_PHYSCAP_ARM_GIC_V2/V3 bits of
XEN_SYSCTL_physinfo in arm_physinfo_caps. Since
XEN_DOMCTL_CONFIG_GIC_NATIVE was removed, the toolstack has to pick a
concrete GIC version itself, which libxl and the Python bindings
already do. The OCaml physinfo stub only reports the SVE vector length
on ARM, so OCaml toolstacks currently can't make that choice.

Patch 2 adds bindings for XEN_DOMCTL_{get,set}_paging_mempool_size. The
existing shadow_allocation_{get,set} bindings use
XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION, which are x86-only and fail
with -ENOSYS on ARM, so there is no way to size the P2M pool of an ARM
domain from OCaml, as libxl does.

The two patches are independent of each other and each applies on its
own to staging. Together with "tools/ocaml: implement
stub_xc_domain_create() for ARM" (currently under review), they are
what xenopsd needs to create ARM domains.

Signed-off-by: Julian Vetter <julian.vetter@vates.tech>

Julian Vetter (2):
  tools/ocaml: expose the supported guest GIC versions in physinfo
  tools/ocaml: add bindings for the paging mempool size

 tools/ocaml/libs/xc/xenctrl.ml      |  7 +++++
 tools/ocaml/libs/xc/xenctrl.mli     |  9 +++++++
 tools/ocaml/libs/xc/xenctrl_stubs.c | 40 ++++++++++++++++++++++++++++-
 3 files changed, 55 insertions(+), 1 deletion(-)

-- 
2.53.0



-- 
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [PATCH 0/2] tools/ocaml: bindings needed to build ARM domains
Posted by Andrew Cooper 1 month ago
On 22/10/2026 3:23 pm, Julian Vetter wrote:
> Hello,
> this series adds two bindings that are still missing for an OCaml
> toolstack, to create and build ARM domains.
>
> Patch 1 exposes the XEN_SYSCTL_PHYSCAP_ARM_GIC_V2/V3 bits of
> XEN_SYSCTL_physinfo in arm_physinfo_caps. Since
> XEN_DOMCTL_CONFIG_GIC_NATIVE was removed, the toolstack has to pick a
> concrete GIC version itself. The OCaml physinfo stub only reports the
> SVE vector length on ARM, so OCaml toolstacks currently can't select a
> GIC version.
>
> Patch 2 adds bindings for XEN_DOMCTL_{get,set}_paging_mempool_size. The
> existing shadow_allocation_{get,set} bindings use
> XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION, which are x86-only and fail
> with -ENOSYS on ARM, so there is no way to size the P2M pool of an ARM
> domain from OCaml, as libxl does.
>
> Even though I'm sending these patches as a series, they are somewhat
> independent from each other. But together with the patch I sent earlier
> today "tools/ocaml: implement stub_xc_domain_create() for ARM", they are
> what xenopsd needs to create ARM domains.

XEN_DOMCTL_{get,set}_paging_mempool_size were added in a security fix,
when it was demonstrated that ARM needed such a memory pool.

A remaining task is to remove
XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION.  Doing so is another small
step along the big API/ABI rewrite, and these calls need purging because
they round to the nearest 1M in various places, rather than doing
precisely what the toolstack asked.

Doing this for the main C code should be relatively easy.  The Ocaml
level is more tricky because of how Xapi statically links.

I expect the least bad option is to reimplement
shadow_allocation_{get,set} in terms of your new
paging_mempool_size_{get,set} in xenctrl.ml, allowing us to remove the
older C bindings.  We can then move Xapi over to the new API, and retire
the compatibility stubs in due course.


On a totally separate note, when you reported the arm segfault
originally, I put together the attached patch which is a derivation of a
smoke test I've had for checking bindings.  The Ocaml part is definitely
not pretty, and would benefit from someone who can write the language
rather better than I can.

But, I think now is about the right time to put this in as a real test
to run in CI.  What I did was a gross hack, but in principle all we need
to do is install it into $(DESTDIR)$(LIBEXEC)/tests and it should get
picked up and run automatically in Gitlab CI.

What I can't find is anything which can truly pretty-print an Ocaml
object without some external structural definition.  To test the
bindings, we need to reference every part of them in Ocaml code (and
have it not crash), to confirm that we built the correct structure in C.

I can probably start by submitting it with test_xenversion only (to get
the plumbing in), and we can build from there?

Thoughts?

Thanks,

~Andrew
Re: [PATCH 0/2] tools/ocaml: bindings needed to build ARM domains
Posted by Andrii Sultanov 4 weeks ago
On 10/22/26 21:57, Andrew Cooper wrote:

> But, I think now is about the right time to put this in as a real test
> to run in CI.  What I did was a gross hack, but in principle all we need
> to do is install it into $(DESTDIR)$(LIBEXEC)/tests and it should get
> picked up and run automatically in Gitlab CI.
>
> What I can't find is anything which can truly pretty-print an Ocaml
> object without some external structural definition.  To test the
> bindings, we need to reference every part of them in Ocaml code (and
> have it not crash), to confirm that we built the correct structure in C.
There's no nice generic way to do this, I'm afraid. It's a common 
complaint...
It can technically be done with PPX-es
(e.g. https://github.com/ocaml-ppx/ppx_deriving#plugin-show), but it's 
going to
be fairly painful to integrate this into Xen given our reqs.