Skip to contentSkip to conversation

xen/console: Fix build when CONFIG_DEBUG_TRACE=y

PATCH In review Julien Grall 2 participants 5 messages Aug 19, 2019 – Aug 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/console: Fix build when CONFIG_DEBUG_TRACE=y

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end of the buffer" extended sercon_puts to take the number of character to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker() were not converted. This result to a build failure when enabling CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig

---
 xen/drivers/char/console.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/drivers/char/console.c +3 -2
index 2c14c2ca73..924d4971ca 100644
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
 
     /* Print oldest portion of the ring. */
     ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));
 
     /* Print youngest portion of the ring. */
     debugtrace_buf[debugtrace_prd] = '\0';
-    sercon_puts(&debugtrace_buf[0]);
+    sercon_puts(&debugtrace_buf[0], debugtrace_prd);
 
     memset(debugtrace_buf, '\0', debugtrace_bytes);
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 19 lines · Julien Grall

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end of the buffer" extended sercon_puts to take the number of character to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker() were not converted. This result to a build failure when enabling CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig

---
 xen/drivers/char/console.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/drivers/char/console.c +0 -0
index 2c14c2ca73..924d4971ca 100644

xen/drivers/char/console.c static void debugtrace_dump_worker(void) · line 1189

Quoted 6 lines
xen/drivers/char/console.c +2 -1
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
 
     /* Print oldest portion of the ring. */
     ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));

Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

~Andrew

xen/drivers/char/console.c static void debugtrace_dump_worker(void) · line 1196

Quoted 8 lines
xen/drivers/char/console.c +1 -1
     /* Print youngest portion of the ring. */
     debugtrace_buf[debugtrace_prd] = '\0';
-    sercon_puts(&debugtrace_buf[0]);
+    sercon_puts(&debugtrace_buf[0], debugtrace_prd);
 
     memset(debugtrace_buf, '\0', debugtrace_bytes);
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw

Hi Andrew,

Quoted 21 lines · Andrew Cooper
Quoted 20 lines · Julien Grall

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end of the buffer" extended sercon_puts to take the number of character to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker() were not converted. This result to a build failure when enabling CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig

---
  xen/drivers/char/console.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
xen/drivers/char/console.c +0 -0
index 2c14c2ca73..924d4971ca 100644
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
 
Quoted 7 lines

xen/drivers/char/console.c static void debugtrace_dump_worker(void) · line 1189

Quoted 5 lines
xen/drivers/char/console.c +2 -1
      /* Print oldest portion of the ring. */
      ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));

Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

I tried and it resulted to print a lot of @^ on the console. This is because the ring may not be full.

So the portion between debugtrace_prd and debugtrace_bytes will be full of zero.

Looking at the code again, I think this portion and either be full of zero character or full of non-zero character. In other word, a mix would not be possible. So how about:

if ( debugtrace_buf[debugtrace_prd] != '\0' )
sercon_puts(&debugtrace_buf[debugtrace_prd],

              debugtrace_bytes - debugtrace_prd - 1);

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw
Quoted 37 lines · Julien Grall

Hi Andrew,

Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Julien Grall

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end of the buffer" extended sercon_puts to take the number of character to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker() were not converted. This result to a build failure when enabling CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig

---
  xen/drivers/char/console.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 12 lines

xen/drivers/char/console.c static void debugtrace_dump_worker(void) · line 1188

Quoted 10 lines
xen/drivers/char/console.c +2 -1
index 2c14c2ca73..924d4971ca 100644
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
         /* Print oldest portion of the ring. */
       ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));

Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

I tried and it resulted to print a lot of @^ on the console. This is because the ring may not be full.

So the portion between debugtrace_prd and debugtrace_bytes will be full of zero.

Quoted 7 lines

Looking at the code again, I think this portion and either be full of zero character or full of non-zero character. In other word, a mix would not be possible. So how about:

if ( debugtrace_buf[debugtrace_prd] != '\0' ) sercon_puts(&debugtrace_buf[debugtrace_prd], debugtrace_bytes - debugtrace_prd - 1);

LGTM.  Acked-by: Andrew Cooper <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

Hi,

Quoted 42 lines · Andrew Cooper
Quoted 41 lines · Julien Grall

Hi Andrew,

Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Julien Grall

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end of the buffer" extended sercon_puts to take the number of character to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker() were not converted. This result to a build failure when enabling CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig

---
   xen/drivers/char/console.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 12 lines

xen/drivers/char/console.c static void debugtrace_dump_worker(void) · line 1188

Quoted 10 lines
xen/drivers/char/console.c +2 -1
index 2c14c2ca73..924d4971ca 100644
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
         /* Print oldest portion of the ring. */
       ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));

Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

I tried and it resulted to print a lot of @^ on the console. This is because the ring may not be full.

So the portion between debugtrace_prd and debugtrace_bytes will be full of zero.

Looking at the code again, I think this portion and either be full of zero character or full of non-zero character. In other word, a mix would not be possible. So how about:

Quoted 5 lines
Quoted 3 lines

if ( debugtrace_buf[debugtrace_prd] != '\0' )
  sercon_puts(&debugtrace_buf[debugtrace_prd], debugtrace_bytes - debugtrace_prd - 1);

LGTM.  Acked-by: Andrew Cooper <[email protected]>

Thank you! I will update the patch and commit it.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel