From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by kanga.kvack.org (Postfix) with ESMTP id B64716B026F for ; Wed, 16 Sep 2015 13:55:12 -0400 (EDT) Received: by pacfv12 with SMTP id fv12so219654658pac.2 for ; Wed, 16 Sep 2015 10:55:12 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTP id e5si15347140pas.193.2015.09.16.10.49.09 for ; Wed, 16 Sep 2015 10:49:09 -0700 (PDT) Subject: [PATCH 17/26] x86, pkeys: dump PTE pkey in /proc/pid/smaps From: Dave Hansen Date: Wed, 16 Sep 2015 10:49:08 -0700 References: <20150916174903.E112E464@viggo.jf.intel.com> In-Reply-To: <20150916174903.E112E464@viggo.jf.intel.com> Message-Id: <20150916174908.3A2FA837@viggo.jf.intel.com> Sender: owner-linux-mm@kvack.org List-ID: To: dave@sr71.net Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org 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 get the same function as if we used the weak generic function. --- b/arch/x86/kernel/setup.c | 9 +++++++++ b/fs/proc/task_mmu.c | 5 +++++ 2 files changed, 14 insertions(+) diff -puN arch/x86/kernel/setup.c~pkeys-40-smaps arch/x86/kernel/setup.c --- a/arch/x86/kernel/setup.c~pkeys-40-smaps 2015-09-16 10:48:18.838309381 -0700 +++ b/arch/x86/kernel/setup.c 2015-09-16 10:48:18.844309653 -0700 @@ -111,6 +111,7 @@ #include #include #include +#include /* * max_low_pfn_mapped: highest direct mapped pfn under 4GB @@ -1264,3 +1265,11 @@ static int __init register_kernel_offset 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 -puN fs/proc/task_mmu.c~pkeys-40-smaps fs/proc/task_mmu.c --- a/fs/proc/task_mmu.c~pkeys-40-smaps 2015-09-16 10:48:18.840309472 -0700 +++ b/fs/proc/task_mmu.c 2015-09-16 10:48:18.844309653 -0700 @@ -625,6 +625,10 @@ static void show_smap_vma_flags(struct s seq_putc(m, '\n'); } +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; @@ -674,6 +678,7 @@ static int show_smap(struct seq_file *m, (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; _ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org