[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <74d81bef-c77d-4b84-a50a-665ff852fba1@oracle.com>
Date: Tue, 13 May 2025 20:06:00 +0200
From: Alexandre Chartre <alexandre.chartre@...cle.com>
To: Eric Biggers <ebiggers@...nel.org>, x86@...nel.org
Cc: alexandre.chartre@...cle.com, Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] x86/its: Fix build errors when CONFIG_MODULES=n
On 5/13/25 04:58, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@...gle.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@...r.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@...gle.com>
> ---
> arch/x86/kernel/alternative.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
Reviewed-by: Alexandre Chartre <alexandre.chartre@...cle.com>
alex.
> 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
Powered by blists - more mailing lists