[RFC PATCH v3 05/22] objtool: Reorganize ORC types

Madhavan T. Venkataraman madvenka at linux.microsoft.com
Mon Mar 6 08:45:34 PST 2023


Sorry for the delay in responding to your comments. I was out sick.
Please find my responses inline.

On 2/18/23 03:30, Suraj Jitindar Singh wrote:
> On Thu, 2023-02-02 at 01:40 -0600, madvenka at linux.microsoft.com wrote:
>> From: "Madhavan T. Venkataraman" <madvenka at linux.microsoft.com>
>>
>> The ORC code needs to be reorganized into arch-specific and generic
>> parts
>> so that architectures other than X86 can use the generic parts.
>>
>> orc_types.h contains the following ORC definitions shared between
>> objtool
>> and the kernel:
>>
>> 	- ORC register definitions which are arch-specific.
>> 	- orc_entry structure which is generic.
>>
>> Move orc_entry into a new file include/linux/orc_entry.h. Also, the
>> field
>> names bp_reg and bp_offset in struct orc_entry are x86-specific.
>> Change
>> them to fp_reg and fp_offset. FP stands for frame pointer.
>>
>> Currently, the type field in orc_entry is only 2 bits. For other
>> architectures, we will need more. So, expand this to 3 bits.
>>
>> Signed-off-by: Madhavan T. Venkataraman <madvenka at linux.microsoft.com
>>>
>> ---
>>  arch/x86/include/asm/orc_types.h       | 37 +++++-------------------
>>  include/linux/orc_entry.h              | 39
>> ++++++++++++++++++++++++++
>>  tools/arch/x86/include/asm/orc_types.h | 37 +++++-------------------
>>  tools/include/linux/orc_entry.h        | 39
>> ++++++++++++++++++++++++++
>>  tools/objtool/orc_gen.c                |  4 +--
>>  tools/objtool/sync-check.sh            |  1 +
>>  6 files changed, 95 insertions(+), 62 deletions(-)
>>  create mode 100644 include/linux/orc_entry.h
>>  create mode 100644 tools/include/linux/orc_entry.h
>>
> 
> [snip]
> 
>> diff --git a/tools/include/linux/orc_entry.h
>> b/tools/include/linux/orc_entry.h
>> new file mode 100644
>> index 000000000000..3d49e3b9dabe
>> --- /dev/null
>> +++ b/tools/include/linux/orc_entry.h
>> @@ -0,0 +1,39 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +/*
>> + * Copyright (C) 2017 Josh Poimboeuf <jpoimboe at redhat.com>
>> + */
>> +
>> +#ifndef _ORC_ENTRY_H
>> +#define _ORC_ENTRY_H
>> +
>> +#ifndef __ASSEMBLY__
>> +#include <asm/byteorder.h>
>> +
>> +/*
>> + * This struct is more or less a vastly simplified version of the
>> DWARF Call
>> + * Frame Information standard.  It contains only the necessary parts
>> of DWARF
>> + * CFI, simplified for ease of access by the in-kernel unwinder.  It
>> tells the
>> + * unwinder how to find the previous SP and BP (and sometimes entry
>> regs) on
>> + * the stack for a given code address.  Each instance of the struct
>> corresponds
>> + * to one or more code locations.
>> + */
>> +struct orc_entry {
>> +	s16		sp_offset;
>> +	s16		fp_offset;
>> +#if defined(__LITTLE_ENDIAN_BITFIELD)
>> +	unsigned	sp_reg:4;
>> +	unsigned	fp_reg:4;
>> +	unsigned	type:3;
>> +	unsigned	end:1;
>> +#elif defined(__BIG_ENDIAN_BITFIELD)
>> +	unsigned	fp_reg:4;
>> +	unsigned	sp_reg:4;
>> +	unsigned	unused:4;
>> +	unsigned	end:1;
>> +	unsigned	type:3;
>> +#
> 
> nit:
> I believe you also need to update fp_reg/bp_offset -> fp_reg/fp_offset
> in orc_dump() in orc_dump.c
> 

OK. Will do.

Madhavan
> - Suraj
> 
>> +
>> +#endif /* __ASSEMBLY__ */
>> +
>> +#endif /* _ORC_ENTRY_H */
>> diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
>> index dd3c64af9db2..68c317daadbf 100644
>> --- a/tools/objtool/orc_gen.c
>> +++ b/tools/objtool/orc_gen.c
>> @@ -98,7 +98,7 @@ static int write_orc_entry(struct elf *elf, struct
>> section *orc_sec,
>>  	orc = (struct orc_entry *)orc_sec->data->d_buf + idx;
>>  	memcpy(orc, o, sizeof(*orc));
>>  	orc->sp_offset = bswap_if_needed(orc->sp_offset);
>> -	orc->bp_offset = bswap_if_needed(orc->bp_offset);
>> +	orc->fp_offset = bswap_if_needed(orc->fp_offset);
>>  
>>  	/* populate reloc for ip */
>>  	if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int),
>> R_X86_64_PC32,
>> @@ -149,7 +149,7 @@ int orc_create(struct objtool_file *file)
>>  
>>  	struct orc_entry null = {
>>  		.sp_reg  = ORC_REG_UNDEFINED,
>> -		.bp_reg  = ORC_REG_UNDEFINED,
>> +		.fp_reg  = ORC_REG_UNDEFINED,
>>  		.type    = UNWIND_HINT_TYPE_CALL,
>>  	};
>>  
>> diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-
>> check.sh
>> index ee49b4e9e72c..ef1acb064605 100755
>> --- a/tools/objtool/sync-check.sh
>> +++ b/tools/objtool/sync-check.sh
>> @@ -18,6 +18,7 @@ arch/x86/include/asm/unwind_hints.h
>>  arch/x86/lib/x86-opcode-map.txt
>>  arch/x86/tools/gen-insn-attr-x86.awk
>>  include/linux/static_call_types.h
>> +include/linux/orc_entry.h
>>  "
>>  
>>  SYNC_CHECK_FILES='



More information about the linux-arm-kernel mailing list