Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079AbcLKAvY (ORCPT ); Sat, 10 Dec 2016 19:51:24 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:32929 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbcLKAvS (ORCPT ); Sat, 10 Dec 2016 19:51:18 -0500 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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2262 Lines: 72 Introduce kaslr_offset() similarly to x86_64 for fixing kcov. Signed-off-by: Alexander Popov --- 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"); } -- 2.7.4