summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew N. Dodd <mdodd@FreeBSD.org>2002-09-22 01:32:48 +0000
committerMatthew N. Dodd <mdodd@FreeBSD.org>2002-09-22 01:32:48 +0000
commite58de9c6bcb6df5b1473e200a93d83886b4d7ca4 (patch)
tree59129b63c5f4f73c0bd94197260f8063464cad2a
parentbe0e6bfc0b301dbb2bec84d894b4c4221f5978c0 (diff)
Notes
-rw-r--r--sys/amd64/amd64/machdep.c17
-rw-r--r--sys/i386/i386/machdep.c17
2 files changed, 8 insertions, 26 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index fcf7434a5459..fb3603d143e5 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -853,6 +853,10 @@ exec_setregs(td, entry, stack, ps_strings)
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
+ /* Reset pc->pcb_gs and %gs before possibly invalidating it. */
+ pcb->pcb_gs = _udatasel;
+ load_gs(_udatasel);
+
if (td->td_proc->p_md.md_ldt)
user_ldt_free(td);
@@ -869,19 +873,6 @@ exec_setregs(td, entry, stack, ps_strings)
/* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
regs->tf_ebx = ps_strings;
- /* reset %gs as well */
- if (pcb == PCPU_GET(curpcb))
- load_gs(_udatasel);
-
- /*
- * Always reset pcb->pcb_gs to udatasel, it will be loaded into gs
- * by cpu_switch_load_gs when this process returns from the system
- * call. Failing to reset pcb_gs here can cause cpu_switch_load_gs
- * to trigger a general protection fault if the parent process had
- * modified gs to point at a LDT entry.
- */
- pcb->pcb_gs = _udatasel;
-
/*
* Reset the hardware debug registers if they were in use.
* They won't have any meaning for the newly exec'd process.
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index fcf7434a5459..fb3603d143e5 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -853,6 +853,10 @@ exec_setregs(td, entry, stack, ps_strings)
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
+ /* Reset pc->pcb_gs and %gs before possibly invalidating it. */
+ pcb->pcb_gs = _udatasel;
+ load_gs(_udatasel);
+
if (td->td_proc->p_md.md_ldt)
user_ldt_free(td);
@@ -869,19 +873,6 @@ exec_setregs(td, entry, stack, ps_strings)
/* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
regs->tf_ebx = ps_strings;
- /* reset %gs as well */
- if (pcb == PCPU_GET(curpcb))
- load_gs(_udatasel);
-
- /*
- * Always reset pcb->pcb_gs to udatasel, it will be loaded into gs
- * by cpu_switch_load_gs when this process returns from the system
- * call. Failing to reset pcb_gs here can cause cpu_switch_load_gs
- * to trigger a general protection fault if the parent process had
- * modified gs to point at a LDT entry.
- */
- pcb->pcb_gs = _udatasel;
-
/*
* Reset the hardware debug registers if they were in use.
* They won't have any meaning for the newly exec'd process.