linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys.
@ 2018-01-30 19:44 Ram Pai
  2018-01-30 19:44 ` [PATCH v11 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Ram Pai
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Ram Pai @ 2018-01-30 19:44 UTC (permalink / raw)
  To: mpe, mingo, akpm
  Cc: linuxppc-dev, linux-mm, x86, linux-arch, linux-kernel,
	dave.hansen, benh, paulus, khandual, aneesh.kumar, bsingharora,
	hbabu, mhocko, bauerman, ebiederm, linuxram, corbet, arnd,
	fweimer, msuchanek

This patch series provides arch-neutral enhancements to
enable memory-keys on new architecutes, and the corresponding
changes in x86 and powerpc specific code to support that.

a) Provides ability to support upto 32 keys.  PowerPC
	can handle 32 keys and hence needs this.

b) Arch-neutral code; and not the arch-specific code,
   determines the format of the string, that displays the key
   for each vma in smaps.

PowerPC implementation of memory-keys is now in powerpc/next tree.
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=92e3da3cf193fd27996909956c12a23c0333da44

History:
-------
version v11:
	(1) code that displays key in smaps is not any more
		defined under CONFIG_ARCH_HAS_PKEYS.
       	    - Comment by Eric W. Biederman and Michal Hocko
	(2) merged two patches that implemented (1).
		- comment by Michal Hocko

version prior to v11:
	(1) used one additional bit from VM_HIGH_ARCH_*
       		to support 32 keys.
	    - Suggestion by Dave Hansen.
	(2) powerpc specific changes to support memory keys.

Ram Pai (3):
  mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS
    is enabled
  mm, powerpc, x86: introduce an additional vma bit for powerpc pkey
  mm, x86: display pkey in smaps only if arch supports pkeys

 arch/x86/include/asm/pkeys.h |    1 +
 arch/x86/kernel/fpu/xstate.c |    5 +++++
 arch/x86/kernel/setup.c      |    8 --------
 fs/proc/task_mmu.c           |   14 +++++++-------
 include/linux/mm.h           |   12 +++++++-----
 include/linux/pkeys.h        |    6 ++++++
 6 files changed, 26 insertions(+), 20 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v11 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled
  2018-01-30 19:44 [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ram Pai
@ 2018-01-30 19:44 ` Ram Pai
  2018-01-30 19:44 ` [PATCH v11 2/3] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey Ram Pai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Ram Pai @ 2018-01-30 19:44 UTC (permalink / raw)
  To: mpe, mingo, akpm
  Cc: linuxppc-dev, linux-mm, x86, linux-arch, linux-kernel,
	dave.hansen, benh, paulus, khandual, aneesh.kumar, bsingharora,
	hbabu, mhocko, bauerman, ebiederm, linuxram, corbet, arnd,
	fweimer, msuchanek

VM_PKEY_BITx are defined only if CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
is enabled. Powerpc also needs these bits. Hence lets define the
VM_PKEY_BITx bits for any architecture that enables
CONFIG_ARCH_HAS_PKEYS.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 fs/proc/task_mmu.c |    4 ++--
 include/linux/mm.h |    9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 339e4c1..b139617 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -674,13 +674,13 @@ 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
+#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
+#endif /* CONFIG_ARCH_HAS_PKEYS */
 	};
 	size_t i;
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ea818ff..01381d3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -228,15 +228,16 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
 #define VM_HIGH_ARCH_4	BIT(VM_HIGH_ARCH_BIT_4)
 #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
 
-#if defined(CONFIG_X86)
-# define VM_PAT		VM_ARCH_1	/* PAT reserves whole VMA at once (x86) */
-#if defined (CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS)
+#ifdef CONFIG_ARCH_HAS_PKEYS
 # define VM_PKEY_SHIFT	VM_HIGH_ARCH_BIT_0
 # define VM_PKEY_BIT0	VM_HIGH_ARCH_0	/* A protection key is a 4-bit value */
 # define VM_PKEY_BIT1	VM_HIGH_ARCH_1
 # define VM_PKEY_BIT2	VM_HIGH_ARCH_2
 # define VM_PKEY_BIT3	VM_HIGH_ARCH_3
-#endif
+#endif /* CONFIG_ARCH_HAS_PKEYS */
+
+#if defined(CONFIG_X86)
+# define VM_PAT		VM_ARCH_1	/* PAT reserves whole VMA at once (x86) */
 #elif defined(CONFIG_PPC)
 # define VM_SAO		VM_ARCH_1	/* Strong Access Ordering (powerpc) */
 #elif defined(CONFIG_PARISC)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v11 2/3] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey
  2018-01-30 19:44 [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ram Pai
  2018-01-30 19:44 ` [PATCH v11 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Ram Pai
@ 2018-01-30 19:44 ` Ram Pai
  2018-01-30 19:44 ` [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys Ram Pai
  2018-01-31  7:07 ` [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ingo Molnar
  3 siblings, 0 replies; 10+ messages in thread
From: Ram Pai @ 2018-01-30 19:44 UTC (permalink / raw)
  To: mpe, mingo, akpm
  Cc: linuxppc-dev, linux-mm, x86, linux-arch, linux-kernel,
	dave.hansen, benh, paulus, khandual, aneesh.kumar, bsingharora,
	hbabu, mhocko, bauerman, ebiederm, linuxram, corbet, arnd,
	fweimer, msuchanek

Currently only 4bits are allocated in the vma flags to hold 16
keys. This is sufficient for x86. PowerPC  supports  32  keys,
which needs 5bits. This patch allocates an  additional bit.

Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 fs/proc/task_mmu.c |    1 +
 include/linux/mm.h |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index b139617..0edd4da 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -680,6 +680,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 		[ilog2(VM_PKEY_BIT1)]	= "",
 		[ilog2(VM_PKEY_BIT2)]	= "",
 		[ilog2(VM_PKEY_BIT3)]	= "",
+		[ilog2(VM_PKEY_BIT4)]	= "",
 #endif /* CONFIG_ARCH_HAS_PKEYS */
 	};
 	size_t i;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 01381d3..ebcb997 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -231,9 +231,10 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
 #ifdef CONFIG_ARCH_HAS_PKEYS
 # define VM_PKEY_SHIFT	VM_HIGH_ARCH_BIT_0
 # define VM_PKEY_BIT0	VM_HIGH_ARCH_0	/* A protection key is a 4-bit value */
-# define VM_PKEY_BIT1	VM_HIGH_ARCH_1
+# define VM_PKEY_BIT1	VM_HIGH_ARCH_1	/* on x86 and 5-bit value on ppc64   */
 # define VM_PKEY_BIT2	VM_HIGH_ARCH_2
 # define VM_PKEY_BIT3	VM_HIGH_ARCH_3
+# define VM_PKEY_BIT4	VM_HIGH_ARCH_4
 #endif /* CONFIG_ARCH_HAS_PKEYS */
 
 #if defined(CONFIG_X86)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys
  2018-01-30 19:44 [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ram Pai
  2018-01-30 19:44 ` [PATCH v11 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Ram Pai
  2018-01-30 19:44 ` [PATCH v11 2/3] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey Ram Pai
@ 2018-01-30 19:44 ` Ram Pai
  2018-01-31 13:34   ` Michal Hocko
  2018-02-02  4:27   ` kbuild test robot
  2018-01-31  7:07 ` [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ingo Molnar
  3 siblings, 2 replies; 10+ messages in thread
From: Ram Pai @ 2018-01-30 19:44 UTC (permalink / raw)
  To: mpe, mingo, akpm
  Cc: linuxppc-dev, linux-mm, x86, linux-arch, linux-kernel,
	dave.hansen, benh, paulus, khandual, aneesh.kumar, bsingharora,
	hbabu, mhocko, bauerman, ebiederm, linuxram, corbet, arnd,
	fweimer, msuchanek

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.  This patch
provides x86 implementation for arch_pkeys_enabled().

x86 arch_show_smap() function is not needed anymore.
Deleting it.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 arch/x86/include/asm/pkeys.h |    1 +
 arch/x86/kernel/fpu/xstate.c |    5 +++++
 arch/x86/kernel/setup.c      |    8 --------
 fs/proc/task_mmu.c           |    9 ++++-----
 include/linux/pkeys.h        |    6 ++++++
 5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h
index a0ba1ff..f6c287b 100644
--- a/arch/x86/include/asm/pkeys.h
+++ b/arch/x86/include/asm/pkeys.h
@@ -6,6 +6,7 @@
 
 extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
 		unsigned long init_val);
+extern bool arch_pkeys_enabled(void);
 
 /*
  * Try to dedicate one of the protection keys to be used as an
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 87a57b7..4f566e9 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -945,6 +945,11 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
 
 	return 0;
 }
+
+bool arch_pkeys_enabled(void)
+{
+	return boot_cpu_has(X86_FEATURE_OSPKE);
+}
 #endif /* ! CONFIG_ARCH_HAS_PKEYS */
 
 /*
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 8af2e8d..ddf945a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1326,11 +1326,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 0edd4da..6f9fbde 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>
@@ -728,10 +729,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)
-{
-}
-
 static int show_smap(struct seq_file *m, void *v, int is_pid)
 {
 	struct proc_maps_private *priv = m->private;
@@ -851,9 +848,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
 			   (unsigned long)(mss->pss >> (10 + PSS_SHIFT)));
 
 	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);
 	return ret;
 }
diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h
index 0794ca7..dfdc609 100644
--- a/include/linux/pkeys.h
+++ b/include/linux/pkeys.h
@@ -13,6 +13,7 @@
 #define arch_override_mprotect_pkey(vma, prot, pkey) (0)
 #define PKEY_DEDICATED_EXECUTE_ONLY 0
 #define ARCH_VM_PKEY_FLAGS 0
+#define vma_pkey(vma) 0
 
 static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
 {
@@ -35,6 +36,11 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
 	return 0;
 }
 
+static inline bool arch_pkeys_enabled(void)
+{
+	return false;
+}
+
 static inline void copy_init_pkru_to_fpregs(void)
 {
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys.
  2018-01-30 19:44 [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ram Pai
                   ` (2 preceding siblings ...)
  2018-01-30 19:44 ` [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys Ram Pai
@ 2018-01-31  7:07 ` Ingo Molnar
  2018-02-01  2:55   ` Michael Ellerman
  3 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2018-01-31  7:07 UTC (permalink / raw)
  To: Ram Pai
  Cc: mpe, mingo, akpm, linuxppc-dev, linux-mm, x86, linux-arch,
	linux-kernel, dave.hansen, benh, paulus, khandual, aneesh.kumar,
	bsingharora, hbabu, mhocko, bauerman, ebiederm, corbet, arnd,
	fweimer, msuchanek


* Ram Pai <linuxram@us.ibm.com> wrote:

> This patch series provides arch-neutral enhancements to
> enable memory-keys on new architecutes, and the corresponding
> changes in x86 and powerpc specific code to support that.
> 
> a) Provides ability to support upto 32 keys.  PowerPC
> 	can handle 32 keys and hence needs this.
> 
> b) Arch-neutral code; and not the arch-specific code,
>    determines the format of the string, that displays the key
>    for each vma in smaps.
> 
> PowerPC implementation of memory-keys is now in powerpc/next tree.
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=92e3da3cf193fd27996909956c12a23c0333da44

All three patches look sane to me. If you would like to carry these generic bits 
in the PowerPC tree as well then:

  Reviewed-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys
  2018-01-30 19:44 ` [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys Ram Pai
@ 2018-01-31 13:34   ` Michal Hocko
  2018-02-02  4:27   ` kbuild test robot
  1 sibling, 0 replies; 10+ messages in thread
From: Michal Hocko @ 2018-01-31 13:34 UTC (permalink / raw)
  To: Ram Pai
  Cc: mpe, mingo, akpm, linuxppc-dev, linux-mm, x86, linux-arch,
	linux-kernel, dave.hansen, benh, paulus, khandual, aneesh.kumar,
	bsingharora, hbabu, bauerman, ebiederm, corbet, arnd, fweimer,
	msuchanek

On Tue 30-01-18 11:44:12, Ram Pai wrote:
> 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.  This patch
> provides x86 implementation for arch_pkeys_enabled().
> 
> x86 arch_show_smap() function is not needed anymore.
> Deleting it.

Thanks for reworking this patch. Looks good to me.

> Signed-off-by: Ram Pai <linuxram@us.ibm.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  arch/x86/include/asm/pkeys.h |    1 +
>  arch/x86/kernel/fpu/xstate.c |    5 +++++
>  arch/x86/kernel/setup.c      |    8 --------
>  fs/proc/task_mmu.c           |    9 ++++-----
>  include/linux/pkeys.h        |    6 ++++++
>  5 files changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h
> index a0ba1ff..f6c287b 100644
> --- a/arch/x86/include/asm/pkeys.h
> +++ b/arch/x86/include/asm/pkeys.h
> @@ -6,6 +6,7 @@
>  
>  extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
>  		unsigned long init_val);
> +extern bool arch_pkeys_enabled(void);
>  
>  /*
>   * Try to dedicate one of the protection keys to be used as an
> diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
> index 87a57b7..4f566e9 100644
> --- a/arch/x86/kernel/fpu/xstate.c
> +++ b/arch/x86/kernel/fpu/xstate.c
> @@ -945,6 +945,11 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
>  
>  	return 0;
>  }
> +
> +bool arch_pkeys_enabled(void)
> +{
> +	return boot_cpu_has(X86_FEATURE_OSPKE);
> +}
>  #endif /* ! CONFIG_ARCH_HAS_PKEYS */
>  
>  /*
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index 8af2e8d..ddf945a 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -1326,11 +1326,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 0edd4da..6f9fbde 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>
> @@ -728,10 +729,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)
> -{
> -}
> -
>  static int show_smap(struct seq_file *m, void *v, int is_pid)
>  {
>  	struct proc_maps_private *priv = m->private;
> @@ -851,9 +848,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
>  			   (unsigned long)(mss->pss >> (10 + PSS_SHIFT)));
>  
>  	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);
>  	return ret;
>  }
> diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h
> index 0794ca7..dfdc609 100644
> --- a/include/linux/pkeys.h
> +++ b/include/linux/pkeys.h
> @@ -13,6 +13,7 @@
>  #define arch_override_mprotect_pkey(vma, prot, pkey) (0)
>  #define PKEY_DEDICATED_EXECUTE_ONLY 0
>  #define ARCH_VM_PKEY_FLAGS 0
> +#define vma_pkey(vma) 0
>  
>  static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
>  {
> @@ -35,6 +36,11 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
>  	return 0;
>  }
>  
> +static inline bool arch_pkeys_enabled(void)
> +{
> +	return false;
> +}
> +
>  static inline void copy_init_pkru_to_fpregs(void)
>  {
>  }
> -- 
> 1.7.1

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys.
  2018-01-31  7:07 ` [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ingo Molnar
@ 2018-02-01  2:55   ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2018-02-01  2:55 UTC (permalink / raw)
  To: Ingo Molnar, Ram Pai
  Cc: mingo, akpm, linuxppc-dev, linux-mm, x86, linux-arch,
	linux-kernel, dave.hansen, benh, paulus, khandual, aneesh.kumar,
	bsingharora, hbabu, mhocko, bauerman, ebiederm, corbet, arnd,
	fweimer, msuchanek

Ingo Molnar <mingo@kernel.org> writes:

> * Ram Pai <linuxram@us.ibm.com> wrote:
>
>> This patch series provides arch-neutral enhancements to
>> enable memory-keys on new architecutes, and the corresponding
>> changes in x86 and powerpc specific code to support that.
>> 
>> a) Provides ability to support upto 32 keys.  PowerPC
>> 	can handle 32 keys and hence needs this.
>> 
>> b) Arch-neutral code; and not the arch-specific code,
>>    determines the format of the string, that displays the key
>>    for each vma in smaps.
>> 
>> PowerPC implementation of memory-keys is now in powerpc/next tree.
>> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=92e3da3cf193fd27996909956c12a23c0333da44
>
> All three patches look sane to me. If you would like to carry these generic bits 
> in the PowerPC tree as well then:
>
>   Reviewed-by: Ingo Molnar <mingo@kernel.org>

Thanks.

I'll put them in powerpc next and probably send to Linus next week in a
2nd pull request for 4.16.

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys
  2018-01-30 19:44 ` [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys Ram Pai
  2018-01-31 13:34   ` Michal Hocko
@ 2018-02-02  4:27   ` kbuild test robot
  2018-02-02  7:21     ` Ram Pai
  1 sibling, 1 reply; 10+ messages in thread
From: kbuild test robot @ 2018-02-02  4:27 UTC (permalink / raw)
  To: Ram Pai
  Cc: kbuild-all, mpe, mingo, akpm, linuxppc-dev, linux-mm, x86,
	linux-arch, linux-kernel, dave.hansen, benh, paulus, khandual,
	aneesh.kumar, bsingharora, hbabu, mhocko, bauerman, ebiederm,
	linuxram, corbet, arnd, fweimer, msuchanek

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]

Hi Ram,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.15 next-20180201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ram-Pai/mm-x86-powerpc-Enhancements-to-Memory-Protection-Keys/20180202-120004
config: x86_64-randconfig-x005-201804 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from arch/x86/include/asm/mmu_context.h:8:0,
                    from arch/x86/events/core.c:36:
>> include/linux/pkeys.h:16:23: error: expected identifier or '(' before numeric constant
    #define vma_pkey(vma) 0
                          ^
>> arch/x86/include/asm/mmu_context.h:298:19: note: in expansion of macro 'vma_pkey'
    static inline int vma_pkey(struct vm_area_struct *vma)
                      ^~~~~~~~

vim +16 include/linux/pkeys.h

     7	
     8	#ifdef CONFIG_ARCH_HAS_PKEYS
     9	#include <asm/pkeys.h>
    10	#else /* ! CONFIG_ARCH_HAS_PKEYS */
    11	#define arch_max_pkey() (1)
    12	#define execute_only_pkey(mm) (0)
    13	#define arch_override_mprotect_pkey(vma, prot, pkey) (0)
    14	#define PKEY_DEDICATED_EXECUTE_ONLY 0
    15	#define ARCH_VM_PKEY_FLAGS 0
  > 16	#define vma_pkey(vma) 0
    17	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30449 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys
  2018-02-02  4:27   ` kbuild test robot
@ 2018-02-02  7:21     ` Ram Pai
  2018-02-06  5:51       ` Michael Ellerman
  0 siblings, 1 reply; 10+ messages in thread
From: Ram Pai @ 2018-02-02  7:21 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, mpe, mingo, akpm, linuxppc-dev, linux-mm, x86,
	linux-arch, linux-kernel, dave.hansen, benh, paulus, khandual,
	aneesh.kumar, bsingharora, hbabu, mhocko, bauerman, ebiederm,
	corbet, arnd, fweimer, msuchanek

On Fri, Feb 02, 2018 at 12:27:27PM +0800, kbuild test robot wrote:
> Hi Ram,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.15 next-20180201]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_0day-2Dci_linux_commits_Ram-2DPai_mm-2Dx86-2Dpowerpc-2DEnhancements-2Dto-2DMemory-2DProtection-2DKeys_20180202-2D120004&d=DwIBAg&c=jf_iaSHvJObTbx-siA1ZOg&r=m-UrKChQVkZtnPpjbF6YY99NbT8FBByQ-E-ygV8luxw&m=Fv3tEHet1bTUrDjOnzEhXvGM_4tGlkYhJHPBnWNWgVA&s=Z1W6CV2tfPmLYU8lVv1oDRl2cAyQA76KE2P064A2CQY&e=
> config: x86_64-randconfig-x005-201804 (attached as .config)
> compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from arch/x86/include/asm/mmu_context.h:8:0,
>                     from arch/x86/events/core.c:36:
> >> include/linux/pkeys.h:16:23: error: expected identifier or '(' before numeric constant
>     #define vma_pkey(vma) 0
>                           ^
> >> arch/x86/include/asm/mmu_context.h:298:19: note: in expansion of macro 'vma_pkey'
>     static inline int vma_pkey(struct vm_area_struct *vma)
>                       ^~~~~~~~
> 
> vim +16 include/linux/pkeys.h
> 
>      7	
>      8	#ifdef CONFIG_ARCH_HAS_PKEYS
>      9	#include <asm/pkeys.h>
>     10	#else /* ! CONFIG_ARCH_HAS_PKEYS */
>     11	#define arch_max_pkey() (1)
>     12	#define execute_only_pkey(mm) (0)
>     13	#define arch_override_mprotect_pkey(vma, prot, pkey) (0)
>     14	#define PKEY_DEDICATED_EXECUTE_ONLY 0
>     15	#define ARCH_VM_PKEY_FLAGS 0
>   > 16	#define vma_pkey(vma) 0

Oops. Thanks for catching the issue. The following fix will resolve the error.

diff --git a/arch/x86/include/asm/mmu_context.h
b/arch/x86/include/asm/mmu_context.h
index 6d16d15..c1aeb19 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -238,11 +238,6 @@ static inline int vma_pkey(struct vm_area_struct
		*vma)
 
        return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
}
-#else
-static inline int vma_pkey(struct vm_area_struct *vma)
-{
-       return 0;
-}
 #endif

RP

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys
  2018-02-02  7:21     ` Ram Pai
@ 2018-02-06  5:51       ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2018-02-06  5:51 UTC (permalink / raw)
  To: Ram Pai, kbuild test robot
  Cc: kbuild-all, mingo, akpm, linuxppc-dev, linux-mm, x86, linux-arch,
	linux-kernel, dave.hansen, benh, paulus, khandual, aneesh.kumar,
	bsingharora, hbabu, mhocko, bauerman, ebiederm, corbet, arnd,
	fweimer, msuchanek

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

> On Fri, Feb 02, 2018 at 12:27:27PM +0800, kbuild test robot wrote:
>> Hi Ram,
>> 
>> Thank you for the patch! Yet something to improve:
>> 
>> [auto build test ERROR on linus/master]
>> [also build test ERROR on v4.15 next-20180201]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>> 
>> url:    https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_0day-2Dci_linux_commits_Ram-2DPai_mm-2Dx86-2Dpowerpc-2DEnhancements-2Dto-2DMemory-2DProtection-2DKeys_20180202-2D120004&d=DwIBAg&c=jf_iaSHvJObTbx-siA1ZOg&r=m-UrKChQVkZtnPpjbF6YY99NbT8FBByQ-E-ygV8luxw&m=Fv3tEHet1bTUrDjOnzEhXvGM_4tGlkYhJHPBnWNWgVA&s=Z1W6CV2tfPmLYU8lVv1oDRl2cAyQA76KE2P064A2CQY&e=
>> config: x86_64-randconfig-x005-201804 (attached as .config)
>> compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
>> reproduce:
>>         # save the attached .config to linux build tree
>>         make ARCH=x86_64 
>> 
>> All error/warnings (new ones prefixed by >>):
>> 
>>    In file included from arch/x86/include/asm/mmu_context.h:8:0,
>>                     from arch/x86/events/core.c:36:
>> >> include/linux/pkeys.h:16:23: error: expected identifier or '(' before numeric constant
>>     #define vma_pkey(vma) 0
>>                           ^
>> >> arch/x86/include/asm/mmu_context.h:298:19: note: in expansion of macro 'vma_pkey'
>>     static inline int vma_pkey(struct vm_area_struct *vma)
>>                       ^~~~~~~~
>> 
>> vim +16 include/linux/pkeys.h
>> 
>>      7	
>>      8	#ifdef CONFIG_ARCH_HAS_PKEYS
>>      9	#include <asm/pkeys.h>
>>     10	#else /* ! CONFIG_ARCH_HAS_PKEYS */
>>     11	#define arch_max_pkey() (1)
>>     12	#define execute_only_pkey(mm) (0)
>>     13	#define arch_override_mprotect_pkey(vma, prot, pkey) (0)
>>     14	#define PKEY_DEDICATED_EXECUTE_ONLY 0
>>     15	#define ARCH_VM_PKEY_FLAGS 0
>>   > 16	#define vma_pkey(vma) 0
>
> Oops. Thanks for catching the issue. The following fix will resolve the error.
>
> diff --git a/arch/x86/include/asm/mmu_context.h
> b/arch/x86/include/asm/mmu_context.h
> index 6d16d15..c1aeb19 100644
> --- a/arch/x86/include/asm/mmu_context.h
> +++ b/arch/x86/include/asm/mmu_context.h
> @@ -238,11 +238,6 @@ static inline int vma_pkey(struct vm_area_struct
> 		*vma)
>  
>         return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
> }
> -#else
> -static inline int vma_pkey(struct vm_area_struct *vma)
> -{
> -       return 0;
> -}
>  #endif

That's not working for me (i386_defconfig):

  In file included from ../include/linux/pkeys.h:6:0,
                   from ../arch/x86/kernel/fpu/xstate.c:9:
  ../arch/x86/include/asm/mmu_context.h: In function ‘arch_vma_access_permitted’:
  ../arch/x86/include/asm/mmu_context.h:276:28: error: implicit declaration of function ‘vma_pkey’ [-Werror=implicit-function-declaration]
    return __pkru_allows_pkey(vma_pkey(vma), write);
                              ^~~~~~~~
  In file included from ../include/linux/pkeys.h:6:0,
                   from ../fs/proc/task_mmu.c:21:
  ../arch/x86/include/asm/mmu_context.h: In function ‘arch_vma_access_permitted’:
  ../arch/x86/include/asm/mmu_context.h:276:28: error: implicit declaration of function ‘vma_pkey’ [-Werror=implicit-function-declaration]
    return __pkru_allows_pkey(vma_pkey(vma), write);
                              ^~~~~~~~
  In file included from ../include/linux/pkeys.h:6:0,
                   from ../mm/mmap.c:46:
  ../arch/x86/include/asm/mmu_context.h: In function ‘arch_vma_access_permitted’:
  ../arch/x86/include/asm/mmu_context.h:276:28: error: implicit declaration of function ‘vma_pkey’ [-Werror=implicit-function-declaration]
    return __pkru_allows_pkey(vma_pkey(vma), write);
                              ^~~~~~~~
  In file included from ../include/linux/pkeys.h:6:0,
                   from ../mm/mprotect.c:27:
  ../arch/x86/include/asm/mmu_context.h: In function ‘arch_vma_access_permitted’:
  ../arch/x86/include/asm/mmu_context.h:276:28: error: implicit declaration of function ‘vma_pkey’ [-Werror=implicit-function-declaration]
    return __pkru_allows_pkey(vma_pkey(vma), write);
                              ^~~~~~~~
  In file included from ../include/linux/pkeys.h:6:0,
                   from ../arch/x86/kernel/fpu/core.c:15:
  ../arch/x86/include/asm/mmu_context.h: In function ‘arch_vma_access_permitted’:
  ../arch/x86/include/asm/mmu_context.h:276:28: error: implicit declaration of function ‘vma_pkey’ [-Werror=implicit-function-declaration]
    return __pkru_allows_pkey(vma_pkey(vma), write);
                              ^~~~~~~~

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-02-06  5:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-30 19:44 [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ram Pai
2018-01-30 19:44 ` [PATCH v11 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Ram Pai
2018-01-30 19:44 ` [PATCH v11 2/3] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey Ram Pai
2018-01-30 19:44 ` [PATCH v11 3/3] mm, x86: display pkey in smaps only if arch supports pkeys Ram Pai
2018-01-31 13:34   ` Michal Hocko
2018-02-02  4:27   ` kbuild test robot
2018-02-02  7:21     ` Ram Pai
2018-02-06  5:51       ` Michael Ellerman
2018-01-31  7:07 ` [PATCH v11 0/3] mm, x86, powerpc: Enhancements to Memory Protection Keys Ingo Molnar
2018-02-01  2:55   ` Michael Ellerman

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).