arm64: setup: introduce kaslr_offset()
authorAlexander Popov <[email protected]>
Tue, 20 Dec 2016 00:23:06 +0000 (16:23 -0800)
committerLinus Torvalds <[email protected]>
Tue, 20 Dec 2016 17:48:46 +0000 (09:48 -0800)
Introduce kaslr_offset() similar to x86_64 to fix kcov.

[ Updated by Will Deacon ]

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexander Popov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Kefeng Wang <[email protected]>
Cc: AKASHI Takahiro <[email protected]>
Cc: Jon Masters <[email protected]>
Cc: David Daney <[email protected]>
Cc: Ganapatrao Kulkarni <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Nicolai Stange <[email protected]>
Cc: James Morse <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Alexander Popov <[email protected]>
Cc: syzkaller <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/arm64/include/asm/memory.h
arch/arm64/kernel/setup.c

index b71086d251954f7b72837899346525322dc5d724..bfe632808d7724c0a51562efb60501e67f6bf157 100644 (file)
@@ -165,6 +165,11 @@ extern u64                 kimage_vaddr;
 /* the offset between the kernel virtual and physical mappings */
 extern u64                     kimage_voffset;
 
+static inline unsigned long kaslr_offset(void)
+{
+       return kimage_vaddr - KIMAGE_VADDR;
+}
+
 /*
  * Allow all memory at the discovery stage. We will clip it later.
  */
index a53f52ac81c62ad4e6e70056949d143f7de4bfd4..b051367e21491cada86f115f4386fda8aace299a 100644 (file)
@@ -338,11 +338,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");
        }