Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1760531pxp; Thu, 17 Mar 2022 16:33:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyny1S5cixBAiedMHw2fx9vHoRwOZkwgHA0vIdWiXqOI4BkT9Yykb9s8Rie/FMdBwyS8InD X-Received: by 2002:a17:907:7e86:b0:6df:939a:81e3 with SMTP id qb6-20020a1709077e8600b006df939a81e3mr5147921ejc.323.1647560029465; Thu, 17 Mar 2022 16:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647560029; cv=none; d=google.com; s=arc-20160816; b=Cpq7INkU0Fx6I+OWIDg9ADhWFSq4o6biZpCNOy6jo0Cvv5KE2UWlBFe8G3VMvBsXWd tS+pqOidjN3dzO/TamqWIWtJcBZGp4tUQfB0wVIb+sAWjHGdZJNX/0PQEAovk10BeZjf rnsRYRVAFdrZPI6oZaqO1i6g5Na/+se+zkCq1HulbXiMciEgTTzGQh7YJYAz0/V2oegu HvN7nV/TtTQBQRIvXv6kxFCRHF9OV0Mp2Y6jtH3c+roI3lYW2RRhEWOLXzK6sDrk+OtA 6q3WH0izym3yIijGA+Lm/b/DbWuhglBPBMErHaGlqRRFytbO7Ixm6OjFWVmIGI3RvRuN EPXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4Ggl/MKy9XRVzUM8Rcs5TJdLd4Il3RiYZLoq63qTJK8=; b=Fu2iqaXWNgPjCTDOBgej/6zUqGtzHOCxFpqcJrlasLfMkD0q1Vpd/c9YUBYgeYIFaw wwyA2cMOWFFQRZxfrDKyqFyd3qpJtnCjkeKbVkx1RWlJUZm7AuQg3IhaQWU5e13xOj8h KLX+rCinwI5XoNZyKeWGfTKoMEhIi/9qgdTVzSqyOvBi5WpjwBrvcR0BTxHJZEMxpQ4r Fuo746nlG09MqGXaigAJcjeF6RUcINdXgMQeZkcfwflUi9QUllsD+VZZwWYYfoVJK3kh 5r6px50FfurVnQQE7OWSYzNcpUHD0vYUKeNho411sXO3CRGFAh/NKz75CxIs9AzvoHVN 0OJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="aB/PPKlD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv26-20020a170907209a00b006df76385f3dsi282582ejb.989.2022.03.17.16.33.24; Thu, 17 Mar 2022 16:33:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="aB/PPKlD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbiCQWxJ (ORCPT + 99 others); Thu, 17 Mar 2022 18:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiCQWxI (ORCPT ); Thu, 17 Mar 2022 18:53:08 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93DC71D190F for ; Thu, 17 Mar 2022 15:51:50 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id o6so9198903ljp.3 for ; Thu, 17 Mar 2022 15:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4Ggl/MKy9XRVzUM8Rcs5TJdLd4Il3RiYZLoq63qTJK8=; b=aB/PPKlDrKRoBhLTrJwzPyuNJHKMZwzBoG0rWaX2qAOgQ9CjuDGv+hSVYksU8EpQTo YalzViobDb8KoaWEuWddyYckVjHqBPFi3+RgSCFumrPJ9guxgC5y4ez7ObNQBMEJugrz umyGFNVU7J5jZGcsHv0h4PyaKF6RxL69ELA78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4Ggl/MKy9XRVzUM8Rcs5TJdLd4Il3RiYZLoq63qTJK8=; b=2pgQK/Gz4KfjxZxE2TrDB9WaVLIM9/1b8kdfcJq402OY70KeaOoOpKkRYyoNPreMma pSa6qm+8DPkPhb23yj6P24cLgjur/xPiiJBYmKEotO85zoaLZA0l/Quy9GzcRrcniJke KsYh7uEBnGQ715eBqYEKEKNyqyEbu2UVebSX/vOvzI17DjZ1JNy6XLLk3z6xGLAQfRbn WzR0/opgU8Sh3yqVfORlL0J+9MbKEopzmegAMIUJ4NBBiFUmygxvsWWRfbnTkW/ZootL l4g3eRukk8WxYvmvHk1T/lZJ/pS44lT1BT8ptyaVek1v+g6bZIaBtv2hKvKa97lXRW+F 3EYA== X-Gm-Message-State: AOAM533sWxMvrOg+AVFYrObvvEUlCPhv+L7VL/AkHp/gAsTTa0e2bTQn PVZHyYlfj1u5IaurjcS6qLDhnYRirzC+SZQWENo= X-Received: by 2002:a2e:9203:0:b0:247:ebe3:7d0c with SMTP id k3-20020a2e9203000000b00247ebe37d0cmr4278918ljg.278.1647557508737; Thu, 17 Mar 2022 15:51:48 -0700 (PDT) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com. [209.85.167.45]) by smtp.gmail.com with ESMTPSA id 24-20020ac24858000000b004481ff4805esm569616lfy.151.2022.03.17.15.51.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 15:51:46 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id p15so700404lfk.8 for ; Thu, 17 Mar 2022 15:51:45 -0700 (PDT) X-Received: by 2002:ac2:4f92:0:b0:448:7eab:c004 with SMTP id z18-20020ac24f92000000b004487eabc004mr4172510lfs.27.1647557504973; Thu, 17 Mar 2022 15:51:44 -0700 (PDT) MIME-Version: 1.0 References: <20220210223134.233757-1-morbo@google.com> <20220301201903.4113977-1-morbo@google.com> In-Reply-To: From: Linus Torvalds Date: Thu, 17 Mar 2022 15:51:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] x86: use builtins to read eflags To: Bill Wendling Cc: Nick Desaulniers , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Nathan Chancellor , Juergen Gross , Peter Zijlstra , Andy Lutomirski , llvm@lists.linux.dev, LKML , linux-toolchains Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 2:45 PM Bill Wendling wrote: > > I'm NOT saying that it WILL change or that it SHOULD change. I'm also > not saying that your concern isn't justified. What I am saying is that > unless you're using a compiler feature that's DEFINED as having a > certain effect, then you are not using that feature correctly, > regardless of how it's acted in the past. And it has the potential to > bite you in the ass sooner or later. We've all seen such things happen > before. So I think most of inline asm constraints are fairly well defined. Certainly "memory" clobbers are. The unfortunate exception to this is, I think, "volatile". It has always had somewhat undefined semantics (iirc originally gcc talked about it not being "moved significantly" etc), and it ends up getting mixed reasons for existing. The *natural* semantics would be to literally make it have the same rules as volatile data accesses: something like "'volatile' marks the asm as having visible side effects in the virtual machine". So I think natural semantics for "asm volatile" - and the ones that would be simple to document - would literally be to compare it to those volatile memory accesses, and say that it can't be optimized away, and it's ordered wrt other volatile operations (whether volatile data accesses or other volatile asm instructions). But that is, afaik, not what it ever did, so it always had somewhat random semantics, the main being "it can't be removed even if its outputs are never used". So the "cannot be optimized away" ends up being the central part of the definition, but without the conceptual sense. And then we in the kernel have then also co-opted 'asm volatile' to just fix some compiler bugs, so we end up using "asm volatile goto" because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 although *that* particular issue is probably historical now that we require more modern compiler versions. I still think that from a sanity standpoint, it would be good to actually strengthen the semantics of "asm volatile" to literally act as - and be ordered with - volatile memory accesses. But I guess that's water under the bridge. Linus