Message ID | 20230319001535.23210-26-rick.p.edgecombe@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 054B8C7618A for <linux-mm@archiver.kernel.org>; Sun, 19 Mar 2023 00:16:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1851E280017; Sat, 18 Mar 2023 20:16:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02467280001; Sat, 18 Mar 2023 20:16:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7FB4280017; Sat, 18 Mar 2023 20:16:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 98AA7280001 for <linux-mm@kvack.org>; Sat, 18 Mar 2023 20:16:39 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7A42D120C89 for <linux-mm@kvack.org>; Sun, 19 Mar 2023 00:16:39 +0000 (UTC) X-FDA: 80583731718.24.FD68020 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by imf21.hostedemail.com (Postfix) with ESMTP id 5AB231C001B for <linux-mm@kvack.org>; Sun, 19 Mar 2023 00:16:37 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UsPgNbv9; spf=pass (imf21.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679184997; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=mwokoOpGillR2xIBR8l2lN8VfHeotneOlmH/z0FhJq4=; b=ySlYwu/fty1tjiBpOwiJZfUFxEaKfojkej5bYhL/lXEn1u8ULZJzZTJfogl1a4Z1xifC3z eVZPIyezvL2oP78y59YV5UrUTiurDFZmVu+xI1JSG8SLlpMyDJsIbgrcUYE6TpSmy31ldu 9y1LxDmmxN1UUo7oVz3HHEGGyqqwbq4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UsPgNbv9; spf=pass (imf21.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679184997; a=rsa-sha256; cv=none; b=Ys9oDCdMkZavdFK6G/W9DhP9Nlcs+qOn4M5uMWCo4pj9RguIfHixDnSJEQLaGLe/b317O5 tLzbOePic/OD0hjIXmyxtmdfX+U2fWP5I5jA/23JNId+z0ygeWJ0VlV7r1BlRTYpCFvdNW QfMqaHJvV2dC4xztNV2FLnzNYD5LRDA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679184997; x=1710720997; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=m2G03CSTQRSNX4YXn65CryKHCN03SDYmmfcTPTkRd8E=; b=UsPgNbv9H5qRBxIxVzow0Gly4GN92clQ/glGgD63xjOMFLoI6LngewtF DZoCWfi2FXGYYXt6kayy6iCYJXHlSG6cOiWxPMWrYlQ323Oz29ikI9IBE pBlRk/j1dJxruSm/RkVFGMWzkwMLp7t5gy2g1V+SEzyzWd5EUhuFzl/tG S2lhODSfl08xgiNIbhrlY07Ec4V4LIVIpMFZ9/DCTvXvYAmlaNzh9EqIB 9VKE1wBqbeSfzTvLN4NART/9p8UISDnc+REu3beQ7bJ9fwdqEMJFq1zKj S540UPSIFTKDl4NKgZO2hFTKDs6j8M628ke4QYpY8oSkrxRkWSTC3FHEe A==; X-IronPort-AV: E=McAfee;i="6600,9927,10653"; a="338491294" X-IronPort-AV: E=Sophos;i="5.98,272,1673942400"; d="scan'208";a="338491294" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2023 17:16:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10653"; a="749672886" X-IronPort-AV: E=Sophos;i="5.98,272,1673942400"; d="scan'208";a="749672886" Received: from bmahatwo-mobl1.gar.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.135.34.5]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2023 17:16:34 -0700 From: Rick Edgecombe <rick.p.edgecombe@intel.com> To: x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, Andy Lutomirski <luto@kernel.org>, Balbir Singh <bsingharora@gmail.com>, Borislav Petkov <bp@alien8.de>, Cyrill Gorcunov <gorcunov@gmail.com>, Dave Hansen <dave.hansen@linux.intel.com>, Eugene Syromiatnikov <esyr@redhat.com>, Florian Weimer <fweimer@redhat.com>, "H . J . Lu" <hjl.tools@gmail.com>, Jann Horn <jannh@google.com>, Jonathan Corbet <corbet@lwn.net>, Kees Cook <keescook@chromium.org>, Mike Kravetz <mike.kravetz@oracle.com>, Nadav Amit <nadav.amit@gmail.com>, Oleg Nesterov <oleg@redhat.com>, Pavel Machek <pavel@ucw.cz>, Peter Zijlstra <peterz@infradead.org>, Randy Dunlap <rdunlap@infradead.org>, Weijiang Yang <weijiang.yang@intel.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, John Allen <john.allen@amd.com>, kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com, szabolcs.nagy@arm.com Cc: rick.p.edgecombe@intel.com Subject: [PATCH v8 25/40] x86/mm: Introduce MAP_ABOVE4G Date: Sat, 18 Mar 2023 17:15:20 -0700 Message-Id: <20230319001535.23210-26-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230319001535.23210-1-rick.p.edgecombe@intel.com> References: <20230319001535.23210-1-rick.p.edgecombe@intel.com> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5AB231C001B X-Rspam-User: X-Stat-Signature: n94yhismwq4hbzctiuamsnkd5ijzu8hu X-HE-Tag: 1679184997-259492 X-HE-Meta: U2FsdGVkX1+bTkKtlyyjOkHXgg8iJ+muMNVbE8EDa6v0/Uej8MnE5HY/v3E/EClIgz8PU4iVGN+hOaiZim+EDSrZfcooPJm0cSBN82Qs5UIR2+NvQOHOLuY/P7lZ67bEoLO2w/L4SINYfcxrg21w+/ZHbHuGNqJAUamMkWXAhoSnPUuYCkFoAzWa9Y7OyTaU6K8MqYVUMEu5skd7EG1INyRlNXFrH7VFhDYary22flj+LknMaSOc8YVJTPAOBHP2CNxkSLKADY9VCcvufp4nwYI7zRKDsvms03BCHc4ReNqTuVlPQhzKCNe0foUb102ac8+BDjqo81usGyzqu4mW7uTSVDBi7Wto5DBnOJmBPXL2t481HwxmdlOtniuS3zmbD9th1lMqMKR4ohNLQ5gBzMwLgQSadqgpF7c2Zu5l800e1NAD0fxTAB4keUZj47pDqqo3Kyce4AqFr668iUEZCio5dPFXGMjqQUQ+03evSxGSLxlNn6lDdK5SW/ojpNZEBCbEfhl4VbXLOdYlkScg+1Fe2/6ANFGBZ+QLaXITXaKiPU+ZFWBX77AaSXbrPBFAu2fK6vbIyFzpc3S6r8dggHGoFUQfeRjLOKFGLTsSdnmLindUE8zxFfkqsmn+rZgECuDG+Z/aGxPuNm6YjjQ+GUQoma5Zbw6TbDzGtYKsVXQgs+/duel/bcB3OrVNqNowxQs1pYpkyvbtKd7U+rG+W2qrQjUkqFEsGNHZQMNwx4kGCYBmXLq/Ncu59//PHeck1lmsyLnrXz+xYSFs+o/P/Thfu9/grQICc2MWBC8EA+HPzF288Tz0D60B9jfjAG3lSU1w69PW4yDvxDRYjs4A4imRvDI1jLJ8VB+3dKss9+Gc2csYPCYs6ERt6uQfESM6F65mwUjE0/bMZoW+wx/xCo+fUTxDTqNzUFn57J+UEEKgmrTvvE18oAc5CJs8fX7y9a+KHksOtqC2b8EfvRC 9SKPaiQF lglkTqK47hVy5qlU1zCX39qImJvaYN4OxXIjS+o0ohHD9I93LcdId30oXUwWYHLa+Xr5uBIthyXa4Ncx9dXAqORR6JeS7aZS/AdFZ1xBX4wgUQJOOIFnKBMrclqJmO9qmoHuS0qpDd7hZWCRzx3WOtsqNXPcVaGIcsAcIDl9TpTEikZNV+2hn7I+LaOG0i+p4KKev9JZ8PdJUyBtEc6S8OwKpf1quyhtia+YSi9Q5jkwv1Ebx3Dis/xszT4Dfm4zbs1wY7SPOCf/rc+GI7bezZX7adHYG8APhMo+CBLem5w3atSNNCmVJG2b4GY7AC5roPKfvg93o5rbLlTrB640lDbnztcD8YRkinxM5xXcIsaZsiho1i5ADWgPyevbjhI1epwERgevyzZXRRUYuhhqFh9am1w== 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: <linux-mm.kvack.org> |
Series |
Shadow stacks for userspace
|
expand
|
diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h index 775dbd3aff73..5a0256e73f1e 100644 --- a/arch/x86/include/uapi/asm/mman.h +++ b/arch/x86/include/uapi/asm/mman.h @@ -3,6 +3,7 @@ #define _ASM_X86_MMAN_H #define MAP_32BIT 0x40 /* only give out 32bit addresses */ +#define MAP_ABOVE4G 0x80 /* only map above 4GB */ #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS #define arch_calc_vm_prot_bits(prot, key) ( \ diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index 8cc653ffdccd..c783aeb37dce 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c @@ -193,7 +193,11 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; - info.low_limit = PAGE_SIZE; + if (!in_32bit_syscall() && (flags & MAP_ABOVE4G)) + info.low_limit = SZ_4G; + else + info.low_limit = PAGE_SIZE; + info.high_limit = get_mmap_base(0); /* diff --git a/include/linux/mman.h b/include/linux/mman.h index cee1e4b566d8..40d94411d492 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -15,6 +15,9 @@ #ifndef MAP_32BIT #define MAP_32BIT 0 #endif +#ifndef MAP_ABOVE4G +#define MAP_ABOVE4G 0 +#endif #ifndef MAP_HUGE_2MB #define MAP_HUGE_2MB 0 #endif @@ -50,6 +53,7 @@ | MAP_STACK \ | MAP_HUGETLB \ | MAP_32BIT \ + | MAP_ABOVE4G \ | MAP_HUGE_2MB \ | MAP_HUGE_1GB)