* [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 [not found] <1507089272-32733-1-git-send-email-ricardo.neri-calderon@linux.intel.com> @ 2017-10-04 3:54 ` Ricardo Neri 2017-10-26 7:51 ` Andy Lutomirski 0 siblings, 1 reply; 6+ messages in thread From: Ricardo Neri @ 2017-10-04 3:54 UTC (permalink / raw) To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andy Lutomirski, Borislav Petkov Cc: Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Liang Z Li, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel, x86, ricardo.neri, Ricardo Neri, Andy Lutomirski, Borislav Petkov, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm Both head_32.S and head_64.S utilize the same value to initialize the control register CR0. Also, other parts of the kernel might want to access this initial definition (e.g., emulation code for User-Mode Instruction Prevention uses this state to provide a sane dummy value for CR0 when emulating the smsw instruction). Thus, relocate this definition to a header file from which it can be conveniently accessed. Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Suggested-by: Borislav Petkov <bp@alien8.de> Reviewed-by: Borislav Petkov <bp@suse.de> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> --- arch/x86/include/uapi/asm/processor-flags.h | 3 +++ arch/x86/kernel/head_32.S | 3 --- arch/x86/kernel/head_64.S | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h index 185f3d1..39946d0 100644 --- a/arch/x86/include/uapi/asm/processor-flags.h +++ b/arch/x86/include/uapi/asm/processor-flags.h @@ -151,5 +151,8 @@ #define CX86_ARR_BASE 0xc4 #define CX86_RCR_BASE 0xdc +#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \ + X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \ + X86_CR0_PG) #endif /* _UAPI_ASM_X86_PROCESSOR_FLAGS_H */ diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index 9ed3074..c3cfc65 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S @@ -211,9 +211,6 @@ ENTRY(startup_32_smp) #endif .Ldefault_entry: -#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \ - X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \ - X86_CR0_PG) movl $(CR0_STATE & ~X86_CR0_PG),%eax movl %eax,%cr0 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 42e32c2..205dabc 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -152,9 +152,6 @@ ENTRY(secondary_startup_64) 1: wrmsr /* Make changes effective */ /* Setup cr0 */ -#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \ - X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \ - X86_CR0_PG) movl $CR0_STATE, %eax /* Make changes effective */ movq %rax, %cr0 -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 2017-10-04 3:54 ` [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 Ricardo Neri @ 2017-10-26 7:51 ` Andy Lutomirski 2017-10-26 9:00 ` Borislav Petkov 0 siblings, 1 reply; 6+ messages in thread From: Andy Lutomirski @ 2017-10-26 7:51 UTC (permalink / raw) To: Ricardo Neri Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andy Lutomirski, Borislav Petkov, Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Liang Z Li, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel@vger.kernel.org, X86 ML, Neri, Ricardo, Borislav Petkov, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm@kvack.org On Tue, Oct 3, 2017 at 8:54 PM, Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote: > Both head_32.S and head_64.S utilize the same value to initialize the > control register CR0. Also, other parts of the kernel might want to access > this initial definition (e.g., emulation code for User-Mode Instruction > Prevention uses this state to provide a sane dummy value for CR0 when > emulating the smsw instruction). Thus, relocate this definition to a > header file from which it can be conveniently accessed. Reviewed-by: Andy Lutomirski <luto@kernel.org> with the slight caveat that I think it might be a wee bit better if UMIP emulation used a separate define UMIP_REPORTED_CR0. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 2017-10-26 7:51 ` Andy Lutomirski @ 2017-10-26 9:00 ` Borislav Petkov 2017-10-26 9:02 ` Andy Lutomirski 0 siblings, 1 reply; 6+ messages in thread From: Borislav Petkov @ 2017-10-26 9:00 UTC (permalink / raw) To: Andy Lutomirski Cc: Ricardo Neri, Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Liang Z Li, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel@vger.kernel.org, X86 ML, Neri, Ricardo, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm@kvack.org On Thu, Oct 26, 2017 at 12:51:25AM -0700, Andy Lutomirski wrote: > with the slight caveat that I think it might be a wee bit better if > UMIP emulation used a separate define UMIP_REPORTED_CR0. Why, do you see CR0_STATE and UMIP_REPORTED_CR0 becoming different at some point? -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix ImendA?rffer, Jane Smithard, Graham Norton, HRB 21284 (AG NA 1/4 rnberg) -- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 2017-10-26 9:00 ` Borislav Petkov @ 2017-10-26 9:02 ` Andy Lutomirski 2017-10-26 12:55 ` Borislav Petkov 0 siblings, 1 reply; 6+ messages in thread From: Andy Lutomirski @ 2017-10-26 9:02 UTC (permalink / raw) To: Borislav Petkov Cc: Andy Lutomirski, Ricardo Neri, Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Liang Z Li, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel@vger.kernel.org, X86 ML, Neri, Ricardo, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm@kvack.org On Thu, Oct 26, 2017 at 2:00 AM, Borislav Petkov <bp@suse.de> wrote: > On Thu, Oct 26, 2017 at 12:51:25AM -0700, Andy Lutomirski wrote: >> with the slight caveat that I think it might be a wee bit better if >> UMIP emulation used a separate define UMIP_REPORTED_CR0. > > Why, do you see CR0_STATE and UMIP_REPORTED_CR0 becoming different at > some point? I'm assuming that UMIP_REPORTED_CR0 will never change. If CR0 gets a new field that we set some day, then I assume that CR0_STATE would add that bit but UMIP_REPORTED_CR0 would not. > > -- > Regards/Gruss, > Boris. > > SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) > -- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 2017-10-26 9:02 ` Andy Lutomirski @ 2017-10-26 12:55 ` Borislav Petkov 2017-10-27 19:02 ` Ricardo Neri 0 siblings, 1 reply; 6+ messages in thread From: Borislav Petkov @ 2017-10-26 12:55 UTC (permalink / raw) To: Andy Lutomirski Cc: Ricardo Neri, Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel@vger.kernel.org, X86 ML, Neri, Ricardo, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm@kvack.org On Thu, Oct 26, 2017 at 02:02:02AM -0700, Andy Lutomirski wrote: > I'm assuming that UMIP_REPORTED_CR0 will never change. If CR0 gets a > new field that we set some day, then I assume that CR0_STATE would add > that bit but UMIP_REPORTED_CR0 would not. Yeah, let's do that when it is actually needed. Thx. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix ImendA?rffer, Jane Smithard, Graham Norton, HRB 21284 (AG NA 1/4 rnberg) -- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 2017-10-26 12:55 ` Borislav Petkov @ 2017-10-27 19:02 ` Ricardo Neri 0 siblings, 0 replies; 6+ messages in thread From: Ricardo Neri @ 2017-10-27 19:02 UTC (permalink / raw) To: Borislav Petkov Cc: Andy Lutomirski, Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Peter Zijlstra, Andrew Morton, Brian Gerst, Chris Metcalf, Dave Hansen, Paolo Bonzini, Masami Hiramatsu, Huang Rui, Jiri Slaby, Jonathan Corbet, Michael S. Tsirkin, Paul Gortmaker, Vlastimil Babka, Chen Yucong, Ravi V. Shankar, Shuah Khan, linux-kernel@vger.kernel.org, X86 ML, Neri, Ricardo, Dave Hansen, Denys Vlasenko, Josh Poimboeuf, Linus Torvalds, linux-arch, linux-mm@kvack.org On Thu, Oct 26, 2017 at 02:55:13PM +0200, Borislav Petkov wrote: > On Thu, Oct 26, 2017 at 02:02:02AM -0700, Andy Lutomirski wrote: > > I'm assuming that UMIP_REPORTED_CR0 will never change. If CR0 gets a > > new field that we set some day, then I assume that CR0_STATE would add > > that bit but UMIP_REPORTED_CR0 would not. > > Yeah, let's do that when it is actually needed. Thanks Andy! I reasoned that for UMIP could report CR0_STATE a value that is already revealed in the source code. Thus, if CR0 ever changes at run time, an attacker could only see what is set programmatically. BR, Ricardo -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-27 19:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1507089272-32733-1-git-send-email-ricardo.neri-calderon@linux.intel.com>
2017-10-04 3:54 ` [PATCH v9 02/29] x86/boot: Relocate definition of the initial state of CR0 Ricardo Neri
2017-10-26 7:51 ` Andy Lutomirski
2017-10-26 9:00 ` Borislav Petkov
2017-10-26 9:02 ` Andy Lutomirski
2017-10-26 12:55 ` Borislav Petkov
2017-10-27 19:02 ` Ricardo Neri
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).