Skip to content

sx127x: fix some coding standard problems#36

Merged
acassis merged 1 commit into
apache:pr36from
raiden00pl:sx127x
Jan 4, 2020
Merged

sx127x: fix some coding standard problems#36
acassis merged 1 commit into
apache:pr36from
raiden00pl:sx127x

Conversation

@raiden00pl
Copy link
Copy Markdown
Member

No description provided.

@acassis acassis changed the base branch from master to pr36 January 4, 2020 11:58
@acassis acassis merged commit d644567 into apache:pr36 Jan 4, 2020
GUIDINGLI added a commit to GUIDINGLI/incubator-nuttx that referenced this pull request Oct 11, 2024
set CONFIG_PRIORITY_INHERITANCE=y
set CONFIG_SEM_PREALLOCHOLDERS=0 or CONFIG_SEM_PREALLOCHOLDERS=8

    apache#24 0x4dcab71 in __assert assert/lib_assert.c:37
    apache#25 0x4d6b0e9 in nxsem_destroyholder semaphore/sem_holder.c:602
    apache#26 0x4d80cf7 in nxsem_destroy semaphore/sem_destroy.c:80
    apache#27 0x4d80db9 in sem_destroy semaphore/sem_destroy.c:120
    apache#28 0x4dcb077 in nxmutex_destroy misc/lib_mutex.c:122
    apache#29 0x4dc6611 in pipecommon_freedev pipes/pipe_common.c:117
    apache#30 0x4dc7fdc in pipecommon_close pipes/pipe_common.c:397
    apache#31 0x4ed4f6d in file_close vfs/fs_close.c:78
    apache#32 0x6a91133 in local_free local/local_conn.c:184
    apache#33 0x6a92a9c in local_release local/local_release.c:129
    apache#34 0x6a91d1a in local_subref local/local_conn.c:271
    apache#35 0x6a75767 in local_close local/local_sockif.c:797
    apache#36 0x4e978f6 in psock_close socket/net_close.c:102
    apache#37 0x4eed1b9 in sock_file_close socket/socket.c:115
    apache#38 0x4ed4f6d in file_close vfs/fs_close.c:78
    apache#39 0x4ed1459 in nx_close_from_tcb inode/fs_files.c:754
    apache#40 0x4ed1501 in nx_close inode/fs_files.c:781
    apache#41 0x4ed154a in close inode/fs_files.c:819
    apache#42 0x6bcb9ce in property_get kvdb/client.c:307
    apache#43 0x6bcd465 in property_get_int32 kvdb/common.c:270
    apache#44 0x5106c9a in tz_offset_restore app/miwear_bluetooth.c:745
    apache#45 0x510893f in miwear_bluetooth_main app/miwear_bluetooth.c:1033
    apache#46 0x4dcf5c8 in nxtask_startup sched/task_startup.c:70
    apache#47 0x4d70873 in nxtask_start task/task_start.c:134
    apache#48 0x4e04a07 in pre_start sim/sim_initialstate.c:52

Signed-off-by: ligd <liguiding1@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Oct 11, 2024
set CONFIG_PRIORITY_INHERITANCE=y
set CONFIG_SEM_PREALLOCHOLDERS=0 or CONFIG_SEM_PREALLOCHOLDERS=8

    #24 0x4dcab71 in __assert assert/lib_assert.c:37
    #25 0x4d6b0e9 in nxsem_destroyholder semaphore/sem_holder.c:602
    #26 0x4d80cf7 in nxsem_destroy semaphore/sem_destroy.c:80
    #27 0x4d80db9 in sem_destroy semaphore/sem_destroy.c:120
    #28 0x4dcb077 in nxmutex_destroy misc/lib_mutex.c:122
    #29 0x4dc6611 in pipecommon_freedev pipes/pipe_common.c:117
    #30 0x4dc7fdc in pipecommon_close pipes/pipe_common.c:397
    #31 0x4ed4f6d in file_close vfs/fs_close.c:78
    #32 0x6a91133 in local_free local/local_conn.c:184
    #33 0x6a92a9c in local_release local/local_release.c:129
    #34 0x6a91d1a in local_subref local/local_conn.c:271
    #35 0x6a75767 in local_close local/local_sockif.c:797
    #36 0x4e978f6 in psock_close socket/net_close.c:102
    #37 0x4eed1b9 in sock_file_close socket/socket.c:115
    #38 0x4ed4f6d in file_close vfs/fs_close.c:78
    #39 0x4ed1459 in nx_close_from_tcb inode/fs_files.c:754
    #40 0x4ed1501 in nx_close inode/fs_files.c:781
    #41 0x4ed154a in close inode/fs_files.c:819
    #42 0x6bcb9ce in property_get kvdb/client.c:307
    #43 0x6bcd465 in property_get_int32 kvdb/common.c:270
    #44 0x5106c9a in tz_offset_restore app/miwear_bluetooth.c:745
    #45 0x510893f in miwear_bluetooth_main app/miwear_bluetooth.c:1033
    #46 0x4dcf5c8 in nxtask_startup sched/task_startup.c:70
    #47 0x4d70873 in nxtask_start task/task_start.c:134
    #48 0x4e04a07 in pre_start sim/sim_initialstate.c:52

Signed-off-by: ligd <liguiding1@xiaomi.com>
owhinata added a commit to owhinata/nuttx that referenced this pull request Apr 26, 2026
…x#59)

97716f5 ("arch/armv7-m: preserve caller r11 across
arm_dispatch_syscall") added a `push {r11}` to save the user
task's frame pointer.  That push is 4 bytes; combined with the
existing `sub sp, sp, apache#32` it leaves SP **4-byte aligned but
not 8-byte aligned** when control transfers into the syscall
stub via `blx ip`.

AAPCS requires SP to be 8-byte aligned at every public function
boundary, and the 8-byte alignment is load-bearing for variadic
functions: their save area must be 8-aligned so a `va_arg` of an
8-byte type (long long / uintmax_t) reads the right pair of
words.  In practice any kernel-side code reached from a user-mode
syscall that called a variadic printf with a `%llu`/`%ju` argument
(notably the timestamp prefix in `drivers/syslog/vsyslog.c`)
returned garbage:

  before fix:  [2377693895065600.000003] [ 6] syslogtest: ...
  after  fix:  [    6.553600]            [ 3] syslogtest: ...

Boot logs at `tv_sec=0` masked the bug because the printed
high half is zero either way.

Fix by allocating 36 bytes instead of 32 below `push {r11}`; the
extra 4 bytes are pad (the existing five stores still target
[sp,#0..apache#16]) and the total `push {r11}` + `sub sp, apache#36` = 40
bytes is 8-aligned.

Tested on STM32F413H-DISCO (BUILD_PROTECTED, SYSTEM_TIME64,
SYSLOG_TIMESTAMP, SYSLOG_PROCESSID) with a tiny user app that
issues `syslog(LOG_INFO, "%llu", value)` from within a syscall
context; the printed value matches the literal both for the
timestamp prefix the kernel adds and for the user format itself.

Refs: spike-nx#59 (root cause), spike-nx#58 (`%lu` workaround
that becomes unnecessary with this commit applied).

Signed-off-by: Katsumi.Ouwa <d2p.yggdrasill@gmail.com>
owhinata added a commit to owhinata/nuttx that referenced this pull request Apr 26, 2026
…x#59)

97716f5 ("arch/armv7-m: preserve caller r11 across
arm_dispatch_syscall") added a `push {r11}` to save the user
task's frame pointer.  That push is 4 bytes; combined with the
existing `sub sp, sp, apache#32` it leaves SP **4-byte aligned but
not 8-byte aligned** when control transfers into the syscall
stub via `blx ip`.

AAPCS requires SP to be 8-byte aligned at every public function
boundary, and the 8-byte alignment is load-bearing for variadic
functions: their save area must be 8-aligned so a `va_arg` of an
8-byte type (long long / uintmax_t) reads the right pair of
words.  In practice any kernel-side code reached from a user-mode
syscall that called a variadic printf with a `%llu`/`%ju` argument
(notably the timestamp prefix in `drivers/syslog/vsyslog.c`)
returned garbage:

  before fix:  [2377693895065600.000003] [ 6] syslogtest: ...
  after  fix:  [    6.553600]            [ 3] syslogtest: ...

Boot logs at `tv_sec=0` masked the bug because the printed
high half is zero either way.

Fix by allocating 36 bytes instead of 32 below `push {r11}`; the
extra 4 bytes are pad (the existing five stores still target
[sp,#0..apache#16]) and the total `push {r11}` + `sub sp, apache#36` = 40
bytes is 8-aligned.

Tested on STM32F413H-DISCO (BUILD_PROTECTED, SYSTEM_TIME64,
SYSLOG_TIMESTAMP, SYSLOG_PROCESSID) with a tiny user app that
issues `syslog(LOG_INFO, "%llu", value)` from within a syscall
context; the printed value matches the literal both for the
timestamp prefix the kernel adds and for the user format itself.

Refs: spike-nx#59 (root cause), spike-nx#58 (`%lu` workaround
that becomes unnecessary with this commit applied).

Signed-off-by: Katsumi.Ouwa <d2p.yggdrasill@gmail.com>
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.

2 participants