From: Andres Salomon <dilinger@queued.net>
To: "H. Peter Anvin" <hpa@linux.intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Dave Jones <davej@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Ian Campbell <ian.campbell@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Rusty Russell <rusty@rustcorp.com.au>,
David Woodhouse <dwmw2@infradead.org>,
Vivek Goyal <vgoyal@in.ibm.com>,
Yinghai Lu <yhlu.kernel@gmail.com>,
"H. Peter Anvin" <hpa@zytor.com>,
techteam@lists.laptop.org
Subject: Re: [RFC PATCH] x86-32: Start out eflags and cr4 clean
Date: Fri, 18 Jan 2013 16:40:43 -0800 [thread overview]
Message-ID: <20130118164043.29674d75@dev.queued.net> (raw)
In-Reply-To: <20121010125927.0968dd8b@dev.queued.net>
Bad news on this patch; I've been told that it breaks booting on an
XO-1.5. Does anyone from OLPC know why yet?
On Wed, 10 Oct 2012 12:59:27 -0700
Andres Salomon <dilinger@queued.net> wrote:
> Thanks for Cc'ing me. I just tested this on an XO-1, and it doesn't
> appear to break anything. So, looks fine to me.
>
> Acked-by: Andres Salomon <dilinger@queued.net>
>
>
> On Mon, 24 Sep 2012 16:27:19 -0700 "H. Peter
> Anvin" <hpa@linux.intel.com> wrote:
>
> > From: "H. Peter Anvin" <hpa@linux.intel.com>
> >
> > %cr4 is supposed to reflect a set of features into which the
> > operating system is opting in. If the BIOS or bootloader leaks
> > bits here, this is not desirable. Consider a bootloader passing in
> > %cr4.pae set to a legacy paging kernel, for example -- it will not
> > have any immediate effect, but the kernel would crash when turning
> > paging on.
> >
> > A similar argument applies to %eflags, and since we have to look for
> > %eflags.id being settable we can use a sequence which clears %eflags
> > as a side effect.
> >
> > Note that we already do this for x86-64.
> >
> > I would like opinions on this especially from the PV crowd and
> > nonstandard platforms (e.g. OLPC) to make sure we don't screw them
> > up.
> >
> > Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
> > ---
> > arch/x86/kernel/head_32.S | 31 ++++++++++++++++---------------
> > 1 files changed, 16 insertions(+), 15 deletions(-)
> >
> > diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
> > index d42ab17..957a47a 100644
> > --- a/arch/x86/kernel/head_32.S
> > +++ b/arch/x86/kernel/head_32.S
> > @@ -287,27 +287,28 @@ ENTRY(startup_32_smp)
> > leal -__PAGE_OFFSET(%ecx),%esp
> >
> > default_entry:
> > -
> > /*
> > * New page tables may be in 4Mbyte page mode and may
> > * be using the global pages.
> > *
> > * NOTE! If we are on a 486 we may have no cr4 at all!
> > - * So we do not try to touch it unless we really have
> > - * some bits in it to set. This won't work if the BSP
> > - * implements cr4 but this AP does not -- very unlikely
> > - * but be warned! The same applies to the pse feature
> > - * if not equally supported. --macro
> > - *
> > - * NOTE! We have to correct for the fact that we're
> > - * not yet offset PAGE_OFFSET..
> > + * Specifically, cr4 exists if and only if CPUID exists,
> > + * which in turn exists if and only if EFLAGS.ID exists.
> > */
> > -#define cr4_bits pa(mmu_cr4_features)
> > - movl cr4_bits,%edx
> > - andl %edx,%edx
> > - jz 6f
> > - movl %cr4,%eax # Turn on paging options
> > (PSE,PAE,..)
> > - orl %edx,%eax
> > + movl $X86_EFLAGS_ID,%ecx
> > + pushl %ecx
> > + popfl
> > + pushfl
> > + popl %eax
> > + pushl $0
> > + popfl
> > + pushfl
> > + popl %edx
> > + xorl %edx,%eax
> > + testl %ecx,%eax
> > + jz 6f # No ID flag = no CPUID = no
> > CR4 +
> > + movl pa(mmu_cr4_features),%eax
> > movl %eax,%cr4
> >
> > testb $X86_CR4_PAE, %al # check if PAE is
> > enabled
next prev parent reply other threads:[~2013-01-19 0:50 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 19:43 [PATCH 00/11] x86: Supervisor Mode Access Prevention H. Peter Anvin
2012-09-21 19:43 ` [PATCH 01/11] x86, cpufeature: Add feature bit for SMAP H. Peter Anvin
2012-09-21 19:43 ` [PATCH 02/11] x86-32, mm: The WP test should be done on a kernel page H. Peter Anvin
2012-09-21 19:58 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 03/11] x86, smap: Add CR4 bit for SMAP H. Peter Anvin
2012-09-21 19:59 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 04/11] x86, alternative: Use .pushsection/.popsection H. Peter Anvin
2012-09-21 20:00 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 05/11] x86, alternative: Add header guards to <asm/alternative-asm.h> H. Peter Anvin
2012-09-21 20:01 ` [tip:x86/smap] x86, alternative: Add header guards to <asm/ alternative-asm.h> tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 06/11] x86, smap: Add a header file with macros for STAC/CLAC H. Peter Anvin
2012-09-21 20:02 ` [tip:x86/smap] x86, smap: Add a header file with macros for STAC/ CLAC tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 07/11] x86, uaccess: Merge prototypes for clear_user/__clear_user H. Peter Anvin
2012-09-21 20:03 ` [tip:x86/smap] x86, uaccess: Merge prototypes for clear_user/ __clear_user tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 08/11] x86, smap: Add STAC and CLAC instructions to control user space access H. Peter Anvin
2012-09-21 20:04 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-22 0:16 ` [tip:x86/smap] x86-32, smap: Add STAC/ CLAC instructions to 32-bit kernel entry tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 09/11] x86, smap: Turn on Supervisor Mode Access Prevention H. Peter Anvin
2012-09-21 20:05 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 10/11] x86, smap: A page fault due to SMAP is an oops H. Peter Anvin
2012-09-21 20:06 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:43 ` [PATCH 11/11] x86, smap: Reduce the SMAP overhead for signal handling H. Peter Anvin
2012-09-21 20:07 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-09-21 19:54 ` [PATCH 00/11] x86: Supervisor Mode Access Prevention Linus Torvalds
2012-09-21 19:57 ` H. Peter Anvin
2012-09-21 20:08 ` Ingo Molnar
2012-09-21 21:03 ` H. Peter Anvin
2012-09-21 21:09 ` Linus Torvalds
2012-09-21 21:12 ` H. Peter Anvin
2012-09-21 22:07 ` Eric W. Biederman
2012-09-21 22:12 ` H. Peter Anvin
2012-09-22 0:41 ` Eric W. Biederman
2012-09-24 23:27 ` [RFC PATCH] x86-32: Start out eflags and cr4 clean H. Peter Anvin
2012-09-25 13:27 ` Konrad Rzeszutek Wilk
2012-09-25 13:48 ` Ian Campbell
2012-09-26 11:29 ` Konrad Rzeszutek Wilk
2012-09-27 6:11 ` [tip:x86/smap] " tip-bot for H. Peter Anvin
2012-11-24 3:49 ` Yuhong Bao
2012-11-24 5:06 ` H. Peter Anvin
2012-09-27 6:11 ` [tip:x86/smap] x86, suspend: On wakeup always initialize cr4 and EFER tip-bot for H. Peter Anvin
2012-10-01 22:04 ` [tip:x86/urgent] x86, suspend: Correct the restore of CR4, EFER; skip computing EFLAGS.ID tip-bot for H. Peter Anvin
2012-10-02 6:52 ` tip-bot for H. Peter Anvin
2012-10-10 19:59 ` [RFC PATCH] x86-32: Start out eflags and cr4 clean Andres Salomon
2013-01-19 0:40 ` Andres Salomon [this message]
2013-01-19 0:42 ` H. Peter Anvin
2013-01-19 1:05 ` [Techteam] " Mitch Bradley
2013-01-19 2:35 ` H. Peter Anvin
2013-01-19 7:44 ` Mitch Bradley
2013-01-19 12:34 ` Daniel Drake
2013-01-19 19:15 ` [tip:x86/urgent] x86-32: Start out cr0 clean, disable paging before modifying cr3/4 tip-bot for H. Peter Anvin
2012-09-21 22:08 ` [PATCH 00/11] x86: Supervisor Mode Access Prevention Dave Jones
2012-09-21 22:10 ` H. Peter Anvin
2012-09-22 11:32 ` Ingo Molnar
2012-09-24 20:31 ` H. Peter Anvin
2012-09-24 20:43 ` Kees Cook
2012-09-24 20:51 ` H. Peter Anvin
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=20130118164043.29674d75@dev.queued.net \
--to=dilinger@queued.net \
--cc=davej@redhat.com \
--cc=dwmw2@infradead.org \
--cc=ebiederm@xmission.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=ian.campbell@citrix.com \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=techteam@lists.laptop.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vgoyal@in.ibm.com \
--cc=yhlu.kernel@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox