lkml.org 
[lkml]   [2019]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] x86/split_lock: Align the x86_capability array to size of unsigned long
Date
From: Fenghua Yu <fenghua.yu@intel.com>

The x86_capability array in cpuinfo_x86 is defined as u32 and thus is
naturally aligned to 4 bytes. But, set_bit() and clear_bit() require
the array to be aligned to size of unsigned long (i.e. 8 bytes in
64-bit).

To fix the alignment issue, align the x86_capability array to size of
unsigned long by using unnamed union and 'unsigned long array_align'
to force the alignment.

Changing the x86_capability array's type to unsigned long may also fix
the issue because the x86_capability array will be naturally aligned
to size of unsigned long. But this needs additional code changes.
So choose the simpler solution by setting the array's alignment to size
of unsigned long.

Suggested-by: David Laight <David.Laight@aculab.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/include/asm/processor.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 6e0a3b43d027..c073534ca485 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -93,7 +93,15 @@ struct cpuinfo_x86 {
__u32 extended_cpuid_level;
/* Maximum supported CPUID level, -1=no CPUID: */
int cpuid_level;
- __u32 x86_capability[NCAPINTS + NBUGINTS];
+ /*
+ * Align to size of unsigned long because the x86_capability array
+ * is passed to bitops which require the alignment. Use unnamed
+ * union to enforce the array is aligned to size of unsigned long.
+ */
+ union {
+ __u32 x86_capability[NCAPINTS + NBUGINTS];
+ unsigned long x86_capability_alignment;
+ };
char x86_vendor_id[16];
char x86_model_id[64];
/* in KB - valid for CPUS which support this call: */
--
2.20.1
\
 
 \ /
  Last update: 2019-09-17 00:40    [W:0.313 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site