From patchwork Wed Oct 17 16:34:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10645901 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 EC46F157A for ; Wed, 17 Oct 2018 16:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA5691FF82 for ; Wed, 17 Oct 2018 16:35:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE6BF2851E; Wed, 17 Oct 2018 16:35:30 +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 2C4A41FF82 for ; Wed, 17 Oct 2018 16:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72CBF6B026B; Wed, 17 Oct 2018 12:35:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6DC236B026C; Wed, 17 Oct 2018 12:35:28 -0400 (EDT) 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 5CAA16B026D; Wed, 17 Oct 2018 12:35:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by kanga.kvack.org (Postfix) with ESMTP id 2EEFE6B026B for ; Wed, 17 Oct 2018 12:35:28 -0400 (EDT) Received: by mail-ot1-f70.google.com with SMTP id s2so20060560ote.13 for ; Wed, 17 Oct 2018 09:35:28 -0700 (PDT) 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=7S8chC9yT3/FjpFMfT4/JB6spqdASyIZ+/YqjjnY9kU=; b=BoxQuqnr8NYQzPnEzOanK+bsE5ZDydVsro0TNCCjfNOmX+6KfpdEwoNZICnrVcbMiO z1ZLYvz2LWNFWXEjxA0n/yUXrUcwmPG4agKA+xCGqa74iysmjveWvvu+5W+q343pnNdD +o5spEE4An9j5Cg9kBFPiPJ5Gu0xL7zGe4GSaNgQFqetiaOdwGHkV7+yFgi/So6T+m88 NPdgcfHz02cAMd0N0jnrTtcoRaWL+0Guh+oIMePXE6//+gl8ZIuQyBWaoFJWvkmxV946 f5TvUolLcvqfCCP79XbfpPvNG/+dveSISVlzq20GmG/IuzuJXIS4yo+sgpghMOh7JJN7 5e5A== 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: ABuFfogUTlyUKc2NOuo/6THN1cQS5+TSvTFFB8nms6UTtZe7jglzZd9z W8+m6YPNwU/vI+i9aLk3UHSOckpWOOkpa2PKyzVkcPlx7DP9XYOJvyS3cQHqImwyDAds8nRHh5K HV8Th0gTFau9b/1T8SHI9bH8D3iw++BtsDSUPOvbAfyYUiIv6HFRLBM8Zsbv/C5nToA== X-Received: by 2002:a9d:f07:: with SMTP id 7mr17881058ott.170.1539794127916; Wed, 17 Oct 2018 09:35:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV621vdeLJ/5k0uR4ebFU6L0InePGrPivCXqc2GIGhtb0o2c4ENDAm09OXD5jQkSu/GhC1jKL X-Received: by 2002:a9d:f07:: with SMTP id 7mr17881027ott.170.1539794127022; Wed, 17 Oct 2018 09:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539794126; cv=none; d=google.com; s=arc-20160816; b=G5al2mSKD4NBSRerupa+ee03uwh+9jGWxtkidwmOB/pEFVKaBGlssP2Ewrhg/Sd3Oo KYrnm0Sd9PhhfAM9IYLLe4BfVbyoeRUtR1lW8+ZF0j5raaaFC5MN7vCpWKN9gDyX3/TL cHGJiTjax0Gtm1Z0cKt23uyvKC+56Wxxmpc0ic+m99bKuBJuwEOyaXfoaDGGu8Yibn98 6gU6KucZXVMeqypkWLvNIYTZ1meCg/I9B0HHLcWuNo2hzX43c0I72Fnjdnmklt3pYJNj 2rXaKYrHlZAUcqTl8S8bp771zB1OFlUYRbjZNmHZRAkvpc5Ge/RU7JQnygFNWbKzpUK8 /aqQ== 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=7S8chC9yT3/FjpFMfT4/JB6spqdASyIZ+/YqjjnY9kU=; b=L0Dnf7XmZYihxTM2LwpdkNhRTPErs5EOpzbfcEYNIBgHOTb0ct078RJpcT+fk9BkXU pCS/UsrBbK1kHgxFevAz7xNWvjI6XrMVHmBz6BWP3AtkaiVcxE6/7pggYi0Z8ja5Ntau 7llCAx4+keTpPYckZcj+HmGSS9dCn2hVGVe5RJw2T2kjJuJJFyILBmvD06mv6CW22tm/ kovYd48o5n8yCP5bbxat5GMPDbDXunn45ZIGwi/W44jClxK0JWCC0Qn27yclXmZo7DOv Pt4WWR9Mk6yHKd+sX0a3JMTNMW+3DLS8j+XBUACjlqRpslTA5jxpa5yd6TCAjx44Ikrr oTDg== 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 (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id w67-v6si8471795oig.136.2018.10.17.09.35.26 for ; Wed, 17 Oct 2018 09:35:26 -0700 (PDT) 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 3EEB11650; Wed, 17 Oct 2018 09:35:26 -0700 (PDT) Received: from capper-debian.emea.arm.com (unknown [10.32.102.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C6E283F71A; Wed, 17 Oct 2018 09:35:24 -0700 (PDT) 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 V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW Date: Wed, 17 Oct 2018 17:34:57 +0100 Message-Id: <20181017163459.20175-3-steve.capper@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181017163459.20175-1-steve.capper@arm.com> References: <20181017163459.20175-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 --- arch/arm64/include/asm/elf.h | 2 +- arch/arm64/include/asm/processor.h | 9 +++++++-- drivers/firmware/efi/arm-runtime.c | 2 +- drivers/firmware/efi/libstub/arm-stub.c | 2 +- 4 files changed, 10 insertions(+), 5 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 79657ad91397..46c9d9ff028c 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -26,6 +26,8 @@ #ifndef __ASSEMBLY__ +#define DEFAULT_MAP_WINDOW_64 (UL(1) << VA_BITS) + /* * Default implementation of macro that returns current * instruction pointer ("program counter"). @@ -58,13 +60,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_tsk_thread_flag(tsk, 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/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 6920033de6d4..ac297c20ab1e 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