From patchwork Thu Dec 6 22:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10717149 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 831161759 for ; Thu, 6 Dec 2018 22:51:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 748872F032 for ; Thu, 6 Dec 2018 22:51:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72B932F07F; Thu, 6 Dec 2018 22:51:06 +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 C9CFE2EFB0 for ; Thu, 6 Dec 2018 22:51:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0D816B7CB4; Thu, 6 Dec 2018 17:51:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ABC506B7CB5; Thu, 6 Dec 2018 17:51:04 -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 95E036B7CCC; Thu, 6 Dec 2018 17:51:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 609AA6B7CB4 for ; Thu, 6 Dec 2018 17:51:04 -0500 (EST) Received: by mail-oi1-f200.google.com with SMTP id d62so978864oia.3 for ; Thu, 06 Dec 2018 14:51: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=j0uIUPrH8bh4tZWdit09WnS/Ns5vp9iNfqUbInmL2og=; b=NcpGZ4zLc5IQMmj/wutZSibfp20uRW+AXmEBsFgqSQdnSltKTFztKZjmr/Jv+pgDlR Lck0+WPtwMg7wHbDCVyoPjL8Kh5CZ6LXOn8zpB+K+WAgjyUgCKCr2Ez6CZr7BEXAc38X FpwBlyLtwuKVYvRryEW0BTTU7+qfRkeEOLSxhfKaAXLy6I9C7bwj6fP9YI1VT/Jsvzhc bSSt7kzpFq6IMRnrVjQY/CtXz4Ok3ZOxbKIazz3xkaK20JO12/VLSiqzqehp7sTI0P49 bcnY4Xmy26R2iWvoS9nlY/np4wHgRl3/PjiL512esCWfu56d9c4G2Vot2ci7M9TFE0Ea p5KQ== 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+aEWYm74QhphoBEnhcBBWG/WpnGaL52v3JFGJY6OHOZl4+sOcEPnMp YfPZNOVt/55+w3+/0jxahvAvjWgdvuUlsoflVvMweuGTOCvNddpejzioG6KrEwJc7kDJ0xkzXg5 cJZnYxW9v76kMPg6GfEzHC89fZZBAtWJbHr4znbTaBuc7r45/r8xcFvaVxbP6qnbf0w== X-Received: by 2002:a9d:4546:: with SMTP id p6mr19539486oti.24.1544136664161; Thu, 06 Dec 2018 14:51:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/VgqRsT85p1pdrX3SVyCZi02iDPrRFGkR4+ViaDGdbOo9gpXMLZ/A+RW44fpjhZPz/wUfXc X-Received: by 2002:a9d:4546:: with SMTP id p6mr19539462oti.24.1544136663277; Thu, 06 Dec 2018 14:51:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544136663; cv=none; d=google.com; s=arc-20160816; b=uM9bBonnVrmwrMWGtXtXJcBRrAL9ftep+N01xi2A79pCwzrNH5uy90nOvjF3jP/B/6 IzsVkTQMSx+xMcHyxd8e3kIePDWsqNwgTfbxVZ15W/kS18T/hj7CN7vuM/b14ngXBpNw uBPF4BTgFr2YKheJnfb2tKWL4Yu/pTtycubFpcxXUo9HEikJ/Y1Eaa3sB1gpcyK180gL Y/QOWmCpSjrn66zRn0bu6+5ZPgVG04w6x+Kh5b11nXuzzHqh4carPrS2cokQkplVGV3q Yxpy19/DzCyDrAqFFRKgpFmWh3wA2160yEg6LIGhEvgyOU4yCPWnjmBwOr9jaBj6JvvK 8cPQ== 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=j0uIUPrH8bh4tZWdit09WnS/Ns5vp9iNfqUbInmL2og=; b=PdmjL8RLK82P0uFweYf+fSkfxDENQoOtGEd/SbVW6bJUbAV88bZGNwpIarhzwi0GTv PcwRFh8PybglkedR7P4MjdQCFTvIXkBa32lqV69e+jiqn0E4cfX1i6J9pl0O7gn7ydXo ajF5lC8Iiu5KcTmQsBoC5ip5WTTkt0BFbc1kH2/+7x1zh8W8lXYIdy8zdczCTcpnEEtk qAv2XCyMVng9QILAnKtiFMxWBA9YBXUnDrg1tTBgvHu+Q+7ywcS2vle6ShAhPZkRKpaA C+PZ2vQRHqoyELcunSZy8dKNpJbbYQNPzV5n7K6jxn5NQ87qrpwfgCJKKmUVTOYMsDJz T85w== 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 a144si619666oib.179.2018.12.06.14.51.03 for ; Thu, 06 Dec 2018 14:51: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 9989A15AD; Thu, 6 Dec 2018 14:51:02 -0800 (PST) Received: from capper-debian.arm.com (unknown [10.37.12.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE43B3F5AF; Thu, 6 Dec 2018 14:51: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, suzuki.poulose@arm.com, jcm@redhat.com, Steve Capper Subject: [PATCH V5 2/7] arm64: mm: Introduce DEFAULT_MAP_WINDOW Date: Thu, 6 Dec 2018 22:50:37 +0000 Message-Id: <20181206225042.11548-3-steve.capper@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206225042.11548-1-steve.capper@arm.com> References: <20181206225042.11548-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