qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Bulekov <alxndr@bu.edu>, Warner Losh <imp@freebsd.org>,
	Qiuhao Li <Qiuhao.Li@outlook.com>
Subject: [PULL 15/15] fuzz: map all BARs and enable PCI devices
Date: Mon, 11 Jan 2021 14:43:28 +0100	[thread overview]
Message-ID: <20210111134328.157775-16-thuth@redhat.com> (raw)
In-Reply-To: <20210111134328.157775-1-thuth@redhat.com>

From: Alexander Bulekov <alxndr@bu.edu>

Prior to this patch, the fuzzer found inputs to map PCI device BARs and
enable the device. While it is nice that the fuzzer can do this, it
added significant overhead, since the fuzzer needs to map all the
BARs (regenerating the memory topology), at the start of each input.
With this patch, we do this once, before fuzzing, mitigating some of
this overhead.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201221181203.1853-1-alxndr@bu.edu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/fuzz/generic_fuzz.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index 07ad690683..be76d47d2d 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -16,6 +16,7 @@
 
 #include "hw/core/cpu.h"
 #include "tests/qtest/libqos/libqtest.h"
+#include "tests/qtest/libqos/pci-pc.h"
 #include "fuzz.h"
 #include "fork_fuzz.h"
 #include "exec/address-spaces.h"
@@ -762,10 +763,29 @@ static int locate_fuzz_objects(Object *child, void *opaque)
     return 0;
 }
 
+
+static void pci_enum(gpointer pcidev, gpointer bus)
+{
+    PCIDevice *dev = pcidev;
+    QPCIDevice *qdev;
+    int i;
+
+    qdev = qpci_device_find(bus, dev->devfn);
+    g_assert(qdev != NULL);
+    for (i = 0; i < 6; i++) {
+        if (dev->io_regions[i].size) {
+            qpci_iomap(qdev, i, NULL);
+        }
+    }
+    qpci_device_enable(qdev);
+    g_free(qdev);
+}
+
 static void generic_pre_fuzz(QTestState *s)
 {
     GHashTableIter iter;
     MemoryRegion *mr;
+    QPCIBus *pcibus;
     char **result;
 
     if (!getenv("QEMU_FUZZ_OBJECTS")) {
@@ -810,6 +830,10 @@ static void generic_pre_fuzz(QTestState *s)
         exit(1);
     }
 
+    pcibus = qpci_new_pc(s, NULL);
+    g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
+    qpci_free_pc(pcibus);
+
     counter_shm_init();
 }
 
-- 
2.27.0



  parent reply	other threads:[~2021-01-11 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 13:43 [PULL 00/15] Testing, CI and bsd-user patches Thomas Huth
2021-01-11 13:43 ` [PULL 01/15] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD Thomas Huth
2021-01-11 13:43 ` [PULL 02/15] qtest/libqtest: fix heap-buffer-overflow in qtest_cb_for_every_machine() Thomas Huth
2021-01-11 13:43 ` [PULL 03/15] util/oslib-win32: Fix _aligned_malloc() arguments order Thomas Huth
2021-01-11 13:43 ` [PULL 04/15] fuzz: accelerate non-crash detection Thomas Huth
2021-01-11 13:43 ` [PULL 05/15] fuzz: double the IOs to remove for every loop Thomas Huth
2021-01-11 13:43 ` [PULL 06/15] fuzz: split write operand using binary approach Thomas Huth
2021-01-11 13:43 ` [PULL 07/15] fuzz: remove IO commands iteratively Thomas Huth
2021-01-11 13:43 ` [PULL 08/15] fuzz: set bits in operand of write/out to zero Thomas Huth
2021-01-11 13:43 ` [PULL 09/15] fuzz: add minimization options Thomas Huth
2021-01-11 13:43 ` [PULL 10/15] fuzz: heuristic split write based on past IOs Thomas Huth
2021-01-11 13:43 ` [PULL 11/15] bsd-user: regenerate FreeBSD's system call numbers Thomas Huth
2021-01-11 13:43 ` [PULL 12/15] bsd-user: move strace OS/arch dependent code to host/arch dirs Thomas Huth
2021-01-11 13:43 ` [PULL 13/15] bsd-user: Update strace.list for FreeBSD's latest syscalls Thomas Huth
2021-01-11 13:43 ` [PULL 14/15] tests/acceptance: Fix race conditions in s390x tests & skip fedora on gitlab-CI Thomas Huth
2021-01-11 13:43 ` Thomas Huth [this message]
2021-01-11 13:46 ` [PULL 00/15] Testing, CI and bsd-user patches Peter Maydell
2021-01-11 13:56   ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111134328.157775-16-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=Qiuhao.Li@outlook.com \
    --cc=alxndr@bu.edu \
    --cc=imp@freebsd.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).