[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 6 May 2015 00:47:59 +0200
From: Borislav Petkov <bp@...en8.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Andy Lutomirski <luto@...capital.net>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Fenghua Yu <fenghua.yu@...el.com>,
"H. Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 176/208] x86/alternatives, x86/fpu: Add
'alternatives_patched' debug flag and use it in xsave_state()
On Tue, May 05, 2015 at 07:58:00PM +0200, Ingo Molnar wrote:
> We'd like to use xsave_state() earlier, but its SYSTEM_BOOTING check
> is too imprecise.
>
> The real condition that xsave_state() would like to check is whether
> alternative XSAVE instructions were patched into the kernel image
> already.
>
> Add such a (read-mostly) debug flag and use it in xsave_state().
>
> Cc: Andy Lutomirski <luto@...capital.net>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: Fenghua Yu <fenghua.yu@...el.com>
> Cc: H. Peter Anvin <hpa@...or.com>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Signed-off-by: Ingo Molnar <mingo@...nel.org>
> ---
> arch/x86/include/asm/alternative.h | 6 ++++++
> arch/x86/include/asm/fpu/xstate.h | 2 +-
> arch/x86/kernel/alternative.c | 5 +++++
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
> index ba32af062f61..7bfc85bbb8ff 100644
> --- a/arch/x86/include/asm/alternative.h
> +++ b/arch/x86/include/asm/alternative.h
> @@ -52,6 +52,12 @@ struct alt_instr {
> u8 padlen; /* length of build-time padding */
> } __packed;
>
> +/*
> + * Debug flag that can be tested to see whether alternative
> + * instructions were patched in already:
> + */
> +extern int alternatives_patched;
Looks useful...
> +
> extern void alternative_instructions(void);
> extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
>
> diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h
> index 31a002ad5aeb..ab2c507b58b6 100644
> --- a/arch/x86/include/asm/fpu/xstate.h
> +++ b/arch/x86/include/asm/fpu/xstate.h
> @@ -119,7 +119,7 @@ static inline int xsave_state(struct xsave_struct *fx)
> u32 hmask = mask >> 32;
> int err = 0;
>
> - WARN_ON(system_state == SYSTEM_BOOTING);
> + WARN_ON(!alternatives_patched);
Btw, shouldn't we be doing this check in what is called now
copy_kernel_to_xregs() too, i.e., right under this function which is now
called copy_xregs_to_kernel()?
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists