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: <20120129131139.GA19049@dirshya.in.ibm.com>
Date:	Sun, 29 Jan 2012 18:41:39 +0530
From:	Vaidyanathan Srinivasan <svaidy@...ux.vnet.ibm.com>
To:	Yinghai Lu <yinghai@...nel.org>
Cc:	Ram Pai <linuxram@...ibm.com>,
	Jesse Barnes <jbarnes@...tuousgeek.org>,
	linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [BUGFIX][PATCH] pci: check for 4k resource_size alignment in
 sriov_init

* Yinghai Lu <yinghai@...nel.org> [2012-01-27 13:05:41]:

> On Fri, Jan 27, 2012 at 11:10 AM, Vaidyanathan Srinivasan
> <svaidy@...ux.vnet.ibm.com> wrote:
> > Hi Ram and Jesse,
> >
> > I found a trivial issue with page size alignment check on IBM POWER
> > box with 64k base page size.  In sriov_init(), changing the check from
> > PAGE_SIZE (arch and config dependent) to HW_PAGE_SIZE (always 4k) was
> > required to use one of the sriov adapter as PF since the
> > resource_size() comes up as 0x8000 and PAGE_SIZE would be 0x10000 for
> > pseries boxes.
> >
> > I think resource_size() could be less than SystemPageSize, but I would
> > like your comments/ack/nack on any consequences of checking for only
> > 4k alignment here in a system with larger base page size.
> >
> > Thanks,
> > Vaidy
> >
> > ---
> >
> >    pci: check for 4k resource_size alignment in sriov_init
> >
> >    pci sriov_init should check for 4k page size alignment of resource_size
> >    even if base page size is larger -- like 64k in powerpc.
> >
> >    Signed-off-by: Vaidyanathan Srinivasan <svaidy@...ux.vnet.ibm.com>
> >
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index 0321fa3..5816fa0 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -474,7 +474,7 @@ found:
> >                                     pos + PCI_SRIOV_BAR + i * 4);
> >                if (!res->flags)
> >                        continue;
> > -               if (resource_size(res) & (PAGE_SIZE - 1)) {
> > +               if (resource_size(res) & (HW_PAGE_SIZE - 1)) {
> >                        rc = -EIO;
> >                        goto failed;
> >                }
> >
> 
> but HW_PAGE_SIZE is only defined for powerpc.

My bad, I picked the #define used in other powerpc code.

> also there is PAGE_SHIFT around in that function.

This gets defined correctly if CONFIG_PPC_64K_PAGES=y.  But the actual
problem is the need for a generic 4K #define for x86 and other archs.

> maybe you can just define another MARCO according to IOV spec?

This is a good idea.  I could not find an IOV specific requirement.
The resource size has to be a multiple of 4K so that the overall
resource-size() * PCI_SRIOV_TOTAL_VF will be a multiple of 4K or more.

Let me share a patch that has a simple #define in drivers/pci/pci.h,
which is needed to get SRIOV cards started on powerpc box.

--Vaidy

---

    pci: check for 4k resource_size alignment in sriov_init
    
    pci sriov_init should check for 4k page size alignment of resource_size
    even if base page size is larger like 64k in powerpc.
    
    Signed-off-by: Vaidyanathan Srinivasan <svaidy@...ux.vnet.ibm.com>

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 0321fa3..10adede 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -474,7 +474,7 @@ found:
 				     pos + PCI_SRIOV_BAR + i * 4);
 		if (!res->flags)
 			continue;
-		if (resource_size(res) & (PAGE_SIZE - 1)) {
+		if (resource_size(res) & (HW_PAGE_SIZE_4K - 1)) {
 			rc = -EIO;
 			goto failed;
 		}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 1009a5e..68703ab 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -6,6 +6,9 @@
 #define PCI_CFG_SPACE_SIZE	256
 #define PCI_CFG_SPACE_EXP_SIZE	4096
 
+/* Constants used in the PCI core code */
+#define HW_PAGE_SIZE_4K		0x1000
+
 /* Functions internal to the PCI core code */
 
 extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ