compat_bsdos leftover

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

compat_bsdos leftover

Vladimir Kirillov-2
Hi!
I guess the following is the leftover.

Index: include/segments.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/include/segments.h,v
retrieving revision 1.17
diff -u -p -r1.17 segments.h
--- include/segments.h 1 Jul 2010 17:30:27 -0000 1.17
+++ include/segments.h 24 Dec 2010 17:09:07 -0000
@@ -228,7 +228,6 @@ void idt_vec_free(int);
 /*
  * Entries in the Local Descriptor Table (LDT)
  */
-#define LBSDICALLS_SEL 16 /* BSDI system call gate */
-#define NLDT 17
+#define NLDT 16
 
 #endif /* _I386_SEGMENTS_H_ */

Reply | Threaded
Open this post in threaded view
|

Re: compat_bsdos leftover

Ted Unangst-2
On Fri, Dec 24, 2010 at 12:10 PM, Vladimir Kirillov <[hidden email]>
wrote:
> Hi!
> I guess the following is the leftover.

Thanks, I removed it.  I left NLDT at 17, though, because there
doesn't appear to be much benefit in shrinking that vs whatever weird
binary compatibility issues there may be.

>
> Index: include/segments.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/include/segments.h,v
> retrieving revision 1.17
> diff -u -p -r1.17 segments.h
> --- include/segments.h  1 Jul 2010 17:30:27 -0000       1.17
> +++ include/segments.h  24 Dec 2010 17:09:07 -0000
> @@ -228,7 +228,6 @@ void idt_vec_free(int);
>  /*
>  * Entries in the Local Descriptor Table (LDT)
>  */
> -#define        LBSDICALLS_SEL  16      /* BSDI system call gate */
> -#define        NLDT            17
> +#define        NLDT            16
>
>  #endif /* _I386_SEGMENTS_H_ */

Reply | Threaded
Open this post in threaded view
|

Re: compat_bsdos leftover

Mark Kettenis
> Date: Fri, 24 Dec 2010 15:27:37 -0500
> From: Ted Unangst <[hidden email]>
>
> On Fri, Dec 24, 2010 at 12:10 PM, Vladimir Kirillov <[hidden email]>
> wrote:
> > Hi!
> > I guess the following is the leftover.
>
> Thanks, I removed it.  I left NLDT at 17, though, because there
> doesn't appear to be much benefit in shrinking that vs whatever weird
> binary compatibility issues there may be.

Well, changing NLDT to 17 should defenitely be tested, but leaving it
at 17 is a bit odd.  I'm actually wondering whether the default LDT is
necessary at all now that LBSDICALLS_SEL is gone.  Then NLDT can go
completely.

Reply | Threaded
Open this post in threaded view
|

Re: compat_bsdos leftover

Ted Unangst-2
On Fri, 24 Dec 2010, Mark Kettenis wrote:

> Well, changing NLDT to 17 should defenitely be tested, but leaving it
> at 17 is a bit odd.  I'm actually wondering whether the default LDT is
> necessary at all now that LBSDICALLS_SEL is gone.  Then NLDT can go
> completely.

From a brief look, eliminating the default entirely just makes things more
complicated, but we can shrink it down to 1.  I switched things over to
using malloc instead of uvm_km_alloc because there's no reason to allocate
full pages for tiny things.

This will need more testing, of course.

Index: i386/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.485
diff -u -r1.485 machdep.c
--- i386/machdep.c 2 Oct 2010 23:31:34 -0000 1.485
+++ i386/machdep.c 24 Dec 2010 21:35:04 -0000
@@ -2868,7 +2868,7 @@
  union descriptor *cpu_ldt;
  size_t len = sizeof(ldt);
 
- cpu_ldt = (union descriptor *)uvm_km_alloc(kernel_map, len);
+ cpu_ldt = malloc(len, M_DEVBUF, M_WAITOK);
  bcopy(ldt, cpu_ldt, len);
  ci->ci_ldt = cpu_ldt;
  ci->ci_ldt_len = len;
Index: i386/pmap.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/pmap.c,v
retrieving revision 1.151
diff -u -r1.151 pmap.c
--- i386/pmap.c 30 Nov 2010 19:28:59 -0000 1.151
+++ i386/pmap.c 24 Dec 2010 21:35:06 -0000
@@ -1547,8 +1547,7 @@
  * we're the last one to use it.
  */
  ldt_free(pmap);
- uvm_km_free(kernel_map, (vaddr_t)pmap->pm_ldt,
-    pmap->pm_ldt_len * sizeof(union descriptor));
+ free(pmap->pm_ldt, M_DEVBUF);
  }
 #endif
  pool_put(&pmap_pmap_pool, pmap);
@@ -1586,11 +1585,7 @@
  size_t len;
 
  len = pmap1->pm_ldt_len * sizeof(union descriptor);
- new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, len);
- if (new_ldt == NULL) {
- /* XXX needs to be able to fail properly */
- panic("pmap_fork: out of kva");
- }
+ new_ldt = malloc(len, M_DEVBUF, M_WAITOK);
  bcopy(pmap1->pm_ldt, new_ldt, len);
  pmap2->pm_ldt = new_ldt;
  pmap2->pm_ldt_len = pmap1->pm_ldt_len;
@@ -1642,7 +1637,7 @@
  simple_unlock(&pmap->pm_obj.vmobjlock);
 
  if (old_ldt != NULL)
- uvm_km_free(kernel_map, (vaddr_t)old_ldt, len);
+ free(old_ldt, M_DEVBUF);
 }
 #endif /* USER_LDT */
 
Index: i386/sys_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/sys_machdep.c,v
retrieving revision 1.27
diff -u -r1.27 sys_machdep.c
--- i386/sys_machdep.c 20 Nov 2010 20:21:13 -0000 1.27
+++ i386/sys_machdep.c 24 Dec 2010 21:35:06 -0000
@@ -262,8 +262,7 @@
  new_len = ldt_len * sizeof(union descriptor);
 
  simple_unlock(&pmap->pm_lock);
- new_ldt = (union descriptor *)uvm_km_alloc(kernel_map,
-    new_len);
+ new_ldt = malloc(new_len, M_DEVBUF, M_WAITOK);
  if (new_ldt == NULL) {
  error = ENOMEM;
  goto out;
@@ -279,7 +278,7 @@
  * hey.. not our problem if user applications
  * have race conditions like that.
  */
- uvm_km_free(kernel_map, (vaddr_t)new_ldt, new_len);
+ free(new_ldt, M_DEVBUF);
  goto copy;
  }
 
@@ -296,7 +295,7 @@
  memset((caddr_t)new_ldt + old_len, 0, new_len - old_len);
 
  if (old_ldt != ldt)
- uvm_km_free(kernel_map, (vaddr_t)old_ldt, old_len);
+ free(old_ldt, M_DEVBUF);
 
  pmap->pm_ldt = new_ldt;
  pmap->pm_ldt_len = ldt_len;
Index: include/segments.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/include/segments.h,v
retrieving revision 1.18
diff -u -r1.18 segments.h
--- include/segments.h 24 Dec 2010 20:26:30 -0000 1.18
+++ include/segments.h 24 Dec 2010 21:35:06 -0000
@@ -227,7 +227,8 @@
 
 /*
  * Entries in the Local Descriptor Table (LDT)
+ * (not normally used)
  */
-#define NLDT 17
+#define NLDT 1
 
 #endif /* _I386_SEGMENTS_H_ */

Reply | Threaded
Open this post in threaded view
|

Re: compat_bsdos leftover

Philip Guenther-2
In reply to this post by Mark Kettenis
On Fri, Dec 24, 2010 at 12:45 PM, Mark Kettenis <[hidden email]>
wrote:
...
> Well, changing NLDT to 17 should defenitely be tested, but leaving it
> at 17 is a bit odd.  I'm actually wondering whether the default LDT is
> necessary at all now that LBSDICALLS_SEL is gone.  Then NLDT can go
> completely.

Yep, the default ldt should be able to go away completely and the ldt
register explicitly set to zero except for processes that use the
i386_set_ldt() sysarch call.  I'm currently separated from my i386
test box, so I won't hazard a diff for this right now, but it deserves
a blow torch to clean it out.


Philip Guenther