From patchwork Wed Nov 14 13:39:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10682651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 148D9139B for ; Wed, 14 Nov 2018 13:39:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0629D2B4AB for ; Wed, 14 Nov 2018 13:39:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE5952B4E0; Wed, 14 Nov 2018 13:39:48 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 5F63D2B4AB for ; Wed, 14 Nov 2018 13:39:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7112B6B000C; Wed, 14 Nov 2018 08:39:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6C1136B000D; Wed, 14 Nov 2018 08:39:45 -0500 (EST) 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 564686B000E; Wed, 14 Nov 2018 08:39:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id 2E7826B000C for ; Wed, 14 Nov 2018 08:39:45 -0500 (EST) Received: by mail-ot1-f72.google.com with SMTP id c33so11005108otb.18 for ; Wed, 14 Nov 2018 05:39:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=pLjC0Gkoap3oEyvo0Prs1yFuJj+eQQIyQgvh8CQZhbI=; b=aXCN65omvV5aotLpyIsomitWJ6atFG1yqusY6AVBugpgHz+rpI61Bj4/Axq9biInca 2Wf79A7V5e8UuAWollpS19DKSAO7nPXVFHjZ8duOcT6uZlRCsOjtYu7bwXtFl9iMYa07 ocsQzlfhFPSFh1PXuT4ejxhXx6tnttYcA6DnGnbmIvE/GiyR95JjlOydUqFsxUqu63qt Z1YTQelllE3bb8bWCi1zzi2bZOQmvy8N0rPJgx0z/TA0jMNwv67zpCnrhiAyNao+MNDv RuvY8FVC+F/RUIu5VIG27KX+lt7GCuBv3C4+pEVjLGlteX8qmU6skBgSH0YGyzN9alWR sBVg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com X-Gm-Message-State: AGRZ1gIOa2dVs0x2O9TkCBM3KXJlN9kEDtDhKWUm8JPVsCJizwoPMw27 tWHiJzopCTMWE9Y39Jvjh33LMy/RpFv7grgsvhmTFLy89t8FqfzcsN1qN2B92/o3mZXACaS+8Vq kp5Eh7BV2xMyLyTRAnMIa3iQmn+kuADqpszJA/BmJfAnRrQcJdKrP8HZvuOWPz/i2TQ== X-Received: by 2002:a9d:6490:: with SMTP id g16mr1022304otl.141.1542202784922; Wed, 14 Nov 2018 05:39:44 -0800 (PST) X-Google-Smtp-Source: AJdET5eQZPUQu9atWiFGcImuqgSNg7rv90wQFh5gf3J4ArFdXzu+ys0qoLRxZGI8Mf5wFn9jcBKW X-Received: by 2002:a9d:6490:: with SMTP id g16mr1022269otl.141.1542202783928; Wed, 14 Nov 2018 05:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542202783; cv=none; d=google.com; s=arc-20160816; b=QvE5unlDLTCkwYGLZbVVe1rMcKQO9sBJURv88ojtkTM2zxhJCSolWVq7zGqekdxbXf u8sEyoJxtPDT2GgP6jE58ecQHx17QzsJ4AkQln4mOuN6s8DLQU2zQuupfGgupXREX/fF lKqpzocsCUIL3Vy+MAyFSfOAzRIRSE/Trg450HlFJK/nNJSyXroYGjpagaSCrc5LthOD B8lE8jFCeO8mUUxvHfhHZ3waC5gSzQXKYvZwD5nAcz7rBz25WhST2+lNgCPMEbBSPupC IBoNgyFKxeniZUKHQruHf2PeFLdyRMAt7nyopoywLY0KaQazFynz47t5q9pMRzFleBsc IN5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=pLjC0Gkoap3oEyvo0Prs1yFuJj+eQQIyQgvh8CQZhbI=; b=pUTkQcIeJn5L6x7LN7RXZYawOmPnaJTMCDPre+g2CS8Nfdk0BK7p3yVEj2YIo4KsMq jGBW2NrBj6RNvVghnih68L8NGLxmXaP/uPciPheJ5dtS9V3RscXoUZYohI6lkXhCCOsx ZZY4j9UdX3hrwwW0v6fLhmGGFY1/Tr1QsZC00Gdzm7vPb8AtCTypYgMZleDjER2lepsU lnEs8Lhl80LYVCXI25d48X1xoM4Cru9I4S+rUo/wch+VWLEAtuXZbGXEXnWUxcBzFco8 r5fJBNZ9GZW1eK5hBCRRc66Vqx8JFEuQvD00PSEqZRqEa7eZGAf+zkWJdAwEUdslRSkR Vx6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id j6-v6si9309198oiw.131.2018.11.14.05.39.43 for ; Wed, 14 Nov 2018 05:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2635E15AB; Wed, 14 Nov 2018 05:39:43 -0800 (PST) Received: from capper-debian.arm.com (unknown [10.37.12.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C4DE53F718; Wed, 14 Nov 2018 05:39:41 -0800 (PST) From: Steve Capper To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, jcm@redhat.com, Steve Capper Subject: [PATCH V3 2/5] arm64: mm: Introduce DEFAULT_MAP_WINDOW Date: Wed, 14 Nov 2018 13:39:17 +0000 Message-Id: <20181114133920.7134-3-steve.capper@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181114133920.7134-1-steve.capper@arm.com> References: <20181114133920.7134-1-steve.capper@arm.com> 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 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 --- Changed in V3: corrections to allow COMPAT 32-bit EL0 mode to work --- arch/arm64/include/asm/elf.h | 2 +- arch/arm64/include/asm/processor.h | 10 ++++++++-- arch/arm64/mm/init.c | 2 +- drivers/firmware/efi/arm-runtime.c | 2 +- drivers/firmware/efi/libstub/arm-stub.c | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 433b9554c6a1..bc9bd9e77d9d 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -117,7 +117,7 @@ * 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__ diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 3e2091708b8e..da41a2655b69 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -25,6 +25,9 @@ #define USER_DS (TASK_SIZE_64 - 1) #ifndef __ASSEMBLY__ + +#define DEFAULT_MAP_WINDOW_64 (UL(1) << VA_BITS) + #ifdef __KERNEL__ #include @@ -51,13 +54,16 @@ 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) ? \ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d9582cac6c4..e5a1dc0beef9 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -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 diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 922cfb813109..952cec5b611a 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -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, }; diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index 30ac0c975f8a..d1ec7136e3e1 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -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