* Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2]
@ 2020-06-03 23:39 Andrew Fish
2020-06-04 0:37 ` [edk2-devel] " Michael D Kinney
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Fish @ 2020-06-03 23:39 UTC (permalink / raw)
To: edk2-devel-groups-io
The x86 instructions do limit then base, but the code is storing base, then limit. Does anyone remember if this is properly defined some place?
Thanks,
Andrew Fish
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2]
2020-06-03 23:39 Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2] Andrew Fish
@ 2020-06-04 0:37 ` Michael D Kinney
2020-06-04 0:56 ` Andrew Fish
0 siblings, 1 reply; 5+ messages in thread
From: Michael D Kinney @ 2020-06-04 0:37 UTC (permalink / raw)
To: devel@edk2.groups.io, afish@apple.com, Kinney, Michael D
Hi Andrew,
Are you referring to the order the fields are filled in by the C code
before the x86 instruction is executed? I do not think that matters.
Thanks,
Mike
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On
> Behalf Of Andrew Fish via groups.io
> Sent: Wednesday, June 3, 2020 4:39 PM
> To: edk2-devel-groups-io <devel@edk2.groups.io>
> Subject: [edk2-devel] Does anyone know the definition of
> EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
>
> The x86 instructions do limit then base, but the code is
> storing base, then limit. Does anyone remember if this
> is properly defined some place?
>
> Thanks,
>
> Andrew Fish
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2]
2020-06-04 0:37 ` [edk2-devel] " Michael D Kinney
@ 2020-06-04 0:56 ` Andrew Fish
2020-06-04 1:43 ` Michael D Kinney
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Fish @ 2020-06-04 0:56 UTC (permalink / raw)
To: edk2-devel-groups-io, Mike Kinney
> On Jun 3, 2020, at 5:37 PM, Michael D Kinney <michael.d.kinney@intel.com> wrote:
>
> Hi Andrew,
>
> Are you referring to the order the fields are filled in by the C code
> before the x86 instruction is executed? I do not think that matters.
>
Mike,
The instructions point to a blob of data that is not UINTN aligned. These register point to a limit then base address. If you execute the instruction you get 2 bytes of limit and 4 or 8 bytes of data. But Idtr[0] is base and Intro[1] is limit, so reversed from the instruction order. What defines index 0 vs. index 1 data contents?
Thanks,
Andrew Fish
> Thanks,
>
> Mike
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On
>> Behalf Of Andrew Fish via groups.io
>> Sent: Wednesday, June 3, 2020 4:39 PM
>> To: edk2-devel-groups-io <devel@edk2.groups.io>
>> Subject: [edk2-devel] Does anyone know the definition of
>> EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
>> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
>>
>> The x86 instructions do limit then base, but the code is
>> storing base, then limit. Does anyone remember if this
>> is properly defined some place?
>>
>> Thanks,
>>
>> Andrew Fish
>>
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2]
2020-06-04 0:56 ` Andrew Fish
@ 2020-06-04 1:43 ` Michael D Kinney
2020-06-04 1:47 ` Andrew Fish
0 siblings, 1 reply; 5+ messages in thread
From: Michael D Kinney @ 2020-06-04 1:43 UTC (permalink / raw)
To: Andrew Fish, edk2-devel-groups-io, Kinney, Michael D
Hi Andrew,
I see the following assembly that reads GDTR and IDTR from
CPU and saves them into the context structure:
;; UINT32 Gdtr[2], Idtr[2];
sub esp, 8
sidt [esp]
mov eax, [esp + 2]
xchg eax, [esp]
and eax, 0xFFFF
mov [esp+4], eax
sub esp, 8
sgdt [esp]
mov eax, [esp + 2]
xchg eax, [esp]
and eax, 0xFFFF
mov [esp+4], eax
This data structure is defined in UEFI Spec, but I do not
see a detailed description of these 2 arrays and the meaning
of each entry. Seems like a gap in the spec description.
Mike
> -----Original Message-----
> From: Andrew Fish <afish@apple.com>
> Sent: Wednesday, June 3, 2020 5:57 PM
> To: edk2-devel-groups-io <devel@edk2.groups.io>; Kinney,
> Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] Does anyone know the
> definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
>
>
>
> > On Jun 3, 2020, at 5:37 PM, Michael D Kinney
> <michael.d.kinney@intel.com> wrote:
> >
> > Hi Andrew,
> >
> > Are you referring to the order the fields are filled
> in by the C code
> > before the x86 instruction is executed? I do not
> think that matters.
> >
>
> Mike,
>
> The instructions point to a blob of data that is not
> UINTN aligned. These register point to a limit then base
> address. If you execute the instruction you get 2 bytes
> of limit and 4 or 8 bytes of data. But Idtr[0] is base
> and Intro[1] is limit, so reversed from the instruction
> order. What defines index 0 vs. index 1 data contents?
>
> Thanks,
>
> Andrew Fish
>
> > Thanks,
> >
> > Mike
> >
> >> -----Original Message-----
> >> From: devel@edk2.groups.io <devel@edk2.groups.io> On
> >> Behalf Of Andrew Fish via groups.io
> >> Sent: Wednesday, June 3, 2020 4:39 PM
> >> To: edk2-devel-groups-io <devel@edk2.groups.io>
> >> Subject: [edk2-devel] Does anyone know the definition
> of
> >> EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
> >> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
> >>
> >> The x86 instructions do limit then base, but the code
> is
> >> storing base, then limit. Does anyone remember if
> this
> >> is properly defined some place?
> >>
> >> Thanks,
> >>
> >> Andrew Fish
> >>
> >
> >
> >
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2]
2020-06-04 1:43 ` Michael D Kinney
@ 2020-06-04 1:47 ` Andrew Fish
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Fish @ 2020-06-04 1:47 UTC (permalink / raw)
To: Mike Kinney; +Cc: edk2-devel-groups-io
> On Jun 3, 2020, at 6:43 PM, Kinney, Michael D <michael.d.kinney@intel.com> wrote:
>
> Hi Andrew,
>
> I see the following assembly that reads GDTR and IDTR from
> CPU and saves them into the context structure:
>
> ;; UINT32 Gdtr[2], Idtr[2];
> sub esp, 8
> sidt [esp]
> mov eax, [esp + 2]
> xchg eax, [esp]
> and eax, 0xFFFF
> mov [esp+4], eax
>
> sub esp, 8
> sgdt [esp]
> mov eax, [esp + 2]
> xchg eax, [esp]
> and eax, 0xFFFF
> mov [esp+4], eax
>
> This data structure is defined in UEFI Spec, but I do not
> see a detailed description of these 2 arrays and the meaning
> of each entry. Seems like a gap in the spec description.
>
Mike,
Yea that is what I saw too, but I had code code doing the opposite and passing the context over did not go well. I can think of at least 3 ways ti could be mapped? Match the instruction, Base 1st, Limit 1st.
Thanks,
Andrew Fish
> Mike
>
>> -----Original Message-----
>> From: Andrew Fish <afish@apple.com>
>> Sent: Wednesday, June 3, 2020 5:57 PM
>> To: edk2-devel-groups-io <devel@edk2.groups.io>; Kinney,
>> Michael D <michael.d.kinney@intel.com>
>> Subject: Re: [edk2-devel] Does anyone know the
>> definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
>> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
>>
>>
>>
>>> On Jun 3, 2020, at 5:37 PM, Michael D Kinney
>> <michael.d.kinney@intel.com> wrote:
>>>
>>> Hi Andrew,
>>>
>>> Are you referring to the order the fields are filled
>> in by the C code
>>> before the x86 instruction is executed? I do not
>> think that matters.
>>>
>>
>> Mike,
>>
>> The instructions point to a blob of data that is not
>> UINTN aligned. These register point to a limit then base
>> address. If you execute the instruction you get 2 bytes
>> of limit and 4 or 8 bytes of data. But Idtr[0] is base
>> and Intro[1] is limit, so reversed from the instruction
>> order. What defines index 0 vs. index 1 data contents?
>>
>> Thanks,
>>
>> Andrew Fish
>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>> -----Original Message-----
>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On
>>>> Behalf Of Andrew Fish via groups.io
>>>> Sent: Wednesday, June 3, 2020 4:39 PM
>>>> To: edk2-devel-groups-io <devel@edk2.groups.io>
>>>> Subject: [edk2-devel] Does anyone know the definition
>> of
>>>> EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and
>>>> EFI_SYSTEM_CONTEXT_X64.Idtr[2]
>>>>
>>>> The x86 instructions do limit then base, but the code
>> is
>>>> storing base, then limit. Does anyone remember if
>> this
>>>> is properly defined some place?
>>>>
>>>> Thanks,
>>>>
>>>> Andrew Fish
>>>>
>>>
>>>
>>>
>>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-04 1:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-03 23:39 Does anyone know the definition of EFI_SYSTEM_CONTEXT_X64.Gdtr[2] and EFI_SYSTEM_CONTEXT_X64.Idtr[2] Andrew Fish
2020-06-04 0:37 ` [edk2-devel] " Michael D Kinney
2020-06-04 0:56 ` Andrew Fish
2020-06-04 1:43 ` Michael D Kinney
2020-06-04 1:47 ` Andrew Fish
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox