From patchwork Fri Oct 28 19:40:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 12528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1014387wru; Fri, 28 Oct 2022 12:55:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fxu5fBx51wk7Iw3yLgrS3KmYtK3/gVzjF9d93xzcD/lXlqU3JZxwpRb5OnZlo7LPpmfc1 X-Received: by 2002:a05:6402:42c7:b0:461:bea2:8a70 with SMTP id i7-20020a05640242c700b00461bea28a70mr1077536edc.261.1666986957863; Fri, 28 Oct 2022 12:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666986957; cv=none; d=google.com; s=arc-20160816; b=vPfW4ju/e8S7t7/802QHeYXbUzlNI/DnUiOH/EM+UuaOnkOV3s69ygPID1UpT4E2hM 9SHmfPZEys0N9neAdCQFcbNVDO+3RXGWC+htMUvFLYCPEmO/dx9dZFCAMfsk+OUWODWP 86pTuORwEiJvc+IBjUwnY+3v3MvAkEVvAORxHJUxXwI6x7vxzuVDLgV1ouaIZQr13ZHg g+t5+tZ6cZVyaWPxpT3VJH/P7drQCdrIEHCORgsTXf+1pebouHgEb+ticjJzMHTkS3Tt FAD10gEH60RChDT2r8w1Dw+QV72DHQO+UU0ZBEEBOMW1uuXK50crwLVlda9mg2ShgLqz yQ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=dw2+KyAKk/Vgq7gh3A5Vj3COoPkFBdj0Z6avPUlckh4=; b=Vle++BJQhYhhUW9Wbe+WfQXK1KRTYrfgA1UdUB77UrzYIWp53SuJ80VKaUQJ+GhT7n sAdaP4k+AhAAeNjm2E7q5ox2t+t+mKCBy78cIaT82RFpidmLehda+qXwQg5Kj9UxTgGR 2uzWokoFbOpkgDlKbdk8kB+5TRgnSApAKQqA89FP8VZLep+0tiVZKIrIaXElBoSL473m CeO3k0YB8R8mvBMjwdsh8ecrAf9KCMRkcbdzwk4N0HnyQAgDy9qEEEhhs0ozqHJ42TXE lNkO3/thB8FopqQXFHL0eKf46TKDO6UsuMCdD9zyV5ymaIIrH8acSGbMnQnUee0AvVRi Rc/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qeQgNOm1; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a056402524600b004574154f09asi1173248edd.529.2022.10.28.12.55.34; Fri, 28 Oct 2022 12:55:57 -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=casper.20170209 header.b=qeQgNOm1; 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 S230151AbiJ1TsK (ORCPT + 99 others); Fri, 28 Oct 2022 15:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiJ1Trz (ORCPT ); Fri, 28 Oct 2022 15:47:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76BD6241B35 for ; Fri, 28 Oct 2022 12:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=dw2+KyAKk/Vgq7gh3A5Vj3COoPkFBdj0Z6avPUlckh4=; b=qeQgNOm135IQHespPW8tvobp0V xikJ7xB2qqPBPAkaBL+pXNXryXDzY40SdFMIATyVZY1JFlOA6t9rDpCCgLGBBIArPoXgT/POmZ7DT AewooojZW7SNctC8ZLtyopjhGxrOmc4I9PMiiwO3O2sNpz5oRqZTyHgS2GjvkZlPbUqCUAaqBM8DV 4zd6qANrbAaxe06rPPKQ2QJ+jwH62H44tVnTZU7+wXh/N4doeluoBp69JNo6Tlf/PgV5d/wj0Lnyj uH++5Q5Qy4/2Wj5P4dt2SM5aBTdgrcfVOQ2fgd4yqYGW8neDvfi//ilCMsWPX5oTpni4S3yt0SQrr JaTR6KGw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooVKW-001V60-V0; Fri, 28 Oct 2022 19:47:49 +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 (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 20B90300C19; Fri, 28 Oct 2022 21:47:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id A7BBD2C6DAB2E; Fri, 28 Oct 2022 21:47:41 +0200 (CEST) Message-ID: <20221028194453.592512209@infradead.org> User-Agent: quilt/0.66 Date: Fri, 28 Oct 2022 21:40:27 +0200 From: Peter Zijlstra To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, djwong@kernel.org, yujie.liu@intel.com, tglx@linutronix.de, jpoimboe@kernel.org, joao.moreira@intel.com, samitolvanen@google.com Subject: [PATCH 5/5] x86: Add prefix symbols for function padding References: <20221028194022.388521751@infradead.org> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747962516634290289?= X-GMAIL-MSGID: =?utf-8?q?1747962516634290289?= When code is compiled with: -fpatchable-function-entry=${PADDING_BYTES},${PADDING_BYTES} functions will have PADDING_BYTES of NOP in front of them. Unwinders and other things that symbolize code locations will typically attribute these bytes to the preceding function. Given that these bytes nominally belong to the following symbol this mis-attribution is confusing. Inspired by the fact that CFI_CLANG emits __cfi_##name symbols to claim these bytes, use objtool to emit __pfx_##name symbols to do the same when CFI_CLANG is not used. This then shows the callthunk for symbol 'name' as: __pfx_##name+0x6/0x10 Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/Kconfig | 4 ++++ scripts/Makefile.lib | 1 + 2 files changed, 5 insertions(+) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2472,6 +2472,10 @@ config CALL_THUNKS def_bool n select FUNCTION_ALIGNMENT_16B +config PREFIX_SYMBOLS + def_bool y + depends on CALL_THUNKS && !CFI_CLANG + menuconfig SPECULATION_MITIGATIONS bool "Mitigations for speculative execution vulnerabilities" default y --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -265,6 +265,7 @@ objtool-args-$(CONFIG_STACK_VALIDATION) objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable +objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES) objtool-args = $(objtool-args-y) \ $(if $(delay-objtool), --link) \