i386 cosmetic patches

Andrea Arcangeli (arcangeli@mbox.queen.it)
Mon, 3 Aug 1998 02:43:09 +0200 (CEST)


I was studing i386 kernel internals and I found that start_kernel(void) is
recalled with parameters from head.S (wasting 32*3 bits).

The asm init.c patch should be the right way to handle the input/output
from the same register according to gcc docs (I hope to be right ;-). It'
s annoying having to set tmp_reg to `0' though...

--- linux/arch/i386/mm/init.c Tue Jul 21 22:16:51 1998
+++ /home/andrea/devel/kernel-tree/linux/arch/i386/mm/init.c Mon Aug 3 01:56:06 1998
@@ -290,6 +290,15 @@

/* Map whole memory from PAGE_OFFSET */
pg_dir += USER_PGD_PTRS;
+
+ if (boot_cpu_data.x86_capability & X86_FEATURE_PSE)
+ {
+ set_in_cr4(X86_CR4_PSE);
+ boot_cpu_data.wp_works_ok = 1;
+ if (boot_cpu_data.x86_capability & X86_FEATURE_PGE)
+ set_in_cr4(X86_CR4_PGE);
+ }
+
while (address < end_mem) {
/*
* If we're running on a Pentium CPU, we can use the 4MB
@@ -302,14 +311,10 @@
if (boot_cpu_data.x86_capability & X86_FEATURE_PSE) {
unsigned long __pe;

- set_in_cr4(X86_CR4_PSE);
- boot_cpu_data.wp_works_ok = 1;
__pe = _KERNPG_TABLE + _PAGE_4M + __pa(address);
/* Make it "global" too if supported */
- if (boot_cpu_data.x86_capability & X86_FEATURE_PGE) {
- set_in_cr4(X86_CR4_PGE);
+ if (boot_cpu_data.x86_capability & X86_FEATURE_PGE)
__pe += _PAGE_GLOBAL;
- }
pgd_val(*pg_dir) = __pe;
pg_dir++;
address += 4*1024*1024;
@@ -356,7 +361,7 @@

__initfunc(void test_wp_bit(void))
{
- unsigned char tmp_reg;
+ unsigned char tmp_reg = 0;
unsigned long old = pg0[0];

printk("Checking if this processor honours the WP bit even in supervisor mode... ");
@@ -365,12 +370,13 @@
current->mm->mmap->vm_start += PAGE_SIZE;
__asm__ __volatile__(
"jmp 1f; 1:\n"
- "movb %0,%1\n"
- "movb %1,%0\n"
+ "movb %2,%1\n"
+ "movb %3,%0\n"
"jmp 1f; 1:\n"
:"=m" (*(char *) __va(0)),
"=q" (tmp_reg)
- :/* no inputs */
+ :"0" (*(char *) __va(0)),
+ "1" (tmp_reg)
:"memory");
pg0[0] = old;
local_flush_tlb();
--- linux/arch/i386/kernel/head.S Fri Jul 17 14:51:50 1998
+++ /home/andrea/devel/kernel-tree/linux/arch/i386/kernel/head.S Mon Aug 3 02:29:42 1998
@@ -241,9 +241,6 @@
#endif
xorl %eax,%eax
lldt %ax
- pushl %eax # These are the parameters to main :-)
- pushl %eax
- pushl %eax
cld # gcc2 wants the direction flag cleared at all times
call SYMBOL_NAME(start_kernel)
L6:

Andrea[s] Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html