Commit 61367688 authored by Juergen Gross's avatar Juergen Gross

xen/virtio: enable grant based virtio on x86

Use an x86-specific virtio_check_mem_acc_cb() for Xen in order to setup
the correct DMA ops.
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> # common code
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 7228113d
...@@ -212,7 +212,7 @@ static void __init xen_hvm_guest_init(void) ...@@ -212,7 +212,7 @@ static void __init xen_hvm_guest_init(void)
return; return;
if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT)) 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(); init_hvm_pv_info();
......
...@@ -112,7 +112,7 @@ static void __init xen_pv_init_platform(void) ...@@ -112,7 +112,7 @@ static void __init xen_pv_init_platform(void)
{ {
/* PV guests can't operate virtio devices without grants. */ /* PV guests can't operate virtio devices without grants. */
if (IS_ENABLED(CONFIG_XEN_VIRTIO)) 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)); populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
......
...@@ -313,7 +313,7 @@ bool xen_is_grant_dma_device(struct device *dev) ...@@ -313,7 +313,7 @@ bool xen_is_grant_dma_device(struct device *dev)
bool xen_virtio_mem_acc(struct virtio_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 true;
return xen_is_grant_dma_device(dev->dev.parent); return xen_is_grant_dma_device(dev->dev.parent);
...@@ -387,6 +387,16 @@ void xen_grant_setup_dma_ops(struct device *dev) ...@@ -387,6 +387,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"); 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_DESCRIPTION("Xen grant DMA-mapping layer");
MODULE_AUTHOR("Juergen Gross <jgross@suse.com>"); MODULE_AUTHOR("Juergen Gross <jgross@suse.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -219,6 +219,7 @@ static inline void xen_preemptible_hcall_end(void) { } ...@@ -219,6 +219,7 @@ static inline void xen_preemptible_hcall_end(void) { }
void xen_grant_setup_dma_ops(struct device *dev); void xen_grant_setup_dma_ops(struct device *dev);
bool xen_is_grant_dma_device(struct device *dev); bool xen_is_grant_dma_device(struct device *dev);
bool xen_virtio_mem_acc(struct virtio_device *dev); bool xen_virtio_mem_acc(struct virtio_device *dev);
bool xen_virtio_restricted_mem_acc(struct virtio_device *dev);
#else #else
static inline void xen_grant_setup_dma_ops(struct device *dev) 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) ...@@ -234,6 +235,11 @@ static inline bool xen_virtio_mem_acc(struct virtio_device *dev)
{ {
return false; return false;
} }
static inline bool xen_virtio_restricted_mem_acc(struct virtio_device *dev)
{
return false;
}
#endif /* CONFIG_XEN_GRANT_DMA_OPS */ #endif /* CONFIG_XEN_GRANT_DMA_OPS */
#endif /* INCLUDE_XEN_OPS_H */ #endif /* INCLUDE_XEN_OPS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment