Skip to content

sched/tls: Shouldn't get tls info directly from sp in kernel space#6377

Merged
masayuki2009 merged 1 commit into
apache:masterfrom
xiaoxiang781216:tls3
Jun 7, 2022
Merged

sched/tls: Shouldn't get tls info directly from sp in kernel space#6377
masayuki2009 merged 1 commit into
apache:masterfrom
xiaoxiang781216:tls3

Conversation

@xiaoxiang781216

@xiaoxiang781216 xiaoxiang781216 commented Jun 7, 2022

Copy link
Copy Markdown
Contributor

Summary

since the stack may switch to the kernel or interrupt stack. Report here: #6337.

Impact

fail to get the tls info in case of CONFIG_TLS_ALIGNED = y

Testing

rv-virt:knsh64

since the stack may switch to the kernel or interrupt stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@masayuki2009

Copy link
Copy Markdown
Contributor

@xiaoxiang781216

I tried this PR with rv-virt:knsh64, but it failed.
The issue also happened with sabre-6quad:knsh.

$ qemu-system-riscv64 -semihosting -nographic -cpu rv64 -smp 8 -M virt -bios none -kernel ./nuttx
ABC[    0.000000] up_assert: Assertion failed at file:init/nx_bringup.c line: 297 task: Idle Task
[    0.000000] up_assert: Assertion failed at file:common/riscv_swint.c line: 189 task: Idle Task
[    0.000000] riscv_registerdump: EPC: 0000000080007202
[    0.000000] riscv_registerdump: A0: 0000000000000000 A1: 0000000000000000 A2: 0000000010000000 A3: 0000000000000001
[    0.000000] riscv_registerdump: A4: 0000000000000001 A5: 0000000000000000 A6: 0000000000000074 A7: 000000000000006a
[    0.000000] riscv_registerdump: T0: 00000000000001ff T1: 000000000000006c T2: 000000000000002d T3: 0000000000000068
[    0.000000] riscv_registerdump: T4: 0000000000000009 T5: 000000000000002a T6: 000000000000002e
[    0.000000] riscv_registerdump: S0: 0000000080200928 S1: 0000000080206b30 S2: 0000000080200928 S3: 0000000080200918
[    0.000000] riscv_registerdump: S4: 0000000080201050 S5: 0000000000000000 S6: 0000000000000000 S7: 0000000000000000
[    0.000000] riscv_registerdump: S8: 0000000000000000 S9: 0000000000000000 S10: 0000000000000000 S11: 0000000000000000
[    0.000000] riscv_registerdump: SP: 0000000080206b20 FP: 0000000080200928 TP: 0000000000000000 RA: 0000000080007202
[    0.000000] riscv_dumpstate: sp:     0000000080200850
[    0.000000] riscv_dumpstate: IRQ stack:
[    0.000000] riscv_dumpstate:   base: 00000000802000f0
[    0.000000] riscv_dumpstate:   size: 0000000000000800
[    0.000000] riscv_stackdump: 0000000080200840: 802000f0 00000000 80006ce0 00000000 000000bd 00000000 80015160 00000000
[    0.000000] riscv_stackdump: 0000000080200860: deadbeef deadbeef 00000000 00000000 80201050 00000000 80200918 00000000
[    0.000000] riscv_stackdump: 0000000080200880: 80201050 00000000 80206a18 00000000 80206a18 00000000 800043ac 00000000
[    0.000000] riscv_stackdump: 00000000802008a0: deadbeef deadbeef 800015f6 00000000 80200928 00000000 80201050 00000000
[    0.000000] riscv_stackdump: 00000000802008c0: 80206a18 00000000 80001812 00000000 deadbeef deadbeef 00000100 00000000
[    0.000000] riscv_dumpstate: sp:     0000000080206b20
[    0.000000] riscv_dumpstate: User stack:
[    0.000000] riscv_dumpstate:   base: 0000000080206030
[    0.000000] riscv_dumpstate:   size: 0000000000000bd0
[    0.000000] riscv_dumpstate: User Stack
[    0.000000] riscv_stackdump: 0000000080206b20: 00000000 00000000 80006e74 00000000 00000129 00000000 800152a8 00000000
[    0.000000] riscv_stackdump: 0000000080206b40: 00000000 00000000 00000000 00000000 00000000 00000000 80200918 00000000
[    0.000000] riscv_stackdump: 0000000080206b60: 80201064 00000000 80201068 00000000 80200928 00000000 800043ac 00000000
[    0.000000] riscv_stackdump: 0000000080206b80: 80200928 00000000 80001b48 00000000 80200928 00000000 80016400 00000000
[    0.000000] riscv_stackdump: 0000000080206ba0: 80200928 00000000 80001a94 00000000 80400000 00000000 00400000 00000000
[    0.000000] riscv_stackdump: 0000000080206bc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    0.000000] riscv_stackdump: 0000000080206be0: 00000000 00000000 80000d72 00000000 00000000 00000000 80000046 00000000
[    0.000000] riscv_showtasks:    PID    PRI      USED     STACK   FILLED    COMMAND
[    0.000000] riscv_showtasks:   ----   ----       744      2048    36.3%    irq
[    0.000000] riscv_dump_task:      0      0      1328      3024    43.9%    Idle Task

If I enable debug messages, it seems that the symbol tls_get_info was not found.

[    0.000000] elf_symvalue: SHN_UNDEF: Exported symbol "tls_get_info" not found
[    0.000000] elf_relocateadd: Section 2 reloc 4815: Failed to get value of symbol[38794]: -2
[    0.000000] elf_loadbinary: Failed to bind symbols program binary: -2
[    0.000000] exec_spawn: ERROR: Failed to load program '/system/bin/init': -2
[    0.000000] up_assert: Assertion failed at file:init/nx_bringup.c line: 297 task: Idle Task
[    0.000000] up_assert: Assertion failed at file:common/riscv_swint.c line: 189 task: Idle Task

Comment thread include/nuttx/tls.h Outdated
@xiaoxiang781216

Copy link
Copy Markdown
Contributor Author

Sorry, @masayuki2009 I just rebuild the kernel not hello elf, so the error isn't catch locally.

@masayuki2009

Copy link
Copy Markdown
Contributor

@xiaoxiang781216

I confirmed that this PR fixes the issue.

@masayuki2009 masayuki2009 merged commit 2707ba5 into apache:master Jun 7, 2022
@xiaoxiang781216 xiaoxiang781216 deleted the tls3 branch June 8, 2022 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants