David Hildenbrand
2021-Aug-31 20:21 UTC
[PATCH v3 0/3] virtio-mem: disallow mapping virtio-mem memory via /dev/mem
I think this might be a good fit for the -mm tree, as the actual virtio-mem changes are rather small. -- Let's add the basic infrastructure to exclude some physical memory regions marked as "IORESOURCE_SYSTEM_RAM" completely from /dev/mem access, even though they are not marked IORESOURCE_BUSY and even though "iomem=relaxed" is set. Resource IORESOURCE_EXCLUSIVE for that purpose instead of adding new flags to express something similar to "soft-busy" or "not busy yet, but already prepared by a driver and not to be mapped by user space". Use it for virtio-mem, to disallow mapping any virtio-mem memory via /dev/mem to user space after the virtio-mem driver was loaded. Details can be found in patch #2 and #3. v2 -> v3: - "kernel/resource: clean up and optimize iomem_is_exclusive()" -- Reshuffled and moved for_each_resource() etc. into this patch - "kernel/resource: disallow access to exclusive system RAM regions" -- Leave CONFIG_STRICT_DEVMEM=n alone. Hoog into iomem_is_exclusive() instead. -- Improve comments - "virtio-mem: disallow mapping virtio-mem memory via /dev/mem" -- Don't allow building virtio_mem without CONFIG_STRICT_DEVMEM when we have CONFIG_DEVMEM, where we don't have any guarantees. - Rework all patch descriptions v1 -> v2: - "/dev/mem: disallow access to explicitly excluded system RAM regions" -- Introduce and use for_each_resource() and next_resource_skip_children() -- s/iomem_range_contains_excluded/iomem_range_contains_excluded_devmem/ - "kernel/resource: cleanup and optimize iomem_is_exclusive()" -- Use for_each_resource() Cc: Arnd Bergmann <arnd at arndb.de> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org> Cc: "Michael S. Tsirkin" <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Cc: "Rafael J. Wysocki" <rafael.j.wysocki at intel.com> Cc: Andrew Morton <akpm at linux-foundation.org> Cc: Dan Williams <dan.j.williams at intel.com> Cc: Hanjun Guo <guohanjun at huawei.com> Cc: Andy Shevchenko <andy.shevchenko at gmail.com> Cc: virtualization at lists.linux-foundation.org Cc: linux-mm at kvack.org David Hildenbrand (3): kernel/resource: clean up and optimize iomem_is_exclusive() kernel/resource: disallow access to exclusive system RAM regions virtio-mem: disallow mapping virtio-mem memory via /dev/mem drivers/virtio/Kconfig | 1 + drivers/virtio/virtio_mem.c | 4 ++- kernel/resource.c | 54 ++++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 16 deletions(-) base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f -- 2.31.1