All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ram Pai <linuxram@us.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org
Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
	khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com,
	bsingharora@gmail.com, dave.hansen@intel.com, hbabu@us.ibm.com,
	linuxram@us.ibm.com, arnd@arndb.de, akpm@linux-foundation.org,
	corbet@lwn.net, mingo@redhat.com
Subject: [RFC v4 17/17] procfs: display the protection-key number associated with a vma
Date: Tue, 27 Jun 2017 03:11:59 -0700	[thread overview]
Message-ID: <1498558319-32466-18-git-send-email-linuxram@us.ibm.com> (raw)
In-Reply-To: <1498558319-32466-1-git-send-email-linuxram@us.ibm.com>

Display the pkey number associated with the vma in smaps of a task.
The key will be seen as below:

VmFlags: rd wr mr mw me dw ac key=0

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 Documentation/filesystems/proc.txt |  3 ++-
 fs/proc/task_mmu.c                 | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 4cddbce..a8c74aa 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -423,7 +423,7 @@ SwapPss:               0 kB
 KernelPageSize:        4 kB
 MMUPageSize:           4 kB
 Locked:                0 kB
-VmFlags: rd ex mr mw me dw
+VmFlags: rd ex mr mw me dw key=<num>
 
 the first of these lines shows the same information as is displayed for the
 mapping in /proc/PID/maps.  The remaining lines show the size of the mapping
@@ -491,6 +491,7 @@ manner. The codes are the following:
     hg  - huge page advise flag
     nh  - no-huge page advise flag
     mg  - mergable advise flag
+    key=<num> - the memory protection key number
 
 Note that there is no guarantee that every flag and associated mnemonic will
 be present in all further kernel releases. Things get changed, the flags may
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 2ddc298..d2eb096 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1,4 +1,6 @@
 #include <linux/mm.h>
+#include <linux/pkeys.h>
+#include <linux/huge_mm.h>
 #include <linux/vmacache.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
@@ -666,22 +668,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_ARCH_HAS_PKEYS
-		/* These come out via ProtectionKey: */
-		[ilog2(VM_PKEY_BIT0)]	= "",
-		[ilog2(VM_PKEY_BIT1)]	= "",
-		[ilog2(VM_PKEY_BIT2)]	= "",
-		[ilog2(VM_PKEY_BIT3)]	= "",
-#endif /* CONFIG_ARCH_HAS_PKEYS */
-#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS
-		/* Additional bit in ProtectionKey: */
-		[ilog2(VM_PKEY_BIT4)]	= "",
-#endif
 	};
 	size_t i;
 
 	seq_puts(m, "VmFlags: ");
 	for (i = 0; i < BITS_PER_LONG; i++) {
+#ifdef CONFIG_ARCH_HAS_PKEYS
+		if (i == ilog2(VM_PKEY_BIT0)) {
+			int keyvalue = vma_pkey(vma);
+
+			i += ilog2(arch_max_pkey())-1;
+			seq_printf(m, "key=%d ", keyvalue);
+			continue;
+		}
+#endif /* CONFIG_ARCH_HAS_PKEYS */
 		if (!mnemonics[i][0])
 			continue;
 		if (vma->vm_flags & (1UL << i)) {
-- 
1.8.3.1

WARNING: multiple messages have this Message-ID (diff)
From: Ram Pai <linuxram@us.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org
Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
	khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com,
	bsingharora@gmail.com, dave.hansen@intel.com, hbabu@us.ibm.com,
	linuxram@us.ibm.com, arnd@arndb.de, akpm@linux-foundation.org,
	corbet@lwn.net, mingo@redhat.com
Subject: [RFC v4 17/17] procfs: display the protection-key number associated with a vma
Date: Tue, 27 Jun 2017 03:11:59 -0700	[thread overview]
Message-ID: <1498558319-32466-18-git-send-email-linuxram@us.ibm.com> (raw)
In-Reply-To: <1498558319-32466-1-git-send-email-linuxram@us.ibm.com>

Display the pkey number associated with the vma in smaps of a task.
The key will be seen as below:

VmFlags: rd wr mr mw me dw ac key=0

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 Documentation/filesystems/proc.txt |  3 ++-
 fs/proc/task_mmu.c                 | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 4cddbce..a8c74aa 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -423,7 +423,7 @@ SwapPss:               0 kB
 KernelPageSize:        4 kB
 MMUPageSize:           4 kB
 Locked:                0 kB
-VmFlags: rd ex mr mw me dw
+VmFlags: rd ex mr mw me dw key=<num>
 
 the first of these lines shows the same information as is displayed for the
 mapping in /proc/PID/maps.  The remaining lines show the size of the mapping
@@ -491,6 +491,7 @@ manner. The codes are the following:
     hg  - huge page advise flag
     nh  - no-huge page advise flag
     mg  - mergable advise flag
+    key=<num> - the memory protection key number
 
 Note that there is no guarantee that every flag and associated mnemonic will
 be present in all further kernel releases. Things get changed, the flags may
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 2ddc298..d2eb096 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1,4 +1,6 @@
 #include <linux/mm.h>
+#include <linux/pkeys.h>
+#include <linux/huge_mm.h>
 #include <linux/vmacache.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
@@ -666,22 +668,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_ARCH_HAS_PKEYS
-		/* These come out via ProtectionKey: */
-		[ilog2(VM_PKEY_BIT0)]	= "",
-		[ilog2(VM_PKEY_BIT1)]	= "",
-		[ilog2(VM_PKEY_BIT2)]	= "",
-		[ilog2(VM_PKEY_BIT3)]	= "",
-#endif /* CONFIG_ARCH_HAS_PKEYS */
-#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS
-		/* Additional bit in ProtectionKey: */
-		[ilog2(VM_PKEY_BIT4)]	= "",
-#endif
 	};
 	size_t i;
 
 	seq_puts(m, "VmFlags: ");
 	for (i = 0; i < BITS_PER_LONG; i++) {
+#ifdef CONFIG_ARCH_HAS_PKEYS
+		if (i == ilog2(VM_PKEY_BIT0)) {
+			int keyvalue = vma_pkey(vma);
+
+			i += ilog2(arch_max_pkey())-1;
+			seq_printf(m, "key=%d ", keyvalue);
+			continue;
+		}
+#endif /* CONFIG_ARCH_HAS_PKEYS */
 		if (!mnemonics[i][0])
 			continue;
 		if (vma->vm_flags & (1UL << i)) {
-- 
1.8.3.1

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-06-27 10:13 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 10:11 [RFC v4 00/17] powerpc: Memory Protection Keys Ram Pai
2017-06-27 10:11 ` Ram Pai
2017-06-27 10:11 ` [RFC v4 01/17] mm: introduce an additional vma bit for powerpc pkey Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:54   ` Balbir Singh
2017-06-27 10:54     ` Balbir Singh
2017-06-27 10:54     ` Balbir Singh
2017-06-27 10:11 ` [RFC v4 02/17] mm: ability to disable execute permission on a key at creation Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 11:32   ` Balbir Singh
2017-06-27 11:32     ` Balbir Singh
2017-06-27 11:32     ` Balbir Singh
2017-06-27 10:11 ` [RFC v4 03/17] x86: key creation with PKEY_DISABLE_EXECUTE disallowed Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 11:32   ` Balbir Singh
2017-06-27 11:32     ` Balbir Singh
2017-06-27 11:32     ` Balbir Singh
2017-06-27 10:11 ` [RFC v4 04/17] powerpc: Implement sys_pkey_alloc and sys_pkey_free system call Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 05/17] powerpc: store and restore the pkey state across context switches Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 06/17] powerpc: Implementation for sys_mprotect_pkey() system call Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 07/17] powerpc: make the hash functions protection-key aware Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 08/17] powerpc: Program HPTE key protection bits Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 09/17] powerpc: call the hash functions with the correct pkey value Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 15:24   ` Aneesh Kumar K.V
2017-06-27 15:24     ` Aneesh Kumar K.V
2017-06-28  7:12     ` Ram Pai
2017-06-28  7:12       ` Ram Pai
2017-06-27 10:11 ` [RFC v4 10/17] powerpc: Macro the mask used for checking DSI exception Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 11/17] powerpc: Handle exceptions caused by pkey violation Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 12/17] powerpc: Deliver SEGV signal on " Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 13/17] selftest: Move protecton key selftest to arch neutral directory Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 14/17] selftest: PowerPC specific test updates to memory protection keys Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 15/17] Documentation: Move protecton key documentation to arch neutral directory Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` [RFC v4 16/17] Documentation: PowerPC specific updates to memory protection keys Ram Pai
2017-06-27 10:11   ` Ram Pai
2017-06-27 10:11 ` Ram Pai [this message]
2017-06-27 10:11   ` [RFC v4 17/17] procfs: display the protection-key number associated with a vma Ram Pai
2017-06-28  1:50   ` Michael Ellerman
2017-06-28  1:50     ` Michael Ellerman
2017-06-28  1:50     ` Michael Ellerman
2017-06-28  1:50     ` Michael Ellerman
2017-06-27 10:46 ` [RFC v4 00/17] powerpc: Memory Protection Keys Balbir Singh
2017-06-27 10:46   ` Balbir Singh
2017-06-27 10:46   ` Balbir Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498558319-32466-18-git-send-email-linuxram@us.ibm.com \
    --to=linuxram@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=bsingharora@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@intel.com \
    --cc=hbabu@us.ibm.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.