From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751571AbbKGKAF (ORCPT ); Sat, 7 Nov 2015 05:00:05 -0500 Received: from www.linutronix.de ([62.245.132.108]:34981 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbbKGKAA (ORCPT ); Sat, 7 Nov 2015 05:00:00 -0500 Date: Sat, 7 Nov 2015 10:59:16 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski cc: x86@kernel.org, linux-kernel@vger.kernel.org, Brian Gerst , Linus Torvalds , Borislav Petkov , =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?= , Peter Zijlstra Subject: Re: [PATCH 1/4] x86/entry/64: Fix irqflag tracing wrt context tracking In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Nov 2015, Andy Lutomirski wrote: > Paolo pointed out that enter_from_user_mode could be called while > irqflags were traced as though IRQs were on. > > In principle, this could confuse lockdep. It doesn't cause any > problems that I've seen in any configuration, but if I build with > CONFIG_DEBUG_LOCKDEP=y, enable a nohz_full CPU, and add code like: > > if (irqs_disabled()) { > spin_lock(&something); > spin_unlock(&something); > } > > to the top of enter_from_user_mode, then lockdep will complain > without this fix. It seems that lockdep's irqflags sanity checks > are too weak to detect this bug without forcing the issue. > > This patch adds one byte to normal kernels, and it's IMO a bit ugly. > I haven't spotted a better way to do this yet, though. The issue is > that we can't do TRACE_IRQS_OFF until after SWAPGS (if needed), but > we're also supposed to do it before calling C code. > > An alternative approach would be to call trace_hardirqs_off in > enter_from_user_mode. That would be less code and would not bloat > normal kernels at all, but it would be harder to see how the code > worked. > > Signed-off-by: Andy Lutomirski Reviewed-by: Thomas Gleixner