I committed the first two patches. I decided to wait with the third patch for
Jan as he was the one with the most remarks.
~Michal
On 27-Apr-26 17:34, Oleksii Kurochko wrote:
> This patch series introduces a new field to track not-yet-used phandles as there
> are some use cases where RISC-V needs to know which phandle number could
> be used for generating a device tree node.
>
> For example, on the RISC-V side in make_cpus_node() [1] it is necessary to know
> which phandle number is unused to use it for device tree node generation.
>
> Here is an example of generated guest DTB:
> cpus {
> ...
> cpu@0 {
> ...
> interrupt-controller {
> compatible = "riscv,cpu-intc";
> #interrupt-cells = <0x1>;
> interrupt-controller;
> phandle = <0xfdea>;
> };
> };
> };
>
> /soc/imsics@28000000 {
>
> interrupts-extended = <0xfdea 0x9 >;
>
> phandle = <0xfdeb>;
> };
>
> /soc/aplic@d000000 {
> ...
> msi-parent = <0xfdeb>;
> phandle = <0x1>;
> };
>
> Note that phandles for imsic and riscv,cpu-intc are generated in this example
> not by get_next_free_phandle(), that is why they have such big numbers.
>
> For non-RISC-V people, APLIC is an interrupt controller (something like GIC in
> Arm), IMSIC is an interrupt controller that provides MSI and connects to
> each CPU.
>
> So (based on the DTS above) for APLIC, kinfo->phandle_intc is reused, which
> will also be re-used for the device node's interrupt property. For all others, I
> just introduced GUEST_PHANDLE_LAST [2] and used it for generation [3]. But I expect
> that it could be useful for other architectures too so I just moved it to common
> and re-use pfdt to understand what the maximum used phandle is.
>
> [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/riscv%2Ccpu-intc.txt
> [2] https://lore.kernel.org/xen-devel/ccd6d21b224b478c88ca5f2fdd2d1dd507671510.1773157782.git.oleksii.kurochko@gmail.com/
> [3] https://lore.kernel.org/xen-devel/fd64b8526a23e9d7775b9b48c5a933b0673c4fba.1773157782.git.oleksii.kurochko@gmail.com/
> *************************************
>
> Another thing introduced in this patch series is moving domain type to common
> code as several architectures (ARM and RISC-V for now) use them and it
> looks pretty architecture-independent. Also, is_64bit_domain() is used by
> dom0less common code, so I found it useful also to move is_{32,64}bit_domain
> macros to common code.
>
> *************************************
>
> And the last thing is changing the prototype of make_cpus_node() to be aligned
> with other make_*_node() and since RISC-V will need access to the free_phandle field
> (even if it will be moved to kinfo->arch.free_phandle) and for the reason that
> this ->free_phandle is updated in make_*_node(), the kinfo argument is passed as
> non-const.
>
> CI: https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2482499536
>
> ---
> Changes in v4:
> - Rebase on top of staging.
> - Add Review-by for patch 1 and 3.
> - Address the comments.
> ---
> Changes in v3:
> - Rebase on top of staging.
> - Address the comments.
> ---
> Changes in v2:
> - Address the comments from ML.
> ---
>
> Oleksii Kurochko (3):
> xen/dom0less: introduce next_phandle in struct kernel_info
> xen/dom0less: pass kernel_info struct instead of fdt to
> make_cpus_node()
> xen: introduce CONFIG_HAS_DOMAIN_TYPE
>
> xen/arch/arm/Kconfig | 1 +
> xen/arch/arm/arm64/domctl.c | 4 +--
> xen/arch/arm/dom0less-build.c | 14 --------
> xen/arch/arm/domain_build.c | 17 +++++-----
> xen/arch/arm/include/asm/domain.h | 16 ---------
> xen/arch/arm/include/asm/kernel.h | 4 ---
> xen/arch/arm/kernel.c | 16 ++++-----
> xen/common/Kconfig | 3 ++
> xen/common/device-tree/dom0less-build.c | 45 ++++++++++++++++++-------
> xen/include/xen/dom0less-build.h | 2 --
> xen/include/xen/domain.h | 13 +++++++
> xen/include/xen/fdt-domain-build.h | 17 +++++++++-
> xen/include/xen/fdt-kernel.h | 11 ++++++
> xen/include/xen/sched.h | 4 +++
> 14 files changed, 98 insertions(+), 69 deletions(-)
>