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]
Message-ID: <20221221133026.s56fitht7dx4n3lo@sgarzare-redhat>
Date:   Wed, 21 Dec 2022 14:30:26 +0100
From:   Stefano Garzarella <sgarzare@...hat.com>
To:     Jason Wang <jasowang@...hat.com>
Cc:     mst@...hat.com, eperezma@...hat.com,
        virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] vdpasim: customize allocation size

On Wed, Dec 21, 2022 at 02:16:50PM +0800, Jason Wang wrote:
>Allow individual simulator to customize the allocation size.
>
>Signed-off-by: Jason Wang <jasowang@...hat.com>
>---
> drivers/vdpa/vdpa_sim/vdpa_sim.c     | 8 ++++++--
> drivers/vdpa/vdpa_sim/vdpa_sim.h     | 1 +
> drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 1 +
> drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 1 +
> 4 files changed, 9 insertions(+), 2 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@...hat.com>

>
>diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>index 757afef86ba0..55aaa023a6e2 100644
>--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>@@ -253,7 +253,10 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr,
> 	struct vdpa_device *vdpa;
> 	struct vdpasim *vdpasim;
> 	struct device *dev;
>-	int i, ret = -ENOMEM;
>+	int i, ret = -EINVAL;
>+
>+	if (!dev_attr->alloc_size)
>+		goto err_alloc;
>
> 	if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) {
> 		if (config->device_features &
>@@ -268,9 +271,10 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr,
> 	else
> 		ops = &vdpasim_config_ops;
>
>+	ret = -ENOMEM;
> 	vdpa = __vdpa_alloc_device(NULL, ops,
> 				   dev_attr->ngroups, dev_attr->nas,
>-				   sizeof(struct vdpasim),
>+				   dev_attr->alloc_size,
> 				   dev_attr->name, false);
> 	if (IS_ERR(vdpa)) {
> 		ret = PTR_ERR(vdpa);
>diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h
>index 0e78737dcc16..51c070a543f1 100644
>--- a/drivers/vdpa/vdpa_sim/vdpa_sim.h
>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h
>@@ -37,6 +37,7 @@ struct vdpasim_dev_attr {
> 	struct vdpa_mgmt_dev *mgmt_dev;
> 	const char *name;
> 	u64 supported_features;
>+	size_t alloc_size;
> 	size_t config_size;
> 	size_t buffer_size;
> 	int nvqs;
>diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
>index c6db1a1baf76..4f7c35f59aa5 100644
>--- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
>@@ -378,6 +378,7 @@ static int vdpasim_blk_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
> 	dev_attr.nvqs = VDPASIM_BLK_VQ_NUM;
> 	dev_attr.ngroups = VDPASIM_BLK_GROUP_NUM;
> 	dev_attr.nas = VDPASIM_BLK_AS_NUM;
>+	dev_attr.alloc_size = sizeof(struct vdpasim);
> 	dev_attr.config_size = sizeof(struct virtio_blk_config);
> 	dev_attr.get_config = vdpasim_blk_get_config;
> 	dev_attr.work_fn = vdpasim_blk_work;
>diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
>index c3cb225ea469..20cd5cdff919 100644
>--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
>@@ -249,6 +249,7 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
> 	dev_attr.nvqs = VDPASIM_NET_VQ_NUM;
> 	dev_attr.ngroups = VDPASIM_NET_GROUP_NUM;
> 	dev_attr.nas = VDPASIM_NET_AS_NUM;
>+	dev_attr.alloc_size = sizeof(struct vdpasim);
> 	dev_attr.config_size = sizeof(struct virtio_net_config);
> 	dev_attr.get_config = vdpasim_net_get_config;
> 	dev_attr.work_fn = vdpasim_net_work;
>-- 
>2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ