arm64: mm: Introduce DEFAULT_MAP_WINDOW
authorSteve Capper <steve.capper@arm.com>
Thu, 6 Dec 2018 22:50:37 +0000 (22:50 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 10 Dec 2018 18:42:17 +0000 (18:42 +0000)
We wish to introduce a 52-bit virtual address space for userspace but
maintain compatibility with software that assumes the maximum VA space
size is 48 bit.

In order to achieve this, on 52-bit VA systems, we make mmap behave as
if it were running on a 48-bit VA system (unless userspace explicitly
requests a VA where addr[51:48] != 0).

On a system running a 52-bit userspace we need TASK_SIZE to represent
the 52-bit limit as it is used in various places to distinguish between
kernelspace and userspace addresses.

Thus we need a new limit for mmap, stack, ELF loader and EFI (which uses
TTBR0) to represent the non-extended VA space.

This patch introduces DEFAULT_MAP_WINDOW and DEFAULT_MAP_WINDOW_64 and
switches the appropriate logic to use that instead of TASK_SIZE.

Signed-off-by: Steve Capper <steve.capper@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/elf.h
arch/arm64/include/asm/processor.h
arch/arm64/mm/init.c
drivers/firmware/efi/arm-runtime.c
drivers/firmware/efi/libstub/arm-stub.c

index 433b9554c6a19c1e72b2be8f827861c14f5856fb..bc9bd9e77d9dc09da0d8bdfb3c5657a3ab84890b 100644 (file)
  * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE                (2 * TASK_SIZE_64 / 3)
+#define ELF_ET_DYN_BASE                (2 * DEFAULT_MAP_WINDOW_64 / 3)
 
 #ifndef __ASSEMBLY__
 
index 6b0d4dff50125e49522212cb7e6db1a778da539d..102bab4344b7fc41677c14cd27ff16ad3cbe6dfb 100644 (file)
  * TASK_SIZE - the maximum size of a user space task.
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
  */
+
+#define DEFAULT_MAP_WINDOW_64  (UL(1) << VA_BITS)
+
 #ifdef CONFIG_COMPAT
 #define TASK_SIZE_32           UL(0x100000000)
 #define TASK_SIZE              (test_thread_flag(TIF_32BIT) ? \
                                TASK_SIZE_32 : TASK_SIZE_64)
 #define TASK_SIZE_OF(tsk)      (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                TASK_SIZE_32 : TASK_SIZE_64)
+#define DEFAULT_MAP_WINDOW     (test_thread_flag(TIF_32BIT) ? \
+                               TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
 #else
 #define TASK_SIZE              TASK_SIZE_64
+#define DEFAULT_MAP_WINDOW     DEFAULT_MAP_WINDOW_64
 #endif /* CONFIG_COMPAT */
 
-#define TASK_UNMAPPED_BASE     (PAGE_ALIGN(TASK_SIZE / 4))
+#define TASK_UNMAPPED_BASE     (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
+#define STACK_TOP_MAX          DEFAULT_MAP_WINDOW_64
 
-#define STACK_TOP_MAX          TASK_SIZE_64
 #ifdef CONFIG_COMPAT
 #define AARCH32_VECTORS_BASE   0xffff0000
 #define STACK_TOP              (test_thread_flag(TIF_32BIT) ? \
index 2983e0fc1786c6d6ba42c38c38299736d97ebd13..6cde00554e9bbfa6151544bdc29196f560de81f2 100644 (file)
@@ -609,7 +609,7 @@ void __init mem_init(void)
         * detected at build time already.
         */
 #ifdef CONFIG_COMPAT
-       BUILD_BUG_ON(TASK_SIZE_32                       > TASK_SIZE_64);
+       BUILD_BUG_ON(TASK_SIZE_32 > DEFAULT_MAP_WINDOW_64);
 #endif
 
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
index a00934d263c519a9d476a57a5bb2388c6041b810..23ea1ed409d1bbc6f77ce4374a0e6bdc8aae3d5b 100644 (file)
@@ -38,7 +38,7 @@ static struct ptdump_info efi_ptdump_info = {
        .mm             = &efi_mm,
        .markers        = (struct addr_marker[]){
                { 0,            "UEFI runtime start" },
-               { TASK_SIZE_64, "UEFI runtime end" }
+               { DEFAULT_MAP_WINDOW_64, "UEFI runtime end" }
        },
        .base_addr      = 0,
 };
index 3d36142cf81208d408cab75e28edf957fa865c9e..6640942a1c0d0a1e00471c92cd12a8c989a74191 100644 (file)
@@ -33,7 +33,7 @@
 #define EFI_RT_VIRTUAL_SIZE    SZ_512M
 
 #ifdef CONFIG_ARM64
-# define EFI_RT_VIRTUAL_LIMIT  TASK_SIZE_64
+# define EFI_RT_VIRTUAL_LIMIT  DEFAULT_MAP_WINDOW_64
 #else
 # define EFI_RT_VIRTUAL_LIMIT  TASK_SIZE
 #endif