Skip to contentSkip to conversation

mm/pkeys: generate pkey system call code only if ARCH_HAS_PKEYS is selected

PATCH Applied Heiko Carstens 2 participants 2 messages Nov 14, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/pkeys: generate pkey system call code only if ARCH_HAS_PKEYS is selected

Having code for the pkey_mprotect, pkey_alloc and pkey_free system calls makes only sense if ARCH_HAS_PKEYS is selected. If not selected these system calls will always return -ENOSPC or -EINVAL.

To simplify things and have less code generate the pkey system call code only if ARCH_HAS_PKEYS is selected.

For architectures which have already wired up the system calls, but do not select ARCH_HAS_PKEYS this will result in less generated code and a different return code: the three system calls will now always return -ENOSYS, using the cond_syscall mechanism.

For architectures which have not wired up the system calls less unreachable code will be generated.

---
 mm/mprotect.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/mprotect.c +4 -0
index 11936526b08b..a06e91c4de29 100644
@@ -484,6 +484,8 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 	return do_mprotect_pkey(start, len, prot, -1);
 }
 
+#ifdef CONFIG_ARCH_HAS_PKEYS
+
 SYSCALL_DEFINE4(pkey_mprotect, unsigned long, start, size_t, len,
 		unsigned long, prot, int, pkey)
 {
@@ -534,3 +536,5 @@ SYSCALL_DEFINE1(pkey_free, int, pkey)
 	 */
 	return ret;
 }
+
+#endif /* CONFIG_ARCH_HAS_PKEYS */
Signature · 1 line
2.8.4
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Heiko Carstens

Having code for the pkey_mprotect, pkey_alloc and pkey_free system calls makes only sense if ARCH_HAS_PKEYS is selected. If not selected these system calls will always return -ENOSPC or -EINVAL.

To simplify things and have less code generate the pkey system call code only if ARCH_HAS_PKEYS is selected.

For architectures which have already wired up the system calls, but do not select ARCH_HAS_PKEYS this will result in less generated code and a different return code: the three system calls will now always return -ENOSYS, using the cond_syscall mechanism.

Quoted 4 lines

For architectures which have not wired up the system calls less unreachable code will be generated.

This is fine with me. FWIW:

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>