lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 16 Oct 2020 17:07:29 +0800
From:   Wei Yang <richard.weiyang@...ux.alibaba.com>
To:     David Hildenbrand <david@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        virtualization@...ts.linux-foundation.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        Pankaj Gupta <pankaj.gupta.linux@...il.com>
Subject: Re: [PATCH v1 24/29] virtio-mem: print debug messages from
 virtio_mem_send_*_request()

On Mon, Oct 12, 2020 at 02:53:18PM +0200, David Hildenbrand wrote:
>Let's move the existing dev_dbg() into the functions, print if something
>went wrong, and also print for virtio_mem_send_unplug_all_request().
>
>Cc: "Michael S. Tsirkin" <mst@...hat.com>
>Cc: Jason Wang <jasowang@...hat.com>
>Cc: Pankaj Gupta <pankaj.gupta.linux@...il.com>
>Signed-off-by: David Hildenbrand <david@...hat.com>

Reviewed-by: Wei Yang <richard.weiyang@...ux.alibaba.com>

>---
> drivers/virtio/virtio_mem.c | 50 ++++++++++++++++++++++++++-----------
> 1 file changed, 35 insertions(+), 15 deletions(-)
>
>diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
>index eb2ad31a8d8a..e68d0d99590c 100644
>--- a/drivers/virtio/virtio_mem.c
>+++ b/drivers/virtio/virtio_mem.c
>@@ -1053,23 +1053,33 @@ static int virtio_mem_send_plug_request(struct virtio_mem *vm, uint64_t addr,
> 		.u.plug.addr = cpu_to_virtio64(vm->vdev, addr),
> 		.u.plug.nb_blocks = cpu_to_virtio16(vm->vdev, nb_vm_blocks),
> 	};
>+	int rc = -ENOMEM;
> 
> 	if (atomic_read(&vm->config_changed))
> 		return -EAGAIN;
> 
>+	dev_dbg(&vm->vdev->dev, "plugging memory: 0x%llx - 0x%llx\n", addr,
>+		addr + size - 1);
>+
> 	switch (virtio_mem_send_request(vm, &req)) {
> 	case VIRTIO_MEM_RESP_ACK:
> 		vm->plugged_size += size;
> 		return 0;
> 	case VIRTIO_MEM_RESP_NACK:
>-		return -EAGAIN;
>+		rc = -EAGAIN;
>+		break;
> 	case VIRTIO_MEM_RESP_BUSY:
>-		return -ETXTBSY;
>+		rc = -ETXTBSY;
>+		break;
> 	case VIRTIO_MEM_RESP_ERROR:
>-		return -EINVAL;
>+		rc = -EINVAL;
>+		break;
> 	default:
>-		return -ENOMEM;
>+		break;
> 	}
>+
>+	dev_dbg(&vm->vdev->dev, "plugging memory failed: %d\n", rc);
>+	return rc;
> }
> 
> static int virtio_mem_send_unplug_request(struct virtio_mem *vm, uint64_t addr,
>@@ -1081,21 +1091,30 @@ static int virtio_mem_send_unplug_request(struct virtio_mem *vm, uint64_t addr,
> 		.u.unplug.addr = cpu_to_virtio64(vm->vdev, addr),
> 		.u.unplug.nb_blocks = cpu_to_virtio16(vm->vdev, nb_vm_blocks),
> 	};
>+	int rc = -ENOMEM;
> 
> 	if (atomic_read(&vm->config_changed))
> 		return -EAGAIN;
> 
>+	dev_dbg(&vm->vdev->dev, "unplugging memory: 0x%llx - 0x%llx\n", addr,
>+		addr + size - 1);
>+
> 	switch (virtio_mem_send_request(vm, &req)) {
> 	case VIRTIO_MEM_RESP_ACK:
> 		vm->plugged_size -= size;
> 		return 0;
> 	case VIRTIO_MEM_RESP_BUSY:
>-		return -ETXTBSY;
>+		rc = -ETXTBSY;
>+		break;
> 	case VIRTIO_MEM_RESP_ERROR:
>-		return -EINVAL;
>+		rc = -EINVAL;
>+		break;
> 	default:
>-		return -ENOMEM;
>+		break;
> 	}
>+
>+	dev_dbg(&vm->vdev->dev, "unplugging memory failed: %d\n", rc);
>+	return rc;
> }
> 
> static int virtio_mem_send_unplug_all_request(struct virtio_mem *vm)
>@@ -1103,6 +1122,9 @@ static int virtio_mem_send_unplug_all_request(struct virtio_mem *vm)
> 	const struct virtio_mem_req req = {
> 		.type = cpu_to_virtio16(vm->vdev, VIRTIO_MEM_REQ_UNPLUG_ALL),
> 	};
>+	int rc = -ENOMEM;
>+
>+	dev_dbg(&vm->vdev->dev, "unplugging all memory");
> 
> 	switch (virtio_mem_send_request(vm, &req)) {
> 	case VIRTIO_MEM_RESP_ACK:
>@@ -1112,10 +1134,14 @@ static int virtio_mem_send_unplug_all_request(struct virtio_mem *vm)
> 		atomic_set(&vm->config_changed, 1);
> 		return 0;
> 	case VIRTIO_MEM_RESP_BUSY:
>-		return -ETXTBSY;
>+		rc = -ETXTBSY;
>+		break;
> 	default:
>-		return -ENOMEM;
>+		break;
> 	}
>+
>+	dev_dbg(&vm->vdev->dev, "unplugging all memory failed: %d\n", rc);
>+	return rc;
> }
> 
> /*
>@@ -1130,9 +1156,6 @@ static int virtio_mem_sbm_plug_sb(struct virtio_mem *vm, unsigned long mb_id,
> 	const uint64_t size = count * vm->sbm.sb_size;
> 	int rc;
> 
>-	dev_dbg(&vm->vdev->dev, "plugging memory block: %lu : %i - %i\n", mb_id,
>-		sb_id, sb_id + count - 1);
>-
> 	rc = virtio_mem_send_plug_request(vm, addr, size);
> 	if (!rc)
> 		virtio_mem_sbm_set_sb_plugged(vm, mb_id, sb_id, count);
>@@ -1151,9 +1174,6 @@ static int virtio_mem_sbm_unplug_sb(struct virtio_mem *vm, unsigned long mb_id,
> 	const uint64_t size = count * vm->sbm.sb_size;
> 	int rc;
> 
>-	dev_dbg(&vm->vdev->dev, "unplugging memory block: %lu : %i - %i\n",
>-		mb_id, sb_id, sb_id + count - 1);
>-
> 	rc = virtio_mem_send_unplug_request(vm, addr, size);
> 	if (!rc)
> 		virtio_mem_sbm_set_sb_unplugged(vm, mb_id, sb_id, count);
>-- 
>2.26.2

-- 
Wei Yang
Help you, Help me

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ