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