i386 support removal

Hasso Tepper hasso at estpak.ee
Wed Nov 7 03:37:33 PST 2007


Some time ago, while looking at others (BSDs, Linux) removing 386 CPU
support from kernels I took a look what it will take to remove it from
DragonFly kernel. It was quite easy, but as I don't see much point of it
at that moment (as I remove all *_CPU options except I686_CPU from my
kernels anyway), I didn't bother to submit it. But I also remember some
discussion that DragonFly doesn't run on 386 CPUs anyway although I can't
find the reference.

It has been sitting my patch queue since then and as I want to cut my
queue to minimum, I'm submitting it now - to either commit or to drop
from my patchqueue. 


-- 
Hasso Tepper
# HG changeset patch
# User Hasso Tepper <hasso at estpak.ee>
# Date 1194435081 -7200
# Branch HEAD
# Node ID 2234d05208e5a0364e652fb5eb42ac5cc01f0212
# Parent  fdf057cbb6a979719b40269abca482a515cc4f08
Drop I386_CPU - the i386 CPU support.

diff --git a/share/doc/handbook/handbook.txt b/share/doc/handbook/handbook.txt
--- a/share/doc/handbook/handbook.txt
+++ b/share/doc/handbook/handbook.txt
@@ -8269,7 +8269,6 @@ 9.4 The Configuration File
 
    This is the machine architecture. It must be either i386, or amd64.
 
- cpu          I386_CPU
  cpu          I486_CPU
  cpu          I586_CPU
  cpu          I686_CPU
diff --git a/share/man/man7/tuning.7 b/share/man/man7/tuning.7
--- a/share/man/man7/tuning.7
+++ b/share/man/man7/tuning.7
@@ -747,14 +747,12 @@ options that can be commented out.
 options that can be commented out.
 If you only want the kernel to run
 on a Pentium class CPU, you can easily remove
-.Dv I386_CPU
-and
 .Dv I486_CPU ,
 but only remove
 .Dv I586_CPU
 if you are sure your CPU is being recognized as a Pentium II or better.
-Some clones may be recognized as a Pentium or even a 486 and not be able
-to boot without those options.
+Some clones may be recognized as a Pentium and not be able to boot
+without those options.
 If it works, great!
 The operating system
 will be able to better-use higher-end CPU features for MMU, task switching,
diff --git a/sys/config/GENERIC b/sys/config/GENERIC
--- a/sys/config/GENERIC
+++ b/sys/config/GENERIC
@@ -9,7 +9,6 @@ platform	pc32
 platform	pc32
 machine		i386
 machine_arch	i386
-cpu		I386_CPU
 cpu		I486_CPU
 cpu		I586_CPU
 cpu		I686_CPU
diff --git a/sys/config/LINT b/sys/config/LINT
--- a/sys/config/LINT
+++ b/sys/config/LINT
@@ -116,7 +116,7 @@ options 	ROOTDEVNAME=\"ufs:da0s2e\"
 #
 #  An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard.
 #
-#  Be sure to disable 'cpu I386_CPU' && 'cpu I486_CPU' for SMP kernels.
+#  Be sure to disable 'cpu I486_CPU' for SMP kernels.
 #
 #  Check the 'Rogue SMP hardware' section to see if additional options
 #   are required by your hardware.
@@ -143,10 +143,8 @@ options 	APIC_IO			# Symmetric (APIC) I/
 #
 # You must specify at least one CPU (the one you intend to run on);
 # deleting the specification for CPUs you don't need to use may make
-# parts of the system run faster.  This is especially true removing
-# I386_CPU.
+# parts of the system run faster.
 #
-cpu		I386_CPU
 cpu		I486_CPU
 cpu		I586_CPU		# aka Pentium(tm)
 cpu		I686_CPU		# aka Pentium Pro(tm)
diff --git a/sys/cpu/i386/include/atomic.h b/sys/cpu/i386/include/atomic.h
--- a/sys/cpu/i386/include/atomic.h
+++ b/sys/cpu/i386/include/atomic.h
@@ -344,10 +344,6 @@ atomic_intr_cond_exit(__atomic_intr_t *p
  * if (*_dst == _old) *_dst = _new (all 32 bit words)
  *
  * Returns 0 on failure, non-zero on success
- *
- * WARNING:
- * This is a !I386_CPU function.  For I386_CPU, a _slower and horrible_
- * version may be used by the dynamic linker
  */
 #if defined(KLD_MODULE)
 extern int atomic_cmpset_int(volatile u_int *_dst, u_int _old, u_int _new);
diff --git a/sys/cpu/i386/include/endian.h b/sys/cpu/i386/include/endian.h
--- a/sys/cpu/i386/include/endian.h
+++ b/sys/cpu/i386/include/endian.h
@@ -99,25 +99,10 @@
 
 #if defined(__GNUC__) || defined(__INTEL_COMPILER_with_DragonFly_endian)
 
-#if (defined(_KERNEL)  && !defined(I386_CPU) && \
-	(defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU))) || \
-    defined(__i486__) || defined(__i586__) || defined(__i686__) || \
-    defined(__k6__) || defined(__athlon__) || defined(__k8__) || \
-    defined(__pentium4__)
-
 #define __byte_swap32_var(x) \
 	__extension__ ({ register __uint32_t __X = (x); \
 	   __asm ("bswap %0" : "+r" (__X)); \
 	   __X; })
-
-#else /* !I386_CPU */
-
-#define __byte_swap32_var(x) \
-	__extension__ ({ register __uint32_t __X = (x); \
-	   __asm ("xchgb %h0, %b0\n\trorl $16, %0\n\txchgb %h0, %b0" \
-	       : "+q" (__X)); \
-	   __X; })
-#endif /* !I386_CPU */
 
 #define __byte_swap16_var(x) \
 	__extension__ ({ register __uint16_t __X = (x); \
diff --git a/sys/crypto/blowfish/arch/i386/bf_enc.S b/sys/crypto/blowfish/arch/i386/bf_enc.S
--- a/sys/crypto/blowfish/arch/i386/bf_enc.S
+++ b/sys/crypto/blowfish/arch/i386/bf_enc.S
@@ -11,7 +11,7 @@
  * XXX Should use CPP symbols defined as a result of
  * XXX `cc -mcpu=pentiumpro'.
  */
-#if defined(I386_CPU) || defined(I486_CPU) || defined(I586_CPU)
+#if defined(I486_CPU) || defined(I586_CPU)
 #include "bf_enc_586.S"
 #else
 #include "bf_enc_686.S"
diff --git a/sys/platform/pc32/conf/options b/sys/platform/pc32/conf/options
--- a/sys/platform/pc32/conf/options
+++ b/sys/platform/pc32/conf/options
@@ -65,7 +65,6 @@ CPU_ATHLON_SSE_HACK		opt_cpu.h
 CPU_ATHLON_SSE_HACK		opt_cpu.h
 
 # The CPU type affects the endian conversion functions all over the kernel.
-I386_CPU		opt_global.h
 I486_CPU		opt_global.h
 I586_CPU		opt_global.h
 I686_CPU		opt_global.h
diff --git a/sys/platform/pc32/i386/identcpu.c b/sys/platform/pc32/i386/identcpu.c
--- a/sys/platform/pc32/i386/identcpu.c
+++ b/sys/platform/pc32/i386/identcpu.c
@@ -597,11 +597,9 @@ printcpuinfo(void)
 	case CPUCLASS_286:
 		kprintf("286");
 		break;
-#if defined(I386_CPU)
 	case CPUCLASS_386:
 		kprintf("386");
 		break;
-#endif
 #if defined(I486_CPU)
 	case CPUCLASS_486:
 		kprintf("486");
@@ -783,7 +781,7 @@ panicifcpuunsupported(void)
 panicifcpuunsupported(void)
 {
 
-#if !defined(I386_CPU) && !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
+#if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
 #error This kernel is not configured for one of the supported CPUs
 #endif
 	/*
@@ -791,10 +789,11 @@ panicifcpuunsupported(void)
 	 * let them know if that machine type isn't configured.
 	 */
 	switch (cpu_class) {
-	case CPUCLASS_286:	/* a 286 should not make it this far, anyway */
-#if !defined(I386_CPU)
+	/*
+	 * A 286 and 386 should not make it this far, anyway.
+	 */
+	case CPUCLASS_286:
 	case CPUCLASS_386:
-#endif
 #if !defined(I486_CPU)
 	case CPUCLASS_486:
 #endif
diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c
--- a/sys/platform/pc32/i386/machdep.c
+++ b/sys/platform/pc32/i386/machdep.c
@@ -1058,10 +1058,7 @@ cpu_setregs(void)
 	cr0 = rcr0();
 	cr0 |= CR0_NE;			/* Done by npxinit() */
 	cr0 |= CR0_MP | CR0_TS;		/* Done at every execve() too. */
-#ifdef I386_CPU
-	if (cpu_class != CPUCLASS_386)
-#endif
-		cr0 |= CR0_WP | CR0_AM;
+	cr0 |= CR0_WP | CR0_AM;
 	load_cr0(cr0);
 	load_gs(_udatasel);
 }
diff --git a/sys/platform/pc32/i386/support.s b/sys/platform/pc32/i386/support.s
--- a/sys/platform/pc32/i386/support.s
+++ b/sys/platform/pc32/i386/support.s
@@ -162,7 +162,7 @@ stack_onfault:
  */
 
 /*
- * copyout(from_kernel, to_user, len)  - MP SAFE (if not I386_CPU)
+ * copyout(from_kernel, to_user, len)  - MP SAFE
  */
 ENTRY(copyout)
 	movl	PCPU(curthread),%eax
@@ -200,66 +200,9 @@ ENTRY(copyout)
 	cmpl	$VM_MAX_USER_ADDRESS,%eax
 	ja	copyout_fault1
 
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
-	cmpl	$CPUCLASS_386,cpu_class
-	jne	3f
-#endif
-/*
- * We have to check each PTE for user write permission.
- * The checking may cause a page fault, so it is important to set
- * up everything for return via copyout_fault before here.
- */
-	/* compute number of pages */
-	movl	%edi,%ecx
-	andl	$PAGE_MASK,%ecx
-	addl	%ebx,%ecx
-	decl	%ecx
-	shrl	$IDXSHIFT+2,%ecx
-	incl	%ecx
-
-	/* compute PTE offset for start address */
-	movl	%edi,%edx
-	shrl	$IDXSHIFT,%edx
-	andb	$0xfc,%dl
-
-1:
-	/* check PTE for each page */
-	leal	PTmap(%edx),%eax
-	shrl	$IDXSHIFT,%eax
-	andb	$0xfc,%al
-	testb	$PG_V,PTmap(%eax)		/* PTE page must be valid */
-	je	4f
-	movb	PTmap(%edx),%al
-	andb	$PG_V|PG_RW|PG_U,%al		/* page must be valid and user writable */
-	cmpb	$PG_V|PG_RW|PG_U,%al
-	je	2f
-
-4:
-	/* simulate a trap */
-	pushl	%edx
-	pushl	%ecx
-	shll	$IDXSHIFT,%edx
-	pushl	%edx
-	call	trapwrite			/* trapwrite(addr) */
-	popl	%edx
-	popl	%ecx
-	popl	%edx
-
-	testl	%eax,%eax			/* if not ok, return EFAULT */
-	jnz	copyout_fault1
-
-2:
-	addl	$4,%edx
-	decl	%ecx
-	jnz	1b				/* check next page */
-#endif /* I386_CPU */
-
 	/*
 	 * Convert copyout to memcpy_vector(dest:%edi, src:%esi, conut:%ecx)
 	 */
-3:
 	movl	%ebx,%ecx
 	call	*memcpy_vector
 
@@ -406,7 +349,7 @@ fusufault:
 	ret
 
 /*
- * su{byte,sword,word} - MP SAFE (if not I386_CPU)
+ * su{byte,sword,word} - MP SAFE
  *
  *	Write a byte (word, longword) to user memory
  */
@@ -416,40 +359,6 @@ ENTRY(suword)
 	movl	$fusufault,PCB_ONFAULT(%ecx)
 	movl	4(%esp),%edx
 
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
-	cmpl	$CPUCLASS_386,cpu_class
-	jne	2f				/* we only have to set the right segment selector */
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
-	/* XXX - page boundary crossing is still not handled */
-	movl	%edx,%eax
-	shrl	$IDXSHIFT,%edx
-	andb	$0xfc,%dl
-
-	leal	PTmap(%edx),%ecx
-	shrl	$IDXSHIFT,%ecx
-	andb	$0xfc,%cl
-	testb	$PG_V,PTmap(%ecx)		/* PTE page must be valid */
-	je	4f
-	movb	PTmap(%edx),%dl
-	andb	$PG_V|PG_RW|PG_U,%dl		/* page must be valid and user writable */
-	cmpb	$PG_V|PG_RW|PG_U,%dl
-	je	1f
-
-4:
-	/* simulate a trap */
-	pushl	%eax
-	call	trapwrite
-	popl	%edx				/* remove junk parameter from stack */
-	testl	%eax,%eax
-	jnz	fusufault
-1:
-	movl	4(%esp),%edx
-#endif
-
-2:
 	cmpl	$VM_MAX_USER_ADDRESS-4,%edx	/* verify address validity */
 	ja	fusufault
 
@@ -462,7 +371,7 @@ 2:
 	ret
 
 /*
- * susword - MP SAFE (if not I386_CPU)
+ * susword - MP SAFE
  */
 ENTRY(susword)
 	movl	PCPU(curthread),%ecx
@@ -470,40 +379,6 @@ ENTRY(susword)
 	movl	$fusufault,PCB_ONFAULT(%ecx)
 	movl	4(%esp),%edx
 
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
-	cmpl	$CPUCLASS_386,cpu_class
-	jne	2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
-	/* XXX - page boundary crossing is still not handled */
-	movl	%edx,%eax
-	shrl	$IDXSHIFT,%edx
-	andb	$0xfc,%dl
-
-	leal	PTmap(%edx),%ecx
-	shrl	$IDXSHIFT,%ecx
-	andb	$0xfc,%cl
-	testb	$PG_V,PTmap(%ecx)		/* PTE page must be valid */
-	je	4f
-	movb	PTmap(%edx),%dl
-	andb	$PG_V|PG_RW|PG_U,%dl		/* page must be valid and user writable */
-	cmpb	$PG_V|PG_RW|PG_U,%dl
-	je	1f
-
-4:
-	/* simulate a trap */
-	pushl	%eax
-	call	trapwrite
-	popl	%edx				/* remove junk parameter from stack */
-	testl	%eax,%eax
-	jnz	fusufault
-1:
-	movl	4(%esp),%edx
-#endif
-
-2:
 	cmpl	$VM_MAX_USER_ADDRESS-2,%edx	/* verify address validity */
 	ja	fusufault
 
@@ -516,7 +391,7 @@ 2:
 	ret
 
 /*
- * subyte - MP SAFE (if not I386_CPU)
+ * subyte - MP SAFE
  */
 ENTRY(subyte)
 	movl	PCPU(curthread),%ecx
@@ -524,39 +399,6 @@ ENTRY(subyte)
 	movl	$fusufault,PCB_ONFAULT(%ecx)
 	movl	4(%esp),%edx
 
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
-	cmpl	$CPUCLASS_386,cpu_class
-	jne	2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
-	movl	%edx,%eax
-	shrl	$IDXSHIFT,%edx
-	andb	$0xfc,%dl
-
-	leal	PTmap(%edx),%ecx
-	shrl	$IDXSHIFT,%ecx
-	andb	$0xfc,%cl
-	testb	$PG_V,PTmap(%ecx)		/* PTE page must be valid */
-	je	4f
-	movb	PTmap(%edx),%dl
-	andb	$PG_V|PG_RW|PG_U,%dl		/* page must be valid and user writable */
-	cmpb	$PG_V|PG_RW|PG_U,%dl
-	je	1f
-
-4:
-	/* simulate a trap */
-	pushl	%eax
-	call	trapwrite
-	popl	%edx				/* remove junk parameter from stack */
-	testl	%eax,%eax
-	jnz	fusufault
-1:
-	movl	4(%esp),%edx
-#endif
-
-2:
 	cmpl	$VM_MAX_USER_ADDRESS-1,%edx	/* verify address validity */
 	ja	fusufault
 
diff --git a/sys/platform/vkernel/i386/cpu_regs.c b/sys/platform/vkernel/i386/cpu_regs.c
--- a/sys/platform/vkernel/i386/cpu_regs.c
+++ b/sys/platform/vkernel/i386/cpu_regs.c
@@ -853,10 +853,7 @@ cpu_setregs(void)
 	cr0 = rcr0();
 	cr0 |= CR0_NE;			/* Done by npxinit() */
 	cr0 |= CR0_MP | CR0_TS;		/* Done at every execve() too. */
-#ifdef I386_CPU
-	if (cpu_class != CPUCLASS_386)
-#endif
-		cr0 |= CR0_WP | CR0_AM;
+	cr0 |= CR0_WP | CR0_AM;
 	load_cr0(cr0);
 	load_gs(_udatasel);
 #endif




More information about the Submit mailing list