On Mon, Jun 5, 2023 at 9:47 AM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab(a)nec.com>
wrote:
Hi Lianbo,
On 2023/05/18 16:53, HAGIO KAZUHITO(萩尾 一仁) wrote:
> From: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> Kernel commit fb799447ae29 ("x86,objtool: Split UNWIND_HINT_EMPTY in
> two"), which is contained in Linux 6.4 and later kernels, changed
> ORC_TYPE_CALL macro from 0 to 2. As a result, the "bt" command cannot
> use ORC entries, and can display stale entries in a call trace.
>
> crash> bt 1
> PID: 1 TASK: ffff93cd06294180 CPU: 51 COMMAND: "systemd"
> #0 [ffffb72bc00cbc98] __schedule at ffffffff86e52aae
> #1 [ffffb72bc00cbd00] schedule at ffffffff86e52f6a
> #2 [ffffb72bc00cbd18] schedule_hrtimeout_range_clock at
ffffffff86e58ef5
> #3 [ffffb72bc00cbd88] ep_poll at ffffffff8669624d
> #4 [ffffb72bc00cbe28] do_epoll_wait at ffffffff86696371
> #5 [ffffb72bc00cbe30] do_timerfd_settime at ffffffff8669902b
<<
> #6 [ffffb72bc00cbe60] __x64_sys_epoll_wait at ffffffff86696bf0
> #7 [ffffb72bc00cbeb0] do_syscall_64 at ffffffff86e3feb9
> #8 [ffffb72bc00cbee0] __task_pid_nr_ns at ffffffff863330d7
<<
> #9 [ffffb72bc00cbf08] syscall_exit_to_user_mode at ffffffff86e466b2
<< stale entries
> #10 [ffffb72bc00cbf18] do_syscall_64 at ffffffff86e3fec9
<<
> #11 [ffffb72bc00cbf50] entry_SYSCALL_64_after_hwframe at
ffffffff870000aa
>
> Also, kernel commit ffb1b4a41016 added a member to struct orc_entry.
> Although this does not affect the crash's unwinder, its debugging
> information can be displayed incorrectly.
>
> To fix these,
> (1) introduce "kernel_orc_entry_6_4" structure corresponding to 6.4 and
> abstruction layer "orc_entry" structure in crash,
> (2) switch ORC_TYPE_CALL to 2 or 0 with kernel's orc_entry structure.
>
> Related orc_entry history:
> v4.14 39358a033b2e introduced struct orc_entry
> v4.19 d31a580266ee added orc_entry.end member
> v6.3 ffb1b4a41016 added orc_entry.signal member
> v6.4 fb799447ae29 removed end member and changed type member to 3 bits
>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> v2:
> - better debugging information for orc_entry.{signal,end}.
>
> defs.h | 27 ++++++++++++-
> x86_64.c | 119 +++++++++++++++++++++++++++++++++++++++++++------------
> 2 files changed, 118 insertions(+), 28 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 21cc760444d1..c1ac347c8e26 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -6354,9 +6354,29 @@ typedef struct __attribute__((__packed__)) {
> unsigned int sp_reg:4;
> unsigned int bp_reg:4;
> unsigned int type:2;
> + unsigned int signal:1;
> unsigned int end:1;
> } kernel_orc_entry;
>
> +typedef struct __attribute__((__packed__)) {
> + signed short sp_offset;
> + signed short bp_offset;
> + unsigned int sp_reg:4;
> + unsigned int bp_reg:4;
> + unsigned int type:3;
> + unsigned int signal:1;
> +} kernel_orc_entry_6_4;
> +
> +typedef struct orc_entry {
> + signed short sp_offset;
> + signed short bp_offset;
> + unsigned int sp_reg;
> + unsigned int bp_reg;
> + unsigned int type;
> + unsigned int signal;
> + unsigned int end;
> +} orc_entry;
> +
> struct ORC_data {
> int module_ORC;
> uint lookup_num_blocks;
> @@ -6367,10 +6387,12 @@ struct ORC_data {
> ulong orc_lookup;
> ulong ip_entry;
> ulong orc_entry;
> - kernel_orc_entry kernel_orc_entry;
> + orc_entry orc_entry_data;
> + int has_signal;
> + int has_end;
> };
>
> -#define ORC_TYPE_CALL 0
> +#define ORC_TYPE_CALL ((machdep->flags & ORC_6_4) ? 2
: 0)
> #define ORC_TYPE_REGS 1
> #define ORC_TYPE_REGS_IRET 2
> #define UNWIND_HINT_TYPE_SAVE 3
These entries are not used in crash so far, remove them?
or add a comment like this?
/* The below entries are not used and must be updated if we use them. */
Agree. And the v2 looks good to me, so: Ack(with the above changes).
BTW: no need to post again, you can apply the v2 with the above changes.
Thanks.
Lianbo