From: Zachary Amsden <zach@vmware.com>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: 2.6.14: CR4 not needed to be inspected on the 486 anymore?
Date: Mon, 07 Nov 2005 07:44:51 -0800 [thread overview]
Message-ID: <436F7673.5040309@vmware.com> (raw)
In-Reply-To: <Pine.LNX.4.55.0511070931560.28165@blysk.ds.pg.gda.pl>
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
Maciej W. Rozycki wrote:
>On Sat, 5 Nov 2005, Andi Kleen wrote:
>
>
>
>>I don't think it's a good idea. Relying on nested faults in oops
>>is a bit unsafe because it could lead to recursive faults in the worst case.
>>
>>
>
> Good point.
>
>
>
>>Better keep the if
>>
>>
>
> Except the condition is wrong. Presence of CR4 could be tested elsewhere
>though, with the result being the condition here.
>
> Maciej
>
>
>
While this is at least no worse in the nested fault case than earlier
kernels, I really wish I had one of those weird 486s so I could test the
faulting mechanism. It seems the trap handling code has gotten quite
complicated now, with notifiers adding nice functionality, but making
the ordering of potential fault paths difficult to reason about (in
particular when considering functionality like kexec, kprobes, NMIs and
friends).
Zach
[-- Attachment #2: cr4-is-valid-on-some-486s --]
[-- Type: text/plain, Size: 1731 bytes --]
So some 486 processors do have CR4 register. Allow them to present it in
register dumps by using the old fault technique rather than testing processor
family.
Thanks to Maciej for noticing this.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Index: linux-2.6.14-zach-work/arch/i386/kernel/process.c
===================================================================
--- linux-2.6.14-zach-work.orig/arch/i386/kernel/process.c 2005-11-05 01:19:21.000000000 -0800
+++ linux-2.6.14-zach-work/arch/i386/kernel/process.c 2005-11-05 03:02:21.000000000 -0800
@@ -314,9 +314,7 @@ void show_regs(struct pt_regs * regs)
cr0 = read_cr0();
cr2 = read_cr2();
cr3 = read_cr3();
- if (current_cpu_data.x86 > 4) {
- cr4 = read_cr4();
- }
+ cr4 = read_cr4_safe();
printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
show_trace(NULL, ®s->esp);
}
Index: linux-2.6.14-zach-work/include/asm-i386/system.h
===================================================================
--- linux-2.6.14-zach-work.orig/include/asm-i386/system.h 2005-11-05 01:11:32.000000000 -0800
+++ linux-2.6.14-zach-work/include/asm-i386/system.h 2005-11-05 03:06:57.000000000 -0800
@@ -97,6 +97,19 @@ extern struct task_struct * FASTCALL(__s
:"=r" (__dummy)); \
__dummy; \
})
+
+#define read_cr4_safe() ({ \
+ unsigned int __dummy; \
+ /* 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" (__dummy): "0" (0)); \
+ __dummy; \
+})
+
#define write_cr4(x) \
__asm__ __volatile__("movl %0,%%cr4": :"r" (x));
#define stts() write_cr0(8 | read_cr0())
next prev parent reply other threads:[~2005-11-07 15:44 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
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 [this message]
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=436F7673.5040309@vmware.com \
--to=zach@vmware.com \
--cc=ak@suse.de \
--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