Hi MUKESH,
Please check your email settings; the output is misformatted. And for
upstream patch review please cc to the mailing list as well.
On Wed, Aug 5, 2026 at 8:32 PM MUKESH KUMAR PILANIYA
<mpilaniy(a)redhat.com> wrote:
> On 5 Aug 2026, at 1:59 PM, MUKESH KUMAR PILANIYA <mpilaniy(a)redhat.com> wrote:
>
>
>
>> On 4 Aug 2026, at 12:59 PM, HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab at nec.com>
wrote:
>>
>> On 2026/08/04 15:57, Tao Liu wrote:
>>> Previously ORC_REG_SP and ORC_REG_PREV_SP will depend on kernel version
>>> for their value, however this is fragile since distributions will
>>> backport the upstream patch to a lower kernel version, thus break the
>>> version assumption.
>>>
>>> This patch fixes by checking the value of ORC_REG_PREV_SP, which can be
>>> get from orc_fp_entry. ORC_REG_PREV_SP's value can work as the
indicator
>>> of whether the current kernel have applied the upstream patch 1735858caa4b
>>> ("objtool/x86: Reorder ORC register numbering").
>>>
>>> Fixes: d0ee428664f9 ("x86_64: Fix "bt" command to use correct
ORC register
>>> values on Linux 7.1 and later")
>>>
>>> Signed-off-by: Tao Liu <ltao(a)redhat.com>
>>
>> thank you for the fix, looks good to me.
>>
>> Thanks,
>> Kazu
>>
>>> ---
>>> v2 -> v1: emit error(WARN) for kernels which doesn't have
orc_fp_entry
>>> symbol.
>>> ---
>>> x86_64.c | 30 +++++++++++++++++++++++-------
>>> 1 file changed, 23 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/x86_64.c b/x86_64.c
>>> index 55648697baf3..81d20ed419d5 100644
>>> --- a/x86_64.c
>>> +++ b/x86_64.c
>>> @@ -6661,6 +6661,9 @@ x86_64_ORC_init(void)
>>> NULL
>>> };
>>> struct ORC_data *orc;
>>> + struct gnu_request request, *req;
>>> + req = &request;
>>> + ulong value = 0;
>
> declaration after statement so that compiler does not give warning as per C90
standards.
> ulong value = 0;
> req = &request;
>
> This will also works.
> struct gnu_request request, *req = &request;
> ulong value = 0;
OK, agreed.
>
>>>
>>> MEMBER_OFFSET_INIT(inactive_task_frame_bp,
"inactive_task_frame", "bp");
>>> MEMBER_OFFSET_INIT(inactive_task_frame_ret_addr,
"inactive_task_frame", "ret_addr");
>>> @@ -6736,13 +6739,26 @@ x86_64_ORC_init(void)
>>> if (orc->has_signal && !orc->has_end)
>>> machdep->flags |= ORC_6_4;
>>>
>>> - /* See kernel commit 1735858caa4b */
>>> - if (THIS_KERNEL_VERSION >= LINUX(7,1,0)) {
>>> - ORC_REG_SP = 3;
>>> - ORC_REG_PREV_SP = 8;
>>> - } else {
>>> - ORC_REG_SP = 5;
>>> - ORC_REG_PREV_SP = 1;
>>> + /* Try get ORC_REG_(PREV)_SP */
>>> + ORC_REG_SP = 5;
>>> + ORC_REG_PREV_SP = 1;
>>> +
>>> + if (kernel_symbol_exists("orc_fp_entry")) {
>
> If orc_fp_entry doesn't exist in the symbol table (possible on stripped vmlinux
without kallsyms, or if a future kernel removes it), the patch silently falls back to old
values.
>
> Also the kernel declares orc_fp_entry as static in arch/x86/kernel/unwind_orc.c.
It's generally available in:
> - vmlinux with debuginfo (.symtab with STB_LOCAL)
> - /proc/kallsyms (with CONFIG_KALLSYMS_ALL=y, the default)
>
> But it won't be available in fully stripped vmlinux without kallsyms. So it
better to implement a fallback logic in else block.
>
> else if (THIS_KERNEL_VERSION >= LINUX(7,1,0)) {
> ORC_REG_SP = 3;
> ORC_REG_PREV_SP = 8;
> }
I'm not a fan of using THIS_KERNEL_VERSION check, this is what the
patch is trying to solve. For crash utility, it relies on debuginfo
stored within vmlinux, if missing, then crash cannot work as expected,
so from my view we needn't consider the missing scenario. If
orc_fp_entry removed in future kernels, then I prefer to let it expose
to address then.
>
>>> + if (get_symbol_type("orc_fp_entry",
"bp_reg", req) == TYPE_CODE_INT) {
>
> Crash utility already defines kernel_orc_entry in defs.h with the identical packed
bitfield layout so why not to use directly that will reduce get_symbol_type + manual
bitfield extraction work ?
> The bp_reg bitfield is at the same offset in both kernel_orc_entry and
kernel_orc_entry_6_4, so either works.
Good catch, I didn't notice the existing structure in crash utility.
>
>>> + get_symbol_data("orc_fp_entry", sizeof(ulong),
&value);
>
> get_symbol_data() calls readmem() with FAULT_ON_ERROR, which aborts crash if the
memory page isn't present in the vmcore. In kdump scenarios, not all pages are
necessarily captured. The patch should use try_get_symbol_data() instead, which returns
FALSE on failure without aborting.
Agreed.
>
>>> + /*
>>> + * orc_fp_entry.bp_reg = ORC_REG_PREV_SP
>>> + * See kernel commit 1735858caa4b. Use ORC_REG_PREV_SP as
the
>>> + * indicator of the commit.
>>> + */
>>> + value >>= req->member_offset;
>>> + value &= ((1UL << req->member_length) -
1);
>>> + if (value == 8) {
>>> + ORC_REG_SP = 3;
>>> + ORC_REG_PREV_SP = 8;
>>> + }
>>> + } else
>>> + error(WARNING, "Cannot get orc_fp_entry.bp_reg
info");
>
> Should not be this is a more user friendly ?
> error(WARNING, "Cannot determine ORC register numbering from orc_fp_entry; “
"using legacy values (ORC_REG_SP=5, ORC_REG_PREV_SP=1)\n");
Personally I prefer the original way: yours makes the warning message
wordy. Frankly, which value crash utility chooses is irrelevant to
users. To crash developers, a single "cannot get xxx info" is enough
for us to locate the issue.
Thanks,
Tao Liu
>
>>> }
>>>
>>> machdep->flags |= ORC;
>
>
> Putting it all together.
> /* Detect ORC register numbering from orc_fp_entry.bp_reg.
> * See kernel commit 1735858caa4b. Note: orc_fp_entry is static,
> * so fall back to the version check if the symbol is unavailable.
> */
> ORC_REG_SP = 5;
> ORC_REG_PREV_SP = 1;
>
> if (kernel_symbol_exists("orc_fp_entry")) {
> kernel_orc_entry fp_entry;
> if (try_get_symbol_data("orc_fp_entry",
> sizeof(kernel_orc_entry), &fp_entry) &&
> fp_entry.bp_reg == 8) {
> ORC_REG_SP = 3;
> ORC_REG_PREV_SP = 8;
> }
> } else if (THIS_KERNEL_VERSION >= LINUX(7,1,0)) {
> ORC_REG_SP = 3;
> ORC_REG_PREV_SP = 8;
> }
>
> Thanks
> Mukesh Pilaniya