Re: NVidia glx stuff dies in sysarch(I386_SET_LDT, ...)

From: Daniel Eischen <eischen_at_vigrid.com>
Date: Fri, 1 Aug 2003 20:10:46 -0400 (EDT)
On Fri, 1 Aug 2003, Julian Elischer wrote:
> 
> Here's my first patch..
> I'd suggest this (along with man page change) to go in first
> for a while before we break people's code.
> 
> cvs server: Diffing .
> Index: sys_machdep.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/i386/i386/sys_machdep.c,v
> retrieving revision 1.86
> diff -u -r1.86 sys_machdep.c
> --- sys_machdep.c       31 Jul 2003 08:20:24 -0000      1.86
> +++ sys_machdep.c       1 Aug 2003 23:58:29 -0000
> _at__at_ -410,6 +410,9 _at__at_
>         return(error);
>  }
>  
> +static int ldt_warnings;
> +#define NUM_LDT_WARNINGS 10
> +
>  static int
>  i386_set_ldt(td, args)
>         struct thread *td;
> _at__at_ -441,7 +444,7 _at__at_
>                         uap->start = NLDT;
>                         uap->num = MAX_LD - NLDT;
>                 }
> -               if (uap->start < NLDT || uap->num <= 0)
> +               if (uap->start <= LUDATA_SEL || uap->num <= 0)
>                         return (EINVAL);
>                 mtx_lock_spin(&sched_lock);
>                 pldt = mdp->md_ldt;
> _at__at_ -460,10 +463,16 _at__at_
>         }
>  
>         if (!(uap->start == 0 && uap->num == 1)) {
> +               /* complain a for a while if using old methods */
> +               if (ldt_warnings++ < NUM_LDT_WARNINGS) {
> +                       printf("Warning: pid %d used static ldt
> allocation.\n",
> +                           td->td_proc->p_pid);
> +                       printf("See the i386_set_ldt man page for more
> info\n");
> +               }
>                 /* verify range of descriptors to modify */
>                 largest_ld = uap->start + uap->num;
> -               if (uap->start < NLDT || uap->start >= MAX_LD ||
> uap->num < 0 ||
> -                   largest_ld > MAX_LD) {
> +               if (uap->start <= LUDATA_SEL || uap->start >= MAX_LD ||
> +                   uap->num < 0 || largest_ld > MAX_LD) {
>                         return (EINVAL);
>                 }
>         }
> _at__at_ -562,7 +571,7 _at__at_
>  again:
>                 mtx_lock_spin(&sched_lock);
>                 dp = &((union descriptor *)(pldt->ldt_base))[NLDT];
> -               for (i = NLDT; i < pldt->ldt_len; ++i) {
> +               for (i = LUDATA_SEL + 1; i < pldt->ldt_len; ++i) {

Looks OK, but if we are doing a dynamic allocation, it might be
better to start at NLDT just to avoid the known problem of someone
using 6...  Just a thought.

-- 
Dan Eischen
Received on Fri Aug 01 2003 - 15:10:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:17 UTC