Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4832876pxy; Tue, 27 Apr 2021 13:48:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtM6gz21ER/EAZmb3+Pjj5XtE507odfhrS4wWh3Kk4zP56/Tf779SU0co4U9tNVYxEhFGv X-Received: by 2002:a17:90a:cb0e:: with SMTP id z14mr183599pjt.128.1619556504564; Tue, 27 Apr 2021 13:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619556504; cv=none; d=google.com; s=arc-20160816; b=SGqsT5U+iv69XeECeNDneqsFU20om5IEEUoSSGOud1omDe5DP3l/cLsal0bWx6HZBO +sq8KuovfGbvwjsilX6iR03S6ObFZzOaVZwTFbmpTR+Lorg+zDr58lTUCz25RBhRwQz/ W+IoZjjNY68go4BpwAx7x4n1DgbJFnKGQA6rZuyk+aGMOPtdCTgtRv0P7vVcueFVMx9Y kaCkR1U8QPdjTXZcxUGkfLo9lJvoW2MQbGb+q+EFQUJlgP8dYT7AXrNPPWwbqcpt2hcf IpQOM/HLX2CIzGma/EtSnmtXN5PmuLigvRcR79gt6zPpmn/fg7Nb4o+mvekyATKv9R7d BXkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=f8KK0bentutbpp2KyONgJ5Xrh3BHv/SfU5H964gPqFU=; b=sjhQEuqgwgZ6+5zfuwPNxAUDBDggSCqXVO9ZZNtr+g8kjZmI7J/sT9OsMLgFSdZiAA gtaXs3U27PfQR8HuJKJ5JoIXqj4BSn+7orSr4MmYWxNGkl2YrXL5kH6ci+uLbYckFPMS R/DyjJZkjvksVieO3ZWNy5RqdTN3kKzI0YzW2abybE6/i4EDXvlkkA4WkM5ktlH7z2us MqVF56BkNBNcdLgcxeYr3YlDKLdSyOJaIHio0X0Iqp/mvgiwHhLu5uD0vuhTQFva5F6h sF7xt7GoRNAr77hhL8ep6y7ht/GNWxrZ3Szwp9XUROAX2IIdmLAX/VakeOlNrLD9DUoK BSlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id iq22si4319510pjb.25.2021.04.27.13.48.11; Tue, 27 Apr 2021 13:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238970AbhD0UrH (ORCPT + 99 others); Tue, 27 Apr 2021 16:47:07 -0400 Received: from mga05.intel.com ([192.55.52.43]:31780 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239355AbhD0Uq2 (ORCPT ); Tue, 27 Apr 2021 16:46:28 -0400 IronPort-SDR: 3LUanfPSItEiQud6zdd6ntENRvdM8zXiW7EBv1fnbQ0cSWOiqme7edkRZNsc0XZvSuAX1Ar3Qr L5lAMS358p8Q== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="281922502" X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="281922502" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:44:25 -0700 IronPort-SDR: sLuunklONRNhbhx66Q9Qc7lgCDoAmqA7cYNZMlv2zMALUcfNaX7QdmhjtfQKnAMg6YsnnvnqIJ yMa/7UyNmEyA== X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="465623570" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:44:24 -0700 From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , 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 , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Cc: Yu-cheng Yu , "Kirill A . Shutemov" Subject: [PATCH v26 28/30] mm: Move arch_calc_vm_prot_bits() to arch/x86/include/asm/mman.h Date: Tue, 27 Apr 2021 13:43:13 -0700 Message-Id: <20210427204315.24153-29-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210427204315.24153-1-yu-cheng.yu@intel.com> References: <20210427204315.24153-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To prepare the introduction of PROT_SHADOW_STACK and be consistent with other architectures, move arch_vm_get_page_prot() and arch_calc_vm_prot_bits() to arch/x86/include/asm/mman.h. Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook Reviewed-by: Kirill A. Shutemov --- arch/x86/include/asm/mman.h | 30 ++++++++++++++++++++++++++++++ arch/x86/include/uapi/asm/mman.h | 28 +++------------------------- 2 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 arch/x86/include/asm/mman.h diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h new file mode 100644 index 000000000000..629f6c81263a --- /dev/null +++ b/arch/x86/include/asm/mman.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_MMAN_H +#define _ASM_X86_MMAN_H + +#include +#include + +#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS +/* + * Take the 4 protection key bits out of the vma->vm_flags + * value and turn them in to the bits that we can put in + * to a pte. + * + * Only override these if Protection Keys are available + * (which is only on 64-bit). + */ +#define arch_vm_get_page_prot(vm_flags) __pgprot( \ + ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \ + ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \ + ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \ + ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0)) + +#define arch_calc_vm_prot_bits(prot, key) ( \ + ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \ + ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \ + ((key) & 0x4 ? VM_PKEY_BIT2 : 0) | \ + ((key) & 0x8 ? VM_PKEY_BIT3 : 0)) +#endif + +#endif /* _ASM_X86_MMAN_H */ diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h index d4a8d0424bfb..f28fa4acaeaf 100644 --- a/arch/x86/include/uapi/asm/mman.h +++ b/arch/x86/include/uapi/asm/mman.h @@ -1,31 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _ASM_X86_MMAN_H -#define _ASM_X86_MMAN_H +#ifndef _UAPI_ASM_X86_MMAN_H +#define _UAPI_ASM_X86_MMAN_H #define MAP_32BIT 0x40 /* only give out 32bit addresses */ -#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS -/* - * Take the 4 protection key bits out of the vma->vm_flags - * value and turn them in to the bits that we can put in - * to a pte. - * - * Only override these if Protection Keys are available - * (which is only on 64-bit). - */ -#define arch_vm_get_page_prot(vm_flags) __pgprot( \ - ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \ - ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \ - ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \ - ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0)) - -#define arch_calc_vm_prot_bits(prot, key) ( \ - ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \ - ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \ - ((key) & 0x4 ? VM_PKEY_BIT2 : 0) | \ - ((key) & 0x8 ? VM_PKEY_BIT3 : 0)) -#endif - #include -#endif /* _ASM_X86_MMAN_H */ +#endif /* _UAPI_ASM_X86_MMAN_H */ -- 2.21.0