Skip to contentSkip to conversation

hw/display/omap_dss: Replace fprintf() call by qemu_log_mask(LOG_UNIMP)

PATCH In review Philippe Mathieu-Daudé 3 participants 4 messages May 24, 2020 – May 26, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/omap_dss: Replace fprintf() call by qemu_log_mask(LOG_UNIMP)

Replace fprintf() call by qemu_log_mask(LOG_UNIMP), which is disabled by default. This avoid flooding the terminal when fuzzing the device.

---
 hw/display/omap_dss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/omap_dss.c +1 -1
index 32dc0d6aa7..21fde58a26 100644
@@ -619,7 +619,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
     if (s->rfbi.control & (1 << 1)) {				/* BYPASS */
         /* TODO: in non-Bypass mode we probably need to just assert the
          * DRQ and wait for DMA to write the pixels.  */
-        fprintf(stderr, "%s: Bypass mode unimplemented\n", __func__);
+        qemu_log_mask(LOG_UNIMP, "%s: Bypass mode unimplemented\n", __func__);
         return;
     }
 
Signature · 1 line
2.21.3
#1 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé

Replace fprintf() call by qemu_log_mask(LOG_UNIMP), which is disabled by default. This avoid flooding the terminal when fuzzing the device.

Hi Philippe,
libfuzzer also lets you pass -close_fd_mask=[1,2,3] to close stdout, stderr or both. As a side-effect, In this mode, libfuzzer will write the crashing stacktraces to individual files ./.$PID, instead of to the terminal's output. As far as I know, closing the FDs doesn't bypass all of printf's allocation/formatting code, so getting rid of calls can still be a good idea for performance, sometimes.
-Alex

Quoted 21 lines
---
 hw/display/omap_dss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/omap_dss.c +1 -1
index 32dc0d6aa7..21fde58a26 100644
@@ -619,7 +619,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
     if (s->rfbi.control & (1 << 1)) {				/* BYPASS */
         /* TODO: in non-Bypass mode we probably need to just assert the
          * DRQ and wait for DMA to write the pixels.  */
-        fprintf(stderr, "%s: Bypass mode unimplemented\n", __func__);
+        qemu_log_mask(LOG_UNIMP, "%s: Bypass mode unimplemented\n", __func__);
         return;
     }
 
Signature · 1 line
2.21.3
#2 lore raw
Quoted 10 lines · Alexander Bulekov
Quoted 4 lines · Philippe Mathieu-Daudé

Replace fprintf() call by qemu_log_mask(LOG_UNIMP), which is disabled by default. This avoid flooding the terminal when fuzzing the device.

Hi Philippe,
libfuzzer also lets you pass -close_fd_mask=[1,2,3] to close stdout, stderr or both. As a side-effect, In this mode, libfuzzer will write the crashing stacktraces to individual files ./.$PID, instead of to the terminal's output.

Thanks, good to know.

This information is worth adding in docs/devel/fuzzing.txt :P

Quoted 3 lines

As far as I know, closing the FDs doesn't bypass all
of printf's allocation/formatting code, so getting rid of calls can still be a good idea for performance, sometimes.

Certainly.

Quoted 24 lines

-Alex

Quoted 21 lines
---
 hw/display/omap_dss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/omap_dss.c +1 -1
index 32dc0d6aa7..21fde58a26 100644
@@ -619,7 +619,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
     if (s->rfbi.control & (1 << 1)) {				/* BYPASS */
         /* TODO: in non-Bypass mode we probably need to just assert the
          * DRQ and wait for DMA to write the pixels.  */
-        fprintf(stderr, "%s: Bypass mode unimplemented\n", __func__);
+        qemu_log_mask(LOG_UNIMP, "%s: Bypass mode unimplemented\n", __func__);
         return;
     }
 
Signature · 1 line
2.21.3
Reviewed-by on v1 1/1
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

Replace fprintf() call by qemu_log_mask(LOG_UNIMP), which is disabled by default. This avoid flooding the terminal when fuzzing the device.

---
 hw/display/omap_dss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/omap_dss.c +0 -0
index 32dc0d6aa7..21fde58a26 100644

hw/display/omap_dss.c static void omap_rfbi_transfer_start(struct omap_dss_s *s) · line 624

Quoted 7 lines
hw/display/omap_dss.c +1 -1
@@ -619,7 +619,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
     if (s->rfbi.control & (1 << 1)) {				/* BYPASS */
         /* TODO: in non-Bypass mode we probably need to just assert the
          * DRQ and wait for DMA to write the pixels.  */
-        fprintf(stderr, "%s: Bypass mode unimplemented\n", __func__);
+        qemu_log_mask(LOG_UNIMP, "%s: Bypass mode unimplemented\n", __func__);
         return;
     }