LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxram@us.ibm.com
Cc: mingo@redhat.com, linuxppc-dev@ozlabs.org, linux-mm@kvack.org,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	dave.hansen@intel.com
Subject: [PATCH 8/8] mm/pkeys, x86, powerpc: Display pkey in smaps if arch supports pkeys
Date: Wed,  9 May 2018 00:59:48 +1000	[thread overview]
Message-ID: <20180508145948.9492-9-mpe@ellerman.id.au> (raw)
In-Reply-To: <20180508145948.9492-1-mpe@ellerman.id.au>

From: Ram Pai <linuxram@us.ibm.com>

Currently the architecture specific code is expected to display the
protection keys in smap for a given vma. This can lead to redundant
code and possibly to divergent formats in which the key gets
displayed.

This patch changes the implementation. It displays the pkey only if
the architecture support pkeys, i.e arch_pkeys_enabled() returns true.

x86 arch_show_smap() function is not needed anymore, delete it.

Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
[mpe: Split out from larger patch, rebased on header changes]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/x86/kernel/setup.c | 8 --------
 fs/proc/task_mmu.c      | 8 +++-----
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 5c623dfe39d1..2f86d883dd95 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1312,11 +1312,3 @@ 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 c2163606e6fb..93cea7b07a80 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -18,6 +18,7 @@
 #include <linux/page_idle.h>
 #include <linux/shmem_fs.h>
 #include <linux/uaccess.h>
+#include <linux/pkeys.h>
 
 #include <asm/elf.h>
 #include <asm/tlb.h>
@@ -730,10 +731,6 @@ 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)
-{
-}
-
 #define SEQ_PUT_DEC(str, val) \
 		seq_put_decimal_ull_width(m, str, (val) >> 10, 8)
 static int show_smap(struct seq_file *m, void *v, int is_pid)
@@ -838,7 +835,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 		seq_puts(m, " kB\n");
 	}
 	if (!rollup_mode) {
-		arch_show_smap(m, vma);
+		if (arch_pkeys_enabled())
+			seq_printf(m, "ProtectionKey:  %8u\n", vma_pkey(vma));
 		show_smap_vma_flags(m, vma);
 	}
 	m_cache_vma(m, vma);
-- 
2.14.1

  parent reply	other threads:[~2018-05-08 15:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 14:59 [PATCH 0/8] mm, x86, powerpc: Consolidate pkey code Michael Ellerman
2018-05-08 14:59 ` [PATCH 1/8] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Michael Ellerman
2018-05-08 14:59 ` [PATCH 2/8] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey Michael Ellerman
2018-05-08 16:18   ` Ram Pai
2018-05-08 14:59 ` [PATCH 3/8] mm/pkeys: Remove include of asm/mmu_context.h from pkeys.h Michael Ellerman
2018-05-08 14:59 ` [PATCH 4/8] mm/pkeys, powerpc, x86: Provide an empty vma_pkey() in linux/pkeys.h Michael Ellerman
2018-05-08 16:27   ` Ram Pai
2018-05-08 16:45   ` Dave Hansen
2018-05-08 14:59 ` [PATCH 5/8] x86/pkeys: Move vma_pkey() into asm/pkeys.h Michael Ellerman
2018-05-08 16:45   ` Dave Hansen
2018-05-09  1:56     ` Michael Ellerman
2018-05-08 14:59 ` [PATCH 6/8] x86/pkeys: Add arch_pkeys_enabled() Michael Ellerman
2018-05-08 14:59 ` [PATCH 7/8] mm/pkeys: Add an empty arch_pkeys_enabled() Michael Ellerman
2018-05-08 14:59 ` Michael Ellerman [this message]
2018-05-08 16:47   ` [PATCH 8/8] mm/pkeys, x86, powerpc: Display pkey in smaps if arch supports pkeys Dave Hansen
2018-05-09  1:57     ` Michael Ellerman
2018-05-10 13:54   ` [PATCH 9/8] powerpc/pkeys: Drop private VM_PKEY definitions Michael Ellerman
2018-05-10 20:24     ` Ram Pai

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=20180508145948.9492-9-mpe@ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=linuxram@us.ibm.com \
    --cc=mingo@redhat.com \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH 8/8] mm/pkeys, x86, powerpc: Display pkey in smaps if arch supports pkeys' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).