Mailing List Archive

[RFC PATCH V1 11/12] libxl: Insert "dma-coherent" property into virtio-mmio device node
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Without "dma-coherent" property present in virtio-mmio device node,
guest assumes it is non-coherent and making non-cacheable accesses
to the vring when the DMA API is used for vring operations.
But virtio-mmio device which runs at the host size is making cacheable
accesses to vring. This all may result in a loss of coherency between
the guest and host.

With this patch we can avoid modifying guest at all, otherwise we
need to force VirtIO framework to not use DMA API for vring operations.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
tools/libxl/libxl_arm.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 469a8b0..a68fb14 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -726,6 +726,9 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
res = fdt_property_interrupts(gc, fdt, &intr, 1);
if (res) return res;

+ res = fdt_property(fdt, "dma-coherent", NULL, 0);
+ if (res) return res;
+
res = fdt_end_node(fdt);
if (res) return res;

--
2.7.4
Re: [RFC PATCH V1 11/12] libxl: Insert "dma-coherent" property into virtio-mmio device node [ In reply to ]
On Mon, 3 Aug 2020, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>
> Without "dma-coherent" property present in virtio-mmio device node,
> guest assumes it is non-coherent and making non-cacheable accesses
> to the vring when the DMA API is used for vring operations.
> But virtio-mmio device which runs at the host size is making cacheable
> accesses to vring. This all may result in a loss of coherency between
> the guest and host.
>
> With this patch we can avoid modifying guest at all, otherwise we
> need to force VirtIO framework to not use DMA API for vring operations.
>
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

This should also be folded in the first patch for libxl

> ---
> tools/libxl/libxl_arm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index 469a8b0..a68fb14 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -726,6 +726,9 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
> res = fdt_property_interrupts(gc, fdt, &intr, 1);
> if (res) return res;
>
> + res = fdt_property(fdt, "dma-coherent", NULL, 0);
> + if (res) return res;
> +
> res = fdt_end_node(fdt);
> if (res) return res;
>
> --
> 2.7.4
>
Re: [RFC PATCH V1 11/12] libxl: Insert "dma-coherent" property into virtio-mmio device node [ In reply to ]
On 05.08.20 02:23, Stefano Stabellini wrote:

Hi Stefano

> On Mon, 3 Aug 2020, Oleksandr Tyshchenko wrote:
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> Without "dma-coherent" property present in virtio-mmio device node,
>> guest assumes it is non-coherent and making non-cacheable accesses
>> to the vring when the DMA API is used for vring operations.
>> But virtio-mmio device which runs at the host size is making cacheable
>> accesses to vring. This all may result in a loss of coherency between
>> the guest and host.
>>
>> With this patch we can avoid modifying guest at all, otherwise we
>> need to force VirtIO framework to not use DMA API for vring operations.
>>
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> This should also be folded in the first patch for libxl

Agree, will do



--
Regards,

Oleksandr Tyshchenko