Hello!
CVSRT:/cvsroot/hurd
Module name:gnumach
Branch:gnumach-1-branch
Changes by:Samuel Thibault <sthibaul>06/11/05 20:39:25
[]
2006-11-05 Barry deFreese <bddebian (AT) comcast (DOT) net>
[task #5878 ``Backport code from GNU Mach's trunk to
gnumach-1-branch: i386_set_gdt, i386_get_gdt'']
[]
* i386/i386/user_ldt.c (i386_set_gdt, i386_get_gdt): New functions.
Since this is a back-port from SKit Mach's code, it might be interesting
to explain the following divergences from the SKit code perhaps
Roland would like to have these changes explained, as he's written the
original code, if I recall correctly:
#v+
@@ -221,16 +223,16 @@ i386_set_ldt(thread, first_selector, des
[]
- else if (thread == current_thread()) {
- struct x86_desc template = {0, 0, 0, ACC_P, 0, 0 ,0};
+ else {
+ struct real_descriptor template = {0, 0, 0, ACC_P, 0, 0 ,0};
#v-
The following differences might be caused simply by the SKit Mach code
being different from the GNU Mach one, but you can confirm that more
easily than I could do right now.
#v+
@@ -411,46 +413,45 @@ i386_set_gdt (thread_t thread, int *sele
if (*selector == -1)
{
- for (idx = sel_idx (USER_GDT); idx < sel_idx (USER_GDT) + USER_GDT_SLTS;
- ++idx)
+ for (idx = 0; idx < USER_GDT_SLTS; ++idx)
if ((thread->pcb->ims.user_gdt[idx].access & ACC_P) == 0)
{
- *selector = (idx << 3) | SEL_PL_U;
+ *selector = ((idx + sel_idx(USER_GDT)) << 3) | SEL_PL_U;
break;
}
- if (idx == sel_idx (USER_GDT) + USER_GDT_SLTS)
+ if (idx == USER_GDT_SLTS)
return KERN_NSPACE; /* ? */
}
else if ((*selector & (SEL_LDT|SEL_PL)) != SEL_PL_U
- || sel_idx (*selector) < USER_GDT
- || sel_idx (*selector) >= USER_GDT + USER_GDT_SLTS)
+ || sel_idx (*selector) < sel_idx(USER_GDT)
+ || sel_idx (*selector) >= sel_idx(USER_GDT) + USER_GDT_SLTS)
return KERN_INVALID_ARGUMENT;
else
- idx = sel_idx (*selector);
+ idx = sel_idx (*selector) - sel_idx(USER_GDT);
- if ((desc->access & ACC_P) == 0)
+ if ((desc.access & ACC_P) == 0)
memset (&thread->pcb->ims.user_gdt[idx], 0,
sizeof thread->pcb->ims.user_gdt[idx]);
- else if ((desc->access & (ACC_TYPE|ACC_PL)) != (ACC_TYPE_USER|ACC_PL_U))
+ else if ((desc.access & (ACC_TYPE_USER|ACC_PL)) != (ACC_TYPE_USER|ACC_PL_U))
return KERN_INVALID_ARGUMENT;
else
- thread->pcb->ims.user_gdt[idx] = *desc;
+ thread->pcb->ims.user_gdt[idx] = desc;
return KERN_SUCCESS;
}
[]
[i386_get_gdt]
if ((selector & (SEL_LDT|SEL_PL)) != SEL_PL_U
- || sel_idx (selector) < USER_GDT
- || sel_idx (selector) >= USER_GDT + USER_GDT_SLTS)
+ || sel_idx (selector) < sel_idx(USER_GDT)
+ || sel_idx (selector) >= sel_idx(USER_GDT) + USER_GDT_SLTS)
return KERN_INVALID_ARGUMENT;
- *desc = thread->pcb->ims.user_gdt[sel_idx (selector)];
+ *desc = thread->pcb->ims.user_gdt[sel_idx (selector) - sel_idx(USER_GDT)];
#v-
Please also add a note to the ChangeLog that this commit is a back-port,
see the Roland McGrath ChangeLog entry from 2006-05-14 for an idea how
this might look like.
* New file.
Please move that file to `linux/src/include/linux/head.h' (and then add a
proper ChangeLog entry for that file). I'm not going to follow the `src'
vs. `dev' distinction any further.
Thanks for completing this task!
Regards,
Thomas
Bug-hurd mailing list
Bug-hurd (AT) gnu (DOT) org
PGP SIGNATURE
Version: GnuPG v1.2.5 (GNU/Linux)
HHblzpt9vn59PcY3Ht2L3M0=
=Xy+I
PGP SIGNATURE