Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp721420iob; Wed, 18 May 2022 11:24:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVZdNayK8yR/v8kEIDWMwu+L8wlMtZM+XZKL9KmokcZo8GcheT5L6npWqMsU3u9JN+fy48 X-Received: by 2002:a63:85c8:0:b0:3da:eb5d:6def with SMTP id u191-20020a6385c8000000b003daeb5d6defmr632468pgd.96.1652898269165; Wed, 18 May 2022 11:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652898269; cv=none; d=google.com; s=arc-20160816; b=KMtI+3xalDPLDBuP0MYxJZSisrl8/IXfq+XjDuqpNu5heUozSUdyGNysvE0jYTyJjl csdAsoVjxgWMMNo2VuxVBE/RSUFu9kklmterUvfmeOoqrRPo14YDL7hAGP/r7rwd2Spc SdGAq2ps9ib+/QHi2GmQZXSuqSu/fVXuBe5o9t3a5tVE5pJ0aU+/vKwbJfunhMjR77Qo 2QS0ku0RpN+2IPHXBAph9FyqWft6KE1Ra9LBo7Ykvm5H1eEBkq0psDwQlGqpLcUbH7gW RO6SBRwCxKQMy5MShrr9cOcd1E3swGCSdb1/o2FQ9WImTnsZLR2C0EtEm30HURr1aiG4 pCbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=BIZAjSskEX4ZGsdDdyHF4V6S1IvnQosszACzcUTuvvw=; b=Eu2LwvAQHUTJtzzYoNWrxzI+andD+R+UzU0m6fh8yoB6uXfsuxGEjyafMwv1zYlyo2 7uhLJyaBExDA0xfRSlbXqAxwOIupS8WNkRcpOZ5PkC84hsiRK6CbBijjai+zVCd93dbK +Sd/Nw5/1Ekb1odOseqCMxTXVLEiAIyCVlS9OmvJdHJijWuv0q1L0pvFOiEdX7T+EalB N7j9Q5pKewXHOv7BhRxkEIazISVb/nFcjeLVtzag2er54rRx0NJUWuxQkArrrn3TvoxL WGolqWIlGQVwvkKNFcAcBIv1CLYmsJH9QIGWJ7OS/dmyW2SeCXtxXiRLoQePdRsgvYit XmCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="M/+uNR8W"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s18-20020a170903201200b0015e8c77a599si3043359pla.1.2022.05.18.11.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 11:24:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="M/+uNR8W"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 620CF1C94EF; Wed, 18 May 2022 11:19:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241376AbiERSTk (ORCPT + 99 others); Wed, 18 May 2022 14:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241339AbiERSTj (ORCPT ); Wed, 18 May 2022 14:19:39 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5611C7435 for ; Wed, 18 May 2022 11:19:36 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IIHYLO019334; Wed, 18 May 2022 18:19:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=BIZAjSskEX4ZGsdDdyHF4V6S1IvnQosszACzcUTuvvw=; b=M/+uNR8WKwNu7M/JW2Pzi3TO/M0oRujQrYJ5g/izFNcOqG+O0AOT8aeX7buNbbyPlb8t S/YXv75ZZqS5xtiP8D4yUVyabftWddM39a+CnoJdh96n+fAMrUJ9w0mt+n/CPpVZBGQM 6SwZ2cPsZXUQ7TmVBWqYzBmMyfRRLuO6jJeP9I7zr/frclNpGjmYYOWGw62BXgfAAdxr M+SiYLAQqsHwp6bD9IMex/flLT83efWBxOVK7RiZbdlBpkRU8V/fVj6EcoyGrt142Byp yhRkzoqn+yXNApSoGXXhyLBILuaYR61wmYuHEF3HwIHmTfaVCKP9spNGh9JnD1YjKhuV kA== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g55xxg151-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 May 2022 18:19:15 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24II8XKa011871; Wed, 18 May 2022 18:19:13 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3g2429e34f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 May 2022 18:19:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24IIJAao52232462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 18:19:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB51C4C046; Wed, 18 May 2022 18:19:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 118784C040; Wed, 18 May 2022 18:19:09 +0000 (GMT) Received: from li-NotSettable.ibm.com.com (unknown [9.43.19.36]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 May 2022 18:19:08 +0000 (GMT) From: "Naveen N. Rao" To: Michael Ellerman , Eric Biederman Cc: , , kexec@lists.infradead.org Subject: [PATCH] kexec_file: Drop weak attribute from arch_kexec_apply_relocations[_add] Date: Wed, 18 May 2022 23:48:28 +0530 Message-Id: <20220518181828.645877-1-naveen.n.rao@linux.vnet.ibm.com> X-Mailer: git-send-email 2.27.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uPzPQywlzQTS2FrupWy_fWcu16Q8beLq X-Proofpoint-ORIG-GUID: uPzPQywlzQTS2FrupWy_fWcu16Q8beLq Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 mlxlogscore=689 bulkscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180106 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Since commit d1bcae833b32f1 ("ELF: Don't generate unused section symbols") [1], binutils (v2.36+) started dropping section symbols that it thought were unused. This isn't an issue in general, but with kexec_file.c, gcc is placing kexec_arch_apply_relocations[_add] into a separate .text.unlikely section and the section symbol ".text.unlikely" is being dropped. Due to this, recordmcount is unable to find a non-weak symbol in .text.unlikely to generate a relocation record against. Address this by dropping the weak attribute from these functions: - arch_kexec_apply_relocations() is not overridden by any architecture today, so just drop the weak attribute. - arch_kexec_apply_relocations_add() is only overridden by x86 and s390. Retain the function prototype for those and move the weak implementation into the header as a static inline for other architectures. [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1 Signed-off-by: Naveen N. Rao --- include/linux/kexec.h | 28 ++++++++++++++++++++++++---- kernel/kexec_file.c | 19 +------------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 58d1b58a971e34..e656f981f43a73 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -193,10 +193,6 @@ void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name); int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, unsigned long buf_len); void *arch_kexec_kernel_image_load(struct kimage *image); -int arch_kexec_apply_relocations_add(struct purgatory_info *pi, - Elf_Shdr *section, - const Elf_Shdr *relsec, - const Elf_Shdr *symtab); int arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, const Elf_Shdr *relsec, @@ -229,6 +225,30 @@ extern int crash_exclude_mem_range(struct crash_mem *mem, unsigned long long mend); extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, void **addr, unsigned long *sz); + +#if defined(CONFIG_X86_64) || defined(CONFIG_S390) +int arch_kexec_apply_relocations_add(struct purgatory_info *pi, + Elf_Shdr *section, + const Elf_Shdr *relsec, + const Elf_Shdr *symtab); +#else +/* + * arch_kexec_apply_relocations_add - apply relocations of type RELA + * @pi: Purgatory to be relocated. + * @section: Section relocations applying to. + * @relsec: Section containing RELAs. + * @symtab: Corresponding symtab. + * + * Return: 0 on success, negative errno on error. + */ +static inline int +arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, + const Elf_Shdr *relsec, const Elf_Shdr *symtab) +{ + pr_err("RELA relocation unsupported.\n"); + return -ENOEXEC; +} +#endif /* CONFIG_X86_64 || CONFIG_S390 */ #endif /* CONFIG_KEXEC_FILE */ #ifdef CONFIG_KEXEC_ELF diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 8347fc158d2b96..6bae253b4d315e 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -108,23 +108,6 @@ int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, } #endif -/* - * arch_kexec_apply_relocations_add - apply relocations of type RELA - * @pi: Purgatory to be relocated. - * @section: Section relocations applying to. - * @relsec: Section containing RELAs. - * @symtab: Corresponding symtab. - * - * Return: 0 on success, negative errno on error. - */ -int __weak -arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, - const Elf_Shdr *relsec, const Elf_Shdr *symtab) -{ - pr_err("RELA relocation unsupported.\n"); - return -ENOEXEC; -} - /* * arch_kexec_apply_relocations - apply relocations of type REL * @pi: Purgatory to be relocated. @@ -134,7 +117,7 @@ arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, * * Return: 0 on success, negative errno on error. */ -int __weak +int arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, const Elf_Shdr *relsec, const Elf_Shdr *symtab) { base-commit: ef1302160bfb19f804451d0e919266703501c875 -- 2.36.1