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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82EC4C43334 for ; Tue, 19 Jul 2022 20:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239034AbiGSULH (ORCPT ); Tue, 19 Jul 2022 16:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbiGSULF (ORCPT ); Tue, 19 Jul 2022 16:11:05 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61224BD07 for ; Tue, 19 Jul 2022 13:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=GOR0llpLdBloIiRCsrXpHgKNvJE14oFor6X1Vr5Wpto=; b=Tfaqp4ttkQei6Oeicdchy18prg 3S7V4zJifcIfx01svr+64oiwdsjfd354P4zmJP6zXuZ/Zv+sP7A+lcSb2XKjm+o5un0nSQ6+cYy3/ pqO31l2si35IgStN24u1jE6dbmondXwK8sFKKxxvZ+tMRYgU87FetIJ098VreftPB1Wy85lHhNspI uWZOzFdGGefDWwvGl6SPKbm+5PkanbL/sH25YFH5Xjujb5ILttJLdjmHnHqUEnv+uPezu9iB/o7s7 3Y/Ae671uzrzQUk+s91Rg4myBhsBOhmcQY3yKddT/WxMiE/1GUmPvFo8+c6A+rWQ9PgM0hMslkTtM +OQip1IA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDtXq-005AAp-4v; Tue, 19 Jul 2022 20:10:15 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 43EA19802A4; Tue, 19 Jul 2022 22:10:11 +0200 (CEST) Date: Tue, 19 Jul 2022 22:10:11 +0200 From: Peter Zijlstra To: Sami Tolvanen Cc: Linus Torvalds , David Laight , Thomas Gleixner , Joao Moreira , LKML , the arch/x86 maintainers , Tim Chen , Josh Poimboeuf , "Cooper, Andrew" , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , "Moreira, Joao" , "Nuzman, Joseph" , Steven Rostedt , "Gross, Jurgen" , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , Peter Collingbourne Subject: Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation Message-ID: References: <87fsiyuhyz.ffs@tglx> <0e038c2795784b7eb4de52f77b67206a@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 19, 2022 at 11:06:40AM -0700, Sami Tolvanen wrote: > On Tue, Jul 19, 2022 at 10:27:00AM -0700, Linus Torvalds wrote: > > On Tue, Jul 19, 2022 at 10:23 AM Sami Tolvanen wrote: > > > > > > The preamble hash is encoded into an instruction just to avoid special > > > casing objtool, which would otherwise get confused about the random > > > bytes. On arm64, we just emit a bare constant before the function. > > > > Ahh. > > > > I think objtool would want to understand about kCFI anyway, so I think > > in the long run that hack isn't a goog idea. > > > > But I get why you'd do it as a "do this as just a compiler thing and > > hide it from objtool" as a development strategy. > > I believe it was actually Peter's idea to use an instruction. :) In > earlier revisions of KCFI, I did teach objtool about the preambles, but > that was just so it can ignore them. Right; even if we teach objtool about kCFI, having text be actual instructions makes things much nicer. Objdump and friends also shit their pants if you put random bytes in. It only costs a single byte to encode the immediate, so why not. Specifically, the encoding used is: movl $0x12345678, %eax and that is 0xb8 followed by the constant, but there's plenty other single byte ops that could be used.