From patchwork Sun Dec 11 00:50:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 9469555 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 EE3BA60231 for ; Sun, 11 Dec 2016 00:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC872281D2 for ; Sun, 11 Dec 2016 00:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0F8328420; Sun, 11 Dec 2016 00:54:11 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85C9F281D2 for ; Sun, 11 Dec 2016 00:54:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cFsNI-0006nF-CB; Sun, 11 Dec 2016 00:52:20 +0000 Received: from mail-lf0-f67.google.com ([209.85.215.67]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cFsMd-0006ez-A7 for linux-arm-kernel@lists.infradead.org; Sun, 11 Dec 2016 00:51:41 +0000 Received: by mail-lf0-f67.google.com with SMTP id x143so3135309lfd.1 for ; Sat, 10 Dec 2016 16:51:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EFV07aV+uh8eouC9h6Zhmx/knuqwzdai3yazuPEGmI0=; b=DqwHkLH+JRmhkCUfheaRDmIZyq7Y/VoGhsFr7Gm+0M18t3qfUcATiPPTNQrPFORbPU U2rsyvlh6UvcGO4kLmMugehk6fJ/JpdcMilFhlD/Ok47UcOAM/PPXTQs5rUCujkuk55D gFFX1g/E3n9By90kssRHXfgMngMUc25AC7I1aX5JVc2ZzNzUEjoutGv5I/v8BzUsiNYR uGShn+8GVFri0g0OG7YCiE05jSJq2EK+sg1Cjv6+1msJV9UV6FFQgcqi/dYqSd7CqHHE m8i3dVMKfJX38EZrPbHrO3QdWoJck3T+0Pmj9WDAf255DX7/di8226IilAzvxhg/NHFU FXUQ== X-Gm-Message-State: AKaTC005l/Uj5ggEn91FUBb+3sONnf/ULUoPkk7GXUvEtWn5GkA7+6k6dU0ZHp+Y5P2Osw== X-Received: by 10.46.74.10 with SMTP id x10mr31060438lja.8.1481417476860; Sat, 10 Dec 2016 16:51:16 -0800 (PST) Received: from localhost.localdomain (95-26-155-251.broadband.corbina.ru. [95.26.155.251]) by smtp.gmail.com with ESMTPSA id 17sm7739080ljh.39.2016.12.10.16.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Dec 2016 16:51:16 -0800 (PST) From: Alexander Popov To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Rob Herring , Kefeng Wang , AKASHI Takahiro , Jon Masters , David Daney , Ganapatrao Kulkarni , Andrew Morton , Dmitry Vyukov , Nicolai Stange , James Morse , Andrey Ryabinin , Andrey Konovalov , Alexander Popov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, syzkaller Subject: [PATCH 1/2] arm64: setup: introduce kaslr_offset() Date: Sun, 11 Dec 2016 03:50:55 +0300 Message-Id: <1481417456-28826-2-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481417456-28826-1-git-send-email-alex.popov@linux.com> References: <1481417456-28826-1-git-send-email-alex.popov@linux.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161210_165139_652132_597D9A04 X-CRM114-Status: GOOD ( 15.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Introduce kaslr_offset() similarly to x86_64 for fixing kcov. Signed-off-by: Alexander Popov Acked-by: Will Deacon --- arch/arm64/include/asm/setup.h | 19 +++++++++++++++++++ arch/arm64/include/uapi/asm/setup.h | 4 ++-- arch/arm64/kernel/setup.c | 8 ++++---- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 arch/arm64/include/asm/setup.h diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h new file mode 100644 index 0000000..e7b59b9 --- /dev/null +++ b/arch/arm64/include/asm/setup.h @@ -0,0 +1,19 @@ +/* + * arch/arm64/include/asm/setup.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_SETUP_H +#define __ASM_SETUP_H + +#include + +static inline unsigned long kaslr_offset(void) +{ + return kimage_vaddr - KIMAGE_VADDR; +} + +#endif diff --git a/arch/arm64/include/uapi/asm/setup.h b/arch/arm64/include/uapi/asm/setup.h index 9cf2e46..26631c8 100644 --- a/arch/arm64/include/uapi/asm/setup.h +++ b/arch/arm64/include/uapi/asm/setup.h @@ -16,8 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef __ASM_SETUP_H -#define __ASM_SETUP_H +#ifndef _UAPI__ASM_SETUP_H +#define _UAPI__ASM_SETUP_H #include diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f534f49..11eefda5 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -329,11 +329,11 @@ subsys_initcall(topology_init); static int dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) { - u64 const kaslr_offset = kimage_vaddr - KIMAGE_VADDR; + const unsigned long offset = kaslr_offset(); - if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset > 0) { - pr_emerg("Kernel Offset: 0x%llx from 0x%lx\n", - kaslr_offset, KIMAGE_VADDR); + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && offset > 0) { + pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n", + offset, KIMAGE_VADDR); } else { pr_emerg("Kernel Offset: disabled\n"); }