]> git.baikalelectronics.ru Git - kernel.git/commit
x86: xen: size struct xen_spinlock to always fit in arch_spinlock_t
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 23 Jan 2012 19:32:25 +0000 (19:32 +0000)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 24 Jan 2012 17:10:19 +0000 (12:10 -0500)
commit2c859d3d58a60c30e941c235094e7dfbabfa770a
treeab4b43b4b3b50913e8f3abfe98190d0e0a472bf5
parenta439428332b2416cde26cf05c4644356b039d878
x86: xen: size struct xen_spinlock to always fit in arch_spinlock_t

If NR_CPUS < 256 then arch_spinlock_t is only 16 bits wide but struct
xen_spinlock is 32 bits.  When a spin lock is contended and
xl->spinners is modified the two bytes immediately after the spin lock
would be corrupted.

This is a regression caused by e31c2208d331c7d1a87cd79c41004f9467ae2d2a
(x86, ticketlock: Clean up types and accessors) which reduced the size
of arch_spinlock_t.

Fix this by making xl->spinners a u8 if NR_CPUS < 256.  A
BUILD_BUG_ON() is also added to check the sizes of the two structures
are compatible.

In many cases this was not noticable as there would often be padding
bytes after the lock (e.g., if any of CONFIG_GENERIC_LOCKBREAK,
CONFIG_DEBUG_SPINLOCK, or CONFIG_DEBUG_LOCK_ALLOC were enabled).

The bnx2 driver is affected. In struct bnx2, phy_lock and
indirect_lock may have no padding after them.  Contention on phy_lock
would corrupt indirect_lock making it appear locked and the driver
would deadlock.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
CC: stable@kernel.org #only 3.2
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/spinlock.c