fuzz-virtio-scsi-test.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * QTest fuzzer-generated testcase for virtio-scsi device
  3. *
  4. * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. */
  9. #include "qemu/osdep.h"
  10. #include "libqtest.h"
  11. /*
  12. * Here a MemoryRegionCache pointed to an MMIO region but had a
  13. * larger size than the underlying region.
  14. */
  15. static void test_mmio_oob_from_memory_region_cache(void)
  16. {
  17. QTestState *s;
  18. s = qtest_init("-M pc-q35-5.2 -display none -m 512M "
  19. "-device virtio-scsi,num_queues=8,addr=03.0 ");
  20. qtest_outl(s, 0xcf8, 0x80001811);
  21. qtest_outb(s, 0xcfc, 0x6e);
  22. qtest_outl(s, 0xcf8, 0x80001824);
  23. qtest_outl(s, 0xcf8, 0x80001813);
  24. qtest_outl(s, 0xcfc, 0xa080000);
  25. qtest_outl(s, 0xcf8, 0x80001802);
  26. qtest_outl(s, 0xcfc, 0x5a175a63);
  27. qtest_outb(s, 0x6e08, 0x9e);
  28. qtest_writeb(s, 0x9f003, 0xff);
  29. qtest_writeb(s, 0x9f004, 0x01);
  30. qtest_writeb(s, 0x9e012, 0x0e);
  31. qtest_writeb(s, 0x9e01b, 0x0e);
  32. qtest_writeb(s, 0x9f006, 0x01);
  33. qtest_writeb(s, 0x9f008, 0x01);
  34. qtest_writeb(s, 0x9f00a, 0x01);
  35. qtest_writeb(s, 0x9f00c, 0x01);
  36. qtest_writeb(s, 0x9f00e, 0x01);
  37. qtest_writeb(s, 0x9f010, 0x01);
  38. qtest_writeb(s, 0x9f012, 0x01);
  39. qtest_writeb(s, 0x9f014, 0x01);
  40. qtest_writeb(s, 0x9f016, 0x01);
  41. qtest_writeb(s, 0x9f018, 0x01);
  42. qtest_writeb(s, 0x9f01a, 0x01);
  43. qtest_writeb(s, 0x9f01c, 0x01);
  44. qtest_writeb(s, 0x9f01e, 0x01);
  45. qtest_writeb(s, 0x9f020, 0x01);
  46. qtest_writeb(s, 0x9f022, 0x01);
  47. qtest_writeb(s, 0x9f024, 0x01);
  48. qtest_writeb(s, 0x9f026, 0x01);
  49. qtest_writeb(s, 0x9f028, 0x01);
  50. qtest_writeb(s, 0x9f02a, 0x01);
  51. qtest_writeb(s, 0x9f02c, 0x01);
  52. qtest_writeb(s, 0x9f02e, 0x01);
  53. qtest_writeb(s, 0x9f030, 0x01);
  54. qtest_outb(s, 0x6e10, 0x00);
  55. qtest_quit(s);
  56. }
  57. int main(int argc, char **argv)
  58. {
  59. g_test_init(&argc, &argv, NULL);
  60. qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",
  61. test_mmio_oob_from_memory_region_cache);
  62. return g_test_run();
  63. }