Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1675241rdb; Sat, 2 Dec 2023 05:24:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuMmOQ/+OGgzWZy7ak2dlewCpmhh5aix54jPdG62RacJS0UtoaqZzAqkNWa6ltjMm6I4T4 X-Received: by 2002:a92:d0c1:0:b0:35d:5027:bc4c with SMTP id y1-20020a92d0c1000000b0035d5027bc4cmr1457011ila.17.1701523460079; Sat, 02 Dec 2023 05:24:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701523460; cv=none; d=google.com; s=arc-20160816; b=EuFrbDIG456ojReUi+KzYCH2ygZVyEBIi8KNPA2aJbwsWGbs3aybM7FQQi/hvNIONz 0de1l8swTKKVAchuUWeFI2ce1+drDj4SaG1956VyZ5I7F0Gb+QlPT2UkaUW5UWHXZrRX fy9MvxGH6MZBw1LO23S1BhfsO/d9qFay8BL/DFZzLQIktgxt7gIbPfmQtjyF3yL9Zupe hM6vCYT/oWim86ThkFUtscqKXbDCQQBumWJWLl4AYTllvXtoZyxB7tnutx4guq6WxB0B sfO7QwnMX+ehcX8hOgrQx9aWsqF9+LHJIdZ1G0ulb5CJz4zQvyVJWcZG0P6b+tsQChX6 oOBQ== 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=xbBDELC7nn7l4G4t/4Hskp3BKJTUD7BpetiKU8zsvnk=; fh=qFPSbSEpDfbw/BY5tMTpSGTFHsbwX3bkhHyVTKhqtbE=; b=fNNOXnNuNAcQ8GMV3g6L9nz7e/FB69nmmg5GD7ELqC+EbM6dg/YhPTwAC9EN89iTFy lmdR51Cl7n+BNNt8SQSWryBB9fn3BMLQTXtmOIWhNOg11mVC4FBNTYYeouw53tXJ0ARd wf9hOZREvZkv9R8BPV5fayh1h46YqHkoLi/ldihOuEKWCZ9layWG5DOeT8Y0T/2u8ZF1 0Y6YSgD6aseSy4Rzxmtw+klUJzlRvZC/2jaR6yCuvrtufmBo/q4oeoURVfUac1357TCd RByvws3oQWvD90UYQ1OSJ4e53CxjvDuMB3tIDes0/eG3mQFNKCcdBNClBkPrnZMMBC3h CYNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h130-20020a636c88000000b005c66a7d710bsi423216pgc.459.2023.12.02.05.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 05:24:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BBA7380C9A49; Sat, 2 Dec 2023 05:24:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232776AbjLBNYB (ORCPT + 99 others); Sat, 2 Dec 2023 08:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjLBNX7 (ORCPT ); Sat, 2 Dec 2023 08:23:59 -0500 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0C1BF3 for ; Sat, 2 Dec 2023 05:24:03 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3B2DNx6S015078; Sat, 2 Dec 2023 14:23:59 +0100 Date: Sat, 2 Dec 2023 14:23:59 +0100 From: Willy Tarreau To: Alexey Dobriyan Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kernel@vger.kernel.org Subject: Re: [PATCH] nolibc: optimise _start() on x86_64 Message-ID: <20231202132359.GA15040@1wt.eu> References: <38183c29-9b7f-4960-8702-d71ce816cf80@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <38183c29-9b7f-4960-8702-d71ce816cf80@p183> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 02 Dec 2023 05:24:17 -0800 (PST) Hi Alexey, On Sat, Dec 02, 2023 at 03:45:13PM +0300, Alexey Dobriyan wrote: > Just jump into _start_c, it is not going to return anyway. Thanks, but what's upper in the stack there ? I'm trying to make sure that if _start_c returns we don't get a random behavior. If we get a systematic crash (e.g. 0 always there) that's fine, what would be annoying would be random infinite loops etc. In the psABI description (table 3.9) I'm seeing "undefined" before argc, which I don't find much appealing. > Signed-off-by: Alexey Dobriyan > --- > > Also, kernel clears all registers before starting process, > I'm not sure why > > xor ebp, ebp > > was added. Hmmm psABI says: Only the registers listed below have specied values at process entry: %rbp The content of this register is unspecied at process initialization time, but the user code should mark the deepest stack frame by setting the frame pointer to zero. %rsp The stack pointer holds the address of the byte with lowest address which is part of the stack. It is guaranteed to be 16-byte aligned at process entry. %rdx a function pointer that the application should register with atexit (BA_OS). Thus apparently it's documented as being our job to clear it :-/ Willy