--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
-@@ -775,13 +775,12 @@ static int patch_return(void *addr, stru
+@@ -778,13 +778,12 @@ static int patch_return(void *addr, stru
{
int i = 0;
bytes[i++] = RET_INSN_OPCODE;
}
-@@ -794,6 +793,14 @@ void __init_or_module noinline apply_ret
+@@ -797,6 +796,14 @@ void __init_or_module noinline apply_ret
{
s32 *s;
Tested-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+[ pawan: backport: Bring ITS dynamic thunk code under CONFIG_MODULES ]
+Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
- arch/x86/kernel/alternative.c | 6 ++++++
- 1 file changed, 6 insertions(+)
+ arch/x86/kernel/alternative.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
-@@ -402,7 +402,9 @@ static int emit_indirect(int op, int reg
+@@ -402,6 +402,7 @@ static int emit_indirect(int op, int reg
#ifdef CONFIG_MITIGATION_ITS
+#ifdef CONFIG_MODULES
static struct module *its_mod;
-+#endif
static void *its_page;
static unsigned int its_offset;
+@@ -518,6 +519,14 @@ static void *its_allocate_thunk(int reg)
-@@ -423,6 +425,7 @@ static void *its_init_thunk(void *thunk,
return thunk;
}
-
-+#ifdef CONFIG_MODULES
- void its_init_mod(struct module *mod)
- {
- if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
-@@ -462,6 +465,7 @@ void its_free_mod(struct module *mod)
- }
- kfree(mod->its_page_array);
- }
++#else /* CONFIG_MODULES */
++
++static void *its_allocate_thunk(int reg)
++{
++ return NULL;
++}
++
+#endif /* CONFIG_MODULES */
- DEFINE_FREE(its_execmem, void *, if (_T) module_memfree(_T));
-
-@@ -472,6 +476,7 @@ static void *its_alloc(void)
- if (!page)
- return NULL;
-
-+#ifdef CONFIG_MODULES
- if (its_mod) {
- void *tmp = krealloc(its_mod->its_page_array,
- (its_mod->its_num_pages+1) * sizeof(void *),
-@@ -482,6 +487,7 @@ static void *its_alloc(void)
- its_mod->its_page_array = tmp;
- its_mod->its_page_array[its_mod->its_num_pages++] = page;
- }
-+#endif /* CONFIG_MODULES */
-
- return no_free_ptr(page);
- }
+ static int __emit_trampoline(void *addr, struct insn *insn, u8 *bytes,
+ void *call_dest, void *jmp_dest)
#if defined(CONFIG_RETHUNK) && defined(CONFIG_OBJTOOL)
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
-@@ -250,6 +250,13 @@ static void *its_allocate_thunk(int reg)
- return thunk;
- }
+@@ -1449,6 +1449,13 @@ static void __apply_fineibt(s32 *start_r
+ static void poison_cfi(void *addr) { }
+ #endif
+u8 *its_static_thunk(int reg)
+{
+
#endif
- /*
+ void apply_fineibt(s32 *start_retpoline, s32 *end_retpoline,
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -475,7 +475,7 @@ static void emit_indirect_jump(u8 **ppro