Message ID | 20221028194022.388521751@infradead.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1014265wru; Fri, 28 Oct 2022 12:55:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LBpmGFm9vEJVptLdlH4u7LT6ViLJ6n8CFyg0h+aRxcq5/dEUusF4dKIbwpACtU9aKsWEs X-Received: by 2002:a17:907:2672:b0:780:8bb5:25a3 with SMTP id ci18-20020a170907267200b007808bb525a3mr869141ejc.281.1666986937596; Fri, 28 Oct 2022 12:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666986937; cv=none; d=google.com; s=arc-20160816; b=cUH8nxmuuLY91TfiCYZdkxVInEsMNDpemhPs/yhFs1aATXvtbokpdbhO2V8veTJz76 BP/mPYPaSnkU65qUaYCleYb4ZBmEFX5SiuXtp5fquEoRSzwLIFNhzvat1Ym8EylfXnWB RVHA29B74f6qwJrCVz2Ylzk/M+acPZiK07kSA9b2c0qY1sr91inzL22/B/oQk7PuhgW4 zSN44mU2Wgr85ugk/rKBOeFpyndm428Tjce3kqUDpH2wq8u2v+3sP/gitdgztPS2lPyZ s2ybjcBJtX0r00OhUM/m6c6I5WoxaFmx7N0Gougk8suxrkMemHI+Au3vj6Fe8XnmRrQ1 aHHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:user-agent:message-id :dkim-signature; bh=WE0U9W6dwiOwdUAAWamaejYu7mRh00CBAA+DvQdSjfE=; b=tj8H/15e0athMCV7y7bj5RP1YxUkbsrbKM3swloVa/Fp2I7h72TsdY+efb2QxVjA07 goSaDR4bj+0npEMP5k5QfvjszL67LoOCm0IJBsT2pZIebDP9cdC42fNrUcf78WcRqHh+ zOM3aw2wiswN/NUrEqivwvFkmt3+AoCDmvAWrHm2XpUFz0+m81n3msM20uBBeFNMZiIu e5B5KTwq7doZtjLuO1qWVIC0EV+b+pRBqnt/tuiEpCVdlXzyDws3KlHNZ5zUPkoi1BWA rfzad4OB/GDkEgSjtwYKlOfGz8znTbGoOePIIfrgCRLWh4yRpmm7aIWnQHTBNrhe19XY sVrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="eaYeJOI/"; 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 gt20-20020a1709072d9400b0078db1343eedsi5681956ejc.774.2022.10.28.12.55.14; Fri, 28 Oct 2022 12:55:37 -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="eaYeJOI/"; 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 S229571AbiJ1TsB (ORCPT <rfc822;norden.jeffspam@gmail.com> + 99 others); Fri, 28 Oct 2022 15:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbiJ1Trz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); 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 197AD241B0B for <linux-kernel@vger.kernel.org>; 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=Subject:Cc:To:From:Date:Message-ID: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=WE0U9W6dwiOwdUAAWamaejYu7mRh00CBAA+DvQdSjfE=; b=eaYeJOI/JkIUgdDdMN+N831oxC Q8byy3AieM7i/k0417HGZBppWRL1GjNYp7/PEykj6mqsngsEoS+mF3bbp0GRJye5EhbFf+/eN56Qo RqbTwvgI0b7bDnzbOIBQTtrXOFvUJP9OrJYo9gJaKDEB0C6bg+tFKtRZ4uTUBp51YxstMjFkywQIp 7euD1FQDsI6BklpWqzALTpgYo5YsjFEfzB0UusP4+K5pV8MStLhEtoou6gZ7U9z21gNeKZrYbG4Vf GA44h7I9KBpyvHZge9QjykXYmvCeMRvLa9bUAQ3+FueenInF6hyuq9QaD6X8hRqv/RDvfhfqaIco4 RdPYCm9g==; 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 1ooVKV-001V5o-VS; Fri, 28 Oct 2022 19:47:48 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B387130010B; Fri, 28 Oct 2022 21:47:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 9314C2C26AB85; Fri, 28 Oct 2022 21:47:41 +0200 (CEST) Message-ID: <20221028194022.388521751@infradead.org> User-Agent: quilt/0.66 Date: Fri, 28 Oct 2022 21:40:22 +0200 From: Peter Zijlstra <peterz@infradead.org> 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 0/5] x86/kallsyms: Fix the call-thunk kallsyms fail 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747962495317224601?= X-GMAIL-MSGID: =?utf-8?q?1747962495317224601?= |
Series |
x86/kallsyms: Fix the call-thunk kallsyms fail
|
|
Message
Peter Zijlstra
Oct. 28, 2022, 7:40 p.m. UTC
Hi all, As reported here: https://lkml.kernel.org/r/202210241614.2ae4c1f5-yujie.liu@intel.com The kallsyms change for call-thunks doesn't really work out as expected. These patches revert that change and propose an alternative.
Comments
On Fri, Oct 28, 2022 at 09:40:22PM +0200, Peter Zijlstra wrote: > Hi all, > > As reported here: > > https://lkml.kernel.org/r/202210241614.2ae4c1f5-yujie.liu@intel.com > > The kallsyms change for call-thunks doesn't really work out as expected. These > patches revert that change and propose an alternative. Robot found it needed the below; have folded back and pushed out again. --- diff --git a/tools/objtool/check.c b/tools/objtool/check.c index cf743520a786..55066c493570 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3479,7 +3479,8 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, if (func && insn_func(insn) && func != insn_func(insn)->pfunc) { /* Ignore KCFI type preambles, which always fall through */ - if (!strncmp(func->name, "__cfi_", 6)) + if (!strncmp(func->name, "__cfi_", 6) || + !strncmp(func->name, "__pfx_", 6)) return 0; WARN("%s() falls through to next function %s()", @@ -4042,6 +4043,7 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func, for (;;) { struct instruction *prev = list_prev_entry(insn, list); + u64 offset; if (&prev->list == &file->insn_list) break; @@ -4049,11 +4051,13 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func, if (prev->type != INSN_NOP) break; - insn = prev; - if (func->offset - prev->offset == opts.prefix) { - elf_create_prefix_symbol(file->elf, func, -opts.prefix); + offset = func->offset - prev->offset; + if (offset >= opts.prefix) { + if (offset == opts.prefix) + elf_create_prefix_symbol(file->elf, func, opts.prefix); break; } + insn = prev; } return 0; diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 9fbdad7a565d..3d636d12d679 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -822,7 +822,7 @@ elf_create_section_symbol(struct elf *elf, struct section *sec) static int elf_add_string(struct elf *elf, struct section *strtab, char *str); struct symbol * -elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend) +elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size) { struct symbol *sym = calloc(1, sizeof(*sym)); size_t namelen = strlen(orig->name) + sizeof("__pfx_"); @@ -840,7 +840,8 @@ elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend) sym->sym.st_name = elf_add_string(elf, NULL, name); sym->sym.st_info = orig->sym.st_info; - sym->sym.st_value = orig->sym.st_value + addend; + sym->sym.st_value = orig->sym.st_value - size; + sym->sym.st_size = size; sym = __elf_create_symbol(elf, sym); if (sym) diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 9e3bd4717a11..b6974e3173aa 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -146,7 +146,7 @@ static inline bool has_multiple_files(struct elf *elf) struct elf *elf_open_read(const char *name, int flags); struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); -struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend); +struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size); int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct symbol *sym, s64 addend);
On Sun, Oct 30, 2022 at 10:15:22AM +0100, Peter Zijlstra wrote: > On Fri, Oct 28, 2022 at 09:40:22PM +0200, Peter Zijlstra wrote: > > Hi all, > > > > As reported here: > > > > https://lkml.kernel.org/r/202210241614.2ae4c1f5-yujie.liu@intel.com > > > > The kallsyms change for call-thunks doesn't really work out as expected. These > > patches revert that change and propose an alternative. > > Robot found it needed the below; have folded back and pushed out again. Hi Peter, We applied the five patches in this patchset plus below extra fixup patch on top of x86/core branch of tip. The xfstests failure and the issue of changed dmesg WARNING are gone. Thanks. Tested-by: Yujie Liu <yujie.liu@intel.com> ========================================================================================= compiler/disk/fs/kconfig/rootfs/tbox_group/test/testcase: gcc-11/4HDD/xfs/x86_64-rhel-8.3-func/debian-11.1-x86_64-20220510.cgz/lkp-ivb-d04/xfs-no-bug-assert/xfstests commit: f1389181622a0 ("kallsyms: Take callthunks into account") 9b10b976b8e2f ("x86/kallsyms: Fix the call-thunk kallsyms fail") f1389181622a08d6 9b10b976b8e2f61d861befc114f ---------------- --------------------------- fail:runs %reproduction fail:runs | | | 12:12 -100% :12 xfstests.xfs.098.fail 12:12 -100% :12 xfstests.xfs.439.fail :12 92% 11:12 dmesg.RIP:assfail[xfs] 12:12 -100% :12 dmesg.WARNING:CPU:#PID:#at_fs/xfs/xfs_message.c:#xfs_buf_alert_ratelimited.cold-#[xfs] :12 92% 11:12 dmesg.WARNING:at_fs/xfs/xfs_message.c:#assfail[xfs] Best Regards, Yujie > > --- > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > index cf743520a786..55066c493570 100644 > --- a/tools/objtool/check.c > +++ b/tools/objtool/check.c > @@ -3479,7 +3479,8 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, > > if (func && insn_func(insn) && func != insn_func(insn)->pfunc) { > /* Ignore KCFI type preambles, which always fall through */ > - if (!strncmp(func->name, "__cfi_", 6)) > + if (!strncmp(func->name, "__cfi_", 6) || > + !strncmp(func->name, "__pfx_", 6)) > return 0; > > WARN("%s() falls through to next function %s()", > @@ -4042,6 +4043,7 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func, > > for (;;) { > struct instruction *prev = list_prev_entry(insn, list); > + u64 offset; > > if (&prev->list == &file->insn_list) > break; > @@ -4049,11 +4051,13 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func, > if (prev->type != INSN_NOP) > break; > > - insn = prev; > - if (func->offset - prev->offset == opts.prefix) { > - elf_create_prefix_symbol(file->elf, func, -opts.prefix); > + offset = func->offset - prev->offset; > + if (offset >= opts.prefix) { > + if (offset == opts.prefix) > + elf_create_prefix_symbol(file->elf, func, opts.prefix); > break; > } > + insn = prev; > } > > return 0; > diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c > index 9fbdad7a565d..3d636d12d679 100644 > --- a/tools/objtool/elf.c > +++ b/tools/objtool/elf.c > @@ -822,7 +822,7 @@ elf_create_section_symbol(struct elf *elf, struct section *sec) > static int elf_add_string(struct elf *elf, struct section *strtab, char *str); > > struct symbol * > -elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend) > +elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size) > { > struct symbol *sym = calloc(1, sizeof(*sym)); > size_t namelen = strlen(orig->name) + sizeof("__pfx_"); > @@ -840,7 +840,8 @@ elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend) > > sym->sym.st_name = elf_add_string(elf, NULL, name); > sym->sym.st_info = orig->sym.st_info; > - sym->sym.st_value = orig->sym.st_value + addend; > + sym->sym.st_value = orig->sym.st_value - size; > + sym->sym.st_size = size; > > sym = __elf_create_symbol(elf, sym); > if (sym) > diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h > index 9e3bd4717a11..b6974e3173aa 100644 > --- a/tools/objtool/include/objtool/elf.h > +++ b/tools/objtool/include/objtool/elf.h > @@ -146,7 +146,7 @@ static inline bool has_multiple_files(struct elf *elf) > struct elf *elf_open_read(const char *name, int flags); > struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); > > -struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long addend); > +struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size); > > int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, > unsigned int type, struct symbol *sym, s64 addend);