RE: [PATCH v2] raid6/test/test.c: bug fix: Specify aligned(alignment) attributes to the char arrays

From: Kammela, Gayatri
Date: Thu Sep 22 2016 - 20:18:08 EST


Hi all,
Sorry for the noise! I didn't mean to send the version2.

-----Original Message-----
From: Kammela, Gayatri
Sent: Thursday, September 22, 2016 5:08 PM
To: linux-raid@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
Cc: shli@xxxxxxxxxx; Anvin, H Peter <h.peter.anvin@xxxxxxxxx>; Shankar, Ravi V <ravi.v.shankar@xxxxxxxxx>; Yu, Fenghua <fenghua.yu@xxxxxxxxx>; Kammela, Gayatri <gayatri.kammela@xxxxxxxxx>; H . Peter Anvin <hpa@xxxxxxxxx>; Yu, Yu-cheng <yu-cheng.yu@xxxxxxxxx>
Subject: [PATCH v2] raid6/test/test.c: bug fix: Specify aligned(alignment) attributes to the char arrays

Specifying the aligned attributes to the char recovi[PAGE_SIZE] and char recovi[PAGE_SIZE] arrays, so that all malloc memory is page boundary aligned.

Without these alignment attributes, the test causes a segfault in userspace when the NDISKS are changed to 4 from 16.

Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Yu-cheng Yu <yu-cheng.yu@xxxxxxxxx>
Signed-off-by: Gayatri Kammela <gayatri.kammela@xxxxxxxxx>
---
lib/raid6/test/test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/raid6/test/test.c b/lib/raid6/test/test.c index 3bebbabdb510..32a00f11ac50 100644
--- a/lib/raid6/test/test.c
+++ b/lib/raid6/test/test.c
@@ -21,12 +21,13 @@

#define NDISKS 16 /* Including P and Q */

-const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256)));
+const char raid6_empty_zero_page[PAGE_SIZE]
+__attribute__((aligned(PAGE_SIZE)));
struct raid6_calls raid6_call;

char *dataptrs[NDISKS];
char data[NDISKS][PAGE_SIZE];
-char recovi[PAGE_SIZE], recovj[PAGE_SIZE];
+char recovi[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
+char recovj[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));

static void makedata(int start, int stop) {
--
2.7.4