From: Zachary Amsden <zach@vmware.com>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.14: CR4 not needed to be inspected on the 486 anymore?
Date: Thu, 03 Nov 2005 08:34:24 -0800 [thread overview]
Message-ID: <436A3C10.9050302@vmware.com> (raw)
In-Reply-To: <Pine.LNX.4.55.0511031600010.24109@blysk.ds.pg.gda.pl>
Maciej W. Rozycki wrote:
>Hello,
>
> The following hunk of the 2.6.14 patch:
>
>diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
>index e3f362e..7a14fdf 100644
>--- a/arch/i386/kernel/process.c
>+++ b/arch/i386/kernel/process.c
>@@ -313,16 +311,12 @@ void show_regs(struct pt_regs * regs)
> printk(" DS: %04x ES: %04x\n",
> 0xffff & regs->xds,0xffff & regs->xes);
>
>- __asm__("movl %%cr0, %0": "=r" (cr0));
>- __asm__("movl %%cr2, %0": "=r" (cr2));
>- __asm__("movl %%cr3, %0": "=r" (cr3));
>- /* This could fault if %cr4 does not exist */
>- __asm__("1: movl %%cr4, %0 \n"
>- "2: \n"
>- ".section __ex_table,\"a\" \n"
>- ".long 1b,2b \n"
>- ".previous \n"
>- : "=r" (cr4): "0" (0));
>+ cr0 = read_cr0();
>+ cr2 = read_cr2();
>+ cr3 = read_cr3();
>+ if (current_cpu_data.x86 > 4) {
>+ cr4 = read_cr4();
>+ }
> printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
> show_trace(NULL, ®s->esp);
> }
>
>disables code to retrieve the actual value of CR4 on 486-class systems
>(which may or may not implement the register, depending on the exact CPU
>type and stepping). This seems suspicious to me, but I have to admit I
>haven't followed the discussion on the issue if there was any.
>
>
This was deliberate. CR4 doesn't exist on standard 486 class systems,
and I'm not sure how you could make use of it anyway, since the features
used by Linux - machine check, page size extensions, time stamp counter,
global pages, are only available in Pentium and later class systems, and
identified by CPUID, which also doesn't exist on 486.
There may be some funky Cyrix or even Intel CPUs that have CR4
registers, but showing the output in a register dump seems very
useless. I would also not recommend using undocumented features in CR4
even if you have such a freaky processor - there were bugs and/or
missing functionality with the early large page and global page
extensions that were not ironed out until the features became
documented, IIRC. YMMV - please let me know if anyone has found ways to
make this useful.
If I am wrong, I am happy to correct this, but I would like to do so
properly by adding safe_read_cr4() or equivalent rather than using raw
inlines assembler to catch the fault.
Thanks,
Zach
next prev parent reply other threads:[~2005-11-03 16:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-03 16:12 2.6.14: CR4 not needed to be inspected on the 486 anymore? Maciej W. Rozycki
2005-11-03 16:34 ` Zachary Amsden [this message]
2005-11-03 17:20 ` Maciej W. Rozycki
2005-11-03 23:49 ` Zachary Amsden
2005-11-05 17:40 ` Andi Kleen
2005-11-07 9:38 ` Maciej W. Rozycki
2005-11-07 15:44 ` Zachary Amsden
2005-11-07 16:37 ` Maciej W. Rozycki
2005-11-07 16:51 ` Zachary Amsden
2005-11-07 17:00 ` linux-os (Dick Johnson)
2005-11-07 17:32 ` Zachary Amsden
2005-11-07 18:17 ` linux-os (Dick Johnson)
2005-11-07 19:02 ` Ondrej Zary
2005-11-07 17:11 ` Maciej W. Rozycki
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=436A3C10.9050302@vmware.com \
--to=zach@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@linux-mips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox