From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1948295AbcBRU2e (ORCPT ); Thu, 18 Feb 2016 15:28:34 -0500 Received: from terminus.zytor.com ([198.137.202.10]:47406 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1426847AbcBRU2a (ORCPT ); Thu, 18 Feb 2016 15:28:30 -0500 Date: Thu, 18 Feb 2016 12:27:26 -0800 From: tip-bot for Dave Hansen Message-ID: Cc: hpa@zytor.com, dvlasenk@redhat.com, tglx@linutronix.de, akpm@linux-foundation.org, mingo@kernel.org, dave.hansen@linux.intel.com, peterz@infradead.org, brgerst@gmail.com, linux-kernel@vger.kernel.org, luto@amacapital.net, dave@sr71.net, torvalds@linux-foundation.org, bp@alien8.de, riel@redhat.com Reply-To: torvalds@linux-foundation.org, bp@alien8.de, dave@sr71.net, riel@redhat.com, luto@amacapital.net, linux-kernel@vger.kernel.org, brgerst@gmail.com, peterz@infradead.org, tglx@linutronix.de, mingo@kernel.org, akpm@linux-foundation.org, hpa@zytor.com, dvlasenk@redhat.com, dave.hansen@linux.intel.com In-Reply-To: <20160212210237.CFB94AD5@viggo.jf.intel.com> References: <20160212210237.CFB94AD5@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:mm/pkeys] x86/mm/pkeys: Create an x86 arch_calc_vm_prot_bits () for VMA flags Git-Commit-ID: 878ba03932d757ce4e954db4defec74a0de0435b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 878ba03932d757ce4e954db4defec74a0de0435b Gitweb: http://git.kernel.org/tip/878ba03932d757ce4e954db4defec74a0de0435b Author: Dave Hansen AuthorDate: Fri, 12 Feb 2016 13:02:37 -0800 Committer: Ingo Molnar CommitDate: Thu, 18 Feb 2016 19:46:32 +0100 x86/mm/pkeys: Create an x86 arch_calc_vm_prot_bits() for VMA flags calc_vm_prot_bits() takes PROT_{READ,WRITE,EXECUTE} bits and turns them in to the vma->vm_flags/VM_* bits. We need to do a similar thing for protection keys. We take a protection key (4 bits) and encode it in to the 4 VM_PKEY_* bits. Note: this code is not new. It was simply a part of the mprotect_pkey() patch in the past. I broke it out for use in the execute-only support. Signed-off-by: Dave Hansen Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rik van Riel Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20160212210237.CFB94AD5@viggo.jf.intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/mman.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h index e8562e0..39bca7f 100644 --- a/arch/x86/include/uapi/asm/mman.h +++ b/arch/x86/include/uapi/asm/mman.h @@ -20,6 +20,12 @@ ((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