From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86EC7C5519F for ; Sun, 22 Nov 2020 21:45:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 443922074B for ; Sun, 22 Nov 2020 21:45:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="1ywLGw0S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgKVVpL (ORCPT ); Sun, 22 Nov 2020 16:45:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:57714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgKVVpK (ORCPT ); Sun, 22 Nov 2020 16:45:10 -0500 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEBF020789 for ; Sun, 22 Nov 2020 21:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606081510; bh=j8kQr1sqydOsvjEY9shLB0wmUrzUic9iCe1dNmPahV0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=1ywLGw0S6Iag6+okOvBgPfWDSIRAX+z1ZSr78Si08frRCT6wlTaFGPbwKtciUr39i O4G4Y6EDiAcTMD7bLatQqayiaSxXNnDjjohYDNfE1OGhJGilgriL+1Ok0nRavMxdql /HYOzGZTzKTS4GqAkezXaMALXqruwPPbUTcCQfII= Received: by mail-wm1-f48.google.com with SMTP id a3so15568446wmb.5 for ; Sun, 22 Nov 2020 13:45:09 -0800 (PST) X-Gm-Message-State: AOAM530pnjjhyKCqmkJP24uuC9JSuzQNdxa/JDM5ne2Ab52JFmKwXsDZ rRGjZn8FecKUS+S1amCTSwGscVfh6j+Ia6RcE9fytA== X-Google-Smtp-Source: ABdhPJwifakpgwUVTLbeDBYdoVmnAfRpiEVwGa2XrrCKUuyY/SYxT6I31Kv43oa6WFJkbjZ+4GFZn5n4pemXbXWt+C8= X-Received: by 2002:a1c:2781:: with SMTP id n123mr3937832wmn.49.1606081506352; Sun, 22 Nov 2020 13:45:06 -0800 (PST) MIME-Version: 1.0 References: <20201120114630.13552-1-jgross@suse.com> <20201120114630.13552-6-jgross@suse.com> <20201120115943.GD3021@hirez.programming.kicks-ass.net> In-Reply-To: From: Andy Lutomirski Date: Sun, 22 Nov 2020 13:44:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 05/12] x86: rework arch_local_irq_restore() to not use popf To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: Peter Zijlstra , Stefano Stabellini , "VMware, Inc." , X86 ML , LKML , Linux Virtualization , Ingo Molnar , Borislav Petkov , Andrew Lutomirski , "H. Peter Anvin" , xen-devel , Thomas Gleixner , Boris Ostrovsky Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 21, 2020 at 10:55 PM J=C3=BCrgen Gro=C3=9F wr= ote: > > On 20.11.20 12:59, Peter Zijlstra wrote: > > On Fri, Nov 20, 2020 at 12:46:23PM +0100, Juergen Gross wrote: > >> +static __always_inline void arch_local_irq_restore(unsigned long flag= s) > >> +{ > >> + if (!arch_irqs_disabled_flags(flags)) > >> + arch_local_irq_enable(); > >> +} > > > > 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... > > > > Maybe something like: > > > > #ifdef CONFIG_DEBUG_ENTRY // for lack of something saner > > WARN_ON_ONCE((arch_local_save_flags() ^ flags) & X86_EFLAGS_IF); > > #endif > > > > At the end? > > I'd like to, but using WARN_ON_ONCE() in include/asm/irqflags.h sounds > like a perfect receipt for include dependency hell. > > We could use a plain asm("ud2") instead. How about out-of-lining it: #ifdef CONFIG_DEBUG_ENTRY extern void warn_bogus_irqrestore(); #endif static __always_inline void arch_local_irq_restore(unsigned long flags) { if (!arch_irqs_disabled_flags(flags)) { arch_local_irq_enable(); } else { #ifdef CONFIG_DEBUG_ENTRY if (unlikely(arch_local_irq_save() & X86_EFLAGS_IF)) warn_bogus_irqrestore(); #endif } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80FADC63697 for ; Sun, 22 Nov 2020 21:45:12 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FE7720782 for ; Sun, 22 Nov 2020 21:45:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="2o1jrHuQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE7720782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C094C85C54; Sun, 22 Nov 2020 21:45:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JdKCt3X1e4CC; Sun, 22 Nov 2020 21:45:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id A13FA85B0D; Sun, 22 Nov 2020 21:45:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7DACDC0891; Sun, 22 Nov 2020 21:45:10 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D62DC0052 for ; Sun, 22 Nov 2020 21:45:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2250A867BD for ; Sun, 22 Nov 2020 21:45:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 34RZ1NWX47pE for ; Sun, 22 Nov 2020 21:45:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8FF4A867BC for ; Sun, 22 Nov 2020 21:45:08 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B80AF20789 for ; Sun, 22 Nov 2020 21:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606081508; bh=j8kQr1sqydOsvjEY9shLB0wmUrzUic9iCe1dNmPahV0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=2o1jrHuQqj+owOO+c9Zeqxrd9M6szemlUmJSqcWPhibowyO6pXzhHfe+VU2CVHSEx 6i9l1pH/OrjB/ycgmevivnDyFQfhPd0sDLvyPdoRmGLzLfeZdce65//c9hJPyiAb0C IF/2dwA3JwvzN2WhaDRzodNq4IxJJOJIIJXD3gjA= Received: by mail-wm1-f44.google.com with SMTP id w24so15582190wmi.0 for ; Sun, 22 Nov 2020 13:45:07 -0800 (PST) X-Gm-Message-State: AOAM5333ucQynVVQXyS4GjNJLneFRJTjNRILhawN4l7TybceS0K/nWy9 N0qWLzfbf+sSNiftZHp+ZoVsunMAHIJ5R8jB+D3jXw== X-Google-Smtp-Source: ABdhPJwifakpgwUVTLbeDBYdoVmnAfRpiEVwGa2XrrCKUuyY/SYxT6I31Kv43oa6WFJkbjZ+4GFZn5n4pemXbXWt+C8= X-Received: by 2002:a1c:2781:: with SMTP id n123mr3937832wmn.49.1606081506352; Sun, 22 Nov 2020 13:45:06 -0800 (PST) MIME-Version: 1.0 References: <20201120114630.13552-1-jgross@suse.com> <20201120114630.13552-6-jgross@suse.com> <20201120115943.GD3021@hirez.programming.kicks-ass.net> In-Reply-To: From: Andy Lutomirski Date: Sun, 22 Nov 2020 13:44:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 05/12] x86: rework arch_local_irq_restore() to not use popf To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: Stefano Stabellini , Peter Zijlstra , X86 ML , LKML , Linux Virtualization , "VMware, Inc." , Ingo Molnar , Borislav Petkov , Andrew Lutomirski , "H. Peter Anvin" , xen-devel , Thomas Gleixner , Boris Ostrovsky X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" T24gU2F0LCBOb3YgMjEsIDIwMjAgYXQgMTA6NTUgUE0gSsO8cmdlbiBHcm/DnyA8amdyb3NzQHN1 c2UuY29tPiB3cm90ZToKPgo+IE9uIDIwLjExLjIwIDEyOjU5LCBQZXRlciBaaWpsc3RyYSB3cm90 ZToKPiA+IE9uIEZyaSwgTm92IDIwLCAyMDIwIGF0IDEyOjQ2OjIzUE0gKzAxMDAsIEp1ZXJnZW4g R3Jvc3Mgd3JvdGU6Cj4gPj4gK3N0YXRpYyBfX2Fsd2F5c19pbmxpbmUgdm9pZCBhcmNoX2xvY2Fs X2lycV9yZXN0b3JlKHVuc2lnbmVkIGxvbmcgZmxhZ3MpCj4gPj4gK3sKPiA+PiArICAgIGlmICgh YXJjaF9pcnFzX2Rpc2FibGVkX2ZsYWdzKGZsYWdzKSkKPiA+PiArICAgICAgICAgICAgYXJjaF9s b2NhbF9pcnFfZW5hYmxlKCk7Cj4gPj4gK30KPiA+Cj4gPiBJZiBzb21lb25lIHdlcmUgdG8gd3Jp dGUgaG9ycmlibGUgY29kZSBsaWtlOgo+ID4KPiA+ICAgICAgIGxvY2FsX2lycV9kaXNhYmxlKCk7 Cj4gPiAgICAgICBsb2NhbF9pcnFfc2F2ZShmbGFncyk7Cj4gPiAgICAgICBsb2NhbF9pcnFfZW5h YmxlKCk7Cj4gPiAgICAgICBsb2NhbF9pcnFfcmVzdG9yZShmbGFncyk7Cj4gPgo+ID4gd2UnZCBi ZSB1cCBzb21lIGNyZWVrIHdpdGhvdXQgYSBwYWRkbGUuLi4gbm93IEkgZG9uJ3QgX3RoaW5rXyB3 ZSBoYXZlCj4gPiBnZW5pdXMgY29kZSBsaWtlIHRoYXQsIGJ1dCBJJ2QgZmVlbCBzYXZlciBpZiB3 ZSBjYW4gaGF6IGFuIGFzc2VydGlvbiBpbgo+ID4gdGhlcmUgc29tZXdoZXJlLi4uCj4gPgo+ID4g TWF5YmUgc29tZXRoaW5nIGxpa2U6Cj4gPgo+ID4gI2lmZGVmIENPTkZJR19ERUJVR19FTlRSWSAv LyBmb3IgbGFjayBvZiBzb21ldGhpbmcgc2FuZXIKPiA+ICAgICAgIFdBUk5fT05fT05DRSgoYXJj aF9sb2NhbF9zYXZlX2ZsYWdzKCkgXiBmbGFncykgJiBYODZfRUZMQUdTX0lGKTsKPiA+ICNlbmRp Zgo+ID4KPiA+IEF0IHRoZSBlbmQ/Cj4KPiBJJ2QgbGlrZSB0bywgYnV0IHVzaW5nIFdBUk5fT05f T05DRSgpIGluIGluY2x1ZGUvYXNtL2lycWZsYWdzLmggc291bmRzCj4gbGlrZSBhIHBlcmZlY3Qg cmVjZWlwdCBmb3IgaW5jbHVkZSBkZXBlbmRlbmN5IGhlbGwuCj4KPiBXZSBjb3VsZCB1c2UgYSBw bGFpbiBhc20oInVkMiIpIGluc3RlYWQuCgpIb3cgYWJvdXQgb3V0LW9mLWxpbmluZyBpdDoKCiNp ZmRlZiBDT05GSUdfREVCVUdfRU5UUlkKZXh0ZXJuIHZvaWQgd2Fybl9ib2d1c19pcnFyZXN0b3Jl KCk7CiNlbmRpZgoKc3RhdGljIF9fYWx3YXlzX2lubGluZSB2b2lkIGFyY2hfbG9jYWxfaXJxX3Jl c3RvcmUodW5zaWduZWQgbG9uZyBmbGFncykKewogICAgICAgaWYgKCFhcmNoX2lycXNfZGlzYWJs ZWRfZmxhZ3MoZmxhZ3MpKSB7CiAgICAgICAgICAgICAgIGFyY2hfbG9jYWxfaXJxX2VuYWJsZSgp OwogICAgICAgfSBlbHNlIHsKI2lmZGVmIENPTkZJR19ERUJVR19FTlRSWQogICAgICAgICAgICAg ICBpZiAodW5saWtlbHkoYXJjaF9sb2NhbF9pcnFfc2F2ZSgpICYgWDg2X0VGTEFHU19JRikpCiAg ICAgICAgICAgICAgICAgICAgd2Fybl9ib2d1c19pcnFyZXN0b3JlKCk7CiNlbmRpZgp9Cl9fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fClZpcnR1YWxpemF0aW9u IG1haWxpbmcgbGlzdApWaXJ0dWFsaXphdGlvbkBsaXN0cy5saW51eC1mb3VuZGF0aW9uLm9yZwpo dHRwczovL2xpc3RzLmxpbnV4Zm91bmRhdGlvbi5vcmcvbWFpbG1hbi9saXN0aW5mby92aXJ0dWFs aXphdGlvbg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E125DC5519F for ; Sun, 22 Nov 2020 21:45:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F3772074B for ; Sun, 22 Nov 2020 21:45:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="2o1jrHuQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F3772074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.33503.64560 (Exim 4.92) (envelope-from ) id 1kgxAW-0002hm-3O; Sun, 22 Nov 2020 21:45:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 33503.64560; Sun, 22 Nov 2020 21:45:12 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kgxAW-0002hf-0J; Sun, 22 Nov 2020 21:45:12 +0000 Received: by outflank-mailman (input) for mailman id 33503; Sun, 22 Nov 2020 21:45:10 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kgxAU-0002ha-Ik for xen-devel@lists.xenproject.org; Sun, 22 Nov 2020 21:45:10 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 11f79419-10fd-421e-b73e-843b6a0110a1; Sun, 22 Nov 2020 21:45:08 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9B702084C for ; Sun, 22 Nov 2020 21:45:07 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id c198so14291657wmd.0 for ; Sun, 22 Nov 2020 13:45:07 -0800 (PST) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kgxAU-0002ha-Ik for xen-devel@lists.xenproject.org; Sun, 22 Nov 2020 21:45:10 +0000 X-Inumbo-ID: 11f79419-10fd-421e-b73e-843b6a0110a1 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 11f79419-10fd-421e-b73e-843b6a0110a1; Sun, 22 Nov 2020 21:45:08 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9B702084C for ; Sun, 22 Nov 2020 21:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606081508; bh=j8kQr1sqydOsvjEY9shLB0wmUrzUic9iCe1dNmPahV0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=2o1jrHuQqj+owOO+c9Zeqxrd9M6szemlUmJSqcWPhibowyO6pXzhHfe+VU2CVHSEx 6i9l1pH/OrjB/ycgmevivnDyFQfhPd0sDLvyPdoRmGLzLfeZdce65//c9hJPyiAb0C IF/2dwA3JwvzN2WhaDRzodNq4IxJJOJIIJXD3gjA= Received: by mail-wm1-f41.google.com with SMTP id c198so14291657wmd.0 for ; Sun, 22 Nov 2020 13:45:07 -0800 (PST) X-Gm-Message-State: AOAM533aLK3TddNWrYmdGe/ittJtb8tAeZ89VQTsA44PWNYO9rwBaUy/ D/RkMYsx6mfVzVXgVJFBbKJ1I5M96is8nUhLtvwsng== X-Google-Smtp-Source: ABdhPJwifakpgwUVTLbeDBYdoVmnAfRpiEVwGa2XrrCKUuyY/SYxT6I31Kv43oa6WFJkbjZ+4GFZn5n4pemXbXWt+C8= X-Received: by 2002:a1c:2781:: with SMTP id n123mr3937832wmn.49.1606081506352; Sun, 22 Nov 2020 13:45:06 -0800 (PST) MIME-Version: 1.0 References: <20201120114630.13552-1-jgross@suse.com> <20201120114630.13552-6-jgross@suse.com> <20201120115943.GD3021@hirez.programming.kicks-ass.net> In-Reply-To: From: Andy Lutomirski Date: Sun, 22 Nov 2020 13:44:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 05/12] x86: rework arch_local_irq_restore() to not use popf To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: Peter Zijlstra , Stefano Stabellini , "VMware, Inc." , X86 ML , LKML , Linux Virtualization , Ingo Molnar , Borislav Petkov , Andrew Lutomirski , "H. Peter Anvin" , xen-devel , Thomas Gleixner , Boris Ostrovsky Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Nov 21, 2020 at 10:55 PM J=C3=BCrgen Gro=C3=9F wr= ote: > > On 20.11.20 12:59, Peter Zijlstra wrote: > > On Fri, Nov 20, 2020 at 12:46:23PM +0100, Juergen Gross wrote: > >> +static __always_inline void arch_local_irq_restore(unsigned long flag= s) > >> +{ > >> + if (!arch_irqs_disabled_flags(flags)) > >> + arch_local_irq_enable(); > >> +} > > > > 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... > > > > Maybe something like: > > > > #ifdef CONFIG_DEBUG_ENTRY // for lack of something saner > > WARN_ON_ONCE((arch_local_save_flags() ^ flags) & X86_EFLAGS_IF); > > #endif > > > > At the end? > > I'd like to, but using WARN_ON_ONCE() in include/asm/irqflags.h sounds > like a perfect receipt for include dependency hell. > > We could use a plain asm("ud2") instead. How about out-of-lining it: #ifdef CONFIG_DEBUG_ENTRY extern void warn_bogus_irqrestore(); #endif static __always_inline void arch_local_irq_restore(unsigned long flags) { if (!arch_irqs_disabled_flags(flags)) { arch_local_irq_enable(); } else { #ifdef CONFIG_DEBUG_ENTRY if (unlikely(arch_local_irq_save() & X86_EFLAGS_IF)) warn_bogus_irqrestore(); #endif }