From patchwork Wed Dec 5 16:41:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10714595 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 5FA2E13BB for ; Wed, 5 Dec 2018 16:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EFFB2DE00 for ; Wed, 5 Dec 2018 16:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D57C2DD16; Wed, 5 Dec 2018 16:42:07 +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 29CC42DD16 for ; Wed, 5 Dec 2018 16:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ED1F6B7548; Wed, 5 Dec 2018 11:42:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 29AA26B754C; Wed, 5 Dec 2018 11:42:05 -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 18B286B754D; Wed, 5 Dec 2018 11:42:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by kanga.kvack.org (Postfix) with ESMTP id E24416B7548 for ; Wed, 5 Dec 2018 11:42:04 -0500 (EST) Received: by mail-oi1-f199.google.com with SMTP id t184so12456484oih.22 for ; Wed, 05 Dec 2018 08:42:04 -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:mime-version :content-transfer-encoding; bh=daHBFJzzY00gC37Wi5yuwHKdc1YnCz4b0ak17N5SJgs=; b=aqElE17/Acg43+46FpkPLYkaWTC7O9xRctjgm0XuoUy7oQXKS09QR6bvFSlV9X3VXu 43K3BS8GXgfdovl3HjDr6yHhw9KmuB9M1jcmxn0DovbHoORh/b5lz3fKx8VZo+CKknJe 90Cy5C+iZNrWOQoB+rK6Bhvme2rWOHd598KGU+DHADKG2PwUZCcxZz5btpAiqR7GUHoo JWyCQC8mnw9jBwTDV1IjSNR38lLZI3Z29zXERCi0PPnCDXnTEQspNOLDywhU/lg9jTIC uD+ldAmbDykOVQYH2m49UfdePbSJU3K2OLyk+VIS/3LIcgp2U4EzwmYQof483hFKP+Bs BjKg== 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: AA+aEWZGToblh3eEgv7oHbnfz15LBv2XfCBpcvG2bfzvusEBChYYfHf7 Nek1/q34kkHeZ22PwoJYMbqsKcLvPF6kDBe5TS2lILKzWxzesfhLurmxE4/6PtL6GvBqQ0nVeuu sDkmRGSP2Mr/ihOt4otHkeDqXMamH5pezl6d3aJZkrl7Wz1YlmhoyE45L8knyxH4+jg== X-Received: by 2002:a9d:22ea:: with SMTP id y97mr14470090ota.311.1544028124603; Wed, 05 Dec 2018 08:42:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXiihPu9wISyLEOfF3AKlr0458snneRIZHP8FBjaN/4ZcpruTBLxVku+9ggfN9Ft6r+uDf X-Received: by 2002:a9d:22ea:: with SMTP id y97mr14470032ota.311.1544028123085; Wed, 05 Dec 2018 08:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544028123; cv=none; d=google.com; s=arc-20160816; b=C1HeIO7n3qxsjRhlYIsB1cpE1dQdbRusI2zKwvebylRlHXSz1aTpsV3OuwzcQ3xyr6 wtGwhjARA1b9HHFU2kU9dmfYUlU8N4y1ifZNF+lIS1EF/l0PDiIufyCycU1ALhVGqu+4 OUS9wxi5uhX1YQxMk/w5q3m4gYf1aeu9Kny2jxtOc5/hnhZHkRKNWm2SNOEFHnVq+63e HJ02Rng/fHzOWmcGPDFiKZd5XXWwC9rdluO3aOaAJ6EVtErn02UdX5XNW7M0CyPrhWfP OCpWdnDlP42sLlh/ST2CeyARJbUKAJ3Zh6s+qHqhsHgDd/5Ekxs7Svc6REjGALAstPwA GIEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=daHBFJzzY00gC37Wi5yuwHKdc1YnCz4b0ak17N5SJgs=; b=Ns22H4NSw9v4C7c4Xi4b8pZFVAGXhoZhVYQGHrvYUf6L76r98IhT6JhgRruSe73AwH xzWrw7PQ3g/sospsgVI3WNuKSZNy2pw5/Mytp9kI9s62U2tZ17ehEgyGcm+bBwwFPuOw K8ssRIzPX072A9kVUQ0xUBpyzzWfsEtTe8Nc2ciwwUyw6uJa2LOH8XAZCC83KPsehy4l EcjY025Elbvh1DJcddK6r+AKopjq9+0MUjkTD2aZ8R+lXhToASCVgCmgMQXGvKAtl84i 7WSrjpBI4KoPQhHyBbzBf2DikiekXxzW+x0jXCTtxLDXRs6hKZ+4B+7OndKj+1cJcsiG J2MA== 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 d64si9016062oia.186.2018.12.05.08.42.02 for ; Wed, 05 Dec 2018 08:42:03 -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 607CA1650; Wed, 5 Dec 2018 08:42:02 -0800 (PST) Received: from capper-debian.emea.arm.com (C02R32KKFVH8.manchester.arm.com [10.32.102.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A8A13F5AF; Wed, 5 Dec 2018 08:42:00 -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 V4 2/6] arm64: mm: Introduce DEFAULT_MAP_WINDOW Date: Wed, 5 Dec 2018 16:41:41 +0000 Message-Id: <20181205164145.24568-3-steve.capper@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205164145.24568-1-steve.capper@arm.com> References: <20181205164145.24568-1-steve.capper@arm.com> MIME-Version: 1.0 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 Reviewed-by: Catalin Marinas --- 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..50586ca6bacb 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -45,19 +45,25 @@ * 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) ? \ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d9582cac6c4..7239c103be06 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