Re: [PATCH 1/2] x86: Add getter/setter static inlines for x86 descriptors

Joe Damato
2009-03-29T21:50:39Z

On Sun, Mar 29, 2009 at 2:28 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> Joe Damato wrote:
>> Static inline getters/setters have been provided to encourage consumers not to touch the internals of 32bit x86 descriptors directly.
>>
>> Signed-off-by: Joe Damato <ice799@gmail.com>
>
> Okay, what is the motivation for this?
>
> This is a serious question.  The x86 descriptors are so complex that
> it's not clear to me that this restriction makes the code any more
> clear.  Especially not with things like:
>
> -               cpu->arch.gdt[i].b |= 0x00000100;
> +               desc_set_hi(tmp,  desc_get_hi(tmp) | 0x00000100);
>
> This isn't an improvement.  If you're doing to so something like this,
> you need to actually implement the *intent* here.

Hi -

In my first patch set several months ago I replaced the structure
desc_struct with bit fields that exposed the fields for IDT/LDT/TSS
entries. This patch set was rejected for several reasons, one of which
was that Linux is trying to move away from bit fields. I also received
other comments such as "take a smaller bite", etc.

So instead of the bit fields, I implemented static inline
getters/setters. I thought that this small change would be a good
first step to re-test the waters of submitting patches to the kernel
before I started to clean out more pieces of the x86 architecture
specific code.

I agree that this isn't very clear, but from comments I received on my
first set, I assumed that this was closer to what people wanted to see
in the kernel. I am happy to iterate and submit something better, but
I am clearly misunderstanding what people would like to see.

Any suggestions on how this first-timer can help are greatly appreciated.

Joe