From patchwork Tue Feb 2 13:36:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 374623 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp212699jah; Tue, 2 Feb 2021 05:47:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUq4Efd/Q6yhY6ldVepT/0T48wn3DqZLxI1FHfDb+P/k3C5kKpUFhhN7AO8i6gyxFRaGnI X-Received: by 2002:a17:907:9483:: with SMTP id dm3mr22141601ejc.120.1612273660988; Tue, 02 Feb 2021 05:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612273660; cv=none; d=google.com; s=arc-20160816; b=Pv/4DIm0beHOMQP7JWVZqZrBpc8tSKZT5PJcCLgT/bOeYc8rzz+fiARBZJJjlCitLk 60JBbt2mfjrPSjin0dwvKedtgwDBy/cRQ7OF/z//9d74tvkG6/f/CmwZp45Hr3URZbZS +HAjTTLbscdfdbOi34YF2rPj7zeCuAj03K42bN85pKUzzBRnamiqmW0DElFfcpBFatxs FVfaeymu5DFVrCFEw4uklFlNRFYhd34fuTKBAvG8IxUl05nPn/VD7f8wxhTSVrqBa60B B8hNb+/HuPlxQFY5EXHL8YzBK0rJShLPUuo72S5KTYD8jerqcJUiyRVgQ7T276BL90eC ttLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Quug6rjO+Y9RwIa1Yx25NP1x22ZbFMJoINQY7fsU99w=; b=WB+3CYNu+YECVzH4C4C6HJQf+LmMiOkPzUIL0lnawyyENMzM6YEP7eeXsP+cxkuHhw JfrUeDvtpu/iSksXX+H2s7E/kZPjGqSmMf4yNBhFIIsqRL+IquhBUFC7arhMy80WV9ok Rm1EtMFGkgxVEez4SPEdfi8IFtx2pxRt9PbwfknPNdqX15rolwSrrbDH0lPke/PgQThx a1DrRulxZKI6KAF+B3BnHv4RLZM6RoIvXRxT6ydsoAfJ5U5JcoR1iAh2VW2LskSfgSwp GKZeeb8lVzbWCfgAZo/X4f8QlQTt0Thz2qlhHHC9qiSjQpdNDg7GnXZBT8VCcHAN0yJp MLCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FBiDYePG; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si13458200eds.7.2021.02.02.05.47.40; Tue, 02 Feb 2021 05:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FBiDYePG; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232820AbhBBNqp (ORCPT + 13 others); Tue, 2 Feb 2021 08:46:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:36350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbhBBNpK (ORCPT ); Tue, 2 Feb 2021 08:45:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 416CD64F76; Tue, 2 Feb 2021 13:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273239; bh=PhylmEDigE/Fyoxcnd+m+iZ6ndgWX3G9KEaOs+tmo5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBiDYePG5Y+u6DqZ021i0SRInRnV2g72ONRtJEjT4rpBPopRP3exkBGuKaMTnq8H8 UbgTbz9zMC6wfUqQAwQl3E6QpUQf0mcONDDo+Cm9rPsYchniB+drD7GU292SUHjWTD N1WTAJKQWWljPsXOvKe3bLe4SO6Gd16i/2QTEut0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Josh Poimboeuf , Borislav Petkov , Mark Brown , Nick Desaulniers , Borislav Petkov , "Peter Zijlstra (Intel)" , Chris Clayton Subject: [PATCH 5.10 032/142] x86/entry: Emit a symbol for register restoring thunk Date: Tue, 2 Feb 2021 14:36:35 +0100 Message-Id: <20210202132959.033676544@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit 5e6dca82bcaa49348f9e5fcb48df4881f6d6c4ae upstream. Arnd found a randconfig that produces the warning: arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at offset 0x3e when building with LLVM_IAS=1 (Clang's integrated assembler). Josh notes: With the LLVM assembler not generating section symbols, objtool has no way to reference this code when it generates ORC unwinder entries, because this code is outside of any ELF function. The limitation now being imposed by objtool is that all code must be contained in an ELF symbol. And .L symbols don't create such symbols. So basically, you can use an .L symbol *inside* a function or a code segment, you just can't use the .L symbol to contain the code using a SYM_*_START/END annotation pair. Fangrui notes that this optimization is helpful for reducing image size when compiling with -ffunction-sections and -fdata-sections. I have observed on the order of tens of thousands of symbols for the kernel images built with those flags. A patch has been authored against GNU binutils to match this behavior of not generating unused section symbols ([1]), so this will also become a problem for users of GNU binutils once they upgrade to 2.36. Omit the .L prefix on a label so that the assembler will emit an entry into the symbol table for the label, with STB_LOCAL binding. This enables objtool to generate proper unwind info here with LLVM_IAS=1 or GNU binutils 2.36+. [ bp: Massage commit message. ] Reported-by: Arnd Bergmann Suggested-by: Josh Poimboeuf Suggested-by: Borislav Petkov Suggested-by: Mark Brown Signed-off-by: Nick Desaulniers Signed-off-by: Borislav Petkov Acked-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com Link: https://github.com/ClangBuiltLinux/linux/issues/1209 Link: https://reviews.llvm.org/D93783 Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1] Cc: Chris Clayton Signed-off-by: Greg Kroah-Hartman --- Documentation/asm-annotations.rst | 5 +++++ arch/x86/entry/thunk_64.S | 8 ++++---- include/linux/linkage.h | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) --- a/Documentation/asm-annotations.rst +++ b/Documentation/asm-annotations.rst @@ -100,6 +100,11 @@ Instruction Macros ~~~~~~~~~~~~~~~~~~ This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above. +``objtool`` requires that all code must be contained in an ELF symbol. Symbol +names that have a ``.L`` prefix do not emit symbol table entries. ``.L`` +prefixed symbols can be used within a code region, but should be avoided for +denoting a range of code via ``SYM_*_START/END`` annotations. + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the most frequent markings**. They are used for functions with standard calling conventions -- global and local. Like in C, they both align the functions to --- a/arch/x86/entry/thunk_64.S +++ b/arch/x86/entry/thunk_64.S @@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name) .endif call \func - jmp .L_restore + jmp __thunk_restore SYM_FUNC_END(\name) _ASM_NOKPROBE(\name) .endm @@ -44,7 +44,7 @@ SYM_FUNC_END(\name) #endif #ifdef CONFIG_PREEMPTION -SYM_CODE_START_LOCAL_NOALIGN(.L_restore) +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore) popq %r11 popq %r10 popq %r9 @@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore) popq %rdi popq %rbp ret - _ASM_NOKPROBE(.L_restore) -SYM_CODE_END(.L_restore) + _ASM_NOKPROBE(__thunk_restore) +SYM_CODE_END(__thunk_restore) #endif --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -178,6 +178,11 @@ * Objtool generates debug info for both FUNC & CODE, but needs special * annotations for each CODE's start (to describe the actual stack frame). * + * Objtool requires that all code must be contained in an ELF symbol. Symbol + * names that have a .L prefix do not emit symbol table entries. .L + * prefixed symbols can be used within a code region, but should be avoided for + * denoting a range of code via ``SYM_*_START/END`` annotations. + * * ALIAS -- does not generate debug info -- the aliased function will */