linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Glauber de Oliveira Costa" <glommer@gmail.com>
To: "Jeremy Fitzhardinge" <jeremy@goop.org>
Cc: "Glauber de Oliveira Costa" <gcosta@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	tglx@linutronix.de, mingo@elte.hu, ehabkost@redhat.com,
	avi@qumranet.com, anthony@codemonkey.ws,
	virtualization@lists.linux-foundation.org, rusty@rustcorp.com.au,
	ak@suse.de, chrisw@sous-sol.org, rostedt@goodmis.org,
	hpa@zytor.com, zach@vmware.com
Subject: Re: [PATCH 1/19] unify desc_struct
Date: Thu, 6 Dec 2007 17:37:27 -0200	[thread overview]
Message-ID: <5d6222a80712061137h74f9db55l7a8473f739549794@mail.gmail.com> (raw)
In-Reply-To: <47584C56.3070804@goop.org>

On Dec 6, 2007 5:24 PM, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
> Glauber de Oliveira Costa wrote:
> > This patch aims to make the access of struct desc_struct variables
> > equal across architectures. In this patch, I unify the i386 and x86_64
> > versions under an anonymous union, keeping the way they are accessed
> > untouched (a and b for 32-bit code, individual bit-fields for 64-bit).
> >
> > This solution is not beautiful, but will allow us to integrate common
> > code that differed by the way descriptors were used. This is to be viewed
> > incrementally. There's simply too much code to be fixed at once.
> >
> > In the future, goal is to set up in a single way of acessing
> > the desc_struct fields.
> >
> > Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
> > ---
> >  arch/x86/kernel/apm_32.c       |    2 +-
> >  arch/x86/kernel/cpu/common.c   |   28 ++++++++++++++--------------
> >  arch/x86/kernel/process_64.c   |    2 +-
> >  arch/x86/kernel/traps_32.c     |    2 +-
> >  include/asm-x86/desc_defs.h    |   28 ++++++++++++++++++++--------
> >  include/asm-x86/processor_32.h |    5 +----
> >  6 files changed, 38 insertions(+), 29 deletions(-)
> >
> > diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
> > index 8cd9778..b8b9339 100644
> > --- a/arch/x86/kernel/apm_32.c
> > +++ b/arch/x86/kernel/apm_32.c
> > @@ -405,7 +405,7 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
> >  static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
> >  static struct apm_user *     user_list;
> >  static DEFINE_SPINLOCK(user_list_lock);
> > -static const struct desc_struct      bad_bios_desc = { 0, 0x00409200 };
> > +static const struct desc_struct      bad_bios_desc = {{{ 0, 0x00409200 }}};
> >
> >  static const char            driver_version[] = "1.16ac";    /* no spaces */
> >
> > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> > index 235cd61..0fe1c1d 100644
> > --- a/arch/x86/kernel/cpu/common.c
> > +++ b/arch/x86/kernel/cpu/common.c
> > @@ -22,31 +22,31 @@
> >  #include "cpu.h"
> >
> >  DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
> > -     [GDT_ENTRY_KERNEL_CS] = { 0x0000ffff, 0x00cf9a00 },
> > -     [GDT_ENTRY_KERNEL_DS] = { 0x0000ffff, 0x00cf9200 },
> > -     [GDT_ENTRY_DEFAULT_USER_CS] = { 0x0000ffff, 0x00cffa00 },
> > -     [GDT_ENTRY_DEFAULT_USER_DS] = { 0x0000ffff, 0x00cff200 },
> > +     [GDT_ENTRY_KERNEL_CS] = {{{ 0x0000ffff, 0x00cf9a00 }}},
> > +     [GDT_ENTRY_KERNEL_DS] = {{{ 0x0000ffff, 0x00cf9200 }}},
> > +     [GDT_ENTRY_DEFAULT_USER_CS] = {{{ 0x0000ffff, 0x00cffa00 }}},
> > +     [GDT_ENTRY_DEFAULT_USER_DS] = {{{ 0x0000ffff, 0x00cff200 }}},
> >
>
> I don't suppose there's some way to make all this more symbolic?

There may be, but it's not the problem I'm trying to address in this
series. It's probably not too hard
to come up with a macro that receives the relevant parts of the
descriptors and create the initializers.

but it's deferred work.

>
>
> >       /*
> >        * Segments used for calling PnP BIOS have byte granularity.
> >        * They code segments and data segments have fixed 64k limits,
> >        * the transfer segment sizes are set at run time.
> >        */
> > -     [GDT_ENTRY_PNPBIOS_CS32] = { 0x0000ffff, 0x00409a00 },/* 32-bit code */
> > -     [GDT_ENTRY_PNPBIOS_CS16] = { 0x0000ffff, 0x00009a00 },/* 16-bit code */
> > -     [GDT_ENTRY_PNPBIOS_DS] = { 0x0000ffff, 0x00009200 }, /* 16-bit data */
> > -     [GDT_ENTRY_PNPBIOS_TS1] = { 0x00000000, 0x00009200 },/* 16-bit data */
> > -     [GDT_ENTRY_PNPBIOS_TS2] = { 0x00000000, 0x00009200 },/* 16-bit data */
> > +     [GDT_ENTRY_PNPBIOS_CS32] = {{{ 0x0000ffff, 0x00409a00 }}},/* 32-bit code */
> > +     [GDT_ENTRY_PNPBIOS_CS16] = {{{ 0x0000ffff, 0x00009a00 }}},/* 16-bit code */
> > +     [GDT_ENTRY_PNPBIOS_DS] = {{{ 0x0000ffff, 0x00009200 }}}, /* 16-bit data */
> > +     [GDT_ENTRY_PNPBIOS_TS1] = {{{ 0x00000000, 0x00009200 }}},/* 16-bit data */
> > +     [GDT_ENTRY_PNPBIOS_TS2] = {{{ 0x00000000, 0x00009200 }}},/* 16-bit data */
> >       /*
> >        * The APM segments have byte granularity and their bases
> >        * are set at run time.  All have 64k limits.
> >        */
> > -     [GDT_ENTRY_APMBIOS_BASE] = { 0x0000ffff, 0x00409a00 },/* 32-bit code */
> > +     [GDT_ENTRY_APMBIOS_BASE] = {{{ 0x0000ffff, 0x00409a00 }}},/* 32-bit code */
> >       /* 16-bit code */
> > -     [GDT_ENTRY_APMBIOS_BASE+1] = { 0x0000ffff, 0x00009a00 },
> > -     [GDT_ENTRY_APMBIOS_BASE+2] = { 0x0000ffff, 0x00409200 }, /* data */
> > +     [GDT_ENTRY_APMBIOS_BASE+1] = {{{ 0x0000ffff, 0x00009a00 }}},
> > +     [GDT_ENTRY_APMBIOS_BASE+2] = {{{ 0x0000ffff, 0x00409200 }}}, /* data */
> >
> > -     [GDT_ENTRY_ESPFIX_SS] = { 0x00000000, 0x00c09200 },
> > -     [GDT_ENTRY_PERCPU] = { 0x00000000, 0x00000000 },
> > +     [GDT_ENTRY_ESPFIX_SS] = {{{ 0x00000000, 0x00c09200 }}},
> > +     [GDT_ENTRY_PERCPU] = {{{ 0x00000000, 0x00000000 }}},
> >  } };
> >  EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
> >
> > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> > index 6724840..9e99cb7 100644
> > --- a/arch/x86/kernel/process_64.c
> > +++ b/arch/x86/kernel/process_64.c
> > @@ -437,7 +437,7 @@ static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
> >               .limit_in_pages = 1,
> >               .useable = 1,
> >       };
> > -     struct n_desc_struct *desc = (void *)t->thread.tls_array;
> > +     struct desc_struct *desc = (void *)t->thread.tls_array;
> >       desc += tls;
> >       desc->a = LDT_entry_a(&ud);
> >       desc->b = LDT_entry_b(&ud);
> > diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
> > index e15014e..94c5aea 100644
> > --- a/arch/x86/kernel/traps_32.c
> > +++ b/arch/x86/kernel/traps_32.c
> > @@ -76,7 +76,7 @@ char ignore_fpu_irq = 0;
> >   * F0 0F bug workaround.. We have a special link segment
> >   * for this.
> >   */
> > -struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {0, 0}, };
> > +struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {{{ 0, 0 }}}, };
> >
> >  asmlinkage void divide_error(void);
> >  asmlinkage void debug(void);
> > diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
> > index 0890040..b3db064 100644
> > --- a/include/asm-x86/desc_defs.h
> > +++ b/include/asm-x86/desc_defs.h
> > @@ -11,18 +11,30 @@
> >
> >  #include <linux/types.h>
> >
> > +/*
> > + * FIXME: Acessing the desc_struct through its fields is more elegant,
> > + * and should be the one valid thing to do. However, a lot of open code
> > + * still touches the a and b acessors, and doing this allow us to do it
> > + * incrementally. We keep the signature as a struct, rather than an union,
> > + * so we can get rid of it transparently in the future -- glommer
> > + */
> > +#define raw_desc_struct struct { unsigned int a, b; }
> > +#define detailed_desc_struct                                   \
> > +  struct {                                                       \
> > +     u16 limit0;                                             \
> > +     u16 base0;                                              \
> > +     unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;    \
> > +     unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 :8;\
> > +  }
> > +
> >  // 8 byte segment descriptor
> >  struct desc_struct {
> > -     u16 limit0;
> > -     u16 base0;
> > -     unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
> > -     unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
> > +     union {
> > +             raw_desc_struct;
> > +             detailed_desc_struct;
> > +     };
> >  } __attribute__((packed));
> >
>
> Is it really necessary to use #defines?  Couldn't you just define the
> structures inline, or give them names?

No, it's not necessary. It's just the less ugly way I found.
As I intend to switch all uses to the field accesses, instead of a and
b, I don't think it's a big deal. When it's done, the struct will be
clean and simple, with no need for
these defines.



-- 
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."

  reply	other threads:[~2007-12-06 19:37 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-06 16:16 [PATCH 0/19] desc_struct integration Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 1/19] unify desc_struct Glauber de Oliveira Costa
2007-12-06 16:16   ` [PATCH 2/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-06 16:16     ` [PATCH 3/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-06 16:16       ` [PATCH 4/19] removed unused variable Glauber de Oliveira Costa
2007-12-06 16:16         ` [PATCH 5/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-06 16:16           ` [PATCH 6/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16             ` [PATCH 7/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-06 16:16               ` [PATCH 8/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-06 16:16                 ` [PATCH 9/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-06 16:16                   ` [PATCH 10/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16                     ` [PATCH 11/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16                       ` [PATCH 12/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-06 16:16                         ` [PATCH 13/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-06 16:16                           ` [PATCH 14/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-06 16:16                             ` [PATCH 15/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-06 16:16                               ` [PATCH 16/19] provide tss_desc Glauber de Oliveira Costa
2007-12-06 16:16                                 ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-06 16:16                                   ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-06 16:16                                     ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-06 19:24   ` [PATCH 1/19] unify desc_struct Jeremy Fitzhardinge
2007-12-06 19:37     ` Glauber de Oliveira Costa [this message]
2007-12-06 20:54   ` Andi Kleen
2007-12-06 21:20     ` Glauber de Oliveira Costa
2007-12-06 22:03       ` Jeremy Fitzhardinge
2007-12-12 12:53 ` [PATCH 0/19] desc_struct integration Glauber de Oliveira Costa
2007-12-12 12:53   ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-12 12:53     ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-12 12:53       ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-12 12:53         ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-12 12:53           ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-12 12:53             ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53               ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-12 12:53                 ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-12 12:53                   ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-12 12:53                     ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-12 12:53                       ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53                         ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53                           ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-12 12:53                             ` [PATCH 14/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-12 12:54                               ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-12 12:54                                 ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-12 12:54                                   ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-12 12:54                                     ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-12 12:54                                       ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-12 17:56                     ` [PATCH 09/19] introduce fill_ldt Ingo Molnar
2007-12-12 17:20   ` [PATCH 0/19] desc_struct integration Ingo Molnar
2007-12-12 18:11     ` Ingo Molnar
2007-12-12 18:20       ` Ingo Molnar
2007-12-12 18:27         ` Glauber de Oliveira Costa
2007-12-12 18:33           ` Ingo Molnar
2007-12-12 19:05             ` Glauber de Oliveira Costa
2007-12-12 18:34           ` Ingo Molnar
2007-12-12 23:39   ` H. Peter Anvin
2007-12-13  2:01 ` [PATCH 0/19 - v3] " Glauber de Oliveira Costa
2007-12-13  2:01   ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-13  2:01     ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-13  2:01       ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-13  2:01         ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-13  2:01           ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-13  2:01             ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-13  2:01               ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-13  2:01                 ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-13  2:01                   ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-13  2:01                     ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-13  2:01                       ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-13  2:01                         ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-13  2:01                           ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-13  2:01                             ` [PATCH 14/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-13  2:01                               ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-13  2:01                                 ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-13  2:01                                   ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-13  2:01                                     ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-13  2:01                                       ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-13 12:46                                         ` Andi Kleen
2007-12-13 14:50                                           ` Glauber de Oliveira Costa
2007-12-13 13:57   ` [PATCH 0/19 -v4] desc_struct integration Glauber de Oliveira Costa
2007-12-13 13:57     ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-13 13:57       ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-13 13:57         ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-13 13:57           ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-13 13:57             ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-13 13:57               ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-13 13:57                 ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-13 13:57                   ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-13 13:57                     ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-13 13:57                       ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-13 13:57                         ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-13 13:58                           ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-13 13:58                             ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-13 13:58                               ` [PATCH 14/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-13 13:58                                 ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-13 13:58                                   ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-13 13:58                                     ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-13 13:58                                       ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-13 13:58                                         ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-22  2:07                                         ` [PATCH 18/19] move _set_gate and its users to a common location Ingo Molnar
2007-12-13 16:47     ` [PATCH 0/19 -v4] desc_struct integration Ingo Molnar
2007-12-13 17:06       ` Glauber de Oliveira Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d6222a80712061137h74f9db55l7a8473f739549794@mail.gmail.com \
    --to=glommer@gmail.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=anthony@codemonkey.ws \
    --cc=avi@qumranet.com \
    --cc=chrisw@sous-sol.org \
    --cc=ehabkost@redhat.com \
    --cc=gcosta@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=zach@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).