Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2008 10:22:35 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Konstantin Belousov <kib@freebsd.org>
Cc:        cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/i386/i386 sys_machdep.c
Message-ID:  <200809121022.36441.jhb@freebsd.org>
In-Reply-To: <200809120951.m8C9pOZj037333@repoman.freebsd.org>
References:  <200809120951.m8C9pOZj037333@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 12 September 2008 05:51:11 am Konstantin Belousov wrote:
> kib         2008-09-12 09:51:11 UTC
> 
>   FreeBSD src repository
> 
>   Modified files:
>     sys/i386/i386        sys_machdep.c 
>   Log:
>   SVN rev 182960 on 2008-09-12 09:51:11Z by kib
>   
>   The user_ldt_alloc() function shall return with dt_lock locked.
>   The user_ldt_free() function shall return with dt_lock unlocked.
>   Error handling code in both functions do not handle this, fix it by
>   doing necessary lock/unlock.
>   
>   While there, fix minor style nits.

Hmm, I had actually thought it was intentional for user_ldt_alloc() to only 
return with the lock held on success and depend on a later call to another 
method to drop the lock in the success case (so the locking isn't visible to 
consumers of the API in theory).  For example, i386_ldt_grow() depended on 
this feature and is now broken (it leaks a lock on failure).  I missed this 
when looking at this yesterday.

Other notes:

- Since user_ldt_free() handles the case of there not being an LDT, the code
  in exec_setregs() on i386 can be simplified to just always call
  user_ldt_free().
- cpu_exit() could possibly do the same.  I wonder if exec_setregs() needs the
  same fixup to %gs that cpu_exit() does.  If so, that could possibly be moved
  into user_ldt_free().  Ah, exec_setregs() does it unconditionally.  I think
  you could make cpu_exit() just do it unconditionally as well before calling
  user_ldt_free().

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809121022.36441.jhb>