Remove illumos-specific code from the x86 fasttrap_isa.c.

The file has not been touched upstream in over a decade, and the nature
of the code means that a lot of FreeBSD-specific bits are required.  Remove
the dead code to improve readability.  No functional change intended.

Discussed with:	cem
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2019-02-26 16:34:43 +00:00
parent 6829dae12b
commit df59ed0787
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344588

View File

@ -28,21 +28,11 @@
* Use is subject to license terms.
*/
#ifdef illumos
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
#include <sys/fasttrap_isa.h>
#include <sys/fasttrap_impl.h>
#include <sys/dtrace.h>
#include <sys/dtrace_impl.h>
#include <sys/cmn_err.h>
#ifdef illumos
#include <sys/regset.h>
#include <sys/privregs.h>
#include <sys/segments.h>
#include <sys/x86_archext.h>
#else
#include <sys/types.h>
#include <sys/dtrace_bsd.h>
#include <sys/proc.h>
@ -53,14 +43,8 @@
#include <machine/reg.h>
#include <machine/pcb.h>
#include <machine/trap.h>
#endif
#include <sys/sysmacros.h>
#ifdef illumos
#include <sys/trap.h>
#include <sys/archsystm.h>
#else
#include <sys/ptrace.h>
#endif /* illumos */
#ifdef __i386__
#define r_rax r_eax
@ -707,16 +691,9 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
fasttrap_tracepoint_t *tp;
fasttrap_bucket_t *bucket;
fasttrap_id_t *id;
#ifdef illumos
kmutex_t *pid_mtx;
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
mutex_enter(pid_mtx);
#else
struct rm_priotracker tracker;
rm_rlock(&fasttrap_tp_lock, &tracker);
#endif
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
@ -731,11 +708,7 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
* is not essential to the correct execution of the process.
*/
if (tp == NULL) {
#ifdef illumos
mutex_exit(pid_mtx);
#else
rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
return;
}
@ -756,30 +729,12 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
rp->r_rax, rp->r_rbx, 0, 0);
}
#ifdef illumos
mutex_exit(pid_mtx);
#else
rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
}
static void
fasttrap_sigsegv(proc_t *p, kthread_t *t, uintptr_t addr)
{
#ifdef illumos
sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
sqp->sq_info.si_signo = SIGSEGV;
sqp->sq_info.si_code = SEGV_MAPERR;
sqp->sq_info.si_addr = (caddr_t)addr;
mutex_enter(&p->p_lock);
sigaddqa(p, t, sqp);
mutex_exit(&p->p_lock);
if (t != NULL)
aston(t);
#else
ksiginfo_t *ksi = kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP);
ksiginfo_init(ksi);
@ -787,7 +742,6 @@ fasttrap_sigsegv(proc_t *p, kthread_t *t, uintptr_t addr)
ksi->ksi_code = SEGV_MAPERR;
ksi->ksi_addr = (caddr_t)addr;
(void) tdksignal(t, SIGSEGV, ksi);
#endif
}
#ifdef __amd64
@ -971,9 +925,6 @@ fasttrap_pid_probe(struct trapframe *tf)
uintptr_t pc;
uintptr_t new_pc = 0;
fasttrap_bucket_t *bucket;
#ifdef illumos
kmutex_t *pid_mtx;
#endif
fasttrap_tracepoint_t *tp, tp_local;
pid_t pid;
dtrace_icookie_t cookie;
@ -1013,15 +964,6 @@ fasttrap_pid_probe(struct trapframe *tf)
* parent. We know that there's only one thread of control in such a
* process: this one.
*/
#ifdef illumos
while (p->p_flag & SVFORK) {
p = p->p_parent;
}
pid = p->p_pid;
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
mutex_enter(pid_mtx);
#else
pp = p;
sx_slock(&proctree_lock);
while (pp->p_vmspace == pp->p_pptr->p_vmspace)
@ -1045,7 +987,6 @@ fasttrap_pid_probe(struct trapframe *tf)
sx_sunlock(&proctree_lock);
rm_rlock(&fasttrap_tp_lock, &tracker);
#endif
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
@ -1064,10 +1005,6 @@ fasttrap_pid_probe(struct trapframe *tf)
* fasttrap_ioctl), or somehow we have mislaid this tracepoint.
*/
if (tp == NULL) {
#ifdef illumos
mutex_exit(pid_mtx);
return (-1);
#else
rm_runlock(&fasttrap_tp_lock, &tracker);
gen = atomic_load_acq_64(&pp->p_fasttrap_tp_gen);
if (pp != p)
@ -1088,7 +1025,6 @@ fasttrap_pid_probe(struct trapframe *tf)
return (0);
}
return (-1);
#endif
}
if (pp != p)
PRELE(pp);
@ -1210,11 +1146,7 @@ fasttrap_pid_probe(struct trapframe *tf)
* tracepoint again later if we need to light up any return probes.
*/
tp_local = *tp;
#ifdef illumos
mutex_exit(pid_mtx);
#else
rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
tp = &tp_local;
/*
@ -1534,28 +1466,6 @@ fasttrap_pid_probe(struct trapframe *tf)
uint8_t scratch[2 * FASTTRAP_MAX_INSTR_SIZE + 7];
#endif
uint_t i = 0;
#ifdef illumos
klwp_t *lwp = ttolwp(curthread);
/*
* Compute the address of the ulwp_t and step over the
* ul_self pointer. The method used to store the user-land
* thread pointer is very different on 32- and 64-bit
* kernels.
*/
#if defined(__amd64)
if (p->p_model == DATAMODEL_LP64) {
addr = lwp->lwp_pcb.pcb_fsbase;
addr += sizeof (void *);
} else {
addr = lwp->lwp_pcb.pcb_gsbase;
addr += sizeof (caddr32_t);
}
#else
addr = USD_GETBASE(&lwp->lwp_pcb.pcb_gsdesc);
addr += sizeof (void *);
#endif
#else /* !illumos */
fasttrap_scrspace_t *scrspace;
scrspace = fasttrap_scraddr(curthread, tp->ftt_proc);
if (scrspace == NULL) {
@ -1571,7 +1481,6 @@ fasttrap_pid_probe(struct trapframe *tf)
break;
}
addr = scrspace->ftss_addr;
#endif /* illumos */
/*
* Generic Instruction Tracing
@ -1813,11 +1722,9 @@ fasttrap_pid_probe(struct trapframe *tf)
rp->r_rip = new_pc;
#ifndef illumos
PROC_LOCK(p);
proc_write_regs(curthread, rp);
PROC_UNLOCK(p);
#endif
return (0);
}