From patchwork Wed Dec 5 16:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10714607 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 3C1C5109C for ; Wed, 5 Dec 2018 16:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D7C02DE33 for ; Wed, 5 Dec 2018 16:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B48C2DE54; Wed, 5 Dec 2018 16:42:20 +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 9D5E72DE3A for ; Wed, 5 Dec 2018 16:42:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 536BF6B7550; Wed, 5 Dec 2018 11:42:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4BF546B7551; Wed, 5 Dec 2018 11:42:13 -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 388296B7552; Wed, 5 Dec 2018 11:42:13 -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 0A8376B7550 for ; Wed, 5 Dec 2018 11:42:13 -0500 (EST) Received: by mail-oi1-f199.google.com with SMTP id b18so12674905oii.1 for ; Wed, 05 Dec 2018 08:42:13 -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=zpJc6dPrTAqjFfHeF4Wbhsj+l8SDpE6gZ8EjXQ6zbPE=; b=M3lMTfEAbEejZgr0ez4J6y0T2UYlFlvI45aIXyZ9U60Q78HptWUMPCoAix7VL2PqNR 8AhdearwTD0GC7BN5LwuZNr2Lv/QuMnSuEOYxDRJqBeHeWNPFf9Zpyv5OdoVXObazriY awqqTkrq08Sx8+1ZF2eXxN/WmWkmGZAoMZQXQmH190G1nbjTgGrbxDZ39YPrKaoe1h7h QEAiq1sL7Luip4LXBjD3i8aLjWet1HQh3wJq7DTk6MP/UgIY/e+HVWbRbQFZnwe+KY1A IF+BcNYn0zUQCnUaOpCM2cTWPNJNS2WraJfXihtB6wdT2awZ5nYbvdMaYy1oCd2lDsy3 PSUg== 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+aEWZxsipNCXk/x7LSYfLwtHLY34mSrFAkMLftLQES+LaSe7n/7cSt P3V/rNKeEhVWm0BGPzgfVPDNfqfk/2Z78sdCLKMS+jTcnlCIovcp4uwMS1MyjTBPKJBwu29R043 fDIDzccfPdnGEnLi8JEQv6wgDZjHYxT+3CwWbhoiKEXm3IyQBxqa9hk+rdl7Okqe2gQ== X-Received: by 2002:a9d:6c3:: with SMTP id 61mr16866616otx.314.1544028132779; Wed, 05 Dec 2018 08:42:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoDbNK9IZTgM3HMxTnrsBUW4mX0jSf8Z2pOWHJUmsHiWQElLClZdIgrhMkivjX3TE/P1b5 X-Received: by 2002:a9d:6c3:: with SMTP id 61mr16866575otx.314.1544028131999; Wed, 05 Dec 2018 08:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544028131; cv=none; d=google.com; s=arc-20160816; b=KHMLsbQWDE/Noof5ABMNNpdI6Tzo78MZ+CjEhtqWQo2DISpxg4z8dvMjS8U/JnGUvD K1nb8hPHpiIDp3xFj/okqjfH3fbgCiryi6OijBkgxroo7kdNghji4T1uKJ9G9tPy5UYd vxYgBx8YrCeg7uf9ep9sO0qGuvEQZwciK0aUfowIxgM4L5w4+WBNl+kTjS6eh9g60kwN 5wDT/5PPA/YJZWD/u+St1t2TKKBBoS8jlM7r+5sCeSstDrEkzxJhRolJiFw+1SVSGJZH 3RmawcyUJDGtG6A+YcaKNNnH8D61ayzumHe6+dCECoO2FG0tieub/57EanQTqDBGWzPv 75Hg== 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=zpJc6dPrTAqjFfHeF4Wbhsj+l8SDpE6gZ8EjXQ6zbPE=; b=frmSwnGyvY3DJ5hmPgXgxbCHmBfNzA39LzjZYKmPJYDS08LmlkKPKjSbQ6YWVo/Bbi LYYmMFouXLibFZcMobiVTtDwIzqas3AkOtGQFORGtY8h1U7oUbxEYwQYoeLeS/511cUz 81lW58zjTjUJ2Quq2Ugjsqx0veiESPepDXdTchHCFvk3GzmcUQd6ewyhkEqq9CVoHOSW CP+ifIs7dzq2Kt2nQhZA9a9xiKceKhn9k8wlhcwOV6kgVk/4jRsHvBaVigb9qUd6TRME KtvFY1NijFroDp3TOK3BBL8//Cski08METWLWuH4xiHFB/qs7nS7WhQMEV4E4TG9ZW27 1/2Q== 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 c189si8702063oia.80.2018.12.05.08.42.11 for ; Wed, 05 Dec 2018 08:42:11 -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 57A02A78; Wed, 5 Dec 2018 08:42:11 -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 13AE33F5AF; Wed, 5 Dec 2018 08:42:09 -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 6/6] arm64: mm: Allow forcing all userspace addresses to 52-bit Date: Wed, 5 Dec 2018 16:41:45 +0000 Message-Id: <20181205164145.24568-7-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 On arm64 52-bit VAs are provided to userspace when a hint is supplied to mmap. This helps maintain compatibility with software that expects at most 48-bit VAs to be returned. In order to help identify software that has 48-bit VA assumptions, this patch allows one to compile a kernel where 52-bit VAs are returned by default on HW that supports it. This feature is intended to be for development systems only. Signed-off-by: Steve Capper Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 13 +++++++++++++ arch/arm64/include/asm/elf.h | 4 ++++ arch/arm64/include/asm/processor.h | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index eab02d24f5d1..9f50dc8af110 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1165,6 +1165,19 @@ config ARM64_CNP at runtime, and does not affect PEs that do not implement this feature. +config ARM64_FORCE_52BIT + bool "Force 52-bit virtual addresses for userspace" + depends on ARM64_52BIT_VA && EXPERT + help + For systems with 52-bit userspace VAs enabled, the kernel will attempt + to maintain compatibility with older software by providing 48-bit VAs + unless a hint is supplied to mmap. + + This configuration option disables the 48-bit compatibility logic, and + forces all userspace addresses to be 52-bit on HW that supports it. One + should only enable this configuration option for stress testing userspace + memory management code. If unsure say N here. + endmenu config ARM64_SVE diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index bc9bd9e77d9d..6adc1a90e7e6 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -117,7 +117,11 @@ * 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. */ +#ifdef CONFIG_ARM64_FORCE_52BIT +#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) +#else #define ELF_ET_DYN_BASE (2 * DEFAULT_MAP_WINDOW_64 / 3) +#endif /* CONFIG_ARM64_FORCE_52BIT */ #ifndef __ASSEMBLY__ diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index b363fc705be4..9abd91570b5b 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -65,8 +65,13 @@ extern u64 vabits_user; #define DEFAULT_MAP_WINDOW DEFAULT_MAP_WINDOW_64 #endif /* CONFIG_COMPAT */ -#define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4)) +#ifdef CONFIG_ARM64_FORCE_52BIT +#define STACK_TOP_MAX TASK_SIZE_64 +#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 4)) +#else #define STACK_TOP_MAX DEFAULT_MAP_WINDOW_64 +#define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4)) +#endif /* CONFIG_ARM64_FORCE_52BIT */ #ifdef CONFIG_COMPAT #define AARCH32_VECTORS_BASE 0xffff0000 @@ -76,12 +81,14 @@ extern u64 vabits_user; #define STACK_TOP STACK_TOP_MAX #endif /* CONFIG_COMPAT */ +#ifndef CONFIG_ARM64_FORCE_52BIT #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\ DEFAULT_MAP_WINDOW) #define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \ base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ base) +#endif /* CONFIG_ARM64_FORCE_52BIT */ extern phys_addr_t arm64_dma_phys_limit; #define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)