Skip to content

Commit

Permalink
x86/its: Fix build errors when CONFIG_MODULES=n
Browse files Browse the repository at this point in the history
Fix several build errors when CONFIG_MODULES=n, including the following:

../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
  195 |         for (int i = 0; i < mod->its_num_pages; i++) {

Fixes: 872df34 ("x86/its: Use dynamic thunks for indirect branches")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
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>
  • Loading branch information
Eric Biggers authored and Linus Torvalds committed May 13, 2025
1 parent 405e6c3 commit 9f35e33
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kernel/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ static bool cfi_paranoid __ro_after_init;

#ifdef CONFIG_MITIGATION_ITS

#ifdef CONFIG_MODULES
static struct module *its_mod;
#endif
static void *its_page;
static unsigned int its_offset;

Expand Down Expand Up @@ -171,6 +173,7 @@ static void *its_init_thunk(void *thunk, int reg)
return thunk + offset;
}

#ifdef CONFIG_MODULES
void its_init_mod(struct module *mod)
{
if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
Expand Down Expand Up @@ -209,6 +212,7 @@ void its_free_mod(struct module *mod)
}
kfree(mod->its_page_array);
}
#endif /* CONFIG_MODULES */

static void *its_alloc(void)
{
Expand All @@ -217,6 +221,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 *),
Expand All @@ -229,6 +234,7 @@ static void *its_alloc(void)

execmem_make_temp_rw(page, PAGE_SIZE);
}
#endif /* CONFIG_MODULES */

return no_free_ptr(page);
}
Expand Down

0 comments on commit 9f35e33

Please sign in to comment.