From patchwork Thu Dec 6 22:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10717159 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 2AE41109C for ; Thu, 6 Dec 2018 22:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3F42F0BB for ; Thu, 6 Dec 2018 22:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 082A52D1B0; Thu, 6 Dec 2018 22:51:25 +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 E8E2E2D1B0 for ; Thu, 6 Dec 2018 22:51:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A72186B7CD2; Thu, 6 Dec 2018 17:51:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9FA776B7CD3; Thu, 6 Dec 2018 17:51:17 -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 8C2E16B7CD4; Thu, 6 Dec 2018 17:51:17 -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 549396B7CD2 for ; Thu, 6 Dec 2018 17:51:17 -0500 (EST) Received: by mail-ot1-f72.google.com with SMTP id c26so924728otl.19 for ; Thu, 06 Dec 2018 14:51:17 -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=Yd+kXQPFKTiyOU5I6I2f1Lewaqb1nQiK3aUYzathaFU=; b=RT40nA34vsW5AVVMfkFqL3LPuHZbHXiYx+f1Yf4HRfQGNKM9OZlCziJ93zyDtbBHP+ 06l/nkZXGJBI5ftXOU6pq2knnH4LfTi1jn1n1c8TkVuFBBzcstsmYxmxz+Z0wRNFTg6S HiH56XfdXvKZoOTbvIoZ/iAoUU9qWp7N9VuMM0Wwv9JUp9YA9Ta4Xs1RkOwWy5vNdTHf oF1BX31tlkkXkhhytLrfO03hV+JWv3jDpuM2drQeDEBukPrpJOf1wxHwr621lRcriy/X 5GfougcyG8Rc+3t+/yCJR2uhfanCupfcxNIQr5NJztxmJ5cY51A9Cwcn/0kbIQsKF/jO cHCA== 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+aEWbgnGslLa/MloLci0+l54xykT+Ha93dAosG57UR8IGoIsEzZLAz 2s+xZ3YnY2WFV6T5zxfDZIq95R5UkWV5PsOMCgfgmp02AbMOYab/HsA8wGuOmJR9lT3NCshDkWQ z2tOsxcmILT6UijcioPxLzPeyKHWrXmi8t+ekeflCL1AFvftnd6VSkg9ZGWuCmI5sgg== X-Received: by 2002:a9d:72e:: with SMTP id 43mr20030334ote.207.1544136677101; Thu, 06 Dec 2018 14:51:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/W+FeWOAfo2iiZO5LAki+2yfbFg9WtcorR88LrNv2h/yyjrtoJ/123yf80sKcVdJQom+qz+ X-Received: by 2002:a9d:72e:: with SMTP id 43mr20030314ote.207.1544136676347; Thu, 06 Dec 2018 14:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544136676; cv=none; d=google.com; s=arc-20160816; b=L+dwy+T5oBPId/8H98CuPp5A277f/1W9HlUN7VcCgxFMeXF1GCpAvCiYDWbZdrmZS4 pziWhhWcmU9dEmX4HFmu/TBnlKsD+IcPPktj4o56s603314TUnU0nyJ5FGNffitVArlb +avyw1fZ/Cw3dwHx+4u3BruRqYriGrPlHGO9YRidq+MIQ+Zvo0MsYKlcMWR45lQ4gWIk g+JeQ36u33hIZlAWBrzyAWB6HErzcRX5uC5MzhixiKOEFGy87Z/XF+ugWdVMVAiR+/za APfaAgjfTsSUiQVHw0oQ9bYYuURRGwfMWK9sSnMrd1pg5kh6W7T5jm9LaU4WkC2X06x9 R+Cw== 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=Yd+kXQPFKTiyOU5I6I2f1Lewaqb1nQiK3aUYzathaFU=; b=LuDUZqWwsArxBkXj7lF6Tf/8roj4oYJ45cq5o3LTTmdK9eB5+6RsuluYTMcnxaS/1r 1xeQ42INl3OQSRPdnLZGCgJE4HMi3EiNDH9wSor8R9IMBXjSaqcAFheCGKKSXZuxoZca ei0TKgvbETOHj9TlgA9pSOTJ03pMT6/Ulzq4YZQP6dLPSYjyBSaPPHbfuPK1y70PraRN eeIiQHryUNfAC2mEQbFrQClRzBM/Zr2Dvr7LXkIwaYHC/UvzjaHUxdsKlfCHCHZKCQ8Q wl7lBV61KArq8AfbBxUQjNMEtuA7yxY4lcTm9cJMe4UFgr89mhYKtGIN//otWrjiDPqo i9ng== 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 j5si417562oiw.131.2018.12.06.14.51.16 for ; Thu, 06 Dec 2018 14:51:16 -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 B844E15AD; Thu, 6 Dec 2018 14:51:15 -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 2DED23F5AF; Thu, 6 Dec 2018 14:51:14 -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 7/7] arm64: mm: Allow forcing all userspace addresses to 52-bit Date: Thu, 6 Dec 2018 22:50:42 +0000 Message-Id: <20181206225042.11548-8-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 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 6a93d5bc7f76..12658f05bb41 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)