Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Sep 2016 14:00:52 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305899 - in head/sys/i386: i386 include
Message-ID:  <201609171400.u8HE0qIU097241@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Sat Sep 17 14:00:52 2016
New Revision: 305899
URL: https://svnweb.freebsd.org/changeset/base/305899

Log:
  Remove all kernel uses of pcb_psl, but keep in in the struct to
  preserve the ABI and API for applications.  It was removed in the port
  to amd64, but was remained as garbage giving a micro-pessimization and
  spurious single-step traps on i386.
  
  pcb_psl was intended to be used just to do a context switch of PSL_I,
  but this context switch was null in most or all versions, and
  mis-switching of PSL_T was done instead.
  
  Some history:
  - in 386BSD-0.0, cpu_switch() ran at splhigh() and splhigh() did too
    much interrupt disabling, so interrupts were hard-disabled across
    cpu_switch() and too many other places
  - in 386BSD-0.0-patchkit through FreeBSD-4 and FreeBSD-5 before
    SMPng, splhigh() did soft interrupt masking, and cpu_switch() was
    excessively cautious and did a cli at the start and a sti at the
    end to hard-disable interrupts across the switch
  - SMPng replaced the spl's and cli's by spinlocks (just sched_lock?),
    so interrupts were hard-disabled across cpu_switch() and too many
    other places again
  - initial attempts to fix this intended to restore some soft
    interrupt disabling, but to support variations in this cpu_switch()
    used pushfl/popfl into pcb_psl to avoid hard-coding the assumption
    that the initial and final states have PSL_I enabled.  But the
    version with soft interrupt disabling wasn't used for long, or was
    never committed, (except I always used my different version of it
    for UP) so the pushfl/popl and pcb_psl to hold them have been doing
    less than nothing for about 14 years.

Modified:
  head/sys/i386/i386/genassym.c
  head/sys/i386/i386/swtch.s
  head/sys/i386/i386/vm_machdep.c
  head/sys/i386/include/pcb.h

Modified: head/sys/i386/i386/genassym.c
==============================================================================
--- head/sys/i386/i386/genassym.c	Sat Sep 17 13:48:01 2016	(r305898)
+++ head/sys/i386/i386/genassym.c	Sat Sep 17 14:00:52 2016	(r305899)
@@ -143,7 +143,6 @@ ASSYM(PCB_DR2, offsetof(struct pcb, pcb_
 ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
 ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
 ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
-ASSYM(PCB_PSL, offsetof(struct pcb, pcb_psl));
 ASSYM(PCB_DBREGS, PCB_DBREGS);
 ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
 

Modified: head/sys/i386/i386/swtch.s
==============================================================================
--- head/sys/i386/i386/swtch.s	Sat Sep 17 13:48:01 2016	(r305898)
+++ head/sys/i386/i386/swtch.s	Sat Sep 17 14:00:52 2016	(r305899)
@@ -131,8 +131,6 @@ ENTRY(cpu_switch)
 	movl	%esi,PCB_ESI(%edx)
 	movl	%edi,PCB_EDI(%edx)
 	mov	%gs,PCB_GS(%edx)
-	pushfl					/* PSL */
-	popl	PCB_PSL(%edx)
 	/* Test if debug registers should be saved. */
 	testl	$PCB_DBREGS,PCB_FLAGS(%edx)
 	jz      1f                              /* no, skip over */
@@ -261,8 +259,6 @@ sw1:
 	movl	PCB_EDI(%edx),%edi
 	movl	PCB_EIP(%edx),%eax
 	movl	%eax,(%esp)
-	pushl	PCB_PSL(%edx)
-	popfl
 
 	movl	%edx, PCPU(CURPCB)
 	movl	TD_TID(%ecx),%eax
@@ -365,8 +361,6 @@ ENTRY(savectx)
 	movl	%esi,PCB_ESI(%ecx)
 	movl	%edi,PCB_EDI(%ecx)
 	mov	%gs,PCB_GS(%ecx)
-	pushfl
-	popl	PCB_PSL(%ecx)
 
 	movl	%cr0,%eax
 	movl	%eax,PCB_CR0(%ecx)

Modified: head/sys/i386/i386/vm_machdep.c
==============================================================================
--- head/sys/i386/i386/vm_machdep.c	Sat Sep 17 13:48:01 2016	(r305898)
+++ head/sys/i386/i386/vm_machdep.c	Sat Sep 17 14:00:52 2016	(r305899)
@@ -273,7 +273,6 @@ cpu_fork(td1, p2, td2, flags)
 	pcb2->pcb_esp = (int)td2->td_frame - sizeof(void *);
 	pcb2->pcb_ebx = (int)td2;		/* fork_trampoline argument */
 	pcb2->pcb_eip = (int)fork_trampoline;
-	pcb2->pcb_psl = PSL_KERNEL;		/* ints disabled */
 	/*-
 	 * pcb2->pcb_dr*:	cloned above.
 	 * pcb2->pcb_savefpu:	cloned above.
@@ -504,7 +503,6 @@ cpu_copy_thread(struct thread *td, struc
 	pcb2->pcb_esp = (int)td->td_frame - sizeof(void *); /* trampoline arg */
 	pcb2->pcb_ebx = (int)td;			    /* trampoline arg */
 	pcb2->pcb_eip = (int)fork_trampoline;
-	pcb2->pcb_psl &= ~(PSL_I);	/* interrupts must be disabled */
 	pcb2->pcb_gs = rgs();
 	/*
 	 * If we didn't copy the pcb, we'd need to do the following registers:

Modified: head/sys/i386/include/pcb.h
==============================================================================
--- head/sys/i386/include/pcb.h	Sat Sep 17 13:48:01 2016	(r305898)
+++ head/sys/i386/include/pcb.h	Sat Sep 17 14:00:52 2016	(r305899)
@@ -89,7 +89,7 @@ struct pcb {
 
 	caddr_t	pcb_onfault;	/* copyin/out fault recovery */
 	struct	pcb_ext	*pcb_ext;	/* optional pcb extension */
-	int	pcb_psl;	/* process status long */
+	int	pcb_waspsl;	/* unused padding for ABI and API compat */
 	u_long	pcb_vm86[2];	/* vm86bios scratch space */
 	union	savefpu *pcb_save;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609171400.u8HE0qIU097241>