Skip to contentSkip to conversation

x86, ds: fix buffer alignment in debug store selftest

PATCH In review Markus Metzger 1 participant 2 messages Apr 24, 2009 – May 7, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, ds: fix buffer alignment in debug store selftest

The debug store selftest code uses a stack-allocated buffer, which is not necessarily correctly aligned.

For tests using a buffer to hold a single entry, the buffer that is passed to ds_request must already be suitably aligned.

Pass a suitably aligned portion of the bigger buffer.

---
arch/x86/kernel/ds_selftest.c | 6 4 + 2 - 0 !

 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/ds_selftest.c +4 -2
Index: b/arch/x86/kernel/ds_selftest.c
===================================================================
@@ -323,13 +323,15 @@ static int ds_selftest_bts_bad_request_t
 int ds_selftest_bts(void)
 {
 	struct ds_selftest_bts_conf conf;
-	unsigned char buffer[BUFFER_SIZE];
+	unsigned char buffer[BUFFER_SIZE], *small_buffer;
 	unsigned long irq;
 	int cpu;
 
 	printk(KERN_INFO "[ds] bts selftest...");
 	conf.error = 0;
 
+	small_buffer = (unsigned char *)ALIGN((unsigned long)buffer, 8) + 8;
+
 	get_online_cpus();
 	for_each_online_cpu(cpu) {
 		conf.suspend = ds_suspend_bts_wrap;
@@ -381,7 +383,7 @@ int ds_selftest_bts(void)
 	conf.suspend = ds_suspend_bts_noirq;
 	conf.resume = ds_resume_bts_noirq;
 	conf.tracer =
-		ds_request_bts_task(current, buffer, SMALL_BUFFER_SIZE,
+		ds_request_bts_task(current, small_buffer, SMALL_BUFFER_SIZE,
 				   NULL, (size_t)-1, BTS_KERNEL);
 	local_irq_save(irq);
 	ds_selftest_bts_cpu(&conf);

---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#1 lore raw
Commit-ID:  782cc5ae6331d63b4febaa312c9d14493aafa9b8
Gitweb:     http://git.kernel.org/tip/782cc5ae6331d63b4febaa312c9d14493aafa9b8
Author:     Markus Metzger <[email protected]>
AuthorDate: Fri, 24 Apr 2009 09:43:09 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 24 Apr 2009 10:18:51 +0200

x86, ds: fix buffer alignment in debug store selftest

The debug store selftest code uses a stack-allocated buffer, which is not necessarily correctly aligned.

For tests using a buffer to hold a single entry, the buffer that is passed to ds_request must already be suitably aligned.

Pass a suitably aligned portion of the bigger buffer.

[ Impact: fix hw-branch-tracer self-test failure ]

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/ds_selftest.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/ds_selftest.c +4 -2
index 5f104a0..6bc7c19 100644
@@ -323,13 +323,15 @@ static int ds_selftest_bts_bad_request_task(void *buffer)
 int ds_selftest_bts(void)
 {
 	struct ds_selftest_bts_conf conf;
-	unsigned char buffer[BUFFER_SIZE];
+	unsigned char buffer[BUFFER_SIZE], *small_buffer;
 	unsigned long irq;
 	int cpu;
 
 	printk(KERN_INFO "[ds] bts selftest...");
 	conf.error = 0;
 
+	small_buffer = (unsigned char *)ALIGN((unsigned long)buffer, 8) + 8;
+
 	get_online_cpus();
 	for_each_online_cpu(cpu) {
 		conf.suspend = ds_suspend_bts_wrap;
@@ -381,7 +383,7 @@ int ds_selftest_bts(void)
 	conf.suspend = ds_suspend_bts_noirq;
 	conf.resume = ds_resume_bts_noirq;
 	conf.tracer =
-		ds_request_bts_task(current, buffer, SMALL_BUFFER_SIZE,
+		ds_request_bts_task(current, small_buffer, SMALL_BUFFER_SIZE,
 				   NULL, (size_t)-1, BTS_KERNEL);
 	local_irq_save(irq);
 	ds_selftest_bts_cpu(&conf);