Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4794275imw; Tue, 19 Jul 2022 13:25:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vG1bTZW1PQkRcRc1QoN7tL1Ps0OJR3GbEHrNUhdiRflWBYyp6zJrO80B62U7mnHWZs7Xtg X-Received: by 2002:a17:90b:4a41:b0:1f0:6928:2363 with SMTP id lb1-20020a17090b4a4100b001f069282363mr1252924pjb.161.1658262325563; Tue, 19 Jul 2022 13:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658262325; cv=none; d=google.com; s=arc-20160816; b=fxyBujOyNirzBuxLPqGlWWc6QJbYbL1Mpy/PorSi6WJZAlMKXkNrJgQEVqfldSpk9u EjdyDUQXZQzAFaWHXE505HpsbOHXi/VBsruUlNn76jNbHBnmMT/2e1x8GJg/uPhP/xOO Rlmn+QCcJluYM1POFGvd7L29aloYTwFq3VvInn6wBwsZFGZs7qdXhlN58G1vrEhAF5CV UMFNrfeo9CunlFsuHcxIyITkPisl9EQ/QzRT5c8MNi/Lh7qIVbjz1HtKnP4dDpw/j6Va fDYyA2N6hTnVKVyYTI6cNUuKQ68aP6ksFzAczKBuXqfDYwpvWus3HVXEbtEq7O+jpEF0 yVOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GOR0llpLdBloIiRCsrXpHgKNvJE14oFor6X1Vr5Wpto=; b=eLHiL6DbJbQ3C2odmKZcWDQNsNrykKD4vnGh9CK/eRa1PswMVw7gP1RimbwIsQ2ALY HjFrDE0dCKtB2IMC5oN5WCHqxfO1hINP6jVMg2WgZV4eOYueSnI3VJg3lv9zLFnprx20 5utihmeFsFCP+cfEwkMWH8vPbe5Jp/rX6LBwQ35LRGExW836VWp10S+xOd8vZz1DlcW2 l8dcTAu+Yr3Yrfd5ExBLckuEbx58PGHvMHocn0QvGPPJCjtY35XzM6cGRkAWpq9fUf// jiYgI4AURm4c1fEtXVM2+3iuL+1hawM050H5H/nWwyQtOWqqhQSkE0uHwb2Ph3MJJEO2 y5pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Tfaqp4tt; 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 f14-20020a056a00228e00b005108171fe28si24004158pfe.162.2022.07.19.13.25.10; Tue, 19 Jul 2022 13:25:25 -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=@infradead.org header.s=desiato.20200630 header.b=Tfaqp4tt; 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 S238314AbiGSULG (ORCPT + 99 others); Tue, 19 Jul 2022 16:11:06 -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: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 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.