diff options
author | David Hildenbrand <david@redhat.com> | 2020-11-12 16:37:59 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2020-12-19 00:14:26 +0300 |
commit | 835491c554fbdbc18452f4b1546df21879b8b26d (patch) | |
tree | 12a3d7b05ea24689828b3581d1737778576990d2 /drivers/virtio/virtio_mem.c | |
parent | 8464e3bdf208e86410e369601ca363b2a81683e3 (diff) | |
download | linux-835491c554fbdbc18452f4b1546df21879b8b26d.tar.xz |
virtio-mem: generalize virtio_mem_overlaps_range()
Avoid using memory block ids. While at it, use uint64_t for
address/size.
This is a preparation for Big Block Mode (BBM).
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20201112133815.13332-14-david@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio_mem.c')
-rw-r--r-- | drivers/virtio/virtio_mem.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 2193c5172195..bd76aa79a82e 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -501,14 +501,10 @@ static int virtio_mem_translate_node_id(struct virtio_mem *vm, uint16_t node_id) * Test if a virtio-mem device overlaps with the given range. Can be called * from (notifier) callbacks lockless. */ -static bool virtio_mem_overlaps_range(struct virtio_mem *vm, - unsigned long start, unsigned long size) +static bool virtio_mem_overlaps_range(struct virtio_mem *vm, uint64_t start, + uint64_t size) { - unsigned long dev_start = virtio_mem_mb_id_to_phys(vm->first_mb_id); - unsigned long dev_end = virtio_mem_mb_id_to_phys(vm->last_mb_id) + - memory_block_size_bytes(); - - return start < dev_end && dev_start < start + size; + return start < vm->addr + vm->region_size && vm->addr < start + size; } /* |