From patchwork Thu Apr 26 13:08:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Vyukov X-Patchwork-Id: 10365955 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 B76D6601BE for ; Thu, 26 Apr 2018 13:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A505D290E7 for ; Thu, 26 Apr 2018 13:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97C7B29129; Thu, 26 Apr 2018 13:09:27 +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=ham 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 35F08290E7 for ; Thu, 26 Apr 2018 13:09:26 +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=jDGuxgMH2bCNxnqTZe+qKDGVKJT0jFXTp7zZ0OA5M9I=; b=feQ ugM4GMtm8QZiXcUNcn/9o8+JaVhIH1YdkmHmiAAhE0bAnL5qBfnN3Adu0+lzSGV47ZxHsztdzaUlt 5zayxI/4AzFaSrguYCitnRH1DGStCWTAkC/uPYpdrph4HVvYF7Un0o3scaioUTZ8xloNhSJvYU5jo fzF+k8HaSitYhkiu4M4tgPk41x5Gj6wf9ZBp8I96divt8RjY84vkNhayNrj6b3Jvm1BgwhzWFh5en 6/0TtfpUbj2pQHfuKI0avF+6XBTig8V4s4zW9ohxsuH9KZVFJe8y2TQT4XJ1yozyG9C7+XdIj9Qpr k/5WapaZ7LuV5+di/h3b5amunboszyg==; 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 1fBgeG-0003AV-D7; Thu, 26 Apr 2018 13:09:20 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBgdz-0002mm-51 for linux-arm-kernel@lists.infradead.org; Thu, 26 Apr 2018 13:09:05 +0000 Received: by mail-wm0-x244.google.com with SMTP id n10so13134677wmc.1 for ; Thu, 26 Apr 2018 06:08:52 -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=+2R0zhG3MstGQEdoZsFlcFgJz54KxPKX6d/49vehINo=; b=HKpb+vdHw1jSmS6wYwmhdpZGEgRFdZZk2nk7Y1V4NsHaEyHOC8scpnEEXUEWOddZvb jHek1P5wAgHKZrZtj+ORgkiRp9DPWn+e+SjYpXJawORefIgJYwt3j+JHqxSYag+Jm0v/ NdM5FTySgLeLwPJbapDbAD6gJwNQRbv3aBfDYduNlYjwscaTeqld4qModTsbDzSN6plP Odev4H/gdqNFyf0MU23nHcBBGN5KmASyKxmu1wGxRx4BRJdnYRTR0U6UxhC1dF7hHrXN LoMZhzmUUVeGEJzgIzps2H+chnPGcoiATR/+8obNWBRjat8ijzNAD6i0HFQldqtaM71n N0Fw== 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=+2R0zhG3MstGQEdoZsFlcFgJz54KxPKX6d/49vehINo=; b=gWK+LQV69X2pSW5WX61FHQh2bNWD40FM2RYtG+/p65/1m0QjZNgc6I3S0oNou8RrBu G8GprhigjWGbBiOv1rAtHNGuRQ1X+uqk5rJ92Qt0ZgzMpAQA6g4iCuPBqsiLiIRWfv+t Qd0VSGZQv0e68uwNRwlWNeV7RnCzPUkS3i0iUh6bOzvjjTFdHIN1w0XWG6OP7749d2L5 SdTPxFJwUbb1+Z1W5EHwpmRHdRMYxNfeB6nFHGjOsHOaostKUphqPu3jABrv7Jfjk4A9 s60FCHeFtUF05t4C1k8TXt5bW/ANMSn2pyB7gTWX14tJwPpMNQMlGpKfK/rImI0Hixvs w3Pg== X-Gm-Message-State: ALQs6tAIMwb6GXTEEB/73/MgCFqjOUL6K8XPCLtCQWmOEeOYwUnENvId HQjdSoPMmzE0SrQIBhHpmi6lLQ== X-Google-Smtp-Source: AIpwx4/W5G7mKEhJcwzfynadCDh8RA7SbD5od8r8DeBwsDkNc85VPSd0a46EV/1H+lhme2WgBlCPDw== X-Received: by 10.28.174.81 with SMTP id x78mr20112728wme.41.1524748129869; Thu, 26 Apr 2018 06:08:49 -0700 (PDT) Received: from dvyukov-z840.muc.corp.google.com ([2a00:79e0:15:10:8971:4ae9:dd1c:10e]) by smtp.gmail.com with ESMTPSA id c21-v6sm17959192wre.43.2018.04.26.06.08.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 06:08:48 -0700 (PDT) Received: by dvyukov-z840.muc.corp.google.com (Postfix, from userid 129372) id 8F46CE0FA4; Thu, 26 Apr 2018 15:08:47 +0200 (CEST) From: Dmitry Vyukov To: linux@armlinux.org.uk, mark.rutland@arm.com, liuwenliang@huawei.com, catalin.marinas@arm.com, takuo.koguchi.sw@hitachi.com, atulp@google.com Subject: [PATCH] arm: port KCOV to arm Date: Thu, 26 Apr 2018 15:08:46 +0200 Message-Id: <20180426130846.130976-1-dvyukov@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180426_060903_346788_042B233F X-CRM114-Status: GOOD ( 12.40 ) 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: syzkaller@googlegroups.com, linux-arm-kernel@lists.infradead.org, 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: Atul Prakash Cc: linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org Cc: syzkaller@googlegroups.com --- arch/arm/Kconfig | 1 + arch/arm/boot/compressed/Makefile | 3 +++ arch/arm/mm/Makefile | 4 ++++ arch/arm/vdso/Makefile | 3 +++ 4 files changed, 11 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a7f8e7f4b88f..60558a6bb744 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -105,6 +105,7 @@ config ARM select REFCOUNT_FULL select RTC_LIB select SYS_SUPPORTS_APM_EMULATION + select ARCH_HAS_KCOV # Above selects are sorted alphabetically; please add new ones # according to that. Thanks. help diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 45a6b9b7af2a..5219700e9161 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/mm/Makefile b/arch/arm/mm/Makefile index 9dbb84923e12..e8be5d904ac7 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -8,6 +8,10 @@ obj-y += dma-mapping$(MMUEXT).o obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \ mmap.o pgd.o mmu.o pageattr.o +# Instrumenting fault.c causes infinite recursion between: +# __dabt_svc -> do_DataAbort -> __sanitizer_cov_trace_pc -> __dabt_svc +KCOV_INSTRUMENT_fault.o := n + ifneq ($(CONFIG_MMU),y) obj-y += nommu.o obj-$(CONFIG_ARM_MPU) += pmsa-v7.o 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