You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/28 03:08:45 UTC

(nuttx) branch master updated (e5e4e3030e -> b29d103ad3)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from e5e4e3030e power:add extern for public function prototypes
     new 98482d429b noteram:overflow may discard all the trace message
     new d888df9673 note: add ringbuffer aligned access handle
     new c055fc2f85 noteram:read noteram may cause crash
     new b29d103ad3 ramlog:flush should reset the tail of the reader

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/note/note_driver.c    |  4 ++--
 drivers/note/noteram_driver.c | 12 ++++++------
 drivers/syslog/ramlog.c       | 17 ++++++++++++++++-
 include/nuttx/sched_note.h    |  3 +++
 4 files changed, 27 insertions(+), 9 deletions(-)


(nuttx) 02/04: note: add ringbuffer aligned access handle

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit d888df967347dca4267976f488b0af5ffa17a58d
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Mon Nov 13 12:11:23 2023 +0800

    note: add ringbuffer aligned access handle
    
    Fix ubsan warning that writes need to be aligned to memory boundaries when writing data
    
    Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
 drivers/note/note_driver.c    | 4 ++--
 drivers/note/noteram_driver.c | 6 +++---
 include/nuttx/sched_note.h    | 3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index 70c8c2dd03..a710c4ee0f 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -585,10 +585,10 @@ static void note_record_taskname(pid_t pid, FAR const char *name)
 
   ti = (FAR struct note_taskname_info_s *)
         &g_note_taskname.buffer[g_note_taskname.head];
-  ti->size = tilen;
+  ti->size = NOTE_ALIGN(tilen);
   ti->pid = pid;
   strlcpy(ti->name, name, namelen + 1);
-  g_note_taskname.head += tilen;
+  g_note_taskname.head += ti->size;
 }
 #endif
 
diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index f6db8ee064..edd84d84a9 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -295,7 +295,7 @@ static void noteram_remove(FAR struct noteram_driver_s *drv)
 
   /* Get the length of the note at the tail index */
 
-  length = drv->ni_buffer[tail];
+  length = NOTE_ALIGN(drv->ni_buffer[tail]);
   DEBUGASSERT(length <= noteram_length(drv));
 
   /* Increment the tail index to remove the entire note from the circular
@@ -387,7 +387,7 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
       remaining--;
     }
 
-  drv->ni_read = read;
+  drv->ni_read = NOTE_ALIGN(read);
 
   return notelen;
 }
@@ -594,7 +594,7 @@ static void noteram_add(FAR struct note_driver_s *driver,
   space = space < notelen ? space : notelen;
   memcpy(drv->ni_buffer + head, note, space);
   memcpy(drv->ni_buffer, buf + space, notelen - space);
-  drv->ni_head = noteram_next(drv, head, notelen);
+  drv->ni_head = noteram_next(drv, head, NOTE_ALIGN(notelen));
   spin_unlock_irqrestore_wo_note(&drv->lock, flags);
 }
 
diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h
index eb0ce3d804..60063f2eac 100644
--- a/include/nuttx/sched_note.h
+++ b/include/nuttx/sched_note.h
@@ -51,6 +51,9 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
+#define NOTE_ALIGN(a) (((a) + sizeof(uintptr_t) - 1) & \
+                       ~(sizeof(uintptr_t) - 1))
+
 /* Provide defaults for some configuration settings (could be undefined with
  * old configuration files)
  */


(nuttx) 01/04: noteram:overflow may discard all the trace message

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 98482d429b14d73952ff8cd31dc53ab07416c322
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Wed Mar 20 14:31:57 2024 +0800

    noteram:overflow may discard all the trace message
    
    noteram_add may cause head = tail when remain == NOTE_ALIGN(notelen)
    log:
    nsh_main-14  [0]   2.132127493: tracing_mark_write: B|14|trace dump -c
    
    nsh_main-14  [0]   2.143322780: tracing_mark_write: E|14|trace dump -c
    
    nsh_main-14  [0]   2.513023895: tracing_mark_write: B|14|trace dump -c
    
    nsh_main-14  [0]   2.524060048: tracing_mark_write: E|14|trace dump -c
    
    nsh_main-14  [0]   2.897055341: tracing_mark_write: B|14|trace dump -c
    
    ap> trace dump -c
    nsh_main-14  [0]   3.270037241: tracing_mark_write: B|14|trace dump -c
    
    ap> trace dump -c
    
    Signed-off-by: dulibo1 <du...@xiaomi.com>
---
 drivers/note/noteram_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index 22aa6ac6d3..f6db8ee064 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -567,7 +567,7 @@ static void noteram_add(FAR struct note_driver_s *driver,
   DEBUGASSERT(note != NULL && notelen < drv->ni_bufsize);
   remain = drv->ni_bufsize - noteram_length(drv);
 
-  if (remain < notelen)
+  if (remain <= NOTE_ALIGN(notelen))
     {
       if (drv->ni_overwrite == NOTERAM_MODE_OVERWRITE_DISABLE)
         {
@@ -586,7 +586,7 @@ static void noteram_add(FAR struct note_driver_s *driver,
           noteram_remove(drv);
           remain = drv->ni_bufsize - noteram_length(drv);
         }
-      while (remain < notelen);
+      while (remain <= NOTE_ALIGN(notelen));
     }
 
   head = drv->ni_head;


(nuttx) 04/04: ramlog:flush should reset the tail of the reader

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b29d103ad324e786c60f5b02490cf30818700d3b
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Mon Mar 25 17:18:45 2024 +0800

    ramlog:flush should reset the tail of the reader
    
    Signed-off-by: dulibo1 <du...@xiaomi.com>
---
 drivers/syslog/ramlog.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c
index 02e9ef0443..c16471edc9 100644
--- a/drivers/syslog/ramlog.c
+++ b/drivers/syslog/ramlog.c
@@ -234,6 +234,21 @@ static void ramlog_pollnotify(FAR struct ramlog_dev_s *priv)
     }
 }
 
+/****************************************************************************
+ * Name: ramlog_flush
+ ****************************************************************************/
+
+static void ramlog_bufferflush(FAR struct ramlog_dev_s *priv)
+{
+  FAR struct ramlog_user_s *upriv;
+
+  priv->rl_header->rl_head = 0;
+  list_for_every_entry(&priv->rl_list, upriv, struct ramlog_user_s, rl_node)
+    {
+      upriv->rl_tail = 0;
+    }
+}
+
 /****************************************************************************
  * Name: ramlog_copybuf
  ****************************************************************************/
@@ -535,7 +550,7 @@ static int ramlog_file_ioctl(FAR struct file *filep, int cmd,
         upriv->rl_threashold = (uint32_t)arg;
         break;
       case BIOC_FLUSH:
-        priv->rl_header->rl_head = 0;
+        ramlog_bufferflush(priv);
         break;
       default:
         ret = -ENOTTY;


(nuttx) 03/04: noteram:read noteram may cause crash

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c055fc2f85246859a3f4c6b8593ef0c6fb922197
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Wed Mar 20 14:40:33 2024 +0800

    noteram:read noteram may cause crash
    
    noteram_get may cause _read = ni_bufsize cause assert crash
    
    [ 1493.627200] [79] [ EMERG] [ap] _assert: Assertion failed : at file: note/noteram_driver.c:370 task: trace process: trace 0x446f238a
    [ 1493.627400] [79] [ EMERG] [ap] backtrace:
    [ 1493.627500] [79] [ EMERG] [ap] [79] [<0xf7933c9d>] _fini+0xae0720b9/0xb673e41b
    [ 1493.628400] [79] [ EMERG] [ap] [79] [<0x498b1b0c>] host_backtrace+0x42/0x72
    [ 1493.629300] [79] [ EMERG] [ap] [79] [<0x48bef3d1>] up_backtrace+0x127/0x2d2
    [ 1493.630200] [79] [ EMERG] [ap] [79] [<0x48b86bed>] sched_backtrace+0x71/0x8a
    [ 1493.631100] [79] [ EMERG] [ap] [79] [<0x44676273>] sched_dumpstack+0xed/0x486
    [ 1493.631600] [79] [ EMERG] [ap] [79] [<0x445c61ff>] _assert+0x9f0/0xb38
    [ 1493.632200] [79] [ EMERG] [ap] [79] [<0x4420dd07>] __assert+0x3f/0x4c
    [ 1493.632800] [79] [ EMERG] [ap] [79] [<0x44151648>] noteram_get+0x1b0/0x5fe
    [ 1493.633600] [79] [ EMERG] [ap] [79] [<0x44152370>] noteram_read+0x331/0x4f7
    [ 1493.634200] [79] [ EMERG] [ap] [79] [<0x444c66f9>] file_read+0x38b/0x3c0
    [ 1493.634700] [79] [ EMERG] [ap] [79] [<0x444c6840>] nx_read+0x112/0x170
    [ 1493.635300] [79] [ EMERG] [ap] [79] [<0x444c68e5>] NXread+0x47/0xfa
    [ 1493.635800] [79] [ EMERG] [ap] [79] [<0x446f2c70>] trace_dump+0x148/0x2f4
    [ 1493.636400] [79] [ EMERG] [ap] [79] [<0x446f110b>] trace_cmd_dump+0x41b/0x4b9
    [ 1493.636900] [79] [ EMERG] [ap] [79] [<0x446f2723>] trace_main+0x399/0x6e2
    [ 1493.637500] [79] [ EMERG] [ap] [79] [<0x44217fc9>] nxtask_startup+0x69/0x7c
    [ 1493.638000] [79] [ EMERG] [ap] [79] [<0x440f9b78>] nxtask_start+0x8a5/0x8b8
    
    Signed-off-by: dulibo1 <du...@xiaomi.com>
---
 drivers/note/noteram_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index edd84d84a9..13fcad98d7 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -365,7 +365,7 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
     {
       /* Skip the large note so that we do not get constipated. */
 
-      drv->ni_read = noteram_next(drv, read, notelen);
+      drv->ni_read = noteram_next(drv, read, NOTE_ALIGN(notelen));
 
       /* and return an error */
 
@@ -387,7 +387,7 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
       remaining--;
     }
 
-  drv->ni_read = NOTE_ALIGN(read);
+  drv->ni_read = noteram_next(drv, drv->ni_read, NOTE_ALIGN(notelen));
 
   return notelen;
 }