summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2002-10-21 05:27:41 +0000
committergrehan <grehan@FreeBSD.org>2002-10-21 05:27:41 +0000
commit0ef7fc1c4a36a733fbf9852e4f971a058997ae11 (patch)
tree156f761baa36237a5a5a2bba3417cf0fd11a1fa2
parentc3675872ba169579604baac393492ee7b66bc8bb (diff)
downloadFreeBSD-src-0ef7fc1c4a36a733fbf9852e4f971a058997ae11.zip
FreeBSD-src-0ef7fc1c4a36a733fbf9852e4f971a058997ae11.tar.gz
Add the USER_SR segment register to pcb state. Initialize correctly,
and save/restore during a context switch. The USER_SR could be overwritten when the current thread was switched out with a faulting copyin/copyout. Approved by: Benno
-rw-r--r--sys/powerpc/aim/swtch.S6
-rw-r--r--sys/powerpc/aim/vm_machdep.c1
-rw-r--r--sys/powerpc/include/pcb.h1
-rw-r--r--sys/powerpc/powerpc/genassym.c1
-rw-r--r--sys/powerpc/powerpc/swtch.S6
-rw-r--r--sys/powerpc/powerpc/swtch.s6
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c1
7 files changed, 22 insertions, 0 deletions
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S
index e02367a..188d5cf 100644
--- a/sys/powerpc/aim/swtch.S
+++ b/sys/powerpc/aim/swtch.S
@@ -83,6 +83,9 @@ ENTRY(cpu_switch)
stw %r16,PCB_CR(%r3)
mflr %r16 /* Save the link register */
stw %r16,PCB_LR(%r3)
+ mfsr %r16,USER_SR /* Save USER_SR for copyin/out */
+ isync
+ stw %r16,PCB_USR(%r3)
stw %r1,PCB_SP(%r3) /* Save the stack pointer */
#if 0
@@ -128,6 +131,9 @@ ENTRY(cpu_switch)
mtcr %r5
lwz %r5,PCB_LR(%r3) /* Load the link register */
mtlr %r5
+ lwz %r5,PCB_USR(%r3) /* Load the USER_SR segment reg */
+ mtsr USER_SR,%r5
+ isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
blr
diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c
index 5d4f6eb..284a031 100644
--- a/sys/powerpc/aim/vm_machdep.c
+++ b/sys/powerpc/aim/vm_machdep.c
@@ -166,6 +166,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
pcb->pcb_sp = (register_t)cf;
pcb->pcb_lr = (register_t)fork_trampoline;
+ pcb->pcb_usr = kernel_pmap->pm_sr[USER_SR];
/*
* Now cpu_switch() can schedule the new process.
diff --git a/sys/powerpc/include/pcb.h b/sys/powerpc/include/pcb.h
index c2042f2..a461b34 100644
--- a/sys/powerpc/include/pcb.h
+++ b/sys/powerpc/include/pcb.h
@@ -42,6 +42,7 @@ struct pcb {
register_t pcb_cr; /* Condition register */
register_t pcb_sp; /* stack pointer */
register_t pcb_lr; /* link register */
+ register_t pcb_usr; /* USER_SR segment register */
struct pmap *pcb_pm; /* pmap of our vmspace */
struct pmap *pcb_pmreal; /* real address of above */
faultbuf *pcb_onfault; /* For use during
diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c
index 0e1995d..02ca3d9 100644
--- a/sys/powerpc/powerpc/genassym.c
+++ b/sys/powerpc/powerpc/genassym.c
@@ -134,6 +134,7 @@ ASSYM(PCB_CR, offsetof(struct pcb, pcb_cr));
ASSYM(PCB_PMR, offsetof(struct pcb, pcb_pmreal));
ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp));
ASSYM(PCB_LR, offsetof(struct pcb, pcb_lr));
+ASSYM(PCB_USR, offsetof(struct pcb, pcb_usr));
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
diff --git a/sys/powerpc/powerpc/swtch.S b/sys/powerpc/powerpc/swtch.S
index e02367a..188d5cf 100644
--- a/sys/powerpc/powerpc/swtch.S
+++ b/sys/powerpc/powerpc/swtch.S
@@ -83,6 +83,9 @@ ENTRY(cpu_switch)
stw %r16,PCB_CR(%r3)
mflr %r16 /* Save the link register */
stw %r16,PCB_LR(%r3)
+ mfsr %r16,USER_SR /* Save USER_SR for copyin/out */
+ isync
+ stw %r16,PCB_USR(%r3)
stw %r1,PCB_SP(%r3) /* Save the stack pointer */
#if 0
@@ -128,6 +131,9 @@ ENTRY(cpu_switch)
mtcr %r5
lwz %r5,PCB_LR(%r3) /* Load the link register */
mtlr %r5
+ lwz %r5,PCB_USR(%r3) /* Load the USER_SR segment reg */
+ mtsr USER_SR,%r5
+ isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
blr
diff --git a/sys/powerpc/powerpc/swtch.s b/sys/powerpc/powerpc/swtch.s
index e02367a..188d5cf 100644
--- a/sys/powerpc/powerpc/swtch.s
+++ b/sys/powerpc/powerpc/swtch.s
@@ -83,6 +83,9 @@ ENTRY(cpu_switch)
stw %r16,PCB_CR(%r3)
mflr %r16 /* Save the link register */
stw %r16,PCB_LR(%r3)
+ mfsr %r16,USER_SR /* Save USER_SR for copyin/out */
+ isync
+ stw %r16,PCB_USR(%r3)
stw %r1,PCB_SP(%r3) /* Save the stack pointer */
#if 0
@@ -128,6 +131,9 @@ ENTRY(cpu_switch)
mtcr %r5
lwz %r5,PCB_LR(%r3) /* Load the link register */
mtlr %r5
+ lwz %r5,PCB_USR(%r3) /* Load the USER_SR segment reg */
+ mtsr USER_SR,%r5
+ isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
blr
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index 5d4f6eb..284a031 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -166,6 +166,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
pcb->pcb_sp = (register_t)cf;
pcb->pcb_lr = (register_t)fork_trampoline;
+ pcb->pcb_usr = kernel_pmap->pm_sr[USER_SR];
/*
* Now cpu_switch() can schedule the new process.
OpenPOWER on IntegriCloud