Alex Kolovsky

Configuring config.dts

This file is the most important part of the entire configuration. It describes guests.

The element that contains all the information is called hypervisor-config:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configurations...
    };
};

Mandatory elements of hypervisor-config are:

mmio-windows

mmio-windows — Contains large ranges where all MMIO regions are located.

It is used to quickly determine whether a guest-requested address is an MMIO address or a standard memory area.

It is intended to cover not only strict MMIO regions, but also the address spaces located between them.

The template for this field is:

mmio-windows = <addr_hi addr_lo size_hi size_lo ...>;

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Elements 0-1: MMIO base address (0x00000000_00000000)
      // Elements 2-3: Size (0x00000000_70000000)
      // Elements 4-5: MMIO base address (0xF0000000_00000000)
      // Elements 6-7: Size (0x0FFFFFFF_FFFFFFFF)
      mmio-windows = <0x0 0x0 0x0 0x70000000 0xF0000000 0x0 0x0FFFFFFF 0xFFFFFFFF>;

      // Configurations...
    };
};

This indicates that there are two MMIO windows in the system:

The more windows defined, the slower the hypervisor becomes. Note that addresses included in these windows cannot be used by the guest as standard memory.

Virtual Machine Descriptions

The main configuration elements are guest descriptions, which are used to define the hypervisor’s guests.

The template for this node is:

vm_name {
  // Configurations...
};

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Configurations...
      };
    };
};

Each VM node has the following required properties:

path

The path property contains the path to the guest binary file.

The template for this field is:

path = "path_str";

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Path of the guest binary.
        path = "target/guest-1/guest-1.bin";

        // Configurations...
      };
    };
};

This indicates that the first guest binary file is located at target/guest-1/guest-1.bin.

entry

The entry property contains the GPA (Guest Physical Address) of the guest entry point.

Info:

The GPA (Guest Physical Address) is the address that the guest OS considers physical, which the hypervisor translates to a Host Physical Address (HPA) via two-stage paging (e.g., RISC-V hgatp).

The template for this field is:

entry = <addr_hi addr_lo>;

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Guest physical address of the guest entry point.
        entry = <0x0 0x100000>;

        // Configurations...
      };
    };
};

This indicates that the guest entry point is at 0x100000.

allowed-mmio

allowed-mmio — Contains the MMIO peripheral regions allowed for the guest.

It can cover either an entire peripheral memory region or specific parts of it, and can also group multiple MMIO peripherals into a single region. Note that regions that do not represent valid MMIO regions will be discarded by the build script.

The template for this field is:

allowed-mmio = <addr_hi addr_lo size_hi size_lo ...>;

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Elements 0-1: MMIO base address (0x00000000_00000000)
        // Elements 2-3: Size (0x00000000_10000000)
        // Elements 4-5: MMIO base address (0xFFFFFFFF_DEADBEEF)
        // Elements 6-7: Size (0x00000000_00000001)
        // Addresses must fall within the defined mmio-windows.
        allowed-mmio = <0x0 0x10000000 0x0 0x1 0xFFFFFFFF 0xDEADBEEF 0x0 0x1>;

        // Configurations...
      };
    };
};

This indicates that there are two allowed MMIO windows for the vm0 guest:

If the base address and size are not page-aligned, accessing them will be significantly slower.

The greater the number of allowed MMIO regions, the slower the hypervisor becomes.

hart-capacity

Info:

In the RISC-V architecture, execution threads are formally referred to as Harts (from Hardware Threads). For readers coming from the x86 architecture, a hart is the direct equivalent of a logical CPU thread.

The hart-capacity property contains the maximum total number of Harts a guest can use, combining both assigned and shared Harts.

The template for this field is:

hart-capacity = <hart_capacity>;

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Maximum total number of Harts a guest can use, combining both assigned and shared Harts.
        hart-capacity = <2>;

        // Configurations...
      };
    };
};

This indicates that the maximum total number of Harts a guest can use is 2.

The hypervisor configuration also includes optional properties:

assigned-harts

The assigned-harts property contains the hart IDs assigned to this guest.

Info:

Assigning means that the hart will execute only guests to which it is assigned. You can assign one hart to multiple guests.

The template for this field is:

assigned-harts = <hart_id hart_id hart_id ...>;

Example:

// config.dts

/dts-v1/;

/ {
    #address-cells = <2>;
    #size-cells = <2>;

    hypervisor-config {

      // Configuration for the first guest VM.
      vm0 {

        // Assigned Hart IDs.
        // Comment out or delete this parameter if you do not need to assign Harts.
        assigned-harts = <0 1>;

        // Configurations...
      };
    };
};

This indicates that the hart IDs assigned to the vm0 guest are 0 and 1.

vlen

Info:

VLEN is the size in bits of a vector register in the RISC-V architecture.

The vlen property specifies the vector register length; if set, vector instructions become available to the guest.

The template for this field is:

vlen = <vlen_in_bits>;

Example:

// config.dts

/dts-v1/;

/ {
  #address-cells = <2>;
  #size-cells = <2>;

  hypervisor-config {

    // Configuration for the first guest VM.
    vm0 {

      // Size of the vector registers in bits.
      // To disable the vector extension,
      // remove this parameter or set vlen to zero.
      vlen = <128>;

      // Configurations...
    };
  };
};

This indicates that the vector register length is 128 bits.

floating-point-extension

The floating-point-extension property specifies whether the RISC-V floating-point extension is allowed for the guest. The template for this field is:

floating-point-extension;

Example:

// config.dts

/dts-v1/;

/ {
  #address-cells = <2>;
  #size-cells = <2>;

  hypervisor-config {

    // Configuration for the first guest VM.
    vm0 {

      // Enables the floating-point extension;
      // comment out or delete this parameter to disable it.
      floating-point-extension;

      // Configurations...
    };
  };
};

This indicates that the RISC-V floating-point extension is allowed for the vm0 guest.