From patchwork Fri May 11 14:32:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Vyukov X-Patchwork-Id: 10394403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3972360170 for ; Fri, 11 May 2018 14:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B9CD2000A for ; Fri, 11 May 2018 14:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ECB728E3D; Fri, 11 May 2018 14:35:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F26E92000A for ; Fri, 11 May 2018 14:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=qmXt50UZm53Sf3zNO/a/6k+Sa6o0jPrBorcSxj1mFyE=; b=Qwm zPxWmJ5JcmyC6aVT7jcphsp9YHueYkoywnXzi3Hqq+WHQc7NuRIUSo3u4nNayyMIIQn3iQdmVePlq Rccgm/HtOOqGRXv53sxqFUpqB0gTyaLWpNCQKd9/Od++kofZfFwFfS+o6UID0jAwbYftd1ons9RdL +8AG8l0PC3zRp3SITy1oN8C24ehq8pdvu+78+nILbHdri+RZc/JAZDB3bqNGSqI8JYtxYrVJoh8WO 0auFZMgM+E6FKmbrV7gmNlVYoLGc5G/59IsRP8dLilVS//5itJeH4JN4IrQn6+r6y98GkAI9TxcP2 0lsch1pV+sDKfOcJWak4RUAqFoRg9tQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fH98r-0004zX-Es; Fri, 11 May 2018 14:35:29 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fH96Y-00035D-7n for linux-arm-kernel@lists.infradead.org; Fri, 11 May 2018 14:33:19 +0000 Received: by mail-wm0-x241.google.com with SMTP id f6-v6so3044881wmc.4 for ; Fri, 11 May 2018 07:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=N2tORmXRwdoSCnTnlBHY943YXkNAMtJbddI/9/4MYs0=; b=A7SmgbJ0Zo0CFFXJAG/Kvea2vhi+tuam7s1+fa5v/f1lf+wk+GHcKLcX5HUr1FB3sX b2IRr8l6MKf1ZZNRnef6Ijs6PxnA1s4jIALZG01bdgyQfTJqRsd20KXZVRRdjDB941H4 j8z6Q5kGUf8B1cZNsQjJGmEZhiYUZ+pc0cJU3smr6v8s2tVwKTyRLJ0JCqYmvmfV/BUQ +xl9lYKyGPeEEIRIBleexZHnFVuzziZVTDkpt6H52ByIcj1PT695A1vuGLEkdwXAUzqK dGOOwePjHs267KK9nxsOiwJZ6bvCgiyB1SK9UyBqBXAIMgTIboUqUuJ4ti+YIimThzHj Bymg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N2tORmXRwdoSCnTnlBHY943YXkNAMtJbddI/9/4MYs0=; b=E0lm04JZpAJMNUDZzJIOqaL0n1DHNvv0mkstMuURMolaFCZKzDdrAb/BRR2+vxGRRu XBlvLg4opR3o6TJw9467i525uRcSL5nrkmFT8akb7GOtojICU7PCy1Li0Y974xMoFeFp xujwtQqcHTdZSHBDOZ+tMD/Azq/EZr1AODLW5wrWGoWYX0j03rHK7Gmktu09JuovFiug 0k+Ox75kZJ+i9OPBEl+uyH2LS5QhGIbx/JkJdAN3XHzhYxHxhONA0aqOe53XShbtlvW9 dHECkRg61Toh6+QjMq1fDLx5J3MAkl4X/YE7LrFmQhrIzxvJiuXgTbYHfjbsDh+SLc6l uZvw== X-Gm-Message-State: ALKqPwcacfdOrm0avvM3MMh33Rv4RCA/qhieTAkmpzVveWbjkvcv/ilk S279J8OFUcXe0pW0KtiXEdA0jw== X-Google-Smtp-Source: AB8JxZpfoaUmzuzogF1o8XADcB3jFIk3tMiAf2rJFKg6quy1386NfED5XryvObA5eLrSAJa1WySWFA== X-Received: by 2002:a1c:dc54:: with SMTP id t81-v6mr2329297wmg.90.1526049172916; Fri, 11 May 2018 07:32:52 -0700 (PDT) Received: from dvyukov-z840.muc.corp.google.com ([100.105.29.198]) by smtp.gmail.com with ESMTPSA id a14-v6sm6006519wra.84.2018.05.11.07.32.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 07:32:51 -0700 (PDT) Received: by dvyukov-z840.muc.corp.google.com (Postfix, from userid 129372) id 8C115E0823; Fri, 11 May 2018 16:32:50 +0200 (CEST) From: Dmitry Vyukov To: linux@armlinux.org.uk, mark.rutland@arm.com, liuwenliang@huawei.com, catalin.marinas@arm.com, inux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [PATCH v2] arm: port KCOV to arm Date: Fri, 11 May 2018 16:32:48 +0200 Message-Id: <20180511143248.112484-1-dvyukov@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180511_073306_451478_D5D62A59 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, syzkaller@googlegroups.com, Koguchi Takuo , Dmitry Vyukov MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP KCOV is code coverage collection facility used, in particular, by syzkaller system call fuzzer. There is some interest in using syzkaller on arm devices. So port KCOV to arm. On implementation level this merely declares that KCOV is supported and disables instrumentation of 3 special cases. Reasons for disabling are commented in code. Tested with qemu-system-arm/vexpress-a15. Signed-off-by: Dmitry Vyukov Cc: Russell King Cc: Mark Rutland Cc: Abbott Liu Cc: Catalin Marinas Cc: Koguchi Takuo Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mm@kvack.org Cc: syzkaller@googlegroups.com Acked-by: Mark Rutland --- Changes since v1: - remove disable of instrumentation for arch/arm/mm/fault.c - disable instrumentation of arch/arm/kvm/hyp/* - resort ARCH_HAS_KCOV alphabetically --- arch/arm/Kconfig | 3 ++- arch/arm/boot/compressed/Makefile | 3 +++ arch/arm/kvm/hyp/Makefile | 8 ++++++++ arch/arm/vdso/Makefile | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3493f840e89c..34591796c36f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -8,9 +8,10 @@ config ARM select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE + select ARCH_HAS_KCOV select ARCH_HAS_PTE_SPECIAL if ARM_LPAE - select ARCH_HAS_SET_MEMORY select ARCH_HAS_PHYS_TO_DMA + select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL select ARCH_HAS_STRICT_MODULE_RWX if MMU select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 6a4e7341ecd3..5f5f081e4879 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -25,6 +25,9 @@ endif GCOV_PROFILE := n +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. +KCOV_INSTRUMENT := n + # # Architecture dependencies # diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile index 7fc0638f263a..d2b5ec9c4b92 100644 --- a/arch/arm/kvm/hyp/Makefile +++ b/arch/arm/kvm/hyp/Makefile @@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o obj-$(CONFIG_KVM_ARM_HOST) += switch.o CFLAGS_switch.o += $(CFLAGS_ARMV7VE) obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o + +# KVM code is run at a different exception code with a different map, so +# compiler instrumentation that inserts callbacks or checks into the code may +# cause crashes. Just disable it. +GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile index bb4118213fee..f4efff9d3afb 100644 --- a/arch/arm/vdso/Makefile +++ b/arch/arm/vdso/Makefile @@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2 # Disable gcov profiling for VDSO code GCOV_PROFILE := n +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. +KCOV_INSTRUMENT := n + # Force dependency $(obj)/vdso.o : $(obj)/vdso.so