save cr2 for the benefit of linux emulation, and normalize use of pcb
in trap(), i.e. always initialize *pcb and use it instead of doing it sometimes.
This commit is contained in:
parent
9e98a7e93d
commit
c8e246669c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: trap.c,v 1.163 2002/02/14 07:08:07 chs Exp $ */
|
/* $NetBSD: trap.c,v 1.164 2002/02/16 16:22:04 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||||
@ -79,7 +79,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.163 2002/02/14 07:08:07 chs Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.164 2002/02/16 16:22:04 christos Exp $");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
#include "opt_kgdb.h"
|
#include "opt_kgdb.h"
|
||||||
@ -170,7 +170,7 @@ trap(frame)
|
|||||||
{
|
{
|
||||||
register struct proc *p = curproc;
|
register struct proc *p = curproc;
|
||||||
int type = frame.tf_trapno;
|
int type = frame.tf_trapno;
|
||||||
struct pcb *pcb = NULL;
|
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||||
extern char fusubail[],
|
extern char fusubail[],
|
||||||
resume_iret[], resume_pop_ds[], resume_pop_es[],
|
resume_iret[], resume_pop_ds[], resume_pop_es[],
|
||||||
resume_pop_fs[], resume_pop_gs[],
|
resume_pop_fs[], resume_pop_gs[],
|
||||||
@ -194,6 +194,7 @@ trap(frame)
|
|||||||
if (!KERNELMODE(frame.tf_cs, frame.tf_eflags)) {
|
if (!KERNELMODE(frame.tf_cs, frame.tf_eflags)) {
|
||||||
type |= T_USER;
|
type |= T_USER;
|
||||||
p->p_md.md_regs = &frame;
|
p->p_md.md_regs = &frame;
|
||||||
|
pcb->pcb_cr2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -234,7 +235,6 @@ trap(frame)
|
|||||||
case T_ALIGNFLT:
|
case T_ALIGNFLT:
|
||||||
case T_TSSFLT:
|
case T_TSSFLT:
|
||||||
/* Check for copyin/copyout fault. */
|
/* Check for copyin/copyout fault. */
|
||||||
pcb = &p->p_addr->u_pcb;
|
|
||||||
if (pcb->pcb_onfault != 0) {
|
if (pcb->pcb_onfault != 0) {
|
||||||
copyefault:
|
copyefault:
|
||||||
error = EFAULT;
|
error = EFAULT;
|
||||||
@ -375,7 +375,6 @@ copyfault:
|
|||||||
case T_PAGEFLT: /* allow page faults in kernel mode */
|
case T_PAGEFLT: /* allow page faults in kernel mode */
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
goto we_re_toast;
|
goto we_re_toast;
|
||||||
pcb = &p->p_addr->u_pcb;
|
|
||||||
/*
|
/*
|
||||||
* fusubail is used by [fs]uswintr() to prevent page faulting
|
* fusubail is used by [fs]uswintr() to prevent page faulting
|
||||||
* from inside the profiling interrupt.
|
* from inside the profiling interrupt.
|
||||||
@ -399,7 +398,8 @@ copyfault:
|
|||||||
|
|
||||||
if (vm == NULL)
|
if (vm == NULL)
|
||||||
goto we_re_toast;
|
goto we_re_toast;
|
||||||
va = trunc_page((vaddr_t)rcr2());
|
pcb->pcb_cr2 = rcr2();
|
||||||
|
va = trunc_page((vaddr_t)pcb->pcb_cr2);
|
||||||
/*
|
/*
|
||||||
* It is only a kernel address space fault iff:
|
* It is only a kernel address space fault iff:
|
||||||
* 1. (type & T_USER) == 0 and
|
* 1. (type & T_USER) == 0 and
|
||||||
@ -444,10 +444,10 @@ copyfault:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fault the original page in. */
|
/* Fault the original page in. */
|
||||||
onfault = p->p_addr->u_pcb.pcb_onfault;
|
onfault = pcb->pcb_onfault;
|
||||||
p->p_addr->u_pcb.pcb_onfault = NULL;
|
pcb->pcb_onfault = NULL;
|
||||||
error = uvm_fault(map, va, 0, ftype);
|
error = uvm_fault(map, va, 0, ftype);
|
||||||
p->p_addr->u_pcb.pcb_onfault = onfault;
|
pcb->pcb_onfault = onfault;
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
if (nss > vm->vm_ssize)
|
if (nss > vm->vm_ssize)
|
||||||
vm->vm_ssize = nss;
|
vm->vm_ssize = nss;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: pcb.h,v 1.29 2001/08/02 21:04:45 thorpej Exp $ */
|
/* $NetBSD: pcb.h,v 1.30 2002/02/16 16:22:03 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
@ -97,7 +97,7 @@ struct pcb {
|
|||||||
#define pcb_ebp pcb_tss.tss_ebp
|
#define pcb_ebp pcb_tss.tss_ebp
|
||||||
#define pcb_ldt_sel pcb_tss.tss_ldt
|
#define pcb_ldt_sel pcb_tss.tss_ldt
|
||||||
int pcb_cr0; /* saved image of CR0 */
|
int pcb_cr0; /* saved image of CR0 */
|
||||||
int pcb_pad0; /* align pcb_savefpu to 16 bytes */
|
int pcb_cr2; /* page fault address (CR2) */
|
||||||
union savefpu pcb_savefpu; /* floating point state for FPU */
|
union savefpu pcb_savefpu; /* floating point state for FPU */
|
||||||
struct emcsts pcb_saveemc; /* Cyrix EMC state */
|
struct emcsts pcb_saveemc; /* Cyrix EMC state */
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user