- Split the unaligned access check flags out of md_flags in struct mdthread
and move them into md_uac in struct mdproc. mdproc is protected by the proc lock. md_flags now is only ever modified by the current thread, so it doesn't need a lock. - Rename the constants for all the per-thread MD flags to use MDTD_* instead of MDP_*.
This commit is contained in:
parent
c488362e1a
commit
7e71ff5ea7
@ -151,7 +151,7 @@
|
||||
|
||||
/* set the hae register if this process has specified a value */
|
||||
ldq t1, TD_MD_FLAGS(s0)
|
||||
and t1, MDP_HAEUSED
|
||||
and t1, MDTD_HAEUSED
|
||||
beq t1, 3f
|
||||
ldq a0, TD_MD_HAE(s0)
|
||||
ldq pv, chipset + CHIPSET_WRITE_HAE
|
||||
@ -302,7 +302,7 @@ Lkernelret:
|
||||
Lrestoreregs:
|
||||
/* set the hae register if this process has specified a value */
|
||||
ldq t1, TD_MD_FLAGS(s0)
|
||||
and t1, MDP_HAEUSED
|
||||
and t1, MDTD_HAEUSED
|
||||
beq t1, Lnohae
|
||||
ldq a0, TD_MD_HAE(t0)
|
||||
ldq pv, chipset + CHIPSET_WRITE_HAE
|
||||
|
@ -92,7 +92,7 @@ ASSYM(TD_MD_HAE, offsetof(struct thread, td_md.md_hae));
|
||||
#ifdef SMP
|
||||
ASSYM(TD_MD_KERNNEST, offsetof(struct thread, td_md.md_kernnest));
|
||||
#endif
|
||||
ASSYM(MDP_HAEUSED, MDP_HAEUSED);
|
||||
ASSYM(MDTD_HAEUSED, MDTD_HAEUSED);
|
||||
|
||||
ASSYM(CHIPSET_WRITE_HAE, offsetof(struct alpha_chipset, write_hae));
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
|
||||
/* save the floating-point state, if necessary, then copy it. */
|
||||
alpha_fpstate_save(td, 1); /* XXX maybe write=0 */
|
||||
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDP_FPUSED;
|
||||
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDTD_FPUSED;
|
||||
bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs,
|
||||
sizeof(struct fpreg));
|
||||
ksi.si_sc.sc_fp_control = td->td_pcb->pcb_fp_control;
|
||||
@ -1332,7 +1332,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
#endif
|
||||
/* save the floating-point state, if necessary, then copy it. */
|
||||
alpha_fpstate_save(td, 1);
|
||||
sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED;
|
||||
sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDTD_FPUSED;
|
||||
bcopy(&td->td_pcb->pcb_fp,
|
||||
(struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs,
|
||||
sizeof(struct fpreg));
|
||||
@ -1606,7 +1606,7 @@ setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
|
||||
tfp->tf_regs[FRAME_T12] = tfp->tf_regs[FRAME_PC]; /* a.k.a. PV */
|
||||
tfp->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
|
||||
td->td_md.md_flags &= ~MDP_FPUSED;
|
||||
td->td_md.md_flags &= ~MDTD_FPUSED;
|
||||
alpha_fpstate_drop(td);
|
||||
}
|
||||
|
||||
@ -1720,13 +1720,13 @@ ptrace_set_bpt(struct thread *td, struct mdbpt *bpt)
|
||||
int
|
||||
ptrace_clear_single_step(struct thread *td)
|
||||
{
|
||||
if (td->td_md.md_flags & MDP_STEP2) {
|
||||
if (td->td_md.md_flags & MDTD_STEP2) {
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[1]);
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
td->td_md.md_flags &= ~MDP_STEP2;
|
||||
} else if (td->td_md.md_flags & MDP_STEP1) {
|
||||
td->td_md.md_flags &= ~MDTD_STEP2;
|
||||
} else if (td->td_md.md_flags & MDTD_STEP1) {
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
td->td_md.md_flags &= ~MDP_STEP1;
|
||||
td->td_md.md_flags &= ~MDTD_STEP1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1740,7 +1740,7 @@ ptrace_single_step(struct thread *td)
|
||||
vm_offset_t addr[2]; /* places to set breakpoints */
|
||||
int count = 0; /* count of breakpoints */
|
||||
|
||||
if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2))
|
||||
if (td->td_md.md_flags & (MDTD_STEP1|MDTD_STEP2))
|
||||
panic("ptrace_single_step: step breakpoints not removed");
|
||||
|
||||
error = ptrace_read_int(td, pc, &ins.bits);
|
||||
@ -1793,9 +1793,9 @@ ptrace_single_step(struct thread *td)
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
return error;
|
||||
}
|
||||
td->td_md.md_flags |= MDP_STEP2;
|
||||
td->td_md.md_flags |= MDTD_STEP2;
|
||||
} else
|
||||
td->td_md.md_flags |= MDP_STEP1;
|
||||
td->td_md.md_flags |= MDTD_STEP1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2132,7 +2132,7 @@ alpha_fpstate_switch(struct thread *td)
|
||||
SET_FEN(td);
|
||||
}
|
||||
|
||||
td->td_md.md_flags |= MDP_FPUSED;
|
||||
td->td_md.md_flags |= MDTD_FPUSED;
|
||||
intr_restore(s);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ alpha_sethae(struct thread *td, char *args)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
td->td_md.md_flags |= MDP_HAEUSED;
|
||||
td->td_md.md_flags |= MDTD_HAEUSED;
|
||||
td->td_md.md_hae = ua.hae;
|
||||
|
||||
return (0);
|
||||
@ -169,8 +169,7 @@ alpha_set_uac(struct thread *td, char *args)
|
||||
{
|
||||
int error;
|
||||
unsigned long uac;
|
||||
struct proc *p;
|
||||
struct thread *td2;
|
||||
struct proc *p, *pp;
|
||||
|
||||
error = copyin(args, &uac, sizeof(uac));
|
||||
if (error)
|
||||
@ -178,13 +177,11 @@ alpha_set_uac(struct thread *td, char *args)
|
||||
|
||||
p = td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pptr) {
|
||||
PROC_LOCK(p->p_pptr);
|
||||
/* XXXKSE which threads? */
|
||||
td2 = FIRST_THREAD_IN_PROC(p->p_pptr);
|
||||
td2->td_md.md_flags &= ~MDP_UAC_MASK;
|
||||
td2->td_md.md_flags |= uac & MDP_UAC_MASK;
|
||||
PROC_UNLOCK(p->p_pptr);
|
||||
pp = p->p_pptr;
|
||||
if (pp != NULL) {
|
||||
PROC_LOCK(pp);
|
||||
pp->p_md.md_uac = uac & MDP_UAC_MASK;
|
||||
PROC_UNLOCK(pp);
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
return 0;
|
||||
@ -193,20 +190,18 @@ alpha_set_uac(struct thread *td, char *args)
|
||||
static int
|
||||
alpha_get_uac(struct thread *td, char *args)
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td2;
|
||||
struct proc *p, *pp;
|
||||
int error;
|
||||
unsigned long uac;
|
||||
|
||||
p = td->td_proc;
|
||||
error = ESRCH;
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pptr) {
|
||||
PROC_LOCK(p->p_pptr);
|
||||
/* XXXKSE which threads? */
|
||||
td2 = FIRST_THREAD_IN_PROC(p->p_pptr);
|
||||
uac = td2->td_md.md_flags & MDP_UAC_MASK;
|
||||
PROC_UNLOCK(p->p_pptr);
|
||||
pp = p->p_pptr;
|
||||
if (pp != NULL) {
|
||||
PROC_LOCK(pp);
|
||||
uac = p->p_md.md_uac;
|
||||
PROC_UNLOCK(pp);
|
||||
PROC_UNLOCK(p);
|
||||
error = copyout(&uac, args, sizeof(uac));
|
||||
} else
|
||||
|
@ -407,7 +407,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
/* FALLTHROUTH */
|
||||
case ALPHA_IF_CODE_BPT:
|
||||
case ALPHA_IF_CODE_BUGCHK:
|
||||
if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2)) {
|
||||
if (td->td_md.md_flags & (MDTD_STEP1|MDTD_STEP2)) {
|
||||
mtx_lock(&Giant);
|
||||
ptrace_clear_single_step(td);
|
||||
td->td_frame->tf_regs[FRAME_PC] -= 4;
|
||||
@ -1033,8 +1033,8 @@ unaligned_fixup(va, opcode, reg, td)
|
||||
*/
|
||||
|
||||
if (td) {
|
||||
uac = td->td_md.md_flags & MDP_UAC_MASK;
|
||||
p = td->td_proc;
|
||||
uac = p->p_md.md_uac;
|
||||
} else {
|
||||
uac = 0;
|
||||
p = NULL;
|
||||
|
@ -133,7 +133,8 @@ cpu_fork(td1, p2, td2, flags)
|
||||
p1 = td1->td_proc;
|
||||
td2->td_pcb = (struct pcb *)
|
||||
(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
|
||||
td2->td_md.md_flags = td1->td_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK);
|
||||
td2->td_md.md_flags = td1->td_md.md_flags & MDTD_FPUSED;
|
||||
p2->p_md.md_uac = p1->p_md.md_uac;
|
||||
|
||||
/*
|
||||
* Cache the physical address of the pcb, so we can
|
||||
|
@ -40,6 +40,11 @@ struct mdbpt {
|
||||
u_int32_t contents;
|
||||
};
|
||||
|
||||
#define MDTD_FPUSED 0x0001 /* Process used the FPU */
|
||||
#define MDTD_STEP1 0x0002 /* Single step normal instruction */
|
||||
#define MDTD_STEP2 0x0004 /* Single step branch instruction */
|
||||
#define MDTD_HAEUSED 0x0008 /* Process used the HAE */
|
||||
|
||||
struct mdthread {
|
||||
u_long md_flags;
|
||||
struct pcb *md_pcbpaddr; /* phys addr of the pcb */
|
||||
@ -50,10 +55,6 @@ struct mdthread {
|
||||
register_t md_savecrit; /* save PSL for critical section */
|
||||
};
|
||||
|
||||
#define MDP_FPUSED 0x0001 /* Process used the FPU */
|
||||
#define MDP_STEP1 0x0002 /* Single step normal instruction */
|
||||
#define MDP_STEP2 0x0004 /* Single step branch instruction */
|
||||
#define MDP_HAEUSED 0x0008 /* Process used the HAE */
|
||||
#define MDP_UAC_NOPRINT 0x0010 /* Don't print unaligned traps */
|
||||
#define MDP_UAC_NOFIX 0x0020 /* Don't fixup unaligned traps */
|
||||
#define MDP_UAC_SIGBUS 0x0040 /* Deliver SIGBUS upon
|
||||
@ -61,6 +62,7 @@ struct mdthread {
|
||||
#define MDP_UAC_MASK (MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS)
|
||||
|
||||
struct mdproc {
|
||||
u_int md_uac; /* Unaligned Access Check flags. */
|
||||
};
|
||||
|
||||
#endif /* !_MACHINE_PROC_H_ */
|
||||
|
@ -631,7 +631,7 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
|
||||
/* save the floating-point state, if necessary, then copy it. */
|
||||
alpha_fpstate_save(td, 1); /* XXX maybe write=0 */
|
||||
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDP_FPUSED;
|
||||
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDTD_FPUSED;
|
||||
bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs,
|
||||
sizeof(struct fpreg));
|
||||
ksi.si_sc.sc_fp_control = td->td_pcb->pcb_fp_control;
|
||||
|
Loading…
Reference in New Issue
Block a user