Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4046905pxu; Wed, 9 Dec 2020 07:09:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjxjp6T7XwFXA6LsD8V0C1QFeigRXQ2YV+H6s0fP1NNsQLjlfixieSYI804ysXlTrL2/qA X-Received: by 2002:a17:906:bc9b:: with SMTP id lv27mr2373408ejb.505.1607526590519; Wed, 09 Dec 2020 07:09:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607526590; cv=none; d=google.com; s=arc-20160816; b=iTzIkAZ96wvFhy/a+oSP43LvtQkuRV8CGwDnw2czwRTUMwOK5sWspSMOU+1gtuTYHD xezKsq3t39ESRl0nzurXtkCJ/xYs8+H9Op3ZzFJjGB7nAylMTYa8fC15gomdcPc9BYST 19FRWEFFJ2PVkvpN8cmUPfDBFG0slQR8w8MGEqCQcMJUYYNrewhOCxx8c0xE6ZFIF1Y5 4lCuTU3sFjhSME8aIIHPzzd2uzlYhb8smviwVmXuzItBYq54jGVD6E1nrAD/Rf3voVEL zrdwbmBikk7Fam2c2cLJcvUr67ISZB+jVTDCwgu/rzk/BFfR00Ij78ZZ4Gf0To6Y/yxz iS+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=RCsTK5wxwzxThwzA9lBUZdHkj8Y89cVzpIEGu8s/+rE=; b=t+VKbfldgZp3q3te7SJr4VJmX7PAfS8RXPNjk/GCXq/wp97vGIGav2eb3jcd3V+nTa DyZAIj2ilviECbspyW0k1ZiRPzDGJlg2uWZkTXd6XjdgxfWuANU47JouOk/RqSbIdPIb jiHxrgS2Y8xgWANz+parvlQ5imp+aELrNN4v6jDo7HPCj4XDzU6hAlGmspA7eZoh9Wac kvAPj+6CKvKQLqGiXV5cUtESXPHM+IiFi4TAC1qL5pBYHteQgbd33zaKSY6dEsvqgjAt uSoyZgs8DZk5R0kVNC2G7iW1hj/APhNPKCX+eqEIzpfE+1Fg/IRD3t9k4AZVLilQexnq ooow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k23si1015839ejk.626.2020.12.09.07.09.26; Wed, 09 Dec 2020 07:09:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbgLIODb (ORCPT + 99 others); Wed, 9 Dec 2020 09:03:31 -0500 Received: from foss.arm.com ([217.140.110.172]:35004 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbgLIODR (ORCPT ); Wed, 9 Dec 2020 09:03:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EAFD31FB; Wed, 9 Dec 2020 06:02:31 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.26.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 067D13F66B; Wed, 9 Dec 2020 06:02:28 -0800 (PST) Date: Wed, 9 Dec 2020 14:02:21 +0000 From: Mark Rutland To: Andy Lutomirski Cc: =?utf-8?B?SsO8cmdlbiBHcm/Dnw==?= , Peter Zijlstra , Stefano Stabellini , "VMware, Inc." , X86 ML , LKML , Linux Virtualization , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , xen-devel , Thomas Gleixner , Boris Ostrovsky Subject: Re: [PATCH v2 05/12] x86: rework arch_local_irq_restore() to not use popf Message-ID: <20201209140221.GA9087@C02TD0UTHF1T.local> References: <20201120114630.13552-1-jgross@suse.com> <20201120114630.13552-6-jgross@suse.com> <20201120115943.GD3021@hirez.programming.kicks-ass.net> <20201209132710.GA8566@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201209132710.GA8566@C02TD0UTHF1T.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 09, 2020 at 01:27:10PM +0000, Mark Rutland wrote: > On Sun, Nov 22, 2020 at 01:44:53PM -0800, Andy Lutomirski wrote: > > On Sat, Nov 21, 2020 at 10:55 PM Jürgen Groß wrote: > > > On 20.11.20 12:59, Peter Zijlstra wrote: > > > > If someone were to write horrible code like: > > > > > > > > local_irq_disable(); > > > > local_irq_save(flags); > > > > local_irq_enable(); > > > > local_irq_restore(flags); > > > > > > > > we'd be up some creek without a paddle... now I don't _think_ we have > > > > genius code like that, but I'd feel saver if we can haz an assertion in > > > > there somewhere... > I was just talking to Peter on IRC about implementing the same thing for > arm64, so could we put this in the generic irqflags code? IIUC we can > use raw_irqs_disabled() to do the check. > > As this isn't really entry specific (and IIUC the cases this should > catch would break lockdep today), maybe we should add a new > DEBUG_IRQFLAGS for this, that DEBUG_LOCKDEP can also select? > > Something like: > > #define local_irq_restore(flags) \ > do { \ > if (!raw_irqs_disabled_flags(flags)) { \ > trace_hardirqs_on(); \ > } else if (IS_ENABLED(CONFIG_DEBUG_IRQFLAGS) { \ > if (unlikely(raw_irqs_disabled()) \ Whoops; that should be !raw_irqs_disabled(). > warn_bogus_irqrestore(); \ > } \ > raw_local_irq_restore(flags); \ > } while (0) > > ... perhaps? (ignoring however we deal with once-ness). If no-one shouts in the next day or two I'll spin this as its own patch. Mark.