diff options
author | Juergen Gross <jgross@suse.com> | 2022-06-22 09:38:36 +0300 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2022-08-01 08:42:49 +0300 |
commit | a603002eea8213eec5211be5a85db8340aea06d0 (patch) | |
tree | 5154e240ad4f487a866e74a055671d66b8b12b6d /include/linux/virtio_anchor.h | |
parent | 8441dac05e7f346abc4f63a15d4af0adeabfaa9b (diff) | |
download | linux-a603002eea8213eec5211be5a85db8340aea06d0.tar.xz |
virtio: replace restricted mem access flag with callback
Instead of having a global flag to require restricted memory access
for all virtio devices, introduce a callback which can select that
requirement on a per-device basis.
For convenience add a common function returning always true, which can
be used for use cases like SEV.
Per default use a callback always returning false.
As the callback needs to be set in early init code already, add a
virtio anchor which is builtin in case virtio is enabled.
Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> # Arm64 guest using Xen
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Link: https://lore.kernel.org/r/20220622063838.8854-2-jgross@suse.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'include/linux/virtio_anchor.h')
-rw-r--r-- | include/linux/virtio_anchor.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/virtio_anchor.h b/include/linux/virtio_anchor.h new file mode 100644 index 000000000000..432e6c00b3ca --- /dev/null +++ b/include/linux/virtio_anchor.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_VIRTIO_ANCHOR_H +#define _LINUX_VIRTIO_ANCHOR_H + +#ifdef CONFIG_VIRTIO_ANCHOR +struct virtio_device; + +bool virtio_require_restricted_mem_acc(struct virtio_device *dev); +extern bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev); + +static inline void virtio_set_mem_acc_cb(bool (*func)(struct virtio_device *)) +{ + virtio_check_mem_acc_cb = func; +} +#else +#define virtio_set_mem_acc_cb(func) do { } while (0) +#endif + +#endif /* _LINUX_VIRTIO_ANCHOR_H */ |