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

Re: [PATCH v2 3/3] xen/virtio: enable grant based virtio on x86


  • To: Juergen Gross <jgross@xxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "x86@xxxxxxxxxx" <x86@xxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Fri, 7 Oct 2022 14:00:35 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=Ags55PeKbSsqNlzYypdKeg9SP0GNzJO8cTuoFQ5Jz3E=; b=T7lrcQqshKqsbhXEtG4nE8u8H6V8OeaJ3bKJasUPa5wuXliYHcu7vBaTRmNkCEU5otr36+MTzn2s7KmPgQG7ao7+mS9MRCvWFKZU97noQ9V4IxMudQPMwXfA9MjsUfPsh5SBBdgrM9f1C0vC/9yXGQLtBnSM98hM1cz9ceWgHHlWpLdliMuJW1vXoFcMCzQWXaba+U/gcZ6f610U7pvl6XMVoPgYX4i1ekhhES9aox+nWRbJ58uRqHLseRiStR4FUjE700Lt7m44c2UJbSxiRCrG7A9pbHiK2pxTHdy5slyzJZpx464xLmg03Rw8PMrRd0uKUn1AuotcB6LxDXfrfQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eFivTvUKWHqpavf7j1zPUPqkhbO0qX+rqnB/JUy6Wh8qNgZOd0TP0Aj4DfXNsHYEvqdf49Mbm6S1tt5qTzAOMrzcvWPv4VW6SQxBPpTHeB49T3MAzA+0RpHykbxDhdtjZYZLdb1ThLbcfPdzwm6DCxSd/xVlQntLcpwIE/9blSNazQNDzOa95744Fv0rOXXgBkySdiUAr1LEUq9K3mwt4GwNk+N561Lz6665nM709BOFs4BKGWMmWiZk1rvX01/qlpIn2XtTBmJ5mUBAaCROrvTgnKwdsHw1kRNbIElQ/GlQHK3Ec0aCrr2UrTFpLmsvEzS36fqQqLQwokDvza6TIQ==
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 07 Oct 2022 14:01:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY2hfsYkIZ8bm8YEiah662d3CFb64C9ieA
  • Thread-topic: [PATCH v2 3/3] xen/virtio: enable grant based virtio on x86

On 07.10.22 09:41, Juergen Gross wrote:

Hello Juergen

> Use an x86-specific virtio_check_mem_acc_cb() for Xen in order to setup
> the correct DMA ops.
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> ---
> V2:
> - add missing PV check in xen_virtio_mem_acc() (Oleksandr Tyshchenko)
> - add xen_virtio_restricted_mem_acc() stub (Oleksandr Tyshchenko)


Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> # 
common code


> ---
>   arch/x86/xen/enlighten_hvm.c |  2 +-
>   arch/x86/xen/enlighten_pv.c  |  2 +-
>   drivers/xen/grant-dma-ops.c  | 12 +++++++++++-
>   include/xen/xen-ops.h        |  6 ++++++
>   4 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
> index 1c1ac418484b..c1cd28e915a3 100644
> --- a/arch/x86/xen/enlighten_hvm.c
> +++ b/arch/x86/xen/enlighten_hvm.c
> @@ -212,7 +212,7 @@ static void __init xen_hvm_guest_init(void)
>               return;
>   
>       if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
> -             virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
> +             virtio_set_mem_acc_cb(xen_virtio_restricted_mem_acc);
>   
>       init_hvm_pv_info();
>   
> diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
> index 9b1a58dda935..45b24c1b646a 100644
> --- a/arch/x86/xen/enlighten_pv.c
> +++ b/arch/x86/xen/enlighten_pv.c
> @@ -112,7 +112,7 @@ static void __init xen_pv_init_platform(void)
>   {
>       /* PV guests can't operate virtio devices without grants. */
>       if (IS_ENABLED(CONFIG_XEN_VIRTIO))
> -             virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
> +             virtio_set_mem_acc_cb(xen_virtio_restricted_mem_acc);
>   
>       populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
>   
> diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c
> index c703b77b33c9..63c3f0dac066 100644
> --- a/drivers/xen/grant-dma-ops.c
> +++ b/drivers/xen/grant-dma-ops.c
> @@ -297,7 +297,7 @@ bool xen_is_grant_dma_device(struct device *dev)
>   
>   bool xen_virtio_mem_acc(struct virtio_device *dev)
>   {
> -     if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
> +     if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT) || xen_pv_domain())
>               return true;
>   
>       return xen_is_grant_dma_device(dev->dev.parent);
> @@ -372,6 +372,16 @@ void xen_grant_setup_dma_ops(struct device *dev)
>       dev_err(dev, "Cannot set up Xen grant DMA ops, retain platform DMA 
> ops\n");
>   }
>   
> +bool xen_virtio_restricted_mem_acc(struct virtio_device *dev)
> +{
> +     bool ret = xen_virtio_mem_acc(dev);
> +
> +     if (ret)
> +             xen_grant_setup_dma_ops(dev->dev.parent);
> +
> +     return ret;
> +}
> +
>   MODULE_DESCRIPTION("Xen grant DMA-mapping layer");
>   MODULE_AUTHOR("Juergen Gross <jgross@xxxxxxxx>");
>   MODULE_LICENSE("GPL");
> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
> index dae0f350c678..a34f4271a2e9 100644
> --- a/include/xen/xen-ops.h
> +++ b/include/xen/xen-ops.h
> @@ -219,6 +219,7 @@ static inline void xen_preemptible_hcall_end(void) { }
>   void xen_grant_setup_dma_ops(struct device *dev);
>   bool xen_is_grant_dma_device(struct device *dev);
>   bool xen_virtio_mem_acc(struct virtio_device *dev);
> +bool xen_virtio_restricted_mem_acc(struct virtio_device *dev);
>   #else
>   static inline void xen_grant_setup_dma_ops(struct device *dev)
>   {
> @@ -234,6 +235,11 @@ static inline bool xen_virtio_mem_acc(struct 
> virtio_device *dev)
>   {
>       return false;
>   }
> +
> +static inline bool xen_virtio_restricted_mem_acc(struct virtio_device *dev)
> +{
> +     return false;
> +}
>   #endif /* CONFIG_XEN_GRANT_DMA_OPS */
>   
>   #endif /* INCLUDE_XEN_OPS_H */

-- 
Regards,

Oleksandr Tyshchenko

 


Rackspace

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