]>
Commit | Line | Data |
---|---|---|
345c7afc SL |
1 | From ac5d3cefba62b94e8d02640f85de9cf7b8a78732 Mon Sep 17 00:00:00 2001 |
2 | From: Dan Williams <dan.j.williams@intel.com> | |
3 | Date: Thu, 18 Apr 2019 17:50:44 -0700 | |
4 | Subject: init: initialize jump labels before command line option parsing | |
5 | ||
6 | [ Upstream commit 6041186a32585fc7a1d0f6cfe2f138b05fdc3c82 ] | |
7 | ||
8 | When a module option, or core kernel argument, toggles a static-key it | |
9 | requires jump labels to be initialized early. While x86, PowerPC, and | |
10 | ARM64 arrange for jump_label_init() to be called before parse_args(), | |
11 | ARM does not. | |
12 | ||
13 | Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1 | |
14 | ------------[ cut here ]------------ | |
15 | WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303 | |
16 | page_alloc_shuffle+0x12c/0x1ac | |
17 | static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used | |
18 | before call to jump_label_init() | |
19 | Modules linked in: | |
20 | CPU: 0 PID: 0 Comm: swapper Not tainted | |
21 | 5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1 | |
22 | Hardware name: ARM Integrator/CP (Device Tree) | |
23 | [<c0011c68>] (unwind_backtrace) from [<c000ec48>] (show_stack+0x10/0x18) | |
24 | [<c000ec48>] (show_stack) from [<c07e9710>] (dump_stack+0x18/0x24) | |
25 | [<c07e9710>] (dump_stack) from [<c001bb1c>] (__warn+0xe0/0x108) | |
26 | [<c001bb1c>] (__warn) from [<c001bb88>] (warn_slowpath_fmt+0x44/0x6c) | |
27 | [<c001bb88>] (warn_slowpath_fmt) from [<c0b0c4a8>] | |
28 | (page_alloc_shuffle+0x12c/0x1ac) | |
29 | [<c0b0c4a8>] (page_alloc_shuffle) from [<c0b0c550>] (shuffle_store+0x28/0x48) | |
30 | [<c0b0c550>] (shuffle_store) from [<c003e6a0>] (parse_args+0x1f4/0x350) | |
31 | [<c003e6a0>] (parse_args) from [<c0ac3c00>] (start_kernel+0x1c0/0x488) | |
32 | ||
33 | Move the fallback call to jump_label_init() to occur before | |
34 | parse_args(). | |
35 | ||
36 | The redundant calls to jump_label_init() in other archs are left intact | |
37 | in case they have static key toggling use cases that are even earlier | |
38 | than option parsing. | |
39 | ||
40 | Link: http://lkml.kernel.org/r/155544804466.1032396.13418949511615676665.stgit@dwillia2-desk3.amr.corp.intel.com | |
41 | Signed-off-by: Dan Williams <dan.j.williams@intel.com> | |
42 | Reported-by: Guenter Roeck <groeck@google.com> | |
43 | Reviewed-by: Kees Cook <keescook@chromium.org> | |
44 | Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
45 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
46 | Cc: Mike Rapoport <rppt@linux.ibm.com> | |
47 | Cc: Russell King <rmk@armlinux.org.uk> | |
48 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
49 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
50 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
51 | --- | |
52 | init/main.c | 4 ++-- | |
53 | 1 file changed, 2 insertions(+), 2 deletions(-) | |
54 | ||
55 | diff --git a/init/main.c b/init/main.c | |
56 | index 49926d95442f8..e88c8cdef6a7c 100644 | |
57 | --- a/init/main.c | |
58 | +++ b/init/main.c | |
59 | @@ -538,6 +538,8 @@ asmlinkage __visible void __init start_kernel(void) | |
60 | page_alloc_init(); | |
61 | ||
62 | pr_notice("Kernel command line: %s\n", boot_command_line); | |
63 | + /* parameters may set static keys */ | |
64 | + jump_label_init(); | |
65 | parse_early_param(); | |
66 | after_dashes = parse_args("Booting kernel", | |
67 | static_command_line, __start___param, | |
68 | @@ -547,8 +549,6 @@ asmlinkage __visible void __init start_kernel(void) | |
69 | parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, | |
70 | NULL, set_init_arg); | |
71 | ||
72 | - jump_label_init(); | |
73 | - | |
74 | /* | |
75 | * These use large bootmem allocations and must precede | |
76 | * kmem_cache_init() | |
77 | -- | |
78 | 2.20.1 | |
79 |