summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorse <se@FreeBSD.org>1997-01-02 01:43:09 +0000
committerse <se@FreeBSD.org>1997-01-02 01:43:09 +0000
commit41dcd5fc8568fd94a8ff858b5861b08a3f20d39b (patch)
tree1fb7e31ee88528140ee185f995d7fa7cb1f5b7f8 /sys
parent92f2d80d98f3f9e8452629a6c7f0a8c0eb1bcac9 (diff)
downloadFreeBSD-src-41dcd5fc8568fd94a8ff858b5861b08a3f20d39b.zip
FreeBSD-src-41dcd5fc8568fd94a8ff858b5861b08a3f20d39b.tar.gz
Add code to copy the LDT, if required.
This code was sent to me by Bruce Evans, and seems to fix some possible kernel panic in case of an execution error. It did not cause any problems on my system, but I did never observe the problem this patch is supposed to fix, anyway. This patch is a NOP, unless the kernel is built with "options USER_LDT", and doesn't affect the GENERIC kernel for this reason. I want to have it in 2.2: it fixes a bug ... Submitted by: bde
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/vm_machdep.c17
-rw-r--r--sys/i386/i386/vm_machdep.c17
2 files changed, 32 insertions, 2 deletions
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index 62ff784..8ffd874 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.70 1996/10/15 03:16:33 dyson Exp $
+ * $Id: vm_machdep.c,v 1.71 1996/10/30 22:38:24 asami Exp $
*/
#include "npx.h"
@@ -572,6 +572,9 @@ cpu_fork(p1, p2)
struct pcb *pcb2 = &p2->p_addr->u_pcb;
int sp, offset;
volatile int retval;
+#ifdef USER_LDT
+ struct pcb *pcb = &p2->p_addr->u_pcb;
+#endif
/*
* Copy pcb and stack from proc p1 to p2.
@@ -595,6 +598,18 @@ cpu_fork(p1, p2)
*pcb2 = p1->p_addr->u_pcb;
pcb2->pcb_cr3 = vtophys(p2->p_vmspace->vm_pmap.pm_pdir);
+#ifdef USER_LDT
+ /* Copy the LDT, if necessary. */
+ if (pcb->pcb_ldt != 0) {
+ union descriptor *new_ldt;
+ size_t len = pcb->pcb_ldt_len * sizeof(union descriptor);
+
+ new_ldt = (union descriptor *)kmem_alloc(kernel_map, len);
+ bcopy(pcb->pcb_ldt, new_ldt, len);
+ pcb->pcb_ldt = (caddr_t)new_ldt;
+ }
+#endif
+
retval = 0; /* return 0 in parent */
savectx(pcb2);
return (retval);
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index 62ff784..8ffd874 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.70 1996/10/15 03:16:33 dyson Exp $
+ * $Id: vm_machdep.c,v 1.71 1996/10/30 22:38:24 asami Exp $
*/
#include "npx.h"
@@ -572,6 +572,9 @@ cpu_fork(p1, p2)
struct pcb *pcb2 = &p2->p_addr->u_pcb;
int sp, offset;
volatile int retval;
+#ifdef USER_LDT
+ struct pcb *pcb = &p2->p_addr->u_pcb;
+#endif
/*
* Copy pcb and stack from proc p1 to p2.
@@ -595,6 +598,18 @@ cpu_fork(p1, p2)
*pcb2 = p1->p_addr->u_pcb;
pcb2->pcb_cr3 = vtophys(p2->p_vmspace->vm_pmap.pm_pdir);
+#ifdef USER_LDT
+ /* Copy the LDT, if necessary. */
+ if (pcb->pcb_ldt != 0) {
+ union descriptor *new_ldt;
+ size_t len = pcb->pcb_ldt_len * sizeof(union descriptor);
+
+ new_ldt = (union descriptor *)kmem_alloc(kernel_map, len);
+ bcopy(pcb->pcb_ldt, new_ldt, len);
+ pcb->pcb_ldt = (caddr_t)new_ldt;
+ }
+#endif
+
retval = 0; /* return 0 in parent */
savectx(pcb2);
return (retval);
OpenPOWER on IntegriCloud