Skip to contentSkip to conversation

Log unimplemented functionality

PATCH In review Blue Swirl 3 participants 14 messages Jun 9, 2012 – Jul 6, 2012 Kbuild

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

v2 cover Log unimplemented functionality

v2: address Kevin's comments to 5/6

Blue Swirl (6):
qemu-log: move logging to qemu-log.c
qemu-log: cleanup
qemu-log: add log category for unimplemented functionality
qemu-log: use LOG_UNIMP for some target CPU cases
fdc: use LOG_UNIMP logging
qtest: add a fuzz test to fdc-test

 Makefile.objs                 |    1 +
 cpu-all.h                     |   24 ------
 exec.c                        |  122 -----------------------------
 hw/fdc.c                      |   30 ++++---
 linux-user/main.c             |    3 +-
 linux-user/signal.c           |   12 +--
 qemu-log.c                    |  170 +++++++++++++++++++++++++++++++++++++++++
 qemu-log.h                    |  145 ++++++++++++++++++++++++-----------
 qemu-tool.c                   |    2 -
 target-i386/op_helper.c       |    1 +
 target-microblaze/translate.c |   11 ++-
 target-ppc/helper.c           |    2 +-
 target-s390x/translate.c      |    2 +-
 target-sparc/ldst_helper.c    |   80 ++++++++++++--------
 tcg/tcg.c                     |   92 ++++++++++++----------
 tcg/tcg.h                     |    2 +-
 tcg/tci/tcg-target.c          |    2 +-
 tests/fdc-test.c              |   17 ++++
 18 files changed, 419 insertions(+), 299 deletions(-)
 create mode 100644 qemu-log.c
Signature · 1 line
1.7.2.5
author
#1 lore raw

PATCH v2 1/6 qemu-log: move logging to qemu-log.c

Move logging functions from exec.c to qemu-log.c,
compile it only once.

---
 Makefile.objs |    1 +
 cpu-all.h     |   24 ---------
 exec.c        |  122 -----------------------------------------------
 qemu-log.c    |  146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-log.h    |   28 +++++++++--
 5 files changed, 170 insertions(+), 151 deletions(-)
 create mode 100644 qemu-log.c
Makefile.objs +1 -0
index 8e72f09..27d57bf 100644
@@ -1,6 +1,7 @@
 #######################################################################
 # Target-independent parts used in system and user emulation
 universal-obj-y =
+universal-obj-y += qemu-log.o
 
 #######################################################################
 # QObject
cpu-all.h +0 -24
index 3a93c0c..50c8b62 100644
@@ -446,30 +446,6 @@ void cpu_single_step(CPUArchState *env, int enabled);
 int cpu_is_stopped(CPUArchState *env);
 void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data);
 
-#define CPU_LOG_TB_OUT_ASM (1 << 0)
-#define CPU_LOG_TB_IN_ASM  (1 << 1)
-#define CPU_LOG_TB_OP      (1 << 2)
-#define CPU_LOG_TB_OP_OPT  (1 << 3)
-#define CPU_LOG_INT        (1 << 4)
-#define CPU_LOG_EXEC       (1 << 5)
-#define CPU_LOG_PCALL      (1 << 6)
-#define CPU_LOG_IOPORT     (1 << 7)
-#define CPU_LOG_TB_CPU     (1 << 8)
-#define CPU_LOG_RESET      (1 << 9)
-
-/* define log items */
-typedef struct CPULogItem {
-    int mask;
-    const char *name;
-    const char *help;
-} CPULogItem;
-
-extern const CPULogItem cpu_log_items[];
-
-void cpu_set_log(int log_flags);
-void cpu_set_log_filename(const char *filename);
-int cpu_str_to_log_mask(const char *str);
-
 #if !defined(CONFIG_USER_ONLY)
 
 /* Return the physical page corresponding to a virtual one. Use it
exec.c +0 -122

140 lines not on this page · raw message

qemu-log.c new file +146 -0

146 lines not on this page · raw message

qemu-log.h +23 -5
index fccfb110..e04ee9a 100644
@@ -5,7 +5,6 @@
 extern FILE *logfile;
 extern int loglevel;
 
-
 /* 
  * The new API:
  *
@@ -17,11 +16,21 @@ extern int loglevel;
  */
 #define qemu_log_enabled() (logfile != NULL)
 
+#define CPU_LOG_TB_OUT_ASM (1 << 0)
+#define CPU_LOG_TB_IN_ASM  (1 << 1)
+#define CPU_LOG_TB_OP      (1 << 2)
+#define CPU_LOG_TB_OP_OPT  (1 << 3)
+#define CPU_LOG_INT        (1 << 4)
+#define CPU_LOG_EXEC       (1 << 5)
+#define CPU_LOG_PCALL      (1 << 6)
+#define CPU_LOG_IOPORT     (1 << 7)
+#define CPU_LOG_TB_CPU     (1 << 8)
+#define CPU_LOG_RESET      (1 << 9)
+
 /* Returns true if a bit is set in the current loglevel mask
  */
 #define qemu_loglevel_mask(b) ((loglevel & (b)) != 0)
 
-
 /* Logging functions: */
 
 /* main logging function
@@ -46,8 +55,6 @@ extern int loglevel;
     } while (0)
 
 
-
-
 /* Special cases: */
 
 /* cpu_dump_state() logging functions: */
@@ -66,7 +73,6 @@ extern int loglevel;
 #define log_page_dump() page_dump(logfile)
 
 
-
 /* Maintenance: */
 
 /* fflush() the log file */
@@ -89,5 +95,17 @@ extern int loglevel;
             logfile = (f);            \
     } while (0)
 
+/* define log items */
+typedef struct CPULogItem {
+    int mask;
+    const char *name;
+    const char *help;
+} CPULogItem;
+
+extern const CPULogItem cpu_log_items[];
+
+void cpu_set_log(int log_flags);
+void cpu_set_log_filename(const char *filename);
+int cpu_str_to_log_mask(const char *str);
 
 #endif
Signature · 1 line
1.7.2.5
#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] qemu-log: move logging to qemu-log.c

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 4 lines

Move logging functions from exec.c to qemu-log.c,
compile it only once.

This broke the TARGET_I386 specific logging options.

Kevin

author
#3 lore raw

Re: [Qemu-devel] [PATCH 1/6] qemu-log: move logging to qemu-log.c

Quoted 7 lines · Kevin Wolf

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 4 lines

Move logging functions from exec.c to qemu-log.c,
compile it only once.

This broke the TARGET_I386 specific logging options.

Also DEBUG_IOPORT. Maybe the logger should be compiled for each target, but that does not look attractive.

Quoted 2 lines

Kevin

#4 lore raw

Re: [Qemu-devel] [PATCH 1/6] qemu-log: move logging to qemu-log.c

Am 03.07.2012 21:19, schrieb Blue Swirl:

Quoted 11 lines · Kevin Wolf
Quoted 7 lines

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 4 lines

Move logging functions from exec.c to qemu-log.c,
compile it only once.

This broke the TARGET_I386 specific logging options.

Also DEBUG_IOPORT. Maybe the logger should be compiled for each target, but that does not look attractive.

The options that I see are more or less:

1. Compile the file for each target
2. Move only cpu_log_items[] to a separately compiled file
3. Replace the #ifdef by a runtime check

Kevin

author
#5 lore raw

Re: [Qemu-devel] [PATCH 1/6] qemu-log: move logging to qemu-log.c

Quoted 10 lines · Kevin Wolf

Am 03.07.2012 21:19, schrieb Blue Swirl:

Quoted 9 lines · Kevin Wolf
Quoted 7 lines

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 4 lines

Move logging functions from exec.c to qemu-log.c,
compile it only once.

This broke the TARGET_I386 specific logging options.

Quoted 8 lines
Quoted 2 lines

Also DEBUG_IOPORT. Maybe the logger should be compiled for each target, but that does not look attractive.

The options that I see are more or less:

1. Compile the file for each target
2. Move only cpu_log_items[] to a separately compiled file
3. Replace the #ifdef by a runtime check

I think we could just remove #ifdeffery and adjust the text with "(x86)", for example
"show protected mode far calls/returns/exceptions (x86 only)"

It should be safe to enable all options, obviously some of them won't do anything if enabled for the wrong architecture.

Quoted 2 lines

Kevin

#6 lore raw

Re: [Qemu-devel] [PATCH 1/6] qemu-log: move logging to qemu-log.c

Am 05.07.2012 20:07, schrieb Blue Swirl:

Quoted 20 lines · Kevin Wolf
Quoted 10 lines

Am 03.07.2012 21:19, schrieb Blue Swirl:

Quoted 9 lines · Kevin Wolf
Quoted 7 lines

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 4 lines

Move logging functions from exec.c to qemu-log.c,
compile it only once.

This broke the TARGET_I386 specific logging options.

Quoted 8 lines
Quoted 2 lines

Also DEBUG_IOPORT. Maybe the logger should be compiled for each target, but that does not look attractive.

The options that I see are more or less:

1. Compile the file for each target
2. Move only cpu_log_items[] to a separately compiled file
3. Replace the #ifdef by a runtime check

Quoted 6 lines

I think we could just remove #ifdeffery and adjust the text with "(x86)", for example
"show protected mode far calls/returns/exceptions (x86 only)"

It should be safe to enable all options, obviously some of them won't do anything if enabled for the wrong architecture.

Right, should be good enough indeed.

Kevin

author
#7 lore raw

PATCH v2 2/6 qemu-log: cleanup

In reply to Blue Swirl

Don't use global variables directly but via accessor functions. Rename globals.

Convert macros to functions, add GCC format attributes.

---
 linux-user/main.c    |    3 +-
 linux-user/signal.c  |   12 ++---
 qemu-log.c           |   54 ++++++++++++++++-------
 qemu-log.h           |  116 ++++++++++++++++++++++++++++++++------------------
 qemu-tool.c          |    2 -
 tcg/tcg.c            |   92 +++++++++++++++++++++------------------
 tcg/tcg.h            |    2 +-
 tcg/tci/tcg-target.c |    2 +-
 8 files changed, 170 insertions(+), 113 deletions(-)
linux-user/main.c +2 -1
index 49108b8..d0e0e4f 100644
@@ -1306,8 +1306,9 @@ do {                                                                    \
     fprintf(stderr, fmt , ## __VA_ARGS__);                              \
     cpu_dump_state(env, stderr, fprintf, 0);                            \
     qemu_log(fmt, ## __VA_ARGS__);                                      \
-    if (logfile)                                                        \
+    if (qemu_log_enabled()) {                                           \
         log_cpu_state(env, 0);                                          \
+    }                                                                   \
 } while (0)
 
 static int do_store_exclusive(CPUPPCState *env)
linux-user/signal.c +4 -8
index b1e139d..43346dc 100644
@@ -4378,8 +4378,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
 sigsegv:
     unlock_user_struct(frame, frame_addr, 1);
-    if (logfile)
-        fprintf (logfile, "segfaulting from setup_frame\n");
+    qemu_log("segfaulting from setup_frame\n");
     force_sig(TARGET_SIGSEGV);
 }
 
@@ -4447,8 +4446,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
 
 sigsegv:
     unlock_user_struct(rt_sf, rt_sf_addr, 1);
-    if (logfile)
-        fprintf (logfile, "segfaulting from setup_rt_frame\n");
+    qemu_log("segfaulting from setup_rt_frame\n");
     force_sig(TARGET_SIGSEGV);
 
 }
@@ -4489,8 +4487,7 @@ long do_sigreturn(CPUPPCState *env)
 sigsegv:
     unlock_user_struct(sr, sr_addr, 1);
     unlock_user_struct(sc, sc_addr, 1);
-    if (logfile)
-        fprintf (logfile, "segfaulting from do_sigreturn\n");
+    qemu_log("segfaulting from do_sigreturn\n");
     force_sig(TARGET_SIGSEGV);
     return 0;
 }
@@ -4552,8 +4549,7 @@ long do_rt_sigreturn(CPUPPCState *env)
 
 sigsegv:
     unlock_user_struct(rt_sf, rt_sf_addr, 1);
-    if (logfile)
-        fprintf (logfile, "segfaulting from do_rt_sigreturn\n");
+    qemu_log("segfaulting from do_rt_sigreturn\n");
     force_sig(TARGET_SIGSEGV);
     return 0;
 }
qemu-log.c +38 -16

85 lines not on this page · raw message

qemu-log.h +75 -41

162 lines not on this page · raw message

qemu-tool.c +0 -2
index 07fc4f2..318c5fc 100644
@@ -24,8 +24,6 @@
 
 #include <sys/time.h>
 
-FILE *logfile;
-
 struct QEMUBH
 {
     QEMUBHFunc *cb;
tcg/tcg.c +49 -43

166 lines not on this page · raw message

tcg/tcg.h +1 -1
index a83bddd..d710694 100644
@@ -571,7 +571,7 @@ TCGArg *tcg_optimize(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg *args,
 /* only used for debugging purposes */
 void tcg_register_helper(void *func, const char *name);
 const char *tcg_helper_get_name(TCGContext *s, void *func);
-void tcg_dump_ops(TCGContext *s, FILE *outfile);
+void tcg_dump_ops(TCGContext *s);
 
 void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
 TCGv_i32 tcg_const_i32(int32_t val);
tcg/tci/tcg-target.c +1 -1
index 453f187..d0a368d 100644
@@ -878,7 +878,7 @@ static void tcg_target_init(TCGContext *s)
 #if defined(CONFIG_DEBUG_TCG_INTERPRETER)
     const char *envval = getenv("DEBUG_TCG");
     if (envval) {
-        loglevel = strtol(envval, NULL, 0);
+        cpu_set_log(strtol(envval, NULL, 0));
     }
 #endif
 
Signature · 1 line
1.7.2.5
author
#8 lore raw

PATCH v2 3/6 qemu-log: add log category for unimplemented functionality

In reply to Blue Swirl

Add new log category (LOG_UNIMP) for unimplemented functionality.

---
 qemu-log.c |    2 ++
 qemu-log.h |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
qemu-log.c +2 -0
index 1dd3de4..1ec70e7 100644
@@ -120,6 +120,8 @@ const CPULogItem cpu_log_items[] = {
     { CPU_LOG_IOPORT, "ioport",
       "show all i/o ports accesses" },
 #endif
+    { LOG_UNIMP, "unimp",
+      "log unimplemented functionality" },
     { 0, NULL, NULL },
 };
 
qemu-log.h +1 -0
index d1e0f2d..40f8b7b 100644
@@ -34,6 +34,7 @@ static inline bool qemu_log_enabled(void)
 #define CPU_LOG_IOPORT     (1 << 7)
 #define CPU_LOG_TB_CPU     (1 << 8)
 #define CPU_LOG_RESET      (1 << 9)
+#define LOG_UNIMP          (1 << 10)
 
 /* Returns true if a bit is set in the current loglevel mask
  */
Signature · 1 line
1.7.2.5
author
#9 lore raw

PATCH v2 4/6 qemu-log: use LOG_UNIMP for some target CPU cases

In reply to Blue Swirl

Use LOG_UNIMP for some target CPU cases.

---
 target-i386/op_helper.c       |    1 +
 target-microblaze/translate.c |   11 ++++--
 target-ppc/helper.c           |    2 +-
 target-s390x/translate.c      |    2 +-
 target-sparc/ldst_helper.c    |   80 ++++++++++++++++++++++++----------------
 5 files changed, 58 insertions(+), 38 deletions(-)
target-i386/op_helper.c +1 -0
index bc3b94e..2862ea4 100644
@@ -3146,6 +3146,7 @@ void helper_rdpmc(void)
     helper_svm_check_intercept_param(SVM_EXIT_RDPMC, 0);
     
     /* currently unimplemented */
+    qemu_log_mask(LOG_UNIMP, "x86: unimplemented rdpmc\n");
     raise_exception_err(EXCP06_ILLOP, 0);
 }
 
target-microblaze/translate.c +7 -4
index c0a6bfd..7470149 100644
@@ -1539,8 +1539,10 @@ static void dec_fpu(DisasContext *dc)
                                        cpu_R[dc->ra], cpu_R[dc->rb]);
                     break;
                 default:
-                    qemu_log ("unimplemented fcmp fpu_insn=%x pc=%x opc=%x\n",
-                              fpu_insn, dc->pc, dc->opcode);
+                    qemu_log_mask(LOG_UNIMP,
+                                  "unimplemented fcmp fpu_insn=%x pc=%x"
+                                  " opc=%x\n",
+                                  fpu_insn, dc->pc, dc->opcode);
                     dc->abort_at_next_insn = 1;
                     break;
             }
@@ -1568,8 +1570,9 @@ static void dec_fpu(DisasContext *dc)
             break;
 
         default:
-            qemu_log ("unimplemented FPU insn fpu_insn=%x pc=%x opc=%x\n",
-                      fpu_insn, dc->pc, dc->opcode);
+            qemu_log_mask(LOG_UNIMP, "unimplemented FPU insn fpu_insn=%x pc=%x"
+                          " opc=%x\n",
+                          fpu_insn, dc->pc, dc->opcode);
             dc->abort_at_next_insn = 1;
             break;
     }
target-ppc/helper.c +1 -1
index f556f85..3f7d8a4 100644
@@ -1621,7 +1621,7 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env)
         break;
 #endif
     default:
-        cpu_fprintf(f, "%s: unimplemented\n", __func__);
+        qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__);
     }
 }
 
target-s390x/translate.c +1 -1
index 9bf8c38..1c1baf5 100644
@@ -5098,7 +5098,7 @@ static void disas_s390_insn(DisasContext *s)
         disas_ed(s, op, r1, x2, b2, d2, r1b);
         break;
     default:
-        LOG_DISAS("unimplemented opcode 0x%x\n", opc);
+        qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%x\n", opc);
         gen_illegal_opcode(s, ilc);
         break;
     }
target-sparc/ldst_helper.c +48 -32

170 lines not on this page · raw message

Signature · 1 line
1.7.2.5
author
#10 lore raw

PATCH v2 5/6 fdc: use LOG_UNIMP logging

In reply to Blue Swirl

Convert uses of FLOPPY_ERROR to either FLOPPY_DPRINTF (for implemented cases) or to use LOG_UNIMP (unimplemented).

---
 hw/fdc.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)
hw/fdc.c +17 -13
index 30d34e3..6625fcb 100644
@@ -36,6 +36,7 @@
 #include "qdev-addr.h"
 #include "blockdev.h"
 #include "sysemu.h"
+#include "qemu-log.h"
 
 /********************************************************/
 /* debug Floppy devices */
@@ -48,9 +49,6 @@
 #define FLOPPY_DPRINTF(fmt, ...)
 #endif
 
-#define FLOPPY_ERROR(fmt, ...)                                          \
-    do { printf("FLOPPY ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0)
-
 /********************************************************/
 /* Floppy drive emulation                               */
 
@@ -147,8 +145,10 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect,
     if (sector != fd_sector(drv)) {
 #if 0
         if (!enable_seek) {
-            FLOPPY_ERROR("no implicit seek %d %02x %02x (max=%d %02x %02x)\n",
-                         head, track, sect, 1, drv->max_track, drv->last_sect);
+            FLOPPY_DPRINTF("error: no implicit seek %d %02x %02x"
+                           " (max=%d %02x %02x)\n",
+                           head, track, sect, 1, drv->max_track,
+                           drv->last_sect);
             return 4;
         }
 #endif
@@ -987,7 +987,8 @@ static void fdctrl_set_fifo(FDCtrl *fdctrl, int fifo_len, int do_irq)
 /* Set an error: unimplemented/unknown command */
 static void fdctrl_unimplemented(FDCtrl *fdctrl, int direction)
 {
-    FLOPPY_ERROR("unimplemented command 0x%02x\n", fdctrl->fifo[0]);
+    qemu_log_mask(LOG_UNIMP, "fdc: unimplemented command 0x%02x\n",
+                  fdctrl->fifo[0]);
     fdctrl->fifo[0] = FD_SR0_INVCMD;
     fdctrl_set_fifo(fdctrl, 1, 0);
 }
@@ -1155,7 +1156,8 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
             DMA_schedule(fdctrl->dma_chann);
             return;
         } else {
-            FLOPPY_ERROR("dma_mode=%d direction=%d\n", dma_mode, direction);
+            FLOPPY_DPRINTF("bad dma_mode=%d direction=%d\n", dma_mode,
+                           direction);
         }
     }
     FLOPPY_DPRINTF("start non-DMA transfer\n");
@@ -1171,7 +1173,7 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
 /* Prepare a transfer of deleted data */
 static void fdctrl_start_transfer_del(FDCtrl *fdctrl, int direction)
 {
-    FLOPPY_ERROR("fdctrl_start_transfer_del() unimplemented\n");
+    qemu_log_mask(LOG_UNIMP, "fdctrl_start_transfer_del() unimplemented\n");
 
     /* We don't handle deleted data,
      * so we don't return *ANYTHING*
@@ -1250,7 +1252,8 @@ static int fdctrl_transfer_handler (void *opaque, int nchan,
                              fdctrl->data_pos, len);
             if (bdrv_write(cur_drv->bs, fd_sector(cur_drv),
                            fdctrl->fifo, 1) < 0) {
-                FLOPPY_ERROR("writing sector %d\n", fd_sector(cur_drv));
+                FLOPPY_DPRINTF("error writing sector %d\n",
+                               fd_sector(cur_drv));
                 fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
                 goto transfer_error;
             }
@@ -1309,7 +1312,7 @@ static uint32_t fdctrl_read_data(FDCtrl *fdctrl)
     cur_drv = get_cur_drv(fdctrl);
     fdctrl->dsr &= ~FD_DSR_PWRDOWN;
     if (!(fdctrl->msr & FD_MSR_RQM) || !(fdctrl->msr & FD_MSR_DIO)) {
-        FLOPPY_ERROR("controller not ready for reading\n");
+        FLOPPY_DPRINTF("error: controller not ready for reading\n");
         return 0;
     }
     pos = fdctrl->data_pos;
@@ -1393,7 +1396,7 @@ static void fdctrl_format_sector(FDCtrl *fdctrl)
     memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
     if (cur_drv->bs == NULL ||
         bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
-        FLOPPY_ERROR("formatting sector %d\n", fd_sector(cur_drv));
+        FLOPPY_DPRINTF("error formatting sector %d\n", fd_sector(cur_drv));
         fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
     } else {
         if (cur_drv->sect == cur_drv->last_sect) {
@@ -1768,7 +1771,7 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
         return;
     }
     if (!(fdctrl->msr & FD_MSR_RQM) || (fdctrl->msr & FD_MSR_DIO)) {
-        FLOPPY_ERROR("controller not ready for writing\n");
+        FLOPPY_DPRINTF("error: controller not ready for writing\n");
         return;
     }
     fdctrl->dsr &= ~FD_DSR_PWRDOWN;
@@ -1782,7 +1785,8 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
             fdctrl->data_pos == fdctrl->data_len) {
             cur_drv = get_cur_drv(fdctrl);
             if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
-                FLOPPY_ERROR("writing sector %d\n", fd_sector(cur_drv));
+                FLOPPY_DPRINTF("error writing sector %d\n",
+                               fd_sector(cur_drv));
                 return;
             }
             if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) {
Signature · 1 line
1.7.2.5
author
#12 lore raw

PATCH v2 6/6 qtest: add a fuzz test to fdc-test

In reply to Blue Swirl

Add a simple register fuzzing test to floppy controller tests.

---
 tests/fdc-test.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
tests/fdc-test.c +17 -0
index 22d24ac..676b215 100644
@@ -185,6 +185,22 @@ static void test_media_change(void)
     assert_bit_set(dir, DSKCHG);
 }
 
+/* success if no crash or abort */
+static void fuzz_registers(void)
+{
+    unsigned int i;
+
+    for (i = 0; i < 1000; i++) {
+        uint8_t reg, val;
+
+        reg = (uint8_t)g_test_rand_int_range(0, 8);
+        val = (uint8_t)g_test_rand_int_range(0, 256);
+
+        outb(FLOPPY_BASE + reg, val);
+        inb(FLOPPY_BASE + reg);
+    }
+}
+
 int main(int argc, char **argv)
 {
     const char *arch = qtest_get_arch();
@@ -215,6 +231,7 @@ int main(int argc, char **argv)
     qtest_add_func("/fdc/cmos", test_cmos);
     qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
     qtest_add_func("/fdc/media_change", test_media_change);
+    qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
 
     ret = g_test_run();
 
Signature · 1 line
1.7.2.5
#13 lore raw
In reply to Blue Swirl

Am 09.06.2012 14:12, schrieb Blue Swirl:

Quoted 9 lines

v2: address Kevin's comments to 5/6

Blue Swirl (6):
qemu-log: move logging to qemu-log.c
qemu-log: cleanup
qemu-log: add log category for unimplemented functionality
qemu-log: use LOG_UNIMP for some target CPU cases
fdc: use LOG_UNIMP logging
qtest: add a fuzz test to fdc-test

Series arrived threaded and git-am was happy, thanks a lot! Also compiles fine, didn't test further.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg