s390/pci: enforce fmb page boundary rule
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Mon, 14 Mar 2016 14:47:23 +0000 (15:47 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 14 Mar 2016 15:19:09 +0000 (16:19 +0100)
The function measurement block must not cross a page boundary. Ensure
that by raising the alignment requirement to the smallest power of 2
larger than the size of the fmb.

Fixes: d0b088531 ("s390/pci: performance statistics and debug infrastructure")
Cc: stable@vger.kernel.org # v3.8+
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c

index dc763eae7c493381ccf8976b1a08ff9091696e87..f833082d91674ef244b713ef1c93bf4354538017 100644 (file)
@@ -45,7 +45,7 @@ struct zpci_fmb {
        u64 rpcit_ops;
        u64 dma_rbytes;
        u64 dma_wbytes;
-} __packed __aligned(16);
+} __packed __aligned(64);
 
 enum zpci_state {
        ZPCI_FN_STATE_RESERVED,
index f76d01e69fb8f220a1c1bd7f849d381c71076348..9fd59a7cfcd3c31133bac69b6e62ffbf0a9654ed 100644 (file)
@@ -860,8 +860,11 @@ static inline int barsize(u8 size)
 
 static int zpci_mem_init(void)
 {
+       BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) ||
+                    __alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb));
+
        zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb),
-                               16, 0, NULL);
+                                          __alignof__(struct zpci_fmb), 0, NULL);
        if (!zdev_fmb_cache)
                goto error_fmb;