diff mbox

libata: Align ata_device's id on a cacheline

Message ID 1456327003-16295-1-git-send-email-harvey.hunt@imgtec.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Harvey Hunt Feb. 24, 2016, 3:16 p.m. UTC
The id buffer in ata_device is a DMA target, but it isn't explicitly
cacheline aligned. Due to this, adjacent fields can be overwritten with
stale data from memory on non coherent architectures. As a result, the
kernel is sometimes unable to communicate with an ATA device.

Fix this by ensuring that the id buffer is cacheline aligned.

This issue is similar to that fixed by Commit 84bda12af31f
("libata: align ap->sector_buf").

Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: <stable@vger.kernel.org> # 2.6.18
---
This patch is based on libata/for-4.6

 include/linux/libata.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tejun Heo Feb. 25, 2016, 9:37 p.m. UTC | #1
On Wed, Feb 24, 2016 at 03:16:43PM +0000, Harvey Hunt wrote:
> The id buffer in ata_device is a DMA target, but it isn't explicitly
> cacheline aligned. Due to this, adjacent fields can be overwritten with
> stale data from memory on non coherent architectures. As a result, the
> kernel is sometimes unable to communicate with an ATA device.
> 
> Fix this by ensuring that the id buffer is cacheline aligned.
> 
> This issue is similar to that fixed by Commit 84bda12af31f
> ("libata: align ap->sector_buf").
> 
> Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: <stable@vger.kernel.org> # 2.6.18

Applied to libata/for-4.5-fixes.

Thanks.
diff mbox

Patch

diff --git a/include/linux/libata.h b/include/linux/libata.h
index bec2abb..2c4ebef 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -720,7 +720,7 @@  struct ata_device {
 	union {
 		u16		id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
 		u32		gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
-	};
+	} ____cacheline_aligned;
 
 	/* DEVSLP Timing Variables from Identify Device Data Log */
 	u8			devslp_timing[ATA_LOG_DEVSLP_SIZE];