From: Alexander Graf <graf@amazon.com>
To: Sam Caccavale <samcacc@amazon.de>
Cc: <samcaccavale@gmail.com>, <nmanthey@amazon.de>,
<wipawel@amazon.de>, <dwmw@amazon.co.uk>, <mpohlack@amazon.de>,
<graf@amazon.de>, <karahmed@amazon.de>,
<andrew.cooper3@citrix.com>, <JBeulich@suse.com>,
<pbonzini@redhat.com>, <rkrcmar@redhat.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <bp@alien8.de>, <hpa@zytor.com>,
<paullangton4@gmail.com>, <anirudhkaushik@google.com>,
<x86@kernel.org>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] Build target for emulate.o as a userspace binary
Date: Fri, 31 May 2019 10:02:25 +0200 [thread overview]
Message-ID: <529ed65f-f82e-7341-3a4f-6eea1f2961a9@amazon.com> (raw)
In-Reply-To: <20190521153924.15110-2-samcacc@amazon.de>
On 21.05.19 17:39, Sam Caccavale wrote:
> This commit contains the minimal set of functionality to build
> afl-harness around arch/x86/emulate.c which allows exercising code
> in that source file, like x86_emulate_insn. Resolving the
> dependencies was done via GCC's -H flag by get_headers.py.
>
> ---
> tools/Makefile | 9 ++
> .../fuzz/x86_instruction_emulation/.gitignore | 2 +
> tools/fuzz/x86_instruction_emulation/Makefile | 57 +++++++
> .../fuzz/x86_instruction_emulation/README.md | 12 ++
> .../x86_instruction_emulation/afl-harness.c | 149 ++++++++++++++++++
> tools/fuzz/x86_instruction_emulation/common.h | 87 ++++++++++
> .../x86_instruction_emulation/emulator_ops.c | 58 +++++++
> .../x86_instruction_emulation/emulator_ops.h | 117 ++++++++++++++
> .../scripts/get_headers.py | 95 +++++++++++
> .../scripts/make_deps | 4 +
> tools/fuzz/x86_instruction_emulation/stubs.c | 56 +++++++
> tools/fuzz/x86_instruction_emulation/stubs.h | 52 ++++++
> 12 files changed, 698 insertions(+)
> create mode 100644 tools/fuzz/x86_instruction_emulation/.gitignore
> create mode 100644 tools/fuzz/x86_instruction_emulation/Makefile
> create mode 100644 tools/fuzz/x86_instruction_emulation/README.md
> create mode 100644 tools/fuzz/x86_instruction_emulation/afl-harness.c
> create mode 100644 tools/fuzz/x86_instruction_emulation/common.h
> create mode 100644 tools/fuzz/x86_instruction_emulation/emulator_ops.c
> create mode 100644 tools/fuzz/x86_instruction_emulation/emulator_ops.h
> create mode 100644 tools/fuzz/x86_instruction_emulation/scripts/get_headers.py
> create mode 100755 tools/fuzz/x86_instruction_emulation/scripts/make_deps
> create mode 100644 tools/fuzz/x86_instruction_emulation/stubs.c
> create mode 100644 tools/fuzz/x86_instruction_emulation/stubs.h
>
> diff --git a/tools/Makefile b/tools/Makefile
> index 3dfd72ae6c1a..4d68817b7e49 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -94,6 +94,12 @@ freefall: FORCE
> kvm_stat: FORCE
> $(call descend,kvm/$@)
>
> +fuzz: FORCE
> + $(call descend,fuzz/x86_instruction_emulation)
> +
> +fuzz_deps: FORCE
> + $(call descend,fuzz/x86_instruction_emulation,fuzz_deps)
> +
> all: acpi cgroup cpupower gpio hv firewire liblockdep \
> perf selftests spi turbostat usb \
> virtio vm bpf x86_energy_perf_policy \
> @@ -171,6 +177,9 @@ tmon_clean:
> freefall_clean:
> $(call descend,laptop/freefall,clean)
>
> +fuzz_clean:
> + $(call descend,fuzz/x86_instruction_emulation,clean)
> +
> build_clean:
> $(call descend,build,clean)
>
> diff --git a/tools/fuzz/x86_instruction_emulation/.gitignore b/tools/fuzz/x86_instruction_emulation/.gitignore
> new file mode 100644
> index 000000000000..7d44f7ce266e
> --- /dev/null
> +++ b/tools/fuzz/x86_instruction_emulation/.gitignore
> @@ -0,0 +1,2 @@
> +*.o
> +*-harness
> diff --git a/tools/fuzz/x86_instruction_emulation/Makefile b/tools/fuzz/x86_instruction_emulation/Makefile
> new file mode 100644
> index 000000000000..d2854a332605
> --- /dev/null
> +++ b/tools/fuzz/x86_instruction_emulation/Makefile
> @@ -0,0 +1,57 @@
> +ROOT_DIR=../../..
> +THIS_DIR=tools/fuzz/x86_instruction_emulation
> +
> +include ../../scripts/Makefile.include
> +
> +.DEFAULT_GOAL := all
> +
> +INCLUDES := $(patsubst -I./%,-I./$(ROOT_DIR)/%, $(LINUXINCLUDE))
> +INCLUDES := $(patsubst ./include/%,./$(ROOT_DIR)/include/%, $(INCLUDES))
> +INCLUDES += -include ./$(ROOT_DIR)/include/linux/compiler_types.h
> +
> +$(ROOT_DIR)/.config:
> + make -C $(ROOT_DIR) menuconfig
> + sed -i -r 's/^#? *CONFIG_KVM(.*)=.*/CONFIG_KVM\1=y/' $(ROOT_DIR)/.config
> +
> +
> +ifdef DEBUG
> +KBUILD_CFLAGS += -DDEBUG
> +endif
> +KBUILD_CFLAGS += -g -O0
Why -O0? I would expect a some bugs to only emerge with optimization
enabled.
Alex
next prev parent reply other threads:[~2019-05-31 8:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-21 15:39 x86 instruction emulator fuzzing Sam Caccavale
2019-05-21 15:39 ` [PATCH 1/3] Build target for emulate.o as a userspace binary Sam Caccavale
2019-05-31 8:02 ` Alexander Graf [this message]
2019-06-12 15:19 ` samcacc
2019-05-21 15:39 ` [PATCH 2/3] Emulate simple x86 instructions in userspace Sam Caccavale
2019-05-31 8:38 ` Alexander Graf
2019-06-12 15:19 ` samcacc
2019-06-21 13:28 ` Alexander Graf
2019-05-21 15:39 ` [PATCH 3/3] Demonstrating unit testing via simple-harness Sam Caccavale
2019-05-31 8:39 ` x86 instruction emulator fuzzing Alexander Graf
2019-06-12 15:19 ` samcacc
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=529ed65f-f82e-7341-3a4f-6eea1f2961a9@amazon.com \
--to=graf@amazon.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=anirudhkaushik@google.com \
--cc=bp@alien8.de \
--cc=dwmw@amazon.co.uk \
--cc=graf@amazon.de \
--cc=hpa@zytor.com \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mpohlack@amazon.de \
--cc=nmanthey@amazon.de \
--cc=paullangton4@gmail.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=samcacc@amazon.de \
--cc=samcaccavale@gmail.com \
--cc=tglx@linutronix.de \
--cc=wipawel@amazon.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®