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.
This commit is contained in:
bde 2016-09-17 14:00:52 +00:00
parent 3d1d054982
commit 74861d13fa
4 changed files with 1 additions and 10 deletions

View File

@ -143,7 +143,6 @@ ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
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));

View File

@ -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)

View File

@ -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, struct thread *td0)
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:

View File

@ -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;