mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yujie Liu <yujie.liu@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <x86@kernel.org>, <linux-kernel@vger.kernel.org>,
	<djwong@kernel.org>, <tglx@linutronix.de>, <jpoimboe@kernel.org>,
	<joao.moreira@intel.com>, <samitolvanen@google.com>,
	<lkp@intel.com>
Subject: Re: [PATCH 0/5] x86/kallsyms: Fix the call-thunk kallsyms fail
Date: Mon, 31 Oct 2022 14:18:13 +0800	[thread overview]
Message-ID: <Y19opTRPIZfmHXtV@yujie-X299> (raw)
In-Reply-To: <Y15AqvPo/JqjVjTx@hirez.programming.kicks-ass.net>

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);

  reply	other threads:[~2022-10-31  6:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 19:40 Peter Zijlstra
2022-10-28 19:40 ` [PATCH 1/5] kallsyms: Revert "Take callthunks into account" Peter Zijlstra
2022-10-28 19:40 ` [PATCH 2/5] objtool: Slice up elf_create_section_symbol() Peter Zijlstra
2022-11-02  9:20   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2022-10-28 19:40 ` [PATCH 3/5] objtool: Avoid O(bloody terrible) behaviour -- an ode to libelf Peter Zijlstra
2022-11-02  9:20   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2022-11-02 22:22   ` [PATCH 3/5] " Josh Poimboeuf
2022-11-03  8:46     ` Peter Zijlstra
2022-10-28 19:40 ` [PATCH 4/5] objtool: Add option to generate prefix symbols Peter Zijlstra
2022-11-02  9:20   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2022-11-02 23:41   ` [PATCH 4/5] " Josh Poimboeuf
2022-10-28 19:40 ` [PATCH 5/5] x86: Add prefix symbols for function padding Peter Zijlstra
2022-11-02  9:20   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2022-10-30  9:15 ` [PATCH 0/5] x86/kallsyms: Fix the call-thunk kallsyms fail Peter Zijlstra
2022-10-31  6:18   ` Yujie Liu [this message]
2022-11-02 21:46 ` [PATCH 6/5] objtool: Optimize elf_dirty_reloc_sym() Peter Zijlstra
2022-11-05 10:36   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y19opTRPIZfmHXtV@yujie-X299 \
    --to=yujie.liu@intel.com \
    --cc=djwong@kernel.org \
    --cc=joao.moreira@intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=peterz@infradead.org \
    --cc=samitolvanen@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®