Skip to contentSkip to conversation

virtio: support requiring restricted access per device

PATCH In review Juergen Gross 3 participants 10 messages Jun 22, 2022 – Jul 5, 2022

Subsystems (10)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

v3 cover virtio: support requiring restricted access per device

Instead of an all or nothing approach add support for requiring restricted memory access per device.

Changes in V3:
- new patches 1 + 2
- basically complete rework of patch 3

Juergen Gross (3):
virtio: replace restricted mem access flag with callback
kernel: remove platform_has() infrastructure
xen: don't require virtio with grants for non-PV guests

 MAINTAINERS                            |  8 --------
 arch/arm/xen/enlighten.c               |  4 +++-
 arch/s390/mm/init.c                    |  4 ++--
 arch/x86/mm/mem_encrypt_amd.c          |  4 ++--
 arch/x86/xen/enlighten_hvm.c           |  4 +++-
 arch/x86/xen/enlighten_pv.c            |  5 ++++-
 drivers/virtio/Kconfig                 |  4 ++++
 drivers/virtio/Makefile                |  1 +
 drivers/virtio/virtio.c                |  4 ++--
 drivers/virtio/virtio_anchor.c         | 18 +++++++++++++++++
 drivers/xen/Kconfig                    |  9 +++++++++
 drivers/xen/grant-dma-ops.c            | 10 ++++++++++
 include/asm-generic/Kbuild             |  1 -
 include/asm-generic/platform-feature.h |  8 --------
 include/linux/platform-feature.h       | 19 ------------------
 include/linux/virtio_anchor.h          | 19 ++++++++++++++++++
 include/xen/xen-ops.h                  |  6 ++++++
 include/xen/xen.h                      |  8 --------
 kernel/Makefile                        |  2 +-
 kernel/platform-feature.c              | 27 --------------------------
 20 files changed, 84 insertions(+), 81 deletions(-)
 create mode 100644 drivers/virtio/virtio_anchor.c
 delete mode 100644 include/asm-generic/platform-feature.h
 delete mode 100644 include/linux/platform-feature.h
 create mode 100644 include/linux/virtio_anchor.h
 delete mode 100644 kernel/platform-feature.c
Signature · 1 line
2.35.3
author maintainer
#1 lore raw

PATCH v3 1/3 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.

---
 arch/s390/mm/init.c              |  4 ++--
 arch/x86/mm/mem_encrypt_amd.c    |  4 ++--
 drivers/virtio/Kconfig           |  4 ++++
 drivers/virtio/Makefile          |  1 +
 drivers/virtio/virtio.c          |  4 ++--
 drivers/virtio/virtio_anchor.c   | 18 ++++++++++++++++++
 include/linux/platform-feature.h |  6 +-----
 include/linux/virtio_anchor.h    | 19 +++++++++++++++++++
 include/xen/xen.h                |  4 ++--
 9 files changed, 51 insertions(+), 13 deletions(-)
 create mode 100644 drivers/virtio/virtio_anchor.c
 create mode 100644 include/linux/virtio_anchor.h
arch/s390/mm/init.c +2 -2
index 6a0ac00d5a42..4a154a084966 100644
@@ -31,7 +31,6 @@
 #include <linux/cma.h>
 #include <linux/gfp.h>
 #include <linux/dma-direct.h>
-#include <linux/platform-feature.h>
 #include <asm/processor.h>
 #include <linux/uaccess.h>
 #include <asm/pgalloc.h>
@@ -48,6 +47,7 @@
 #include <asm/kasan.h>
 #include <asm/dma-mapping.h>
 #include <asm/uv.h>
+#include <linux/virtio_anchor.h>
 #include <linux/virtio_config.h>
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(".bss..swapper_pg_dir");
@@ -175,7 +175,7 @@ static void pv_init(void)
 	if (!is_prot_virt_guest())
 		return;
 
-	platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
+	virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
 
 	/* make sure bounce buffers are shared */
 	swiotlb_init(true, SWIOTLB_FORCE | SWIOTLB_VERBOSE);
arch/x86/mm/mem_encrypt_amd.c +2 -2
index f6d038e2cd8e..97452688f99f 100644
@@ -20,8 +20,8 @@
 #include <linux/bitops.h>
 #include <linux/dma-mapping.h>
 #include <linux/virtio_config.h>
+#include <linux/virtio_anchor.h>
 #include <linux/cc_platform.h>
-#include <linux/platform-feature.h>
 
 #include <asm/tlbflush.h>
 #include <asm/fixmap.h>
@@ -245,7 +245,7 @@ void __init sev_setup_arch(void)
 	swiotlb_adjust_size(size);
 
 	/* Set restricted memory access for virtio. */
-	platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
+	virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
 }
 
 static unsigned long pg_level_to_pfn(int level, pte_t *kpte, pgprot_t *ret_prot)
drivers/virtio/Kconfig +4 -0
index a6dc8b5846fe..ce93966575a1 100644
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config VIRTIO_ANCHOR
+	bool
+
 config VIRTIO
 	tristate
+	select VIRTIO_ANCHOR
 	help
 	  This option is selected by any driver which implements the virtio
 	  bus, such as CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_MMIO, CONFIG_RPMSG
drivers/virtio/Makefile +1 -0
index 0a82d0873248..8e98d24917cc 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o
+obj-$(CONFIG_VIRTIO_ANCHOR) += virtio_anchor.o
 obj-$(CONFIG_VIRTIO_PCI_LIB) += virtio_pci_modern_dev.o
 obj-$(CONFIG_VIRTIO_PCI_LIB_LEGACY) += virtio_pci_legacy_dev.o
 obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
drivers/virtio/virtio.c +2 -2
index 6bace84ae37e..21e753fe1b50 100644
@@ -2,10 +2,10 @@
 #include <linux/virtio.h>
 #include <linux/spinlock.h>
 #include <linux/virtio_config.h>
+#include <linux/virtio_anchor.h>
 #include <linux/module.h>
 #include <linux/idr.h>
 #include <linux/of.h>
-#include <linux/platform-feature.h>
 #include <uapi/linux/virtio_ids.h>
 
 /* Unique numbering for virtio devices. */
@@ -174,7 +174,7 @@ static int virtio_features_ok(struct virtio_device *dev)
 
 	might_sleep();
 
-	if (platform_has(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS)) {
+	if (virtio_check_mem_acc_cb(dev)) {
 		if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) {
 			dev_warn(&dev->dev,
 				 "device must provide VIRTIO_F_VERSION_1\n");
drivers/virtio/virtio_anchor.c new file +18 -0
new file mode 100644
index 000000000000..4d6a5d269b55
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/virtio.h>
+#include <linux/virtio_anchor.h>
+
+bool virtio_require_restricted_mem_acc(struct virtio_device *dev)
+{
+	return true;
+}
+EXPORT_SYMBOL_GPL(virtio_require_restricted_mem_acc);
+
+static bool virtio_no_restricted_mem_acc(struct virtio_device *dev)
+{
+	return false;
+}
+
+bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev) =
+	virtio_no_restricted_mem_acc;
+EXPORT_SYMBOL_GPL(virtio_check_mem_acc_cb);
include/linux/platform-feature.h +1 -5
index b2f48be999fa..6ed859928b97 100644
@@ -6,11 +6,7 @@
 #include <asm/platform-feature.h>
 
 /* The platform features are starting with the architecture specific ones. */
-
-/* Used to enable platform specific DMA handling for virtio devices. */
-#define PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS	(0 + PLATFORM_ARCH_FEAT_N)
-
-#define PLATFORM_FEAT_N				(1 + PLATFORM_ARCH_FEAT_N)
+#define PLATFORM_FEAT_N				(0 + PLATFORM_ARCH_FEAT_N)
 
 void platform_set(unsigned int feature);
 void platform_clear(unsigned int feature);
include/linux/virtio_anchor.h new file +19 -0
new file mode 100644
index 000000000000..432e6c00b3ca
@@ -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 */
include/xen/xen.h +2 -2
index 0780a81e140d..ac5a144c6a65 100644
@@ -52,12 +52,12 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 extern u64 xen_saved_max_mem_size;
 #endif
 
-#include <linux/platform-feature.h>
+#include <linux/virtio_anchor.h>
 
 static inline void xen_set_restricted_virtio_memory_access(void)
 {
 	if (IS_ENABLED(CONFIG_XEN_VIRTIO) && xen_domain())
-		platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
+		virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
 }
 
 #ifdef CONFIG_XEN_UNPOPULATED_ALLOC
Signature · 1 line
2.35.3
author maintainer
#2 lore raw

PATCH v3 2/3 kernel: remove platform_has() infrastructure

In reply to Juergen Gross

The only use case of the platform_has() infrastructure has been removed again, so remove the whole feature.

---
 MAINTAINERS                            |  8 --------
 include/asm-generic/Kbuild             |  1 -
 include/asm-generic/platform-feature.h |  8 --------
 include/linux/platform-feature.h       | 15 --------------
 kernel/Makefile                        |  2 +-
 kernel/platform-feature.c              | 27 --------------------------
 6 files changed, 1 insertion(+), 60 deletions(-)
 delete mode 100644 include/asm-generic/platform-feature.h
 delete mode 100644 include/linux/platform-feature.h
 delete mode 100644 kernel/platform-feature.c
MAINTAINERS +0 -8
index 3cf9842d9233..1a800f6becd2 100644
@@ -15835,14 +15835,6 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.yaml
 F:	drivers/iio/chemical/pms7003.c
 
-PLATFORM FEATURE INFRASTRUCTURE
-M:	Juergen Gross <[email protected]>
-S:	Maintained
-F:	arch/*/include/asm/platform-feature.h
-F:	include/asm-generic/platform-feature.h
-F:	include/linux/platform-feature.h
-F:	kernel/platform-feature.c
-
 PLDMFW LIBRARY
 M:	Jacob Keller <[email protected]>
 S:	Maintained
include/asm-generic/Kbuild +0 -1
index 8e47d483b524..302506bbc2a4 100644
@@ -44,7 +44,6 @@ mandatory-y += msi.h
 mandatory-y += pci.h
 mandatory-y += percpu.h
 mandatory-y += pgalloc.h
-mandatory-y += platform-feature.h
 mandatory-y += preempt.h
 mandatory-y += rwonce.h
 mandatory-y += sections.h
include/asm-generic/platform-feature.h deleted +0 -8
deleted file mode 100644
index 4b0af3d51588..000000000000
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_GENERIC_PLATFORM_FEATURE_H
-#define _ASM_GENERIC_PLATFORM_FEATURE_H
-
-/* Number of arch specific feature flags. */
-#define PLATFORM_ARCH_FEAT_N	0
-
-#endif /* _ASM_GENERIC_PLATFORM_FEATURE_H */
include/linux/platform-feature.h deleted +0 -15
deleted file mode 100644
index 6ed859928b97..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _PLATFORM_FEATURE_H
-#define _PLATFORM_FEATURE_H
-
-#include <linux/bitops.h>
-#include <asm/platform-feature.h>
-
-/* The platform features are starting with the architecture specific ones. */
-#define PLATFORM_FEAT_N				(0 + PLATFORM_ARCH_FEAT_N)
-
-void platform_set(unsigned int feature);
-void platform_clear(unsigned int feature);
-bool platform_has(unsigned int feature);
-
-#endif /* _PLATFORM_FEATURE_H */
kernel/Makefile +1 -1
index a7e1f49ab2b3..318789c728d3 100644
@@ -7,7 +7,7 @@ obj-y     = fork.o exec_domain.o panic.o \
 	    cpu.o exit.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o user.o \
 	    signal.o sys.o umh.o workqueue.o pid.o task_work.o \
-	    extable.o params.o platform-feature.o \
+	    extable.o params.o \
 	    kthread.o sys_ni.o nsproxy.o \
 	    notifier.o ksysfs.o cred.o reboot.o \
 	    async.o range.o smpboot.o ucount.o regset.o
kernel/platform-feature.c deleted +0 -27
deleted file mode 100644
index cb6a6c3e4fed..000000000000
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#include <linux/bitops.h>
-#include <linux/cache.h>
-#include <linux/export.h>
-#include <linux/platform-feature.h>
-
-#define PLATFORM_FEAT_ARRAY_SZ  BITS_TO_LONGS(PLATFORM_FEAT_N)
-static unsigned long __read_mostly platform_features[PLATFORM_FEAT_ARRAY_SZ];
-
-void platform_set(unsigned int feature)
-{
-	set_bit(feature, platform_features);
-}
-EXPORT_SYMBOL_GPL(platform_set);
-
-void platform_clear(unsigned int feature)
-{
-	clear_bit(feature, platform_features);
-}
-EXPORT_SYMBOL_GPL(platform_clear);
-
-bool platform_has(unsigned int feature)
-{
-	return test_bit(feature, platform_features);
-}
-EXPORT_SYMBOL_GPL(platform_has);
Signature · 1 line
2.35.3
author maintainer
#3 lore raw

PATCH v3 3/3 xen: don't require virtio with grants for non-PV guests

In reply to Juergen Gross

Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings") introduced a new requirement for using virtio
devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM feature.

This is an undue requirement for non-PV guests, as those can be operated with existing backends without any problem, as long as those backends are running in dom0.

Per default allow virtio devices without grant support for non-PV guests.

On Arm require VIRTIO_F_ACCESS_PLATFORM for devices having been listed in the device tree to use grants.

Add a new config item to always force use of grants for virtio.

Fixes fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings")

---
V2:
- remove command line parameter (Christoph Hellwig) V3:
- rebase to callback method

---
 arch/arm/xen/enlighten.c     |  4 +++-
 arch/x86/xen/enlighten_hvm.c |  4 +++-
 arch/x86/xen/enlighten_pv.c  |  5 ++++-
 drivers/xen/Kconfig          |  9 +++++++++
 drivers/xen/grant-dma-ops.c  | 10 ++++++++++
 include/xen/xen-ops.h        |  6 ++++++
 include/xen/xen.h            |  8 --------
 7 files changed, 35 insertions(+), 11 deletions(-)
arch/arm/xen/enlighten.c +3 -1
index 1f9c3ba32833..93c8ccbf2982 100644
@@ -34,6 +34,7 @@
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
 #include <linux/acpi.h>
+#include <linux/virtio_anchor.h>
 
 #include <linux/mm.h>
 
@@ -443,7 +444,8 @@ static int __init xen_guest_init(void)
 	if (!xen_domain())
 		return 0;
 
-	xen_set_restricted_virtio_memory_access();
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO))
+		virtio_set_mem_acc_cb(xen_virtio_mem_acc);
 
 	if (!acpi_disabled)
 		xen_acpi_guest_init();
arch/x86/xen/enlighten_hvm.c +3 -1
index 8b71b1dd7639..28762f800596 100644
@@ -4,6 +4,7 @@
 #include <linux/cpu.h>
 #include <linux/kexec.h>
 #include <linux/memblock.h>
+#include <linux/virtio_anchor.h>
 
 #include <xen/features.h>
 #include <xen/events.h>
@@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)
 	if (xen_pv_domain())
 		return;
 
-	xen_set_restricted_virtio_memory_access();
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+		virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
 
 	init_hvm_pv_info();
 
arch/x86/xen/enlighten_pv.c +4 -1
index e3297b15701c..5aaae8a77f55 100644
@@ -31,6 +31,7 @@
 #include <linux/gfp.h>
 #include <linux/edd.h>
 #include <linux/reboot.h>
+#include <linux/virtio_anchor.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
 
 static void __init xen_pv_init_platform(void)
 {
-	xen_set_restricted_virtio_memory_access();
+	/* 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);
 
 	populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
 
drivers/xen/Kconfig +9 -0
index bfd5f4f706bc..a65bd92121a5 100644
@@ -355,4 +355,13 @@ config XEN_VIRTIO
 
 	  If in doubt, say n.
 
+config XEN_VIRTIO_FORCE_GRANT
+	bool "Require Xen virtio support to use grants"
+	depends on XEN_VIRTIO
+	help
+	  Require virtio for Xen guests to use grant mappings.
+	  This will avoid the need to give the backend the right to map all
+	  of the guest memory. This will need support on the backend side
+	  (e.g. qemu or kernel, depending on the virtio device types used).
+
 endmenu
drivers/xen/grant-dma-ops.c +10 -0
index fc0142484001..8973fc1e9ccc 100644
@@ -12,6 +12,8 @@
 #include <linux/of.h>
 #include <linux/pfn.h>
 #include <linux/xarray.h>
+#include <linux/virtio_anchor.h>
+#include <linux/virtio.h>
 #include <xen/xen.h>
 #include <xen/xen-ops.h>
 #include <xen/grant_table.h>
@@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)
 	return has_iommu;
 }
 
+bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+		return true;
+
+	return xen_is_grant_dma_device(dev->dev.parent);
+}
+
 void xen_grant_setup_dma_ops(struct device *dev)
 {
 	struct xen_grant_dma_data *data;
include/xen/xen-ops.h +6 -0
index 80546960f8b7..98c399a960a3 100644
@@ -5,6 +5,7 @@
 #include <linux/percpu.h>
 #include <linux/notifier.h>
 #include <linux/efi.h>
+#include <linux/virtio_anchor.h>
 #include <xen/features.h>
 #include <asm/xen/interface.h>
 #include <xen/interface/vcpu.h>
@@ -217,6 +218,7 @@ static inline void xen_preemptible_hcall_end(void) { }
 #ifdef CONFIG_XEN_GRANT_DMA_OPS
 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);
 #else
 static inline void xen_grant_setup_dma_ops(struct device *dev)
 {
@@ -225,6 +227,10 @@ static inline bool xen_is_grant_dma_device(struct device *dev)
 {
 	return false;
 }
+static inline bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
+	return false;
+}
 #endif /* CONFIG_XEN_GRANT_DMA_OPS */
 
 #endif /* INCLUDE_XEN_OPS_H */
include/xen/xen.h +0 -8
index ac5a144c6a65..a99bab817523 100644
@@ -52,14 +52,6 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 extern u64 xen_saved_max_mem_size;
 #endif
 
-#include <linux/virtio_anchor.h>
-
-static inline void xen_set_restricted_virtio_memory_access(void)
-{
-	if (IS_ENABLED(CONFIG_XEN_VIRTIO) && xen_domain())
-		virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
-}
-
 #ifdef CONFIG_XEN_UNPOPULATED_ALLOC
 int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
 void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
Signature · 1 line
2.35.3
#4 lore raw

Re: [PATCH v3 3/3] xen: don't require virtio with grants for non-PV guests

On 22.06.22 09:38, Juergen Gross wrote:

Hello Juergen

Quoted 17 lines

Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings") introduced a new requirement for using virtio
devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM feature.

This is an undue requirement for non-PV guests, as those can be operated with existing backends without any problem, as long as those backends are running in dom0.

Per default allow virtio devices without grant support for non-PV guests.

On Arm require VIRTIO_F_ACCESS_PLATFORM for devices having been listed in the device tree to use grants.

Add a new config item to always force use of grants for virtio.

Quoted 8 lines
Fixes fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings")

---
V2:
- remove command line parameter (Christoph Hellwig) V3:
- rebase to callback method

Patch looks good, just one NIT ...

Quoted 109 lines
---
  arch/arm/xen/enlighten.c     |  4 +++-
  arch/x86/xen/enlighten_hvm.c |  4 +++-
  arch/x86/xen/enlighten_pv.c  |  5 ++++-
  drivers/xen/Kconfig          |  9 +++++++++
  drivers/xen/grant-dma-ops.c  | 10 ++++++++++
  include/xen/xen-ops.h        |  6 ++++++
  include/xen/xen.h            |  8 --------
  7 files changed, 35 insertions(+), 11 deletions(-)
arch/arm/xen/enlighten.c +3 -1
index 1f9c3ba32833..93c8ccbf2982 100644
@@ -34,6 +34,7 @@
  #include <linux/timekeeping.h>
  #include <linux/timekeeper_internal.h>
  #include <linux/acpi.h>
+#include <linux/virtio_anchor.h>
 
  #include <linux/mm.h>
 
@@ -443,7 +444,8 @@ static int __init xen_guest_init(void)
  	if (!xen_domain())
  		return 0;
 
-	xen_set_restricted_virtio_memory_access();
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO))
+		virtio_set_mem_acc_cb(xen_virtio_mem_acc);
 
  	if (!acpi_disabled)
  		xen_acpi_guest_init();
arch/x86/xen/enlighten_hvm.c +3 -1
index 8b71b1dd7639..28762f800596 100644
@@ -4,6 +4,7 @@
  #include <linux/cpu.h>
  #include <linux/kexec.h>
  #include <linux/memblock.h>
+#include <linux/virtio_anchor.h>
 
  #include <xen/features.h>
  #include <xen/events.h>
@@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)
  	if (xen_pv_domain())
  		return;
 
-	xen_set_restricted_virtio_memory_access();
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+		virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
 
  	init_hvm_pv_info();
 
arch/x86/xen/enlighten_pv.c +4 -1
index e3297b15701c..5aaae8a77f55 100644
@@ -31,6 +31,7 @@
  #include <linux/gfp.h>
  #include <linux/edd.h>
  #include <linux/reboot.h>
+#include <linux/virtio_anchor.h>
 
  #include <xen/xen.h>
  #include <xen/events.h>
@@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
 
  static void __init xen_pv_init_platform(void)
  {
-	xen_set_restricted_virtio_memory_access();
+	/* 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);
 
  	populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
 
drivers/xen/Kconfig +9 -0
index bfd5f4f706bc..a65bd92121a5 100644
@@ -355,4 +355,13 @@ config XEN_VIRTIO
 
  	  If in doubt, say n.
 
+config XEN_VIRTIO_FORCE_GRANT
+	bool "Require Xen virtio support to use grants"
+	depends on XEN_VIRTIO
+	help
+	  Require virtio for Xen guests to use grant mappings.
+	  This will avoid the need to give the backend the right to map all
+	  of the guest memory. This will need support on the backend side
+	  (e.g. qemu or kernel, depending on the virtio device types used).
+
  endmenu
drivers/xen/grant-dma-ops.c +2 -0
index fc0142484001..8973fc1e9ccc 100644
@@ -12,6 +12,8 @@
  #include <linux/of.h>
  #include <linux/pfn.h>
  #include <linux/xarray.h>
+#include <linux/virtio_anchor.h>
+#include <linux/virtio.h>
  #include <xen/xen.h>
  #include <xen/xen-ops.h>
  #include <xen/grant_table.h>

drivers/xen/grant-dma-ops.c bool xen_is_grant_dma_device(struct device *dev) · line 298

Quoted 10 lines
drivers/xen/grant-dma-ops.c +7 -0
@@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)
  	return has_iommu;
  }
 
+bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
+	if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+		return true;
+
+	return xen_is_grant_dma_device(dev->dev.parent);
+}

   ... I am thinking would it be better to move this to xen/xen-ops.h as grant-dma-ops.c is generic (not only for virtio, although the virtio is the first use-case)

drivers/xen/grant-dma-ops.c +0 -0
index 8973fc1..fc01424 100644
@@ -12,8 +12,6 @@

 #include <linux/of.h>
 #include <linux/pfn.h>
 #include <linux/xarray.h>
-#include <linux/virtio_anchor.h>
-#include <linux/virtio.h>
 #include <xen/xen.h>
 #include <xen/xen-ops.h>
 #include <xen/grant_table.h>
@@ -289,14 +287,6 @@ bool xen_is_grant_dma_device(struct device *dev) return has_iommu;
 }

-bool xen_virtio_mem_acc(struct virtio_device *dev) -{
-       if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT)) -               return true;
-
-       return xen_is_grant_dma_device(dev->dev.parent); -}
-
 void xen_grant_setup_dma_ops(struct device *dev) {
        struct xen_grant_dma_data *data;

include/xen/xen-ops.h +0 -0
index 98c399a..a9ae51b 100644
@@ -6,6 +6,7 @@

 #include <linux/notifier.h>
 #include <linux/efi.h>
 #include <linux/virtio_anchor.h>
+#include <linux/virtio.h>
 #include <xen/features.h>
 #include <asm/xen/interface.h>
 #include <xen/interface/vcpu.h>
@@ -218,7 +219,13 @@ static inline void xen_preemptible_hcall_end(void) { } #ifdef CONFIG_XEN_GRANT_DMA_OPS
 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);
+static inline bool xen_virtio_mem_acc(struct virtio_device *dev) +{
+       if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+               return true;
+
+       return xen_is_grant_dma_device(dev->dev.parent);
+}
 #else
 static inline void xen_grant_setup_dma_ops(struct device *dev) {

Quoted 54 lines
drivers/xen/grant-dma-ops.c +1 -0
+
  void xen_grant_setup_dma_ops(struct device *dev)
  {
  	struct xen_grant_dma_data *data;
include/xen/xen-ops.h +6 -0
index 80546960f8b7..98c399a960a3 100644
@@ -5,6 +5,7 @@
  #include <linux/percpu.h>
  #include <linux/notifier.h>
  #include <linux/efi.h>
+#include <linux/virtio_anchor.h>
  #include <xen/features.h>
  #include <asm/xen/interface.h>
  #include <xen/interface/vcpu.h>
@@ -217,6 +218,7 @@ static inline void xen_preemptible_hcall_end(void) { }
  #ifdef CONFIG_XEN_GRANT_DMA_OPS
  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);
  #else
  static inline void xen_grant_setup_dma_ops(struct device *dev)
  {
@@ -225,6 +227,10 @@ static inline bool xen_is_grant_dma_device(struct device *dev)
  {
  	return false;
  }
+static inline bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
+	return false;
+}
  #endif /* CONFIG_XEN_GRANT_DMA_OPS */
 
  #endif /* INCLUDE_XEN_OPS_H */
include/xen/xen.h +0 -8
index ac5a144c6a65..a99bab817523 100644
@@ -52,14 +52,6 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
  extern u64 xen_saved_max_mem_size;
  #endif
 
-#include <linux/virtio_anchor.h>
-
-static inline void xen_set_restricted_virtio_memory_access(void)
-{
-	if (IS_ENABLED(CONFIG_XEN_VIRTIO) && xen_domain())
-		virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
-}
-
  #ifdef CONFIG_XEN_UNPOPULATED_ALLOC
  int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
  void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
Signature · 3 lines
Regards,

Oleksandr Tyshchenko
author maintainer
#5 lore raw

Re: [PATCH v3 3/3] xen: don't require virtio with grants for non-PV guests

Quoted 135 lines · Oleksandr

On 22.06.22 09:38, Juergen Gross wrote:

Hello Juergen

Quoted 17 lines

Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings") introduced a new requirement for using virtio
devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM feature.

This is an undue requirement for non-PV guests, as those can be operated with existing backends without any problem, as long as those backends are running in dom0.

Per default allow virtio devices without grant support for non-PV guests.

On Arm require VIRTIO_F_ACCESS_PLATFORM for devices having been listed in the device tree to use grants.

Add a new config item to always force use of grants for virtio.

Quoted 8 lines
Fixes fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings")

---
V2:
- remove command line parameter (Christoph Hellwig) V3:
- rebase to callback method

Patch looks good, just one NIT ...

Quoted 100 lines

---
  arch/arm/xen/enlighten.c     |  4 +++-
  arch/x86/xen/enlighten_hvm.c |  4 +++-
  arch/x86/xen/enlighten_pv.c  |  5 ++++-
  drivers/xen/Kconfig          |  9 +++++++++
  drivers/xen/grant-dma-ops.c  | 10 ++++++++++
  include/xen/xen-ops.h        |  6 ++++++
  include/xen/xen.h            |  8 --------

  7 files changed, 35 insertions(+), 11 deletions(-)
arch/arm/xen/enlighten.c +3 -1
index 1f9c3ba32833..93c8ccbf2982 100644
@@ -34,6 +34,7 @@
   #include <linux/timekeeping.h>
   #include <linux/timekeeper_internal.h>
   #include <linux/acpi.h>
+#include <linux/virtio_anchor.h>
   #include <linux/mm.h>
@@ -443,7 +444,8 @@ static int __init xen_guest_init(void)
       if (!xen_domain())
           return 0;
-    xen_set_restricted_virtio_memory_access();
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO))
+        virtio_set_mem_acc_cb(xen_virtio_mem_acc);
       if (!acpi_disabled)
           xen_acpi_guest_init();
arch/x86/xen/enlighten_hvm.c +3 -1
index 8b71b1dd7639..28762f800596 100644
@@ -4,6 +4,7 @@
   #include <linux/cpu.h>
   #include <linux/kexec.h>
   #include <linux/memblock.h>
+#include <linux/virtio_anchor.h>
   #include <xen/features.h>
   #include <xen/events.h>
@@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)
       if (xen_pv_domain())
           return;
-    xen_set_restricted_virtio_memory_access();
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+        virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
       init_hvm_pv_info();
arch/x86/xen/enlighten_pv.c +4 -1
index e3297b15701c..5aaae8a77f55 100644
@@ -31,6 +31,7 @@
   #include <linux/gfp.h>
   #include <linux/edd.h>
   #include <linux/reboot.h>
+#include <linux/virtio_anchor.h>
   #include <xen/xen.h>
   #include <xen/events.h>
@@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
   static void __init xen_pv_init_platform(void)
   {
-    xen_set_restricted_virtio_memory_access();
+    /* 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);
       populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
drivers/xen/Kconfig +0 -0
index bfd5f4f706bc..a65bd92121a5 100644
@@ -355,4 +355,13 @@ config XEN_VIRTIO

        If in doubt, say n.

drivers/xen/Kconfig +9 -0
+config XEN_VIRTIO_FORCE_GRANT
+    bool "Require Xen virtio support to use grants"
+    depends on XEN_VIRTIO
+    help
+      Require virtio for Xen guests to use grant mappings.
+      This will avoid the need to give the backend the right to map all
+      of the guest memory. This will need support on the backend side
+      (e.g. qemu or kernel, depending on the virtio device types used).
+

  endmenu

drivers/xen/grant-dma-ops.c +5 -0
index fc0142484001..8973fc1e9ccc 100644
@@ -12,6 +12,8 @@
   #include <linux/of.h>
   #include <linux/pfn.h>
   #include <linux/xarray.h>
+#include <linux/virtio_anchor.h>
+#include <linux/virtio.h>
   #include <xen/xen.h>
   #include <xen/xen-ops.h>
   #include <xen/grant_table.h>
@@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)
       return has_iommu;
   }
+bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
Quoted 8 lines

drivers/xen/grant-dma-ops.c bool xen_is_grant_dma_device(struct device *dev) · line 297

Quoted 4 lines
drivers/xen/grant-dma-ops.c +4 -0
+        return true;
+
+    return xen_is_grant_dma_device(dev->dev.parent);
+}

   ... I am thinking would it be better to move this to xen/xen-ops.h as
grant-dma-ops.c is generic (not only for virtio, although the virtio is the first use-case)

I dislike using a function marked as inline in a function vector.

We could add another module "xen-virtio" for this purpose, but this seems to be overkill.

I think we should just leave it here and move it later in case more real virtio dependent stuff is being added.

Juergen

Reviewed-by Oleksandr Tyshchenko
#6 lore raw

Re: [PATCH v3 3/3] xen: don't require virtio with grants for non-PV guests

On 22.06.22 17:35, Juergen Gross wrote:

Hello Juergen

Quoted 147 lines · Oleksandr
Quoted 137 lines · Juergen Gross

Hello Juergen

Quoted 17 lines

Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings") introduced a new requirement for using virtio
devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM feature.

This is an undue requirement for non-PV guests, as those can be operated with existing backends without any problem, as long as those backends are running in dom0.

Per default allow virtio devices without grant support for non-PV guests.

On Arm require VIRTIO_F_ACCESS_PLATFORM for devices having been listed in the device tree to use grants.

Add a new config item to always force use of grants for virtio.

Quoted 8 lines
Fixes fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings")

---
V2:
- remove command line parameter (Christoph Hellwig) V3:
- rebase to callback method

Patch looks good, just one NIT ...

Quoted 102 lines

---
  arch/arm/xen/enlighten.c     |  4 +++-
  arch/x86/xen/enlighten_hvm.c |  4 +++-
  arch/x86/xen/enlighten_pv.c  |  5 ++++-
  drivers/xen/Kconfig          |  9 +++++++++
  drivers/xen/grant-dma-ops.c  | 10 ++++++++++
  include/xen/xen-ops.h        |  6 ++++++
  include/xen/xen.h            |  8 --------

  7 files changed, 35 insertions(+), 11 deletions(-)
arch/arm/xen/enlighten.c +3 -1
index 1f9c3ba32833..93c8ccbf2982 100644
@@ -34,6 +34,7 @@
   #include <linux/timekeeping.h>
   #include <linux/timekeeper_internal.h>
   #include <linux/acpi.h>
+#include <linux/virtio_anchor.h>
   #include <linux/mm.h>
@@ -443,7 +444,8 @@ static int __init xen_guest_init(void)
       if (!xen_domain())
           return 0;
-    xen_set_restricted_virtio_memory_access();
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO))
+        virtio_set_mem_acc_cb(xen_virtio_mem_acc);
       if (!acpi_disabled)
           xen_acpi_guest_init();
arch/x86/xen/enlighten_hvm.c +3 -1
index 8b71b1dd7639..28762f800596 100644
@@ -4,6 +4,7 @@
   #include <linux/cpu.h>
   #include <linux/kexec.h>
   #include <linux/memblock.h>
+#include <linux/virtio_anchor.h>
   #include <xen/features.h>
   #include <xen/events.h>
@@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)
       if (xen_pv_domain())
           return;
-    xen_set_restricted_virtio_memory_access();
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+ virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
       init_hvm_pv_info();
arch/x86/xen/enlighten_pv.c +4 -1
index e3297b15701c..5aaae8a77f55 100644
@@ -31,6 +31,7 @@
   #include <linux/gfp.h>
   #include <linux/edd.h>
   #include <linux/reboot.h>
+#include <linux/virtio_anchor.h>
   #include <xen/xen.h>
   #include <xen/events.h>
@@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, 
 shadow_tls_desc);
   static void __init xen_pv_init_platform(void)
   {
-    xen_set_restricted_virtio_memory_access();
+    /* 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);
       populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
drivers/xen/Kconfig +0 -0
index bfd5f4f706bc..a65bd92121a5 100644
@@ -355,4 +355,13 @@ config XEN_VIRTIO

        If in doubt, say n.
+config XEN_VIRTIO_FORCE_GRANT
+    bool "Require Xen virtio support to use grants"
+    depends on XEN_VIRTIO
+    help
+      Require virtio for Xen guests to use grant mappings. +      This will avoid the need to give the backend the right to map all
+      of the guest memory. This will need support on the backend side +      (e.g. qemu or kernel, depending on the virtio device types used).
+
  endmenu

drivers/xen/grant-dma-ops.c +4 -0
index fc0142484001..8973fc1e9ccc 100644
@@ -12,6 +12,8 @@
   #include <linux/of.h>
   #include <linux/pfn.h>
   #include <linux/xarray.h>
+#include <linux/virtio_anchor.h>
+#include <linux/virtio.h>
   #include <xen/xen.h>
   #include <xen/xen-ops.h>
   #include <xen/grant_table.h>
@@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)
       return has_iommu;
   }
+bool xen_virtio_mem_acc(struct virtio_device *dev)
+{
Quoted 8 lines

drivers/xen/grant-dma-ops.c bool xen_is_grant_dma_device(struct device *dev) · line 297

Quoted 5 lines
drivers/xen/grant-dma-ops.c +5 -0
+    if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
+        return true;
+
+    return xen_is_grant_dma_device(dev->dev.parent);
+}

    ... I am thinking would it be better to move this to xen/xen-ops.h as grant-dma-ops.c is generic (not only for virtio, although the virtio is the first use-case)

Quoted 7 lines

I dislike using a function marked as inline in a function vector.

We could add another module "xen-virtio" for this purpose, but this seems to be overkill.

I think we should just leave it here and move it later in case more real virtio dependent stuff is being added.

I am happy with that explanation.

Quoted 4 lines

Juergen

Signature · 3 lines
Regards,

Oleksandr Tyshchenko
Tested-by Oleksandr Tyshchenko on the v3 series
#7 lore raw
In reply to Juergen Gross

On 22.06.22 09:38, Juergen Gross wrote:

Hello Juergen

Quoted 33 lines

Instead of an all or nothing approach add support for requiring restricted memory access per device.

Changes in V3:
- new patches 1 + 2
- basically complete rework of patch 3

Juergen Gross (3):
virtio: replace restricted mem access flag with callback
kernel: remove platform_has() infrastructure
xen: don't require virtio with grants for non-PV guests

  MAINTAINERS                            |  8 --------
  arch/arm/xen/enlighten.c               |  4 +++-
  arch/s390/mm/init.c                    |  4 ++--
  arch/x86/mm/mem_encrypt_amd.c          |  4 ++--
  arch/x86/xen/enlighten_hvm.c           |  4 +++-
  arch/x86/xen/enlighten_pv.c            |  5 ++++-
  drivers/virtio/Kconfig                 |  4 ++++
  drivers/virtio/Makefile                |  1 +
  drivers/virtio/virtio.c                |  4 ++--
  drivers/virtio/virtio_anchor.c         | 18 +++++++++++++++++
  drivers/xen/Kconfig                    |  9 +++++++++
  drivers/xen/grant-dma-ops.c            | 10 ++++++++++
  include/asm-generic/Kbuild             |  1 -
  include/asm-generic/platform-feature.h |  8 --------
  include/linux/platform-feature.h       | 19 ------------------
  include/linux/virtio_anchor.h          | 19 ++++++++++++++++++
  include/xen/xen-ops.h                  |  6 ++++++
  include/xen/xen.h                      |  8 --------
  kernel/Makefile                        |  2 +-
  kernel/platform-feature.c              | 27 --------------------------
  20 files changed, 84 insertions(+), 81 deletions(-)
Quoted 5 lines

create mode 100644 drivers/virtio/virtio_anchor.c delete mode 100644 include/asm-generic/platform-feature.h delete mode 100644 include/linux/platform-feature.h create mode 100644 include/linux/virtio_anchor.h delete mode 100644 kernel/platform-feature.c

I have tested the series on Arm64 guest using Xen hypervisor and didn't notice any issues.

I assigned two virtio-mmio devices to the guest:
#1 - grant dma device (required DT binding is present, so xen_is_grant_dma_device() returns true), virtio-mmio modern transport (backend offers VIRTIO_F_VERSION_1, VIRTIO_F_ACCESS_PLATFORM) #2 - non grant dma device (required DT binding is absent, so xen_is_grant_dma_device() returns false), virtio-mmio legacy transport (backend does not offer these flags)

# CONFIG_XEN_VIRTIO is not set

both works, and both do not use grant mappings for virtio

CONFIG_XEN_VIRTIO=y
# CONFIG_XEN_VIRTIO_FORCE_GRANT is not set

both works, #1 uses grant mappings for virtio, #2 does not use it

CONFIG_XEN_VIRTIO=y
CONFIG_XEN_VIRTIO_FORCE_GRANT=y

only #1 works and uses grant mappings for virtio, #2 was rejected by validation in virtio_features_ok()

You can add my:

Quoted 1 line
Signature · 3 lines
Regards,

Oleksandr Tyshchenko
maintainer Reviewed-by on the v3 series
#8 lore raw
In reply to Juergen Gross
Quoted 11 lines · Juergen Gross

Instead of an all or nothing approach add support for requiring restricted memory access per device.

Changes in V3:
- new patches 1 + 2
- basically complete rework of patch 3

Juergen Gross (3):
virtio: replace restricted mem access flag with callback
kernel: remove platform_has() infrastructure
xen: don't require virtio with grants for non-PV guests

On the whole series:

Quoted 36 lines
 MAINTAINERS                            |  8 --------
 arch/arm/xen/enlighten.c               |  4 +++-
 arch/s390/mm/init.c                    |  4 ++--
 arch/x86/mm/mem_encrypt_amd.c          |  4 ++--
 arch/x86/xen/enlighten_hvm.c           |  4 +++-
 arch/x86/xen/enlighten_pv.c            |  5 ++++-
 drivers/virtio/Kconfig                 |  4 ++++
 drivers/virtio/Makefile                |  1 +
 drivers/virtio/virtio.c                |  4 ++--
 drivers/virtio/virtio_anchor.c         | 18 +++++++++++++++++
 drivers/xen/Kconfig                    |  9 +++++++++
 drivers/xen/grant-dma-ops.c            | 10 ++++++++++
 include/asm-generic/Kbuild             |  1 -
 include/asm-generic/platform-feature.h |  8 --------
 include/linux/platform-feature.h       | 19 ------------------
 include/linux/virtio_anchor.h          | 19 ++++++++++++++++++
 include/xen/xen-ops.h                  |  6 ++++++
 include/xen/xen.h                      |  8 --------
 kernel/Makefile                        |  2 +-
 kernel/platform-feature.c              | 27 --------------------------
 20 files changed, 84 insertions(+), 81 deletions(-)
 create mode 100644 drivers/virtio/virtio_anchor.c
 delete mode 100644 include/asm-generic/platform-feature.h
 delete mode 100644 include/linux/platform-feature.h
 create mode 100644 include/linux/virtio_anchor.h
 delete mode 100644 kernel/platform-feature.c
Signature · 7 lines
2.35.3


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#9 lore raw
In reply to Juergen Gross
Quoted 11 lines · Juergen Gross

Instead of an all or nothing approach add support for requiring restricted memory access per device.

Changes in V3:
- new patches 1 + 2
- basically complete rework of patch 3

Juergen Gross (3):
virtio: replace restricted mem access flag with callback
kernel: remove platform_has() infrastructure
xen: don't require virtio with grants for non-PV guests

Any further comments?

Juergen