Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  1. Carve out a range of memory to be used for sharing
    You can do that by editing the host device tree, reducing the amount of RAM in the memory node, and adding a separate new "mmio-sram" node as follows:

    Code Block
    --- mpsoc.dts.1 2019-10-31 16:00:35.574817353 -0700
    +++ mpsoc.dts.2 2019-10-31 16:00:24.850379706 -0700
    @@ -1738,6 +1738,11 @@
        memory {
            device_type = "memory";
    -       reg = <0x0 0x0 0x0 0x80000000 0x8 0x0 0x0 0x80000000>;
    +       reg = <0x0 0x0 0x0 0x7f000000 0x8 0x0 0x0 0x80000000>;
    +   };
    +   sram@7f000000 {
    +       compatible = "mmio-sram";
    +       reg = <0x0 0x7f000000 0x0 0x1000000>;

    In this example the range 0x7f000000 - 0x80000000 was removed from the memory node and exposed as a special mmio-sram region to be assigned.

    If you don’t want dom0 to get access automatically to the range, add xen,passthrough; under the sram@7f000000 node.

  2. Share the sram region with dom0-less domUs
    Dom0 will get access to the sram region automatically (unless xen,passthrough; was specified). You can map the region to one or more dom0-less domUs by adding an sram node to the dom0-less DomU partial device tree. For instance:

    Code Block
    / {
        #address-cells = <0x2>;
        #size-cells = <0x1>;
        gic: gic {
            #interrupt-cells = <0x3>;
        passthrough {
            compatible = "simple-bus";
            #address-cells = <0x2>;
            #size-cells = <0x1>;
            sram@7f000000 {
                compatible = "mmio-sram";
                reg = <0x0 0x7f000000 0x0 0x1000000>;
                xen,reg = <0x0 0x7f000000 0x1000000 0x0 0x7f000000>;
                xen,force-assign-without-iommu = <0x1>;

    Note that the xen,reg property is key because it triggers the remapping of the memory range at the same location into the DomU. If you want to map the memory as cacheable is possible to use xen,reg-cacheable instead of xen,reg.

  3. Use the sram region
    When you boot the system, Dom0 and the DomUs will get a mapping of the sram region (0x7f000000 - 0x80000000) automatically. You can use the shared memory by calling `ioremap' in your kernel.