virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE

Support the VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE feature in virtio-mem, now
 that "accidential" access to logically unplugged memory inside added
 Linux memory blocks is no longer possible, because we:
 
 1. Removed /dev/kmem in commit bbcd53c960 ("drivers/char: remove
    /dev/kmem for good")
 2. Disallowed access to virtio-mem device memory via /dev/mem in commit
    2128f4e21a ("virtio-mem: disallow mapping virtio-mem memory via
    /dev/mem")
 3. Sanitized access to virtio-mem device memory via /proc/kcore in
    commit 0daa322b8f ("fs/proc/kcore: don't read offline sections,
    logically offline pages and hwpoisoned pages")
 4. Sanitized access to virtio-mem device memory via /proc/vmcore in
    commit ce2814622e ("virtio-mem: kdump mode to sanitize /proc/vmcore
    access")
 
 The new VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE feature that will be required
 by some hypervisors implementing virtio-mem in the near future, so let's
 support it now that we safely can.
 
 Signed-off-by: David Hildenbrand <david@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEG9nKrXNcTDpGDfzKTd4Q9wD/g1oFAmGL2C8RHGRhdmlkQHJl
 ZGhhdC5jb20ACgkQTd4Q9wD/g1r2QA/+IdGIOX8TcFqsCYwf8YK9Lt3HyyabFVvJ
 WzIdWvCLlrbKIQDi7suAVlQlTOccFtjWSUJNd2B6Sk6GzlRGeySabZZMhKEzcUQL
 vTEtDoLsuKUzZRuNHzyK2FUemevTavZ+O+F4Gk6gg0X5drqhOlPyfJwp/FuNnBCl
 KuMzYlre//62Uq/Be0+OlYS4rmfmVRfY6KSJmy9EudmMv7py3YTpz2Pa8WcrTntd
 ClsdL65xCUdit5xTB4foApSOGplN6mjE04DAYpcAH5FUNLrsgE4sa9odtO0SQyfv
 ZAT/zrWPksqN5ZsgEgKo/SnAsAySylPzSMzUGzrsWaThOmwqJvCLZNorUrqKXrVs
 7D7mW4SlXU3joaF8vW6AXuLAq8S53l9ULx1vAHoU1d1otmLr/erMq85Ziko2muoM
 gr5IuqN0uTrPO6cvK6bAJIbm2TYoSEp+yUwauMGfS0Rg0oIWLiDa9KJlBkQK9AN1
 zTddrRZq21suuxgtUZNaGSzvNJPqNCVZW2UYcjr/zr5MOIyQpK7z6hViWDNUCywn
 4kKGN+imWBkAFbv+uJTcDqR2NCXWdDCK2gU6dwfZ7F1lfV/oPK8JhZpA1A9gHmY6
 FSwSCqKQJBUgvhyeQr6fuOjl1PoWVGNGHrxr8u4ID6uReyVu7y4GoOKbA3epAqO2
 WfZ58Xx62BM=
 =gxVD
 -----END PGP SIGNATURE-----

Merge tag 'virtio-mem-for-5.16' of git://github.com/davidhildenbrand/linux

Pull virtio-mem update from David Hildenbrand:
 "Support the VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE feature in virtio-mem,
  now that "accidential" access to logically unplugged memory inside
  added Linux memory blocks is no longer possible, because we:

   - Removed /dev/kmem in commit bbcd53c960 ("drivers/char: remove
     /dev/kmem for good")

   - Disallowed access to virtio-mem device memory via /dev/mem in
     commit 2128f4e21a ("virtio-mem: disallow mapping virtio-mem memory
     via /dev/mem")

   - Sanitized access to virtio-mem device memory via /proc/kcore in
     commit 0daa322b8f ("fs/proc/kcore: don't read offline sections,
     logically offline pages and hwpoisoned pages")

   - Sanitized access to virtio-mem device memory via /proc/vmcore in
     commit ce2814622e ("virtio-mem: kdump mode to sanitize
     /proc/vmcore access")

  The new VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE feature that will be
  required by some hypervisors implementing virtio-mem in the near
  future, so let's support it now that we safely can"

* tag 'virtio-mem-for-5.16' of git://github.com/davidhildenbrand/linux:
  virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
This commit is contained in:
Linus Torvalds 2021-11-13 13:14:05 -08:00
commit ccfff0a2bd
2 changed files with 7 additions and 3 deletions

View File

@ -2889,6 +2889,7 @@ static unsigned int virtio_mem_features[] = {
#if defined(CONFIG_NUMA) && defined(CONFIG_ACPI_NUMA)
VIRTIO_MEM_F_ACPI_PXM,
#endif
VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE,
};
static const struct virtio_device_id virtio_mem_id_table[] = {

View File

@ -68,9 +68,10 @@
* explicitly triggered (VIRTIO_MEM_REQ_UNPLUG).
*
* There are no guarantees what will happen if unplugged memory is
* read/written. Such memory should, in general, not be touched. E.g.,
* even writing might succeed, but the values will simply be discarded at
* random points in time.
* read/written. In general, unplugged memory should not be touched, because
* the resulting action is undefined. There is one exception: without
* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable
* region can be read, to simplify creation of memory dumps.
*
* It can happen that the device cannot process a request, because it is
* busy. The device driver has to retry later.
@ -87,6 +88,8 @@
/* node_id is an ACPI PXM and is valid */
#define VIRTIO_MEM_F_ACPI_PXM 0
/* unplugged memory must not be accessed */
#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1
/* --- virtio-mem: guest -> host requests --- */