public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
       [not found] ` <20221219083511.73205-4-alvaro.karsz@solid-run.com>
@ 2022-12-20 16:32   ` Nathan Chancellor
  2022-12-20 16:46     ` Alvaro Karsz
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2022-12-20 16:32 UTC (permalink / raw)
  To: Alvaro Karsz
  Cc: virtualization, linux-pci, bhelgaas, Michael S. Tsirkin,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

Hi Alvaro,

On Mon, Dec 19, 2022 at 10:35:11AM +0200, Alvaro Karsz wrote:
> This commit includes:
>  1) The driver to manage the controlplane over vDPA bus.
>  2) A HW monitor device to read health values from the DPU.
> 
> Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>

<snip>

> +static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)
> +{
> +	char name[25];
> +	int ret, i, mask = 0;
> +	/* We don't know which BAR will be used to communicate..
> +	 * We will map every bar with len > 0.
> +	 *
> +	 * Later, we will discover the BAR and unmap all other BARs.
> +	 */
> +	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
> +		if (pci_resource_len(pdev, i))
> +			mask |= (1 << i);
> +	}
> +
> +	/* No BAR can be used.. */
> +	if (!mask) {
> +		SNET_ERR(pdev, "Failed to find a PCI BAR\n");
> +		return -ENODEV;
> +	}
> +
> +	snprintf(name, SNET_NAME_SIZE, "psnet[%s]-bars", pci_name(pdev));
> +	ret = pcim_iomap_regions(pdev, mask, name);
> +	if (ret) {
> +		SNET_ERR(pdev, "Failed to request and map PCI BARs\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
> +		if (mask & (1 << i))
> +			psnet->bars[i] = pcim_iomap_table(pdev)[i];
> +	}
> +
> +	return 0;
> +}
> +
> +static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet)
> +{
> +	char name[20];
> +	int ret;
> +
> +	snprintf(name, SNET_NAME_SIZE, "snet[%s]-bar", pci_name(pdev));
> +	/* Request and map BAR */
> +	ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name);
> +	if (ret) {
> +		SNET_ERR(pdev, "Failed to request and map PCI BAR for a VF\n");
> +		return ret;
> +	}
> +
> +	snet->bar = pcim_iomap_table(pdev)[snet->psnet->cfg.vf_bar];
> +
> +	return 0;
> +}

This patch as commit 73a720b16fa1 ("virtio: vdpa: new SolidNET DPU
driver.") in next-20221220 causes the following clang warnings:

  drivers/vdpa/solidrun/snet_main.c:561:2: error: 'snprintf' size argument is too large; destination buffer has size 25, but size argument is 256 [-Werror,-Wfortify-source]
          snprintf(name, SNET_NAME_SIZE, "psnet[%s]-bars", pci_name(pdev));
          ^
  drivers/vdpa/solidrun/snet_main.c:581:2: error: 'snprintf' size argument is too large; destination buffer has size 20, but size argument is 256 [-Werror,-Wfortify-source]
          snprintf(name, SNET_NAME_SIZE, "snet[%s]-bar", pci_name(pdev));
          ^
  2 errors generated.

This does not appear to be a false positive but what was the intent
here? Should the local name variables increase their length or should
the buffer length be reduced?

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-20 16:32   ` [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver Nathan Chancellor
@ 2022-12-20 16:46     ` Alvaro Karsz
  2022-12-20 20:49       ` Nathan Chancellor
                         ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alvaro Karsz @ 2022-12-20 16:46 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: virtualization, linux-pci, bhelgaas, Michael S. Tsirkin,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

Hi Nathan,

> This does not appear to be a false positive but what was the intent
> here? Should the local name variables increase their length or should
> the buffer length be reduced?

You're right, the local name variables and snprintf argument don't match.
Thanks for noticing.
I think that we should increase the name variables  to be
SNET_NAME_SIZE bytes long.

How should I proceed from here?
Should I create a new version for this patch, or should I fix it in a
follow up patch?

Thanks,
Alvaro

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-20 16:46     ` Alvaro Karsz
@ 2022-12-20 20:49       ` Nathan Chancellor
  2022-12-20 23:20         ` Michael S. Tsirkin
  2022-12-20 21:48       ` Arnd Bergmann
  2022-12-21  6:40       ` Michael S. Tsirkin
  2 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2022-12-20 20:49 UTC (permalink / raw)
  To: Alvaro Karsz
  Cc: virtualization, linux-pci, bhelgaas, Michael S. Tsirkin,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

On Tue, Dec 20, 2022 at 06:46:20PM +0200, Alvaro Karsz wrote:
> Hi Nathan,
> 
> > This does not appear to be a false positive but what was the intent
> > here? Should the local name variables increase their length or should
> > the buffer length be reduced?
> 
> You're right, the local name variables and snprintf argument don't match.
> Thanks for noticing.
> I think that we should increase the name variables  to be
> SNET_NAME_SIZE bytes long.
> 
> How should I proceed from here?
> Should I create a new version for this patch, or should I fix it in a
> follow up patch?

That is up to Michael at the end of the day (each maintainer handles
their tree differently) but I would recommend sending a follow up fix,
as it is easy to fold it in if they want to rebase the tree for it or
just take it as a fix.

Thanks for the quick triage and response!

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-20 16:46     ` Alvaro Karsz
  2022-12-20 20:49       ` Nathan Chancellor
@ 2022-12-20 21:48       ` Arnd Bergmann
  2022-12-21  6:40       ` Michael S. Tsirkin
  2 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2022-12-20 21:48 UTC (permalink / raw)
  To: Alvaro Karsz, Nathan Chancellor
  Cc: virtualization, linux-pci, bhelgaas, Michael S. Tsirkin,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

On Tue, Dec 20, 2022, at 17:46, Alvaro Karsz wrote:
> Hi Nathan,
>
>> This does not appear to be a false positive but what was the intent
>> here? Should the local name variables increase their length or should
>> the buffer length be reduced?
>
> You're right, the local name variables and snprintf argument don't match.
> Thanks for noticing.
> I think that we should increase the name variables  to be
> SNET_NAME_SIZE bytes long.

If you can show that the string fits into the current length, it
would be better to keep the stack usage low and just adapt the
length to be sizeof(string) instead of SNET_NAME_SIZE.

    Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-20 20:49       ` Nathan Chancellor
@ 2022-12-20 23:20         ` Michael S. Tsirkin
  0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2022-12-20 23:20 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alvaro Karsz, virtualization, linux-pci, bhelgaas, Jason Wang,
	Jean Delvare, Guenter Roeck, llvm

On Tue, Dec 20, 2022 at 01:49:04PM -0700, Nathan Chancellor wrote:
> On Tue, Dec 20, 2022 at 06:46:20PM +0200, Alvaro Karsz wrote:
> > Hi Nathan,
> > 
> > > This does not appear to be a false positive but what was the intent
> > > here? Should the local name variables increase their length or should
> > > the buffer length be reduced?
> > 
> > You're right, the local name variables and snprintf argument don't match.
> > Thanks for noticing.
> > I think that we should increase the name variables  to be
> > SNET_NAME_SIZE bytes long.
> > 
> > How should I proceed from here?
> > Should I create a new version for this patch, or should I fix it in a
> > follow up patch?
> 
> That is up to Michael at the end of the day (each maintainer handles
> their tree differently) but I would recommend sending a follow up fix,
> as it is easy to fold it in if they want to rebase the tree for it or
> just take it as a fix.
> 
> Thanks for the quick triage and response!
> 
> Cheers,
> Nathan

on top is ok but post soon please as i need to send this to Linus.

-- 
MST


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-20 16:46     ` Alvaro Karsz
  2022-12-20 20:49       ` Nathan Chancellor
  2022-12-20 21:48       ` Arnd Bergmann
@ 2022-12-21  6:40       ` Michael S. Tsirkin
  2022-12-21  7:05         ` Alvaro Karsz
  2 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2022-12-21  6:40 UTC (permalink / raw)
  To: Alvaro Karsz
  Cc: Nathan Chancellor, virtualization, linux-pci, bhelgaas,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

On Tue, Dec 20, 2022 at 06:46:20PM +0200, Alvaro Karsz wrote:
> Hi Nathan,
> 
> > This does not appear to be a false positive but what was the intent
> > here? Should the local name variables increase their length or should
> > the buffer length be reduced?
> 
> You're right, the local name variables and snprintf argument don't match.
> Thanks for noticing.
> I think that we should increase the name variables  to be
> SNET_NAME_SIZE bytes long.
> 
> How should I proceed from here?
> Should I create a new version for this patch, or should I fix it in a
> follow up patch?
> 
> Thanks,
> Alvaro


Please post a follow-up ASAP. I can squash myself if I rebase.

Thanks!

-- 
MST


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver.
  2022-12-21  6:40       ` Michael S. Tsirkin
@ 2022-12-21  7:05         ` Alvaro Karsz
  0 siblings, 0 replies; 7+ messages in thread
From: Alvaro Karsz @ 2022-12-21  7:05 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Nathan Chancellor, virtualization, linux-pci, bhelgaas,
	Jason Wang, Jean Delvare, Guenter Roeck, llvm

> Please post a follow-up ASAP. I can squash myself if I rebase.
>
> Thanks!

Sure, I'll do it now

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-21  7:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20221219083511.73205-1-alvaro.karsz@solid-run.com>
     [not found] ` <20221219083511.73205-4-alvaro.karsz@solid-run.com>
2022-12-20 16:32   ` [PATCH 3/3 v6] virtio: vdpa: new SolidNET DPU driver Nathan Chancellor
2022-12-20 16:46     ` Alvaro Karsz
2022-12-20 20:49       ` Nathan Chancellor
2022-12-20 23:20         ` Michael S. Tsirkin
2022-12-20 21:48       ` Arnd Bergmann
2022-12-21  6:40       ` Michael S. Tsirkin
2022-12-21  7:05         ` Alvaro Karsz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox