From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1948213AbcBRUZ6 (ORCPT ); Thu, 18 Feb 2016 15:25:58 -0500 Received: from terminus.zytor.com ([198.137.202.10]:47247 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1948154AbcBRUZy (ORCPT ); Thu, 18 Feb 2016 15:25:54 -0500 Date: Thu, 18 Feb 2016 12:24:25 -0800 From: tip-bot for Dave Hansen Message-ID: Cc: ldufour@linux.vnet.ibm.com, dave.hansen@linux.intel.com, vbabka@suse.cz, bp@suse.de, riel@redhat.com, jmarchan@redhat.com, dave@sr71.net, koct9i@gmail.com, peterz@infradead.org, hannes@cmpxchg.org, mwilliamson@undo-software.com, brgerst@gmail.com, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, bp@alien8.de, viro@zeniv.linux.org.uk, pbonzini@redhat.com, luto@amacapital.net, bhe@redhat.com, msalter@redhat.com, mingo@kernel.org, mhocko@suse.com, n-horiguchi@ah.jp.nec.com, kirill.shutemov@linux.intel.com, jkosina@suse.cz, akpm@linux-foundation.org, torvalds@linux-foundation.org, jroedel@suse.de, dvlasenk@redhat.com, dyoung@redhat.com Reply-To: n-horiguchi@ah.jp.nec.com, mhocko@suse.com, mingo@kernel.org, msalter@redhat.com, bhe@redhat.com, luto@amacapital.net, pbonzini@redhat.com, viro@zeniv.linux.org.uk, dyoung@redhat.com, jroedel@suse.de, dvlasenk@redhat.com, torvalds@linux-foundation.org, akpm@linux-foundation.org, jkosina@suse.cz, kirill.shutemov@linux.intel.com, dave@sr71.net, jmarchan@redhat.com, riel@redhat.com, bp@suse.de, vbabka@suse.cz, dave.hansen@linux.intel.com, ldufour@linux.vnet.ibm.com, bp@alien8.de, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, brgerst@gmail.com, mwilliamson@undo-software.com, peterz@infradead.org, hannes@cmpxchg.org, koct9i@gmail.com In-Reply-To: <20160212210227.4F8EB3F8@viggo.jf.intel.com> References: <20160212210227.4F8EB3F8@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:mm/pkeys] x86/mm/pkeys: Dump pkey from VMA in /proc/pid/ smaps Git-Commit-ID: c1192f8428414679c8126180e690f8daa1d4d98a 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: c1192f8428414679c8126180e690f8daa1d4d98a Gitweb: http://git.kernel.org/tip/c1192f8428414679c8126180e690f8daa1d4d98a Author: Dave Hansen AuthorDate: Fri, 12 Feb 2016 13:02:27 -0800 Committer: Ingo Molnar CommitDate: Thu, 18 Feb 2016 19:46:29 +0100 x86/mm/pkeys: Dump pkey from VMA in /proc/pid/smaps The protection key can now be just as important as read/write permissions on a VMA. We need some debug mechanism to help figure out if it is in play. smaps seems like a logical place to expose it. arch/x86/kernel/setup.c is a bit of a weirdo place to put this code, but it already had seq_file.h and there was not a much better existing place to put it. We also use no #ifdef. If protection keys is .config'd out we will effectively get the same function as if we used the weak generic function. Signed-off-by: Dave Hansen Reviewed-by: Thomas Gleixner Cc: Al Viro Cc: Andrew Morton Cc: Andy Lutomirski Cc: Baoquan He Cc: Borislav Petkov Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Dave Young Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jerome Marchand Cc: Jiri Kosina Cc: Joerg Roedel Cc: Johannes Weiner Cc: Kirill A. Shutemov Cc: Konstantin Khlebnikov Cc: Laurent Dufour Cc: Linus Torvalds Cc: Mark Salter Cc: Mark Williamson Cc: Michal Hocko Cc: Naoya Horiguchi Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Rik van Riel Cc: Vlastimil Babka Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20160212210227.4F8EB3F8@viggo.jf.intel.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/setup.c | 9 +++++++++ fs/proc/task_mmu.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d3d80e6..7260f99 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -112,6 +112,7 @@ #include #include #include +#include /* * max_low_pfn_mapped: highest direct mapped pfn under 4GB @@ -1282,3 +1283,11 @@ static int __init register_kernel_offset_dumper(void) return 0; } __initcall(register_kernel_offset_dumper); + +void arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) +{ + if (!boot_cpu_has(X86_FEATURE_OSPKE)) + return; + + seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); +} diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index fa95ab2..9df4316 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -660,11 +660,20 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_MERGEABLE)] = "mg", [ilog2(VM_UFFD_MISSING)]= "um", [ilog2(VM_UFFD_WP)] = "uw", +#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS + /* These come out via ProtectionKey: */ + [ilog2(VM_PKEY_BIT0)] = "", + [ilog2(VM_PKEY_BIT1)] = "", + [ilog2(VM_PKEY_BIT2)] = "", + [ilog2(VM_PKEY_BIT3)] = "", +#endif }; size_t i; seq_puts(m, "VmFlags: "); for (i = 0; i < BITS_PER_LONG; i++) { + if (!mnemonics[i][0]) + continue; if (vma->vm_flags & (1UL << i)) { seq_printf(m, "%c%c ", mnemonics[i][0], mnemonics[i][1]); @@ -702,6 +711,10 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask, } #endif /* HUGETLB_PAGE */ +void __weak arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) +{ +} + static int show_smap(struct seq_file *m, void *v, int is_pid) { struct vm_area_struct *vma = v; @@ -783,6 +796,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) (vma->vm_flags & VM_LOCKED) ? (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); + arch_show_smap(m, vma); show_smap_vma_flags(m, vma); m_cache_vma(m, vma); return 0;