Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1675498 > unrolled thread
| Started by | Ram Pai <linuxram@us.ibm.com> |
|---|---|
| First post | 2017-06-27 12:20 +0200 |
| Last post | 2017-06-28 04:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC v4 17/17] procfs: display the protection-key number associated with a vma Ram Pai <linuxram@us.ibm.com> - 2017-06-27 12:20 +0200
Re: [RFC v4 17/17] procfs: display the protection-key number associated with a vma Michael Ellerman <mpe@ellerman.id.au> - 2017-06-28 04:00 +0200
| From | Ram Pai <linuxram@us.ibm.com> |
|---|---|
| Date | 2017-06-27 12:20 +0200 |
| Subject | [RFC v4 17/17] procfs: display the protection-key number associated with a vma |
| Message-ID | <tWVLc-7w2-15@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-06-28 04:00 +0200 |
| Message-ID | <tXaqR-ld-11@gated-at.bofh.it> |
| In reply to | #1675498 |
Ram Pai <linuxram@us.ibm.com> writes: > 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 Why wouldn't we just emit a "ProtectionKey:" line like x86 does? See their arch_show_smap(). You should probably also do what x86 does, which is to not display the key on CPUs that don't support keys. cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web