From patchwork Wed Mar 23 23:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 553805 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 EE95CC433FE for ; Wed, 23 Mar 2022 23:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345439AbiCWXI5 (ORCPT ); Wed, 23 Mar 2022 19:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345483AbiCWXIz (ORCPT ); Wed, 23 Mar 2022 19:08:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2827790FDA; Wed, 23 Mar 2022 16:07:18 -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=mj8PXvWr7idtmZWEBEDAzY/76f/xydcoSsKld+xUHEU=; b=BcZYwqNU0fJX+RTgM9TtGhxWDh YTQv4IH3xPlj9fadook3ZkO+aXwhLbNnZwX/hrXAKl282yxqKSsKMPkQQtP8tA+PwU817c4ruS/6A MtI5Ux3w6w8WsLShgZDkTfiJjzFZZocwMC8OCsBQbA2za8hM91edmovyj5CPoEIrIMZLfxwiUJwpW 7FT9ycmr65iiHIM4yGG4ulHoRyCWGepvvqvq/nT3IlDV4SKKN9zNAqMmCLi8+5HBueHWd5h9a7WNq tNV6rba/qtUufF+CbMJ/BKb1ni1ZpNIhmRbnElnILHuOjCc0gdoMPW/1JIxZeVPicprnQeR9qrB/e ZO7O1c/w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXA4O-00CvCt-PW; Wed, 23 Mar 2022 23:07:12 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 64BA5986200; Thu, 24 Mar 2022 00:07:12 +0100 (CET) Date: Thu, 24 Mar 2022 00:07:12 +0100 From: Peter Zijlstra To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, ebiggers@google.com, herbert@gondor.apana.org.au, Jason@zx2c4.com, Josh Poimboeuf Subject: [PATCH 4/2] objtool: Fix SLS validation for KCOV tail-call replacement Message-ID: <20220323230712.GA8939@worktop.programming.kicks-ass.net> References: <20220322114809.381992456@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220322114809.381992456@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Since not all compilers have a function attribute to disable KCOV instrumentation, objtool can rewrite KCOV instrumentation in noinstr functions as per commit: f56dae88a81f ("objtool: Handle __sanitize_cov*() tail calls") However, this has subtle interaction with the SLS validation from commit: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") In that when a tail-call instrucion is replaced with a RET an additional INT3 instruction is also written, but is not represented in the decoded instruction stream. This then leads to false positive missing INT3 objtool warnings in noinstr code. Instead of adding additional struct instruction objects, mark the RET instruction with retpoline_safe to suppress the warning (since we know there really is an INT3). Fixes: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1090,6 +1099,17 @@ static void annotate_call_site(struct ob : arch_nop_insn(insn->len)); insn->type = sibling ? INSN_RETURN : INSN_NOP; + + if (sibling) { + /* + * We've replaced the tail-call JMP insn by two new + * insn: RET; INT3, except we only have a single struct + * insn here. Mark it retpoline_safe to avoid the SLS + * warning, instead of adding another insn. + */ + insn->retpoline_safe = true; + } + return; } From patchwork Fri Mar 25 12:30:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 554104 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 53C6FC433F5 for ; Fri, 25 Mar 2022 12:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237386AbiCYMcb (ORCPT ); Fri, 25 Mar 2022 08:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244732AbiCYMc3 (ORCPT ); Fri, 25 Mar 2022 08:32:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765E3D0817; Fri, 25 Mar 2022 05:30:56 -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=YcSVVivNSS6HKwFtzFw9OEfDniOM+I9GJAUb7FZ1W4A=; b=fxduNBYyWHO7Q1Uha+uM3IlStL lTG/7c1EFPnG0OYn5uQ6TJEuaizhCeLP5adQrm26TsmRP7uZPScATVueABjnfn2sg0ocQO1wkR6IA e9YxSGZrMvzUu4XZCoJPfekTLsjnlLYiivJD6F9XYR4NEWARiqVKLGG3DBf8CuV+wj6CoDVrdiuo8 LoqIB+iwnrCoERz0M9v0HOK9Zl0kfsMHIEdoqT3GKx8NBFheOqDyqR5G1ZF//Aekrl0P/sjJD0FYv vPprZhs55FC4NtDE+I6pHZQT4wKMkIFjjDNeio2ub3qLZFqIvqLMIzD2iXlBDAK5qFxnqBAWcwO77 F6rD3BUg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXj5c-00EM6s-F7; Fri, 25 Mar 2022 12:30:48 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 13483987D26; Fri, 25 Mar 2022 13:30:48 +0100 (CET) Date: Fri, 25 Mar 2022 13:30:47 +0100 From: Peter Zijlstra To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, ebiggers@google.com, herbert@gondor.apana.org.au, Jason@zx2c4.com, Josh Poimboeuf Subject: [PATCH 5/2] x86/sm3: Fixup SLS Message-ID: <20220325123047.GR8939@worktop.programming.kicks-ass.net> References: <20220322114809.381992456@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220322114809.381992456@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This missed the big asm update due to being merged through the crypto tree. Fixes: f94909ceb1ed ("x86: Prepare asm files for straight-line-speculation") Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/crypto/sm3-avx-asm_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/crypto/sm3-avx-asm_64.S +++ b/arch/x86/crypto/sm3-avx-asm_64.S @@ -513,5 +513,5 @@ SYM_FUNC_START(sm3_transform_avx) movq %rbp, %rsp; popq %rbp; - ret; + RET; SYM_FUNC_END(sm3_transform_avx)