[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal for virtual IOMMU binding b/w vIOMMU and passthrough devices


  • To: Xen developer discussion <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Wed, 26 Oct 2022 13:17:43 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7L45+M+So87NQD79rx1b/VxFV+qYJWUyiyGYdUS3X/o=; b=Em70HyqAuLE1xJj/VDKc2+zJNpdQpPVcYfl6MeZmyteqB66K1p9u4ilidEZGSMo0zQwRyXbymCaZb/t3jwn279oX+Gd8wOn+o8/DBO+MyaFc0oawOJGTgv6YdkJ+HwIQIJ+O/dpgeVdxCSMouCh/GF/qRbYNqUvuEUcDfUCHnZzZ/0NP8U5M25qywYz3rQMp44cDcBRxkm2SZtTw6OjZ5ou+6EufeOYQB2jkK39SXARAOB/pQDtOUAnsyiFZxb4eVv3BLwusmt2x81/YZ9HfJ3ylTccS9y54jJA/kuWC76aR6zdY5/F6UB5A8rCKxg/JJ/G+PENPx04dodVh2Vuyfg==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7L45+M+So87NQD79rx1b/VxFV+qYJWUyiyGYdUS3X/o=; b=LL+hrEyQYQG8j6BXqi5FxSpuJvvW6et0tk6UMcErtK5CIpzFPVKyBeBkGbFC/QaC9TFCrpZTm1jjDHk+ULLybrmvq+OTk80uDt4BPPniSo15oYTQfJSvwkN3pDYYRAx1hXl+m04lrfa3iOnbHmHOVS381605GrRm2xQCYjKQWiVoQQBbtpiI7aFbaCqncX3dGPlAydGPYGfmac7MnrO1uwyyCFOoUvZNdQndeEvU0jzl7brI1pa+vzbqW1FUdV6c8MfrzLF/CYWPu5iY0d0r8NnKcC53b7wbygFeWKcuAeF1t62PGdsWR+5zBE5BWYyh5HzTjM61ARpYF/H9ltxOTw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=F/jEgtfh7dsxALAxiyDYGSrXDtnDfpoIB2FWP/IT71KLfHTPN9Xkzqvgvp+ztUIR2iyjqaQqyTgmVCbHyGR/h+NxCjGhUTWf2Ko2HM2/UZW1ik0BZ/InBde3vBKa0GRtsEXGJpb618/2nAU5FUAIWg4SCvdd2Qo7gMrY4pKI2DUW0WxhamVEOrRRBvop5pkCbGNMtIHuUFh9didCRHR9nNCSZhYafPzl+u12n+BGc26iZQPdaX5Gksn8k62XintCHItFflNOHalHu1NBG4ZC1XjmVP6fj1H4OkZ+nprVHQyZc4MfO18jSlX1DRO3z0OntbvjIIkL8CG9WgDK5kN16Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q8PzA9xPZ5xvBrJSeyNL7NMj6036AclA+87zy80v+7uqZur3efrRfywQb6l9iN+gUGc3WvGsLOAzxFIku6IefOiynQWWraEWX/WkC7CTklWV91uX4TtdwH9fav4exAvniXCkAzWUpJbWaGYOLREnjOaVPUt6zMiQpPjOfKgL1MRY2V2BXADzNmbkO8sJzueVSxT9uWymIy/W0Wr3VWxlIAiAW8UIky9hsdzc67DqlGZfSyjTdO1Ay4szkaPOpu4+3dMdxbKA5gEY+7BIbabZgmeOXjJRkwh35T6nCGVc3lN6mwataLImIZBS9E5OW00kZ6cEOsFqZvSq5Z9dR/ukHw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <Michal.Orzel@xxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Wed, 26 Oct 2022 13:18:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY6T1V+gcJbmRqpEyt0b8GeG9bFg==
  • Thread-topic: Proposal for virtual IOMMU binding b/w vIOMMU and passthrough devices

Hi All,

At Arm, we started to implement the POC to support 2 levels of page 
tables/nested translation in SMMUv3.
To support nested translation for guest OS Xen needs to expose the virtual 
IOMMU. If we passthrough the
device to the guest that is behind an IOMMU and virtual IOMMU is enabled for 
the guest there is a need to
add IOMMU binding for the device in the passthrough node as per [1]. This email 
is to get an agreement on
how to add the IOMMU binding for guest OS.

Before I will explain how to add the IOMMU binding let me give a brief overview 
of how we will add support for virtual
IOMMU on Arm. In order to implement virtual IOMMU Xen need SMMUv3 Nested 
translation support. SMMUv3 hardware
supports two stages of translation. Each stage of translation can be 
independently enabled. An incoming address is logically
translated from VA to IPA in stage 1, then the IPA is input to stage 2 which 
translates the IPA to the output PA. Stage 1 is
intended to be used by a software entity( Guest OS) to provide isolation or 
translation to buffers within the entity, for example,
DMA isolation within an OS. Stage 2 is intended to be available in systems 
supporting the Virtualization Extensions and is
intended to virtualize device DMA to guest VM address spaces. When both stage 1 
and stage 2 are enabled, the translation
configuration is called nesting.

Stage 1 translation support is required to provide isolation between different 
devices within the guest OS. XEN already supports
Stage 2 translation but there is no support for Stage 1 translation for guests. 
We will add support for guests to configure
the Stage 1 transition via virtual IOMMU. XEN will emulate the SMMU hardware 
and exposes the virtual SMMU to the guest.
Guest can use the native SMMU driver to configure the stage 1 translation. When 
the guest configures the SMMU for Stage 1,
XEN will trap the access and configure the hardware accordingly.

Now back to the question of how we can add the IOMMU binding between the 
virtual IOMMU and the master devices so that
guests can configure the IOMMU correctly. The solution that I am suggesting is 
as below:

For dom0, while handling the DT node(handle_node()) Xen will replace the 
phandle in the "iommus" property with the virtual
IOMMU node phandle.

For domU guests, when passthrough the device to the guest as per [2],  add the 
below property in the partial device tree
node that is required to describe the generic device tree binding for IOMMUs 
and their master(s)

"iommus = < &magic_phandle 0xvMasterID>  
        • magic_phandle will be the phandle ( vIOMMU phandle in xl)  that will 
be documented so that the user can set that in partial DT node (0xfdea).  
        • vMasterID will be the virtual master ID that the user will provide.

The partial device tree will look like this:
/dts-v1/;
 
/ {
    /* #*cells are here to keep DTC happy */
    #address-cells = <2>;
    #size-cells = <2>;
 
    aliases {
        net = &mac0;
    };
 
    passthrough {
        compatible = "simple-bus";
        ranges;
        #address-cells = <2>;
        #size-cells = <2>;
        mac0: ethernet@10000000 {
            compatible = "calxeda,hb-xgmac";
            reg = <0 0x10000000 0 0x1000>;
            interrupts = <0 80 4  0 81 4  0 82 4>;
           iommus = <0xfdea 0x01>;
        };
    };
};
 
In xl.cfg we need to define a new option to inform Xen about vMasterId to 
pMasterId mapping and to which IOMMU device this
the master device is connected so that Xen can configure the right IOMMU. This 
is required if the system has devices that have
the same master ID but behind a different IOMMU.
 
iommu_devid_map = [ “PMASTER_ID[@VMASTER_ID],IOMMU_BASE_ADDRESS” , 
“PMASTER_ID[@VMASTER_ID],IOMMU_BASE_ADDRESS”]

        • PMASTER_ID is the physical master ID of the device from the physical 
DT.
        • VMASTER_ID is the virtual master Id that the user will configure in 
the partial device tree.
        • IOMMU_BASE_ADDRESS is the base address of the physical IOMMU device 
to which this device is connected. 
 
Example: Let's say the user wants to assign the below physical device in DT to 
the guest.
 
iommu@4f000000 {
                compatible = "arm,smmu-v3";
                interrupts = <0x00 0xe4 0xf04>;
                interrupt-parent = <0x01>;
                #iommu-cells = <0x01>;
                interrupt-names = "combined";
                reg = <0x00 0x4f000000 0x00 0x40000>;
                phandle = <0xfdeb>;
                name = "iommu";
};
 
test@10000000 {
        compatible = "viommu-test”;
        iommus = <0xfdeb 0x10>;
        interrupts = <0x00 0xff 0x04>;
        reg = <0x00 0x10000000 0x00 0x1000>;
        name = "viommu-test";
};
 
The partial Device tree node will be like this:
 
/ {
    /* #*cells are here to keep DTC happy */
    #address-cells = <2>;
    #size-cells = <2>;
 
    passthrough {
        compatible = "simple-bus";
        ranges;
        #address-cells = <2>;
        #size-cells = <2>;

        test@10000000 {
                compatible = "viommu-test";
                reg = <0 0x10000000 0 0x1000>;
                interrupts = <0 80 4  0 81 4  0 82 4>;
                iommus = <0xfdea 0x01>;
        };
    };
};
 
 iommu_devid_map = [ “0x10@0x01,0x4f000000”]
        • 0x10 is the real physical master id from the physical DT.
        • 0x01 is the virtual master Id that the user defines as a partial 
device tree.
        • 0x4f000000 is the base address of the IOMMU device.

[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/iommu/iommu.txt
[2] https://xenbits.xen.org/docs/unstable/misc/arm/passthrough.txt

Regards,
Rahul

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.