Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755356AbbGUJmd (ORCPT ); Tue, 21 Jul 2015 05:42:33 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40537 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754601AbbGUJma (ORCPT ); Tue, 21 Jul 2015 05:42:30 -0400 Date: Tue, 21 Jul 2015 02:41:54 -0700 From: tip-bot for Waiman Long Message-ID: Cc: peterz@infradead.org, Waiman.Long@hp.com, tglx@linutronix.de, mingo@kernel.org, masami.hiramatsu.pt@hitachi.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com Reply-To: masami.hiramatsu.pt@hitachi.com, mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, Waiman.Long@hp.com, hpa@zytor.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org In-Reply-To: <1436663959-53092-1-git-send-email-Waiman.Long@hp.com> References: <1436663959-53092-1-git-send-email-Waiman.Long@hp.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/urgent] locking/pvqspinlock: Fix kernel panic in locking-selftest Git-Commit-ID: cba77f03f2c7b6cc0b0a44a3c679e0abade7da62 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2844 Lines: 76 Commit-ID: cba77f03f2c7b6cc0b0a44a3c679e0abade7da62 Gitweb: http://git.kernel.org/tip/cba77f03f2c7b6cc0b0a44a3c679e0abade7da62 Author: Waiman Long AuthorDate: Sat, 11 Jul 2015 21:19:19 -0400 Committer: Ingo Molnar CommitDate: Tue, 21 Jul 2015 10:18:07 +0200 locking/pvqspinlock: Fix kernel panic in locking-selftest Enabling locking-selftest in a VM guest may cause the following kernel panic: kernel BUG at .../kernel/locking/qspinlock_paravirt.h:137! This is due to the fact that the pvqspinlock unlock function is expecting either a _Q_LOCKED_VAL or _Q_SLOW_VAL in the lock byte. This patch prevents that bug report by ignoring it when debug_locks_silent is set. Otherwise, a warning will be printed if it contains an unexpected value. With this patch applied, the kernel locking-selftest completed without any noise. Tested-by: Masami Hiramatsu Signed-off-by: Waiman Long Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1436663959-53092-1-git-send-email-Waiman.Long@hp.com Signed-off-by: Ingo Molnar --- kernel/locking/qspinlock_paravirt.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index 04ab181..df19ae4 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h @@ -4,6 +4,7 @@ #include #include +#include /* * Implement paravirt qspinlocks; the general idea is to halt the vcpus instead @@ -286,15 +287,23 @@ __visible void __pv_queued_spin_unlock(struct qspinlock *lock) { struct __qspinlock *l = (void *)lock; struct pv_node *node; + u8 lockval = cmpxchg(&l->locked, _Q_LOCKED_VAL, 0); /* * We must not unlock if SLOW, because in that case we must first * unhash. Otherwise it would be possible to have multiple @lock * entries, which would be BAD. */ - if (likely(cmpxchg(&l->locked, _Q_LOCKED_VAL, 0) == _Q_LOCKED_VAL)) + if (likely(lockval == _Q_LOCKED_VAL)) return; + if (unlikely(lockval != _Q_SLOW_VAL)) { + if (debug_locks_silent) + return; + WARN(1, "pvqspinlock: lock %p has corrupted value 0x%x!\n", lock, atomic_read(&lock->val)); + return; + } + /* * Since the above failed to release, this must be the SLOW path. * Therefore start by looking up the blocked node and unhashing it. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/