lkml.org 
[lkml]   [2006]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Assignment of GDT entries
Albert Cahalan wrote
>>
>> There are only 32 possible GDT entries in 32-bit i386 Linux, and only
>> three of them are usable for userspace. You can't find out which slots
>> are in use, but you can cause one to be allocated and returned to you.
>> This seems like a perfectly reasonable API to me, why do you think it is
>> so ugly?
>
> Eh, "returned to you" doesn't work for me. I need to
> figure out what other code (not written by me) uses.

I don't understand. Why do you need to figure that out? You need a
selector, you ask for one, and you get assigned one. It is that
simple. You can't figure out what other code uses, and the kernel has
no way to tell you, because that is an application level allocation
problem, not a kernel responsibility. The kernel has no visibility into
userspace intentions regarding segment usage.

> I may need to "borrow" a slot if all three slots are in
> use. Without using evil knowledge of the GDT, how
> am I to do that? I don't know what slots might have
> been allocated by other libraries.

What kind of libraries are you using? Unless this is really, really,
special purpose, they are going to allocate at most one, and that is
only if you use TLS libraries.

If all three slots are in use (i.e. your allocation fails), you'll have
to allocate an LDT selector, just like wine:

void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry )
{
if ((sel & ~3) == (global_fs_sel & ~3))
{
#ifdef __linux__
struct modify_ldt_s ldt_info;
int ret;

ldt_info.entry_number = sel >> 3;
fill_modify_ldt_struct( &ldt_info, entry );
if ((ret = set_thread_area( &ldt_info ) < 0)) perror(
"set_thread_area" );
#elif defined(__APPLE__)
int ret = thread_set_user_ldt( wine_ldt_get_base(entry),
wine_ldt_get_limit(entry), 0 );
if (ret == -1) perror( "thread_set_user_ldt" );
else assert( ret == global_fs_sel );
#endif /* __APPLE__ */
}
else /* LDT selector */
{
internal_set_entry( sel, entry ); <---- just like this
}
wine_set_fs( sel );
}

Zach
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-09-14 09:27    [W:0.039 / U:1.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site