Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750818AbcDMQfy (ORCPT ); Wed, 13 Apr 2016 12:35:54 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38257 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbcDMQfw convert rfc822-to-8bit (ORCPT ); Wed, 13 Apr 2016 12:35:52 -0400 MIME-Version: 1.0 In-Reply-To: <570E6FF3.5000104@arm.com> References: <57cb1b66d85b85eadea28ef3304a62b1327ded45.1459432254.git.glider@google.com> <20160331142908.GG26532@leverpostej> <20160331160052.GA26393@leverpostej> <20160331171434.GC26393@leverpostej> <570E6FF3.5000104@arm.com> Date: Wed, 13 Apr 2016 18:35:50 +0200 Message-ID: Subject: Re: [PATCH v1] arm64: allow building with kcov coverage on ARM64 From: Alexander Potapenko To: James Morse Cc: Dmitry Vyukov , Mark Rutland , Catalin Marinas , Quentin Casasnovas , Will Deacon , Kostya Serebryany , Andrew Morton , syzkaller , LKML , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , marc.zyngier@arm.com, Christoffer Dall Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3411 Lines: 105 Hi James, On Wed, Apr 13, 2016 at 6:12 PM, James Morse wrote: > Hi Alex, > > On 12/04/16 12:17, Alexander Potapenko wrote: >> I also wonder if we can, say, land the change to arch/arm64/Kconfig >> separately from makefile changes that improve the precision or fix >> certain build configurations. > > (I'm not sure what you mean by precision) > > It depends which build configurations get broken, for example the first build I > tried doesn't boot. > > I tested the Kconfig change, and added 'KCOV_INSTRUMENT := n' to kvm's two > Makefiles[0]. > > defconfig+KCOV boots fine, and I can start a guest, but if I build with > defconfig+KCOV+STACK_TRACER, I get a kernel that fails to boot. It boils down to > a loop between ftrace and kcov, I will send a patch. > > > It looks like syzkaller is the only user of this data, and it doesn't appear to > support arm64: >> 2016/04/13 15:42:55 failed to create instance: qemu stopped: >> "kvm" accelerator not found. >> No accelerator found! syzcaller is able to work with bare-metal Android devices using ADB, but those are usually running ancient kernels. Looks like It's time for me to start cross-compiling and testing an arm64 kernel on a QEMU, so I'll try that out and update the patch. > This happens because syzkaller expects to be able to use 'qemu-system-x86_64': >> [pid 3670] execve("/usr/bin/qemu-system-x86_64", ["qemu-system-x86_64", >> "-hda", "/foo.img", "-snapshot", "-m", "1024", "-net", "nic", "-net", >> "user,host=10.0.2.10,hostfwd=tcp:"..., "-nographic", "-enable-kvm", "-numa", >> "node,nodeid=0,cpus=0-1", "-numa", "node,nodeid=1,cpus=2-3", ...], > > qemu-system-x86_64 is installed and works fine, it just doesn't have the > expected hardware acceleration... > > My approximation of your qemu command for arm64 may be useful[1], but I'm not > able to hack the go source to fix it! > > > > Thanks, > > James > > > > [0] > diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile > index 122cff482ac4..7d111f06bbf3 100644 > --- a/arch/arm64/kvm/Makefile > +++ b/arch/arm64/kvm/Makefile > @@ -9,6 +9,10 @@ CFLAGS_mmu.o := -I. > KVM=../../../virt/kvm > ARM=../../../arch/arm/kvm > > +# Code built here may run at EL2, in which case __sanitizer_cov_trace_pc() will > +# not be callable. For now, disable the instrumentation. > +KCOV_INSTRUMENT := n > + > obj-$(CONFIG_KVM_ARM_HOST) += kvm.o > obj-$(CONFIG_KVM_ARM_HOST) += hyp/ > > diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile > index 778d0effa2af..1150f8664c85 100644 > --- a/arch/arm64/kvm/hyp/Makefile > +++ b/arch/arm64/kvm/hyp/Makefile > @@ -20,3 +20,4 @@ obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o > GCOV_PROFILE := n > KASAN_SANITIZE := n > UBSAN_SANITIZE := n > +KCOV_INSTRUMENT := n > > > [1] > qemu-system-aarch64 -enable-kvm > -cpu host -m 1024 -M virt -nographic > -kernel ./syzkaller/Image > -append "console=ttyAMA0,115200 root=/dev/vda" > -drive format=raw,file=/foo.img,media=disk,if=none,cache=writeback,id=root > -device virtio-blk-device,drive=root > -netdev user,host=10.0.2.10,hostfwd=tcp::23505-:22,id=unet > -device virtio-net-device,netdev=unet > > -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg