Skip to content

virtio-mem: disallow mapping virtio-mem memory via /dev/mem

David Hildenbrand linux-mm lkml virtualization 5 versions – Applied

Status from this message: [merged] virtio-mem-disallow-mapping-virtio-mem-memory-via-dev-mem.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 0 repliesApplied 3/3
  2. v43 patches 5 repliesSuperseded
  3. v33 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v23 patches5 repliesSuperseded
v13 patches6 repliesSuperseded

Changes in v5 from the cover letter

- "kernel/resource: disallow access to exclusive system RAM regions" -- Add CONFIG_EXCLUSIVE_SYSTEM_RAM
- "virtio-mem: disallow mapping virtio-mem memory via /dev/mem" -- Use CONFIG_EXCLUSIVE_SYSTEM_RAM
-- Add ACK from MST

Patches in v5 All 3 applied

#Subject and filesSizeRepliesApplied
1/3kernel/resource: clean up and optimize iomem_is_exclusive()kernel/resource.c+20 -50 repliesApplied
2/3kernel/resource: disallow access to exclusive system RAM regionskernel/resource.c mm/Kconfig+26 -100 repliesApplied
3/3virtio-mem: disallow mapping virtio-mem memory via /dev/memdrivers/virtio/Kconfig drivers/virtio/virtio_mem.c+4 -10 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDan WilliamsMichael S. Tsirkin
1/3R-b
2/3R-b
3/3R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/3] virtio-mem: disallow mapping virtio-mem memory via /dev/mem

@Andrew, can you take this via the -mm tree?

--

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.

v4 -> v5:
- "kernel/resource: disallow access to exclusive system RAM regions" -- Add CONFIG_EXCLUSIVE_SYSTEM_RAM
- "virtio-mem: disallow mapping virtio-mem memory via /dev/mem" -- Use CONFIG_EXCLUSIVE_SYSTEM_RAM
-- Add ACK from MST

v3 -> v4:
- Added Dans RBs (thanks!)
- Actually send the patches to the CC list ...

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 <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Dan Williams <[email protected]>
Cc Hanjun Guo <[email protected]>
Cc Andy Shevchenko <[email protected]>

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 ++++++++++++++++++++++++++-----------
 mm/Kconfig                  |  7 +++++
 4 files changed, 50 insertions(+), 16 deletions(-)

base-commit: e4e737bb5c170df6135a127739a9e6148ee3da82

Signature · 1 line
2.31.1