Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2281270pxp; Mon, 21 Mar 2022 15:47:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyil9li7v2GWiX3HgNDWENHAnUns9zdhhy2Q7N2FQ1GzrsQnA7ltnaE2URWblVV06WUPZG1 X-Received: by 2002:a17:902:cf04:b0:14d:79fd:a2c9 with SMTP id i4-20020a170902cf0400b0014d79fda2c9mr14919907plg.104.1647902839641; Mon, 21 Mar 2022 15:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902839; cv=none; d=google.com; s=arc-20160816; b=kjJ0sB8rxYTUdtW1xG3TMT3WfqAl2bKrzhXyduvlUnO3V4wrdcK+4QtoSJVUBNxcat Qe+shHN1cBILyYLhd4SkONyhd8fNo9U0d6tRgsvsvcx6rDByu5+CjYHgJrMVIZfXLDEc c7ymzkg5S2htkVfS+aD5Q1B7sPeL4SMw4O9fmoSjFWp0amLikaIPlWpLKfs+zrzpeoAJ uJ2ucjiV0Fb+cDBc1Z8BegSlWjWTqDJl7PJumdbYoUx4D4FkyTTSM8VFMJ4wthvfrpQL YrNe10XahNjGXLZ5dViERCiS7ggoOUYtGFdaN81cscwaT7V4uAAbWIkANLYxpknS+xwV HlAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Q398MZyop6JzLH9PcL3JT7c7GhYUdzoqQzK/9MAaZ20=; b=KpYhIhopbIHaStUyE5cYAdWXPQX0wJxF2WSW1FbdcHOoGTXfHTYcJz2RxOGhMYL9Sk xo3l2vn/gTtCr7ei8lkCUYK1fodhHJ1kLBsCuSWi0S83yKcgl3lFs0cknklEfyTonEZs LGh9piVrug8xQ2lNEL6MwdyLVufyD8EHosP0QUspmV/fGpmfm1NF7RG3ZhXZpoQWApiJ gTklRiBmnYcRdXWRj+IHJBWWn8BfrjakPDwtxGhS+vtJ7yhqEB+0XvALfPHlEySB//E9 LAwld866B88U6/SqxLJLC/KAP8GJz2xpKb6NWljUxbRPcR6+ldRGnS+R3cBY5TOE17+y 2DrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id gf21-20020a17090ac7d500b001bed0171c8esi562705pjb.13.2022.03.21.15.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C2183E9386; Mon, 21 Mar 2022 14:55:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241555AbiCRXuM (ORCPT + 99 others); Fri, 18 Mar 2022 19:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241551AbiCRXuK (ORCPT ); Fri, 18 Mar 2022 19:50:10 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C506F52E47; Fri, 18 Mar 2022 16:48:49 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 22INgDNB014381; Fri, 18 Mar 2022 18:42:13 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 22INgCLj014380; Fri, 18 Mar 2022 18:42:12 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 18 Mar 2022 18:42:12 -0500 From: Segher Boessenkool To: Linus Torvalds Cc: Andrew Cooper , Andy Lutomirski , Nick Desaulniers , "H. Peter Anvin" , Bill Wendling , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Nathan Chancellor , Juergen Gross , Peter Zijlstra , "llvm@lists.linux.dev" , LKML , linux-toolchains Subject: Re: [PATCH v5] x86: use builtins to read eflags Message-ID: <20220318234212.GU614@gate.crashing.org> References: <83b33afc-8502-0065-60bc-3a91528632d8@kernel.org> <9a97330b-e5ee-7b7e-4c7a-cfdf15032094@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,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 Fri, Mar 18, 2022 at 04:10:55PM -0700, Linus Torvalds wrote: > It would be lovely to have some explicit model for "I want the frame > to have been set up for backtraces", but here we are. So please define exactly what that *means*? Preferably portably, but I reckon at least some of it will have to be machine-specific (and ABI- specific). But it needs to be well-defined, clearly defined, defined at all, and *documented* :-) > Marking '%rsp > used makes the compiler understand it's not a leaf function. As I said before, this is explicitly incorrect code. Always was, but it is documented since a while (since GCC 9). Clobbering the stack pointer can never be correct, the stack pointer after an asm has to be identical to the one before that asm! > And while we have other uses for it that then use the actual value, > those don't care about the exact value of the stack pointer register, > they just want "give me a pointer that is contained within the current > stack", because we control the stack allocation and do funky things > there. So "any random stack pointer value in this function" is > perfectly fine and expected. You can use %rsp as *input* operand just fine, which is all you need for that. > But for user mode, it would probably be a great idea to also have a "I > cannot use a redzone in this function" thing. The kernel can't use it > because we have nested exceptions, but maybe some day even the kernel > could make use of (controlled) red-zoning. Yes. We just have to figure out what the exact semantics we want is, and how to express that in a target-independent way, and then relatedly what a good name for it would be ("redzone" in the clobber list is the best I can come up with right now, but that may have to change). Segher