From 1d3c0fa7b25a75ea8444ef4e4e52569e894c9e91 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Sat, 17 Sep 2016 14:00:52 +0000 Subject: [PATCH] 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. --- sys/i386/i386/genassym.c | 1 - sys/i386/i386/swtch.s | 6 ------ sys/i386/i386/vm_machdep.c | 2 -- sys/i386/include/pcb.h | 2 +- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 30878344dc8e..a0e4d242cfa2 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -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)); diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 6bedb48c3647..a270b4845125 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -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) diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index a73b60d1b5dc..b051179b7c25 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -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: diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index 558565b872cb..dc9dcb252e4c 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -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;