All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: x86@kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] x86/its: Fix build errors when CONFIG_MODULES=n
Date: Mon, 12 May 2025 19:58:39 -0700	[thread overview]
Message-ID: <20250513025839.495755-1-ebiggers@kernel.org> (raw)

From: Eric Biggers <ebiggers@google.com>

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: 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 arch/x86/kernel/alternative.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 48fd04e90114..45bcff181cba 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -131,11 +131,13 @@ const unsigned char * const x86_nops[ASM_NOP_MAX+1] =
 static bool cfi_paranoid __ro_after_init;
 #endif
 
 #ifdef CONFIG_MITIGATION_ITS
 
+#ifdef CONFIG_MODULES
 static struct module *its_mod;
+#endif
 static void *its_page;
 static unsigned int its_offset;
 
 /* Initialize a thunk with the "jmp *reg; int3" instructions. */
 static void *its_init_thunk(void *thunk, int reg)
@@ -169,10 +171,11 @@ static void *its_init_thunk(void *thunk, int reg)
 	bytes[i++] = 0xcc;
 
 	return thunk + offset;
 }
 
+#ifdef CONFIG_MODULES
 void its_init_mod(struct module *mod)
 {
 	if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
 		return;
 
@@ -207,18 +210,20 @@ void its_free_mod(struct module *mod)
 		void *page = mod->its_page_array[i];
 		execmem_free(page);
 	}
 	kfree(mod->its_page_array);
 }
+#endif /* CONFIG_MODULES */
 
 static void *its_alloc(void)
 {
 	void *page __free(execmem) = execmem_alloc(EXECMEM_MODULE_TEXT, PAGE_SIZE);
 
 	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 *),
 				     GFP_KERNEL);
 		if (!tmp)
@@ -227,10 +232,11 @@ static void *its_alloc(void)
 		its_mod->its_page_array = tmp;
 		its_mod->its_page_array[its_mod->its_num_pages++] = page;
 
 		execmem_make_temp_rw(page, PAGE_SIZE);
 	}
+#endif /* CONFIG_MODULES */
 
 	return no_free_ptr(page);
 }
 
 static void *its_allocate_thunk(int reg)

base-commit: 627277ba7c2398dc4f95cc9be8222bb2d9477800
-- 
2.49.0


             reply	other threads:[~2025-05-13  2:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13  2:58 Eric Biggers [this message]
2025-05-13 18:06 ` [PATCH] x86/its: Fix build errors when CONFIG_MODULES=n Alexandre Chartre
2025-05-13 18:15 ` Steven Rostedt
2025-05-13 18:17 ` Steven Rostedt
2025-05-13 19:23   ` Harshit Mogalapalli
2025-05-13 19:30     ` Steven Rostedt
2025-05-13 18:54 ` Dave Hansen
2025-05-13 20:32   ` Dave Hansen
2025-05-13 21:36     ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2025-05-14  4:38 Pawan Gupta
2025-05-14 20:13 ` Sasha Levin
2025-05-14  4:46 Pawan Gupta
2025-05-14  4:55 ` Pawan Gupta
2025-05-14  9:47   ` Greg KH
2025-05-14 20:13 ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250513025839.495755-1-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.