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: 10394393 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 306BC601A0 for ; Fri, 11 May 2018 14:32:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2621928560 for ; Fri, 11 May 2018 14:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A7AC28BDB; Fri, 11 May 2018 14:32:58 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3336D28560 for ; Fri, 11 May 2018 14:32:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3F396B0668; Fri, 11 May 2018 10:32:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DEF616B066A; Fri, 11 May 2018 10:32:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDEF36B066B; Fri, 11 May 2018 10:32:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 6E03A6B0668 for ; Fri, 11 May 2018 10:32:55 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id b192-v6so1248864wmb.1 for ; Fri, 11 May 2018 07:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=N2tORmXRwdoSCnTnlBHY943YXkNAMtJbddI/9/4MYs0=; b=Jrn6HtYEeP6jgmmC5F8EJc9CLVh0WnTn6tcp7pD47qXn/o8zmW4F+SIy0QGHquXo5U SFlU5ugy/x92m4W0ltCF/lnd2uYc1GuIDNDcV0986H8MR9KKRY7FcHYd5cpJWFG+ekUq gpGq1hxX0kp+xveagvCXRWjbCxiOp3T3WM4YGCwZbJWj4p4jsCQSCn/jUviJV+TftBqE yCOMurIwJvM2inIYAKLXJsfNBBHgoqvew6a/J/ge+BZy0g0+qoseSaZgl48ZoFPQcy9j Xm9gaNyy/YEfxpCuB1otMo30kQ/GB+FGIeppIAe9JROsvP8KI/YtEJ9xuhedd5AfoiJz ASoQ== X-Gm-Message-State: ALKqPwez8JAI9/F2aVjuPHyXCrabP58ZmbptGgml9rB7negaKNSt69wJ LctfnbsOcstaYCKWyy6BtjuVvTVpFM/Vy/vcTko1L/U/uqClWyccmp0aHr9pSeVaSmu1LWkecqm /K8ZNMNGeggameqAycgplMrCa9wRBV0JR5/vBQ3ts8Tpdq8MPRGWjVH+nIpcQQ6P4hOm1m6XB7P 0oZ4jDsuizFAm02qCVlgHzD7QDCiep/fyEzuRw8VJiko4y0rJvQC2RHRPeMU40lWZgiUGjetoTw bHXukcnKJ3CiPscaoOUzFtewqcJVljqu5SCYJ9uY9y5xQ2k/UmRvxpydMYpeUeuAJNSPkGugnWA 5pWyTSQfJP+H9Hyi9NXaBn/G5C1gPLp2JefHIrsiIofVYIzEQsszm9GciJ74ny/MW+g8oVtV2u+ m X-Received: by 2002:a1c:b20d:: with SMTP id b13-v6mr2171331wmf.130.1526049174780; Fri, 11 May 2018 07:32:54 -0700 (PDT) X-Received: by 2002:a1c:b20d:: with SMTP id b13-v6mr2171288wmf.130.1526049173766; Fri, 11 May 2018 07:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526049173; cv=none; d=google.com; s=arc-20160816; b=NVJO8/L6/4vbOGrnMpDK3Pi09Iw76kLKX3g9HSqPZMN159s0F/Zz1hYHFylai1sTUu xbVFVoeHEmeSesJQWcQ/fUshbZnK91oZoIioYPK19b7ggshse80uQtR8QPvYLJPeI+Zp Me6X8AIFk86O0P5q7KsvmjPkQe6sI8I8tKpv7Ajr174br1jDVlOvCNdJkqIhuPruB51O /q6f9fWqSUmvjO15G7vae9HUAojcY2qase8/uDSURTsVVRrPNJx+yI7hx3K5BnyUTQ7I gVxYIxZ0p3PHFBW19MEFIJzgfDm4SycGsA4D83u7o7rYbGwi76V8VnC0zqJ9mAh/OByS +mHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=N2tORmXRwdoSCnTnlBHY943YXkNAMtJbddI/9/4MYs0=; b=GXwvj5uW5R8Zk+Vu42WCZc0wfacypXhk1i6XcAQ4bOwyfnlOBZqk75uNRbZFQNO4fU phPxgRy41Q3KGrifJqWYdNxySJwnGxLWZT4OxHB0AeFZ90MVgLs1zgRpJcE+HnAQLisK s3GRe30QlbY47dNHw0A4LDoj97DdhQaqcoEqQ9ssacNOOrg/oULHKePXNWE7gGiY22uD F9eB4ooUd9P0quknTPGCCXRrh8kURNx1nzB0hPYVjSFhl7nQqinPFxu/kKdFc+0Grtyi 4q3O95UqWHsFqdkZRwdndgWFi96VsVldvuwUfByZOP1gyOPtAIwO0QuwwytFQoT3We7Z s1bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A7SmgbJ0; spf=pass (google.com: domain of dvyukov@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=dvyukov@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a139-v6sor351835wma.71.2018.05.11.07.32.53 for (Google Transport Security); Fri, 11 May 2018 07:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of dvyukov@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A7SmgbJ0; spf=pass (google.com: domain of dvyukov@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=dvyukov@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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-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 Cc: Dmitry Vyukov , Koguchi Takuo , linux-arm-kernel@lists.infradead.org, syzkaller@googlegroups.com 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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