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 Feb 2024 20:28:04 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
CC: "haiyangz@...rosoft.com" <haiyangz@...rosoft.com>, "wei.liu@...nel.org"
	<wei.liu@...nel.org>, "decui@...rosoft.com" <decui@...rosoft.com>,
	"lpieralisi@...nel.org" <lpieralisi@...nel.org>, "kw@...ux.com"
	<kw@...ux.com>, "robh@...nel.org" <robh@...nel.org>, "bhelgaas@...gle.com"
	<bhelgaas@...gle.com>, "linux-pci@...r.kernel.org"
	<linux-pci@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
	"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>
Subject: RE: [PATCH v2 1/1] PCI: hv: Fix ring buffer size calculation

From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com> Sent: Friday, February 16, 2024 6:46 AM
> 
> On Wed, 14 Feb 2024, mhkelley58@...il.com wrote:
> >
> > For a physical PCI device that is passed through to a Hyper-V guest VM,
> > current code specifies the VMBus ring buffer size as 4 pages.  But this
> > is an inappropriate dependency, since the amount of ring buffer space
> > needed is unrelated to PAGE_SIZE. For example, on x86 the ring buffer
> > size ends up as 16 Kbytes, while on ARM64 with 64 Kbyte pages, the ring
> > size bloats to 256 Kbytes. The ring buffer for PCI pass-thru devices
> > is used for only a few messages during device setup and removal, so any
> > space above a few Kbytes is wasted.
> >
> > Fix this by declaring the ring buffer size to be a fixed 16 Kbytes.
> > Furthermore, use the VMBUS_RING_SIZE() macro so that the ring buffer
> > header is properly accounted for, and so the size is rounded up to a
> > page boundary, using the page size for which the kernel is built. While
> > w/64 Kbyte pages this results in a 64 Kbyte ring buffer header plus a
> > 64 Kbyte ring buffer, that's the smallest possible with that page size.
> > It's still 128 Kbytes better than the current code.
> >
> > Cc: <stable@...r.kernel.org> # 5.15.x
> > Signed-off-by: Michael Kelley <mhklinux@...look.com>
> > Reviewed-by: Kuppuswamy Sathyanarayanan
> <sathyanarayanan.kuppuswamy@...ux.intel.com>
> > ---
> > Changes in v2:
> > * Use SZ_16K instead of 16 * 1024
> > ---
> >  drivers/pci/controller/pci-hyperv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-
> hyperv.c
> > index 1eaffff40b8d..baadc1e5090e 100644
> > --- a/drivers/pci/controller/pci-hyperv.c
> > +++ b/drivers/pci/controller/pci-hyperv.c
> > @@ -465,7 +465,7 @@ struct pci_eject_response {
> >  	u32 status;
> >  } __packed;
> >
> > -static int pci_ring_size = (4 * PAGE_SIZE);
> > +static int pci_ring_size = VMBUS_RING_SIZE(SZ_16K);
> >
> >  /*
> >   * Driver specific state.
> >
> 
> Hi,
> 
> You forgot to add #include <linux/sizes.h> for it.
> 
> With that fixed:
> 
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> 

Fixed in v3.  I mis-interpreted your previous comment about
adding the #include "if needed".  It's not needed to compile
correctly, as sizes.h is indirectly included through some other
#include.  But it's better to directly #include what's needed
lest some unrelated change cause a failure.

Michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ