bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Change i386 RPC subsystem to include descriptor instead of r


From: Samuel Thibault
Subject: Re: [PATCH] Change i386 RPC subsystem to include descriptor instead of real_descriptor
Date: Fri, 27 Jan 2023 08:56:00 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Flavio Cruz, le ven. 27 janv. 2023 01:41:02 -0500, a ecrit:
> This should avoid issues with glibc and hurd as introduced in 
> https://git.savannah.gnu.org/cgit/hurd/gnumach.git/commit/?id=b379d5afdf65cce11426ab0349a3778b3fd632f5
>  
> since we are changing the types of the parameters when implementing the RPCs 
> to match the previous 
> declaration using `struct descriptor`.
> 
> ---
>  i386/i386/seg.h                          | 32 ++++++++++++++++++-
>  i386/i386/user_ldt.c                     | 18 ++++++-----
>  i386/include/mach/i386/mach_i386.defs    | 11 +++----
>  i386/include/mach/i386/mach_i386_types.h | 40 +++---------------------
>  4 files changed, 50 insertions(+), 51 deletions(-)
> 
> diff --git a/i386/i386/seg.h b/i386/i386/seg.h
> index 74853718..1177fdd9 100644
> --- a/i386/i386/seg.h
> +++ b/i386/i386/seg.h
> @@ -32,7 +32,6 @@
>  #define      _I386_SEG_H_
>  
>  #include <mach/inline.h>
> -#include <mach/machine/mach_i386_types.h>
>  
>  /*
>   * i386 segmentation.
> @@ -117,6 +116,37 @@ struct real_gate {
>  #include <mach/inline.h>
>  #include <mach/xen.h>
>  
> +/*
> + * Real segment descriptor.
> + */
> +struct real_descriptor {
> +     unsigned int    limit_low:16,   /* limit 0..15 */
> +                     base_low:16,    /* base  0..15 */
> +                     base_med:8,     /* base  16..23 */
> +                     access:8,       /* access byte */
> +                     limit_high:4,   /* limit 16..19 */
> +                     granularity:4,  /* granularity */
> +                     base_high:8;    /* base 24..31 */
> +};
> +typedef struct real_descriptor real_descriptor_t;
> +typedef real_descriptor_t *real_descriptor_list_t;
> +typedef const real_descriptor_list_t const_real_descriptor_list_t;
> +
> +#ifdef __x86_64__
> +struct real_descriptor64 {
> +     unsigned int    limit_low:16,   /* limit 0..15 */
> +                     base_low:16,    /* base  0..15 */
> +                     base_med:8,     /* base  16..23 */
> +                     access:8,       /* access byte */
> +                     limit_high:4,   /* limit 16..19 */
> +                     granularity:4,  /* granularity */
> +                     base_high:8,    /* base 24..31 */
> +                     base_ext:32,    /* base 32..63 */
> +                     reserved1:8,
> +                     zero:5,
> +                     reserved2:19;
> +};
> +#endif
>  
>  /* Format of a "pseudo-descriptor", used for loading the IDT and GDT.  */
>  struct pseudo_descriptor
> diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c
> index 858da681..4c89bd44 100644
> --- a/i386/i386/user_ldt.c
> +++ b/i386/i386/user_ldt.c
> @@ -52,10 +52,11 @@ kern_return_t
>  i386_set_ldt(
>       thread_t                thread,
>       int                     first_selector,
> -     struct real_descriptor  *desc_list,
> +     const struct descriptor  *descriptor_list,
>       unsigned int            count,
>       boolean_t               desc_list_inline)
>  {
> +     struct real_descriptor* desc_list = (struct real_descriptor 
> *)descriptor_list;
>       user_ldt_t      new_ldt, old_ldt, temp;
>       struct real_descriptor *dp;
>       unsigned        i;
> @@ -257,10 +258,11 @@ kern_return_t
>  i386_get_ldt(const thread_t thread,
>            int first_selector,
>            int selector_count,                 /* number wanted */
> -          struct real_descriptor **desc_list, /* in/out */
> +          struct descriptor **descriptor_list, /* in/out */
>            unsigned int *count                /* in/out */
>       )
>  {
> +     struct real_descriptor** desc_list = (struct real_descriptor 
> **)descriptor_list;
>       struct user_ldt *user_ldt;
>       pcb_t           pcb;
>       int             first_desc = sel_idx(first_selector);
> @@ -386,8 +388,9 @@ user_ldt_free(user_ldt_t user_ldt)
>  
>  
>  kern_return_t
> -i386_set_gdt (thread_t thread, int *selector, struct real_descriptor desc)
> +i386_set_gdt (thread_t thread, int *selector, struct descriptor descriptor)
>  {
> +     const struct real_descriptor *desc = (struct real_descriptor 
> *)&descriptor;
>    int idx;
>  
>    if (thread == THREAD_NULL)
> @@ -411,14 +414,14 @@ i386_set_gdt (thread_t thread, int *selector, struct 
> real_descriptor desc)
>    else
>      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_USER|ACC_PL)) != 
> (ACC_TYPE_USER|ACC_PL_U) || (desc.granularity & SZ_64))
> +  else if ((desc->access & (ACC_TYPE_USER|ACC_PL)) != 
> (ACC_TYPE_USER|ACC_PL_U) || (desc->granularity & SZ_64))
>  
>      return KERN_INVALID_ARGUMENT;
>    else
> -    thread->pcb->ims.user_gdt[idx] = desc;
> +             memcpy (&thread->pcb->ims.user_gdt[idx], desc, sizeof (struct 
> descriptor));
>  
>    /*
>     * If we are modifying the GDT for the current thread,
> @@ -431,8 +434,9 @@ i386_set_gdt (thread_t thread, int *selector, struct 
> real_descriptor desc)
>  }
>  
>  kern_return_t
> -i386_get_gdt (const thread_t thread, int selector, struct real_descriptor 
> *desc)
> +i386_get_gdt (const thread_t thread, int selector, struct descriptor 
> *descriptor)
>  {
> +     struct real_descriptor *desc = (struct real_descriptor *)descriptor;
>    if (thread == THREAD_NULL)
>      return KERN_INVALID_ARGUMENT;
>  
> diff --git a/i386/include/mach/i386/mach_i386.defs 
> b/i386/include/mach/i386/mach_i386.defs
> index 4694522b..965d5c3b 100644
> --- a/i386/include/mach/i386/mach_i386.defs
> +++ b/i386/include/mach/i386/mach_i386.defs
> @@ -43,9 +43,6 @@ MACH_I386_IMPORTS
>  type descriptor_t    =       struct[2] of uint32_t;
>  type descriptor_list_t =     array[*] of descriptor_t;
>  
> -type real_descriptor_t       =       descriptor_t;
> -type real_descriptor_list_t  =       array[*] of real_descriptor_t;
> -
>  import <mach/machine/mach_i386_types.h>;
>  
>  #if  KERNEL_SERVER
> @@ -69,13 +66,13 @@ skip;     /* i386_io_port_list */
>  routine      i386_set_ldt(
>               target_thread   : thread_t;
>               first_selector  : int;
> -             desc_list       : real_descriptor_list_t, serverCopy);
> +             desc_list       : descriptor_list_t, serverCopy);
>  
>  routine      i386_get_ldt(
>               target_thread   : thread_t;
>               first_selector  : int;
>               selector_count  : int;
> -     out     desc_list       : real_descriptor_list_t);
> +     out     desc_list       : descriptor_list_t);
>  
>  /* Request a new port IO_PERM that represents the capability to access
>     the I/O ports [FROM; TO] directly.  MASTER_PORT is the master device port.
> @@ -107,10 +104,10 @@ routine i386_io_perm_modify(
>  routine      i386_set_gdt(
>               target_thread   : thread_t;
>       inout   selector        : int;
> -             desc            : real_descriptor_t);
> +             desc            : descriptor_t);
>  
>  /* Fetch a segment descriptor set with a prior i386_set_gdt call.  */
>  routine      i386_get_gdt(
>               target_thread   : thread_t;
>               selector        : int;
> -     out     desc            : real_descriptor_t);
> +     out     desc            : descriptor_t);
> diff --git a/i386/include/mach/i386/mach_i386_types.h 
> b/i386/include/mach/i386/mach_i386_types.h
> index bfa91ca0..f5177fb5 100644
> --- a/i386/include/mach/i386/mach_i386_types.h
> +++ b/i386/include/mach/i386/mach_i386_types.h
> @@ -34,46 +34,14 @@
>  /*
>   * i386 segment descriptor.
>   */
> -struct segment_descriptor {
> +struct descriptor {
>       unsigned int    low_word;
>       unsigned int    high_word;
>  };
>  
> -typedef struct segment_descriptor descriptor_t;
> -typedef      struct segment_descriptor *descriptor_list_t;
> -typedef        const struct descriptor *const_segment_descriptor_list_t;
> -
> -/*
> - * Real segment descriptor.
> - */
> -struct real_descriptor {
> -     unsigned int    limit_low:16,   /* limit 0..15 */
> -                     base_low:16,    /* base  0..15 */
> -                     base_med:8,     /* base  16..23 */
> -                     access:8,       /* access byte */
> -                     limit_high:4,   /* limit 16..19 */
> -                     granularity:4,  /* granularity */
> -                     base_high:8;    /* base 24..31 */
> -};
> -typedef struct real_descriptor real_descriptor_t;
> -typedef real_descriptor_t *real_descriptor_list_t;
> -typedef const real_descriptor_list_t const_real_descriptor_list_t;
> -
> -#ifdef __x86_64__
> -struct real_descriptor64 {
> -     unsigned int    limit_low:16,   /* limit 0..15 */
> -                     base_low:16,    /* base  0..15 */
> -                     base_med:8,     /* base  16..23 */
> -                     access:8,       /* access byte */
> -                     limit_high:4,   /* limit 16..19 */
> -                     granularity:4,  /* granularity */
> -                     base_high:8,    /* base 24..31 */
> -                     base_ext:32,    /* base 32..63 */
> -                     reserved1:8,
> -                     zero:5,
> -                     reserved2:19;
> -};
> -#endif
> +typedef struct descriptor descriptor_t;
> +typedef      struct descriptor *descriptor_list_t;
> +typedef        const struct descriptor *const_descriptor_list_t;
>  
>  #endif /* !__ASSEMBLER__ */
>  
> -- 
> 2.39.0
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]