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 1CA48C43334 for ; Tue, 19 Jul 2022 17:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239776AbiGSR6n (ORCPT ); Tue, 19 Jul 2022 13:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236212AbiGSR6j (ORCPT ); Tue, 19 Jul 2022 13:58:39 -0400 X-Greylist: delayed 63558 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 19 Jul 2022 10:58:38 PDT Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3515B491F8 for ; Tue, 19 Jul 2022 10:58:37 -0700 (PDT) Received: (Authenticated sender: joao@overdrivepizza.com) by mail.gandi.net (Postfix) with ESMTPA id 352F6240006; Tue, 19 Jul 2022 17:58:30 +0000 (UTC) MIME-Version: 1.0 Date: Tue, 19 Jul 2022 10:58:30 -0700 From: Joao Moreira To: Sami Tolvanen Cc: Linus Torvalds , Thomas Gleixner , Peter Zijlstra , 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 In-Reply-To: References: <87o7xmup5t.ffs@tglx> <87lesqukm5.ffs@tglx> <2f7f899cb75b79b08b0662ff4d2cb877@overdrivepizza.com> <87fsiyuhyz.ffs@tglx> Message-ID: <656a965d6241d3a697180cc4d05ada2b@overdrivepizza.com> X-Sender: joao@overdrivepizza.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Clang always uses r11 for the indirect call with retpolines, so we'd > need to use another register. Nevertheless, splitting the constant into > two instructions would solve the call target gadget issue. Yeah, it clicked later yesterday. But, FWIIW, R10 is also considered a scratch register, although used for passing static chain pointers which I think is not a thing in kernel context. Last case scenario we can always do liveness analysis and I doubt we'll have a significant (if any) number of spills. If we are comparing through registers, I would suggest using a sub instruction instead of a cmp, as this will destroy the contents of the register and prevent it from being re-used on further unprotected indirect branches, if any exists.