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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 2A198C433ED for ; Tue, 18 May 2021 13:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0048D6008E for ; Tue, 18 May 2021 13:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239145AbhERNY5 (ORCPT ); Tue, 18 May 2021 09:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244483AbhERNY4 (ORCPT ); Tue, 18 May 2021 09:24:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A641AC061573 for ; Tue, 18 May 2021 06:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YA9ce+bo8JYjuOoUAJcCgE/jJYMQZd1AYXIAE1nwU1w=; b=bKWD29vwzdmNW3yJ7BzMuwyp9C IvzRJzQoxfIiNaOV+U8rRjBBjd+Qb4G73bzVmwTxcbaRrbt5KvltXPzkcm7cGWOtqghGYUQ6LZRNt dQcZ6Zhw2F5bwp6PENklvqDHVy5qTZwAW7TyFHcqNDcayv0t2ioMA10ePVvtq7Gr4OiZtfWRkIz2W HUlfAKf1YczPo4EBqo/hB+Ruk6/4YDPw0gg7QwK1L7pASpfmlJQdOKYPG+gAahtQEDkukN5l6qAhC inxI/ebyOSrvgrJcbreUZjp1cMAjAjOgQHOX4KwjAUUeZWqBSMgLJkdpiwsqSu+3twbt/4qFBRApm mZGfXmRA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lizfc-00E0YE-Bl; Tue, 18 May 2021 13:22:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1AD4930022C; Tue, 18 May 2021 15:21:58 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D9BB52027ACE9; Tue, 18 May 2021 15:21:58 +0200 (CEST) Date: Tue, 18 May 2021 15:21:58 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: Will Deacon , Nick Desaulniers , "Jose E. Marchesi" , "Paul E. McKenney" , ardb@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-toolchains@vger.kernel.org Subject: Re: Linux Plumbers Conf 2021 Message-ID: References: <20210518121447.GB7914@willie-the-truck> <20210518124311.r4fwv6lfz3erkqnb@treble> <20210518124819.lkzzgjcrh4cc5a6i@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210518124819.lkzzgjcrh4cc5a6i@treble> Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Tue, May 18, 2021 at 07:48:19AM -0500, Josh Poimboeuf wrote: > Fixing linux-toolchains list address. > > On Tue, May 18, 2021 at 07:43:13AM -0500, Josh Poimboeuf wrote: > > On Tue, May 18, 2021 at 01:14:48PM +0100, Will Deacon wrote: > > > If it's not too late, I'd definitely be interested in a discussion around > > > objtool support for arm64. Specifically, I would very much like us _not_ > > > to have a hard dependency on objtool and instead treat it as a binary > > > linter of sorts. However, this likely requires help from the toolchain > > > where some of the jobs which are performed by objtool on x86 today now > > > need to be done by the compiler/linker for arm64. > > > > > > I don't have a good handle on exactly what is needed and whether there's > > > any appetite from the toolchain developers to implement this, so it would > > > be very helpful to kick that discussion off. > > > > Objtool stack validation already is pretty much a "binary linter". If > > all the warnings are fixed then we can trust the unwind metadata (e.g. > > frame pointers) for reliable unwinding / live patching. > > > > All warnings are expected to be fixed by humans, so objtool doesn't have > > to edit the binary (assuming no ORC, which is optional). Objtool is > > only considered a hard dependency for live patching because unfixed > > warnings could mean a livepatch fail. > > > > So I wonder what specifically you have in mind? Things objtool does (in no apparent order): - validate stack frames - generate ORC unwind data (optional) - validates unreachable instructions; specifically the lack thereof (optional) - validates retpoline; or specifically the lack of indirect jump/call sites (with annotations for those few that are okay). (optional) - validates uaccess rules; specifically no call/ret in between __user_access_begin() and __user_access_end(). (optional) - validates noinstr annotation; *HOWEVER* we rely on objtool to NOP all __sanitizer_cov_* calls in .noinstr/.entry text sections because __no_sanitize_cov is 'broken' in all known compilers. - generates __mcount_loc section and NOPs the __fentry call sites (optional) - generates .static_call_sites section for STATIC_CALL_INLINE support - rewrites compiler generates call/jump to the retpoline thunk to an alternative such that we can patch out the thunk with an indirect call/jmp when retpolines are disabled. (arch dependent) - rewrites specific jmp.d8 sites (as found through the __jump_table section) to nop2, because GAS is unable to determine if a jmp becomes a jmp.d8 or jmp.d32 and emit the right sized nop. (optional) So all except the __sanitize_cov__ crud would be fine, but that thing in specific really wants fixing in the toolchains. Aside of that, all the things where objtool generates/modifies sections/code are optional and or architecture dependent. Aside of that, objtool depends on being able to reconstruct the code flow as generated by the compiler and a few code-gen options are known to generate things objtool simply cannot follow, arm64 in specific had some trouble with jump-tables.