Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2908867pxb; Sat, 26 Mar 2022 06:57:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5si82RS6hz0mmZPigsAN5w3VI/BXCP81x43vBRH9i6M2A6e5VcUOIaVAjRp7f9OtYhaae X-Received: by 2002:a17:907:1b0e:b0:6da:81ae:a798 with SMTP id mp14-20020a1709071b0e00b006da81aea798mr17688253ejc.699.1648303076177; Sat, 26 Mar 2022 06:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303076; cv=none; d=google.com; s=arc-20160816; b=tXwek1CrySHeV+wC7vndBaimNSV1/8vyjM6PPC4i3RlucVj4itWG7CQeRScceeBGNL 6CgvBy10XfmVzLg1iH8XJtJj9RWnwVGXne3y4L0W7lgkKo9Wwf5OKVcjAgMC4dVQZmNz TMjCjEq7WNraMpE6IiYemgbqYN6I+zIpUBZyetPn4EP8zMa3Zrbwpo+D1ipo2YPIqF3i Ux/YojL7Gr7V/FGw1iIOGb+k48yVY6KK1LCgsjCE4vSPQNUGbPnTZZ4bTtegMnDWshCQ 1OCSxHhKjrV8EjySKZnnTEKXtp72eRWYSfgfW65opJJndLHKXlCTUpazXiYY57cdSgOv Q88Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rzzd6b9qzoOw4Fh+0NGed+kmeZV+jYIbvrLiUED1BVY=; b=Bpx4SQA+7qJAN9YA8749h6dyvxM5xEQ+vIdV0FCYmZ+ujFYQNG08R66x3bkP0P7qUH I8Ny0ommBd4dMKQoxqwytJNnYT6Z4y8Q92QyqlAW4x1ffjN/JK9Wv47zUw899/x5kIoH JyPZfv18XlTC3iUK+RiJF6tSyBNxKOUJdaKLODSpYu3pPsFGTqrOZAzcIeUs+v0wX3YV HhoIpUmbxaX40GvESoVAIeFdatFQiMrcS0/cG8qU6X9Or8FUCf2UKd0/Nv/Hg5rNyFJ4 NAwLnidOGaXcJ6iZuECWDcSAqWPorl+KK/fNj+XcDsuUlnjBDdx9oTng9hmL5gQRgMxa r/uA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a50e793000000b004193b0a8af1si6740910edn.285.2022.03.26.06.57.31; Sat, 26 Mar 2022 06:57:56 -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; 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 S231958AbiCZIAg (ORCPT + 99 others); Sat, 26 Mar 2022 04:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbiCZIAf (ORCPT ); Sat, 26 Mar 2022 04:00:35 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8EDB1EEE1 for ; Sat, 26 Mar 2022 00:58:57 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4KQWYq15Qsz9sSk; Sat, 26 Mar 2022 08:58:55 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MWd_2_uPwi9A; Sat, 26 Mar 2022 08:58:55 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4KQWYp6thGz9sSg; Sat, 26 Mar 2022 08:58:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D0F348B766; Sat, 26 Mar 2022 08:58:54 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id BDLFlGK4czpi; Sat, 26 Mar 2022 08:58:54 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.204.30]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 83F078B763; Sat, 26 Mar 2022 08:58:54 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 22Q7wdPf2233517 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 26 Mar 2022 08:58:39 +0100 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 22Q7wYrd2233515; Sat, 26 Mar 2022 08:58:34 +0100 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Sathvika Vasireddy Cc: Christophe Leroy , "aik@ozlabs.ru" , "linux-kernel@vger.kernel.org" , "rostedt@goodmis.org" , Peter Zijlstra , "jpoimboe@redhat.com" , "naveen.n.rao@linux.vnet.ibm.com" , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [RFC PATCH 3/3] objtool/mcount: Add powerpc specific functions Date: Sat, 26 Mar 2022 08:58:28 +0100 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1648281498; l=5533; s=20211009; h=from:subject:message-id; bh=pqy69GtQ37gBmhkxEFcXQTJnF0YiL4OahbeYhVhf0xQ=; b=q1llzLWfDJRF22MRB95arYV9fbbQviEkLJOO+XlAHTjVsavxpDhS+8OloaQLsqVR+elDBn9qHioJ luyaJCgvB28UUAb6d1ezx6v8Oy7P9t+wgNUgFmDmS8o7GJwpqwTd X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Le 21/03/2022 a 08:56, Christophe Leroy a ecrit : > > > Le 21/03/2022 a 03:27, Michael Ellerman a ecrit : >> Christophe Leroy writes: >>> Le 18/03/2022 a 13:26, Peter Zijlstra a ecrit : >>>> On Fri, Mar 18, 2022 at 04:21:40PM +0530, Sathvika Vasireddy wrote: >>>>> This patch adds powerpc specific functions required for >>>>> 'objtool mcount' to work, and enables mcount for ppc. >>>> >>>> I would love to see more objtool enablement for Power :-) >>> >>> I have not received this series and I can't see it on powerpc patchwork >>> either (https://patchwork.ozlabs.org/project/linuxppc-dev/list/) >>> >>> Did you send it to linuxppc-dev list ? If not can you resend it there ? >> >> It is there, might have been delayed? >> >> http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=291129 >> >> There are some CI failures. >> > > On PPC32 I get : > > [ 0.000000] ftrace: No functions to be traced? > > Without this series I get: > > [ 0.000000] ftrace: allocating 22508 entries in 17 pages > [ 0.000000] ftrace: allocated 17 pages with 2 groups > With the changes below I managed to get a working ftrace on a PPC32 target. Christophe --------- From: Christophe Leroy Subject: [PATCH] powerpc/objtool: Set to big endian and 32 bits Small ack to crossbuild a PPC32 kernel with a x86_64 host. Signed-off-by: Christophe Leroy --- tools/objtool/arch/powerpc/decode.c | 3 ++- tools/objtool/arch/powerpc/include/arch/endianness.h | 9 +++++++++ tools/objtool/elf.c | 4 ++-- tools/objtool/utils.c | 12 +++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 tools/objtool/arch/powerpc/include/arch/endianness.h diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c index 58988f88b315..330af382e39f 100644 --- a/tools/objtool/arch/powerpc/decode.c +++ b/tools/objtool/arch/powerpc/decode.c @@ -8,6 +8,7 @@ #include #include #include +#include int arch_decode_instruction(struct objtool_file *file, const struct section *sec, unsigned long offset, unsigned int maxlen, @@ -20,7 +21,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec u64 imm; *immediate = imm = 0; - memcpy(&insn, sec->data->d_buf+offset, 4); + insn = bswap_if_needed(*(u32 *)(sec->data->d_buf + offset)); *len = 4; *type = INSN_OTHER; diff --git a/tools/objtool/arch/powerpc/include/arch/endianness.h b/tools/objtool/arch/powerpc/include/arch/endianness.h new file mode 100644 index 000000000000..275087bfcc16 --- /dev/null +++ b/tools/objtool/arch/powerpc/include/arch/endianness.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ARCH_ENDIANNESS_H +#define _ARCH_ENDIANNESS_H + +#include + +#define __TARGET_BYTE_ORDER __BIG_ENDIAN + +#endif /* _ARCH_ENDIANNESS_H */ diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4b384c907027..433f0e327b68 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -867,7 +867,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec strcpy(relocname, ".rela"); strcat(relocname, base->name); - sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0); + sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0); free(relocname); if (!sec) return NULL; @@ -876,7 +876,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec sec->base = base; sec->sh.sh_type = SHT_RELA; - sec->sh.sh_addralign = 8; + sec->sh.sh_addralign = 4; sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx; sec->sh.sh_info = base->idx; sec->sh.sh_flags = SHF_INFO_LINK; diff --git a/tools/objtool/utils.c b/tools/objtool/utils.c index c9c14fa0dfd7..f77695c81386 100644 --- a/tools/objtool/utils.c +++ b/tools/objtool/utils.c @@ -151,7 +151,7 @@ int decode_instructions(struct objtool_file *file) int create_mcount_loc_sections(struct objtool_file *file) { struct section *sec; - unsigned long *loc; + unsigned int *loc; struct instruction *insn; int idx; @@ -169,15 +169,17 @@ int create_mcount_loc_sections(struct objtool_file *file) list_for_each_entry(insn, &file->mcount_loc_list, call_node) idx++; - sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx); + sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned int), idx); if (!sec) return -1; + sec->sh.sh_addralign = 4; + idx = 0; list_for_each_entry(insn, &file->mcount_loc_list, call_node) { - loc = (unsigned long *)sec->data->d_buf + idx; - memset(loc, 0, sizeof(unsigned long)); + loc = (unsigned int *)sec->data->d_buf + idx; + memset(loc, 0, sizeof(unsigned int)); if (file->elf->ehdr.e_machine == EM_X86_64) { if (elf_add_reloc_to_insn(file->elf, sec, @@ -197,7 +199,7 @@ int create_mcount_loc_sections(struct objtool_file *file) if (file->elf->ehdr.e_machine == EM_PPC) { if (elf_add_reloc_to_insn(file->elf, sec, - idx * sizeof(unsigned long), + idx * sizeof(unsigned int), R_PPC_ADDR32, insn->sec, insn->offset)) return -1; -- 2.35.1