Andrew,
Yes, I did this and follow few changes to byte definitions and finally got obj
file to have the same codes. But I didn't report because I have no final
success.
The QEMU+Ovmf still not started so I should search more.
Same mistake here
---------
#movw %bp, (_ESP - IA32_REGS_SIZE)(%rsi)
# .byte 0x66
# mov %ebp, 0xffffffd4(%esi) # mov [bp-002c], ebp
movw %bp, 0xffffffd4(%rsi)
# .byte 0x66
#movl (_EIP - IA32_REGS_SIZE)(%rsi), %ebx
mov 0xfffffff8(%esi), %ebx # mov ebx, [bp-8]
---------
and here
---------
L_RealMode:
.byte 0x66,0x2e # CS and operand size override
# lidt (_16Idtr - L_Base1)(%rsi)
lidt 0xffffffd2(%rsi)
---------
Sergey
23.01.2013, в 0:39, Andrew Fish написал(а):
> Sergey,
>
> Can you see if this patch fixes the issue?
>
>
> ~/work/edk2TOT>svn diff --diff-cmd diff MdePkg/Library/BaseLib/X64/Thunk16.S
> Index: MdePkg/Library/BaseLib/X64/Thunk16.S
> ===================================================================
> --- MdePkg/Library/BaseLib/X64/Thunk16.S (revision 14077)
> +++ MdePkg/Library/BaseLib/X64/Thunk16.S (working copy)
> @@ -129,10 +129,10 @@
> L_SavedCr4: .space 4
> movq %rax, %cr4
> #
> - # rdi in the instruction below is indeed bx in 16-bit code
> - #
> - .byte 0x66,0x2e # 2eh is "cs:" segment override
> - lgdt (SavedGdt - L_Base)(%rdi)
> + # lgdt cs:[bx-0012]
> + # 0x12 is (SavedGdt - L_Base)
> + .byte 0x66,0x2e, 0x0f,0x01,0x57,0xee #
> +
> .byte 0x66
> movl $0xc0000080,%ecx
> rdmsr
>
>
> Andrew Fish
>
>
> On Jan 21, 2013, at 8:00 PM, Isakov Sergey <isakov...@bk.ru> wrote:
>
>> Andrew,
>> This is how the first subroutine look if compiled by gcc
>> ---------
>> 0000004a 16 push ss
>>
>> 0000004b 0e push cs
>>
>> 0000004c 66e800000000 call 0x52
>>
>> 00000052 666a00 push 0x0
>>
>> 00000055 669c pushfd
>>
>> 00000057 fa cli
>>
>> 00000058 0fa8 push gs
>>
>> 0000005a 0fa0 push fs
>>
>> 0000005c 06 push es
>>
>> 0000005d 1e push ds
>>
>> 0000005e 6660 pushad
>>
>> 00000060 66ba00000000 mov edx, 0x0
>>
>> 00000066 f6c202 test dl, 0x2
>>
>> 00000069 7408 jz 0x73
>>
>> 0000006b b80124 mov ax, 2401
>>
>> 0000006e cd15 int 0x15
>>
>> 00000070 fa cli
>>
>> 00000071 730b jnc 0x7e
>>
>> 00000073 f6c204 test dl, 0x4
>>
>> 00000076 7406 jz 0x7e
>>
>> 00000078 e492 in al, 0x92
>>
>> 0000007a 0c02 or al, 0x2
>>
>> 0000007c e692 out 0x92, al
>>
>> 0000007e 6631c0 xor eax, eax
>>
>> 00000081 8cd0 mov ax, ss
>>
>> 00000083 67668d6c2438 lea ebp, [esp+0x38]
>>
>> 00000089 66896ed4 mov [bp-002c], ebp
>>
>> 0000008d 668b5ef8 mov ebx, [bp-8]
>>
>> 00000091 66c1e004 shl eax, 0x4
>>
>> 00000095 6601c5 add ebp, eax
>>
>> 00000098 668cc8 mov eax, cs
>>
>> 0000009b 66c1e004 shl eax, 0x4
>>
>> 0000009f 67668d840389000000 lea eax, [ebx+eax+0x89]
>>
>> 000000a8 662e89878300 mov cs:[bx+0x83], eax
>>
>> 000000ae 66b800000000 mov eax, 0x0
>>
>> 000000b4 0f22e0 mov cr4, eax
>>
>> 000000b7 662e0f0157ee lgdt cs:[bx-0012]
>>
>> 000000bd 66b9800000c0 mov ecx, c0000080
>>
>> 000000c3 0f32 rdmsr
>>
>> 000000c5 80cc01 or ah, 0x1
>>
>> 000000c8 0f30 wrmsr
>>
>> 000000ca 66b800000000 mov eax, 0x0
>>
>> 000000d0 0f22c0 mov cr0, eax
>>
>> 000000d3 66ea000000000000 jmp 0x0
>>
>> 000000db 90 nop
>>
>> 000000dc 67bc0000 mov sp, 0x0
>>
>> 000000e0 0000 add [bx+si], al
>>
>> 000000e2 90 nop
>>
>> 000000e3 c3 ret
>>
>> ---------
>> I am sorry, I am using interactive dissasembler hte.sf.net that can't save
>> to file so this is screen copy.
>> Look attachments Thunk16.obj by gcc and Thunk16_1.obj by Clang
>> <Thunk16_1.obj.zip>
>>
>> <Thunk16.obj.zip>
>>
>> On 22.01.2013, at 0:31, Andrew Fish wrote:
>>
>>> Sergey,
>>>
>>> I don't have a 16-bit disassembler handy, or a gcc toolchain installed. Can
>>> you send the disassembly of the entire function, including the byte values.
>>>
>>> It is not clear to me how this works correctly with gcc? The 0x66 prefix
>>> changes the operand size, and the 0x2e prefix forces the CS segment. But a
>>> 0x2e prefix is ignored in 64-bit mode.
>>>
>>> Thus it looks to me that clang is generating a 32-bit instruction, which
>>> kind of makes sense? But that is not what gcc is doing?
>>> Thunk16.obj[0x77]: 66 2e 0f 01 97 f8 ff ff ff lgdt %cs:-8(%edi)
>>>
>>> I'll try and fix stuff with .byte directives.
>>>
>>> Thanks,
>>>
>>> Andrew Fish
>>>
>>>
>>> On Jan 21, 2013, at 11:40 AM, Isakov Sergey <isakov...@bk.ru> wrote:
>>>
>>>> Hi Andrew,
>>>> As you are maintainer of XCLANG compilation I call to you to resolve the
>>>> problem.
>>>> I reported about it a year ago but now I see the wrong version of
>>>> Thunk16.s is returned into the library
>>>> MdePkg/Library/BaseLib/X64/Thunk16.S
>>>> The problematic codes is here
>>>> --------------
>>>> .byte 0x66,0x2e # 2eh is "cs:" segment override
>>>> lgdt (SavedGdt - L_Base)(%rdi)
>>>> .byte 0x66
>>>> movl $0xc0000080,%ecx
>>>> rdmsr
>>>>
>>>> --------------
>>>> Good compilation with GCC toolset. Disassemble as
>>>> --------------
>>>> 000000b7 662e0f0157ee lgdt cs:[bx-0012]
>>>>
>>>> 000000bd 66b9800000c0 mov ecx, c0000080
>>>>
>>>> 000000c3 0f32 rdmsr
>>>>
>>>> -------------
>>>> Now the same produced by XCLANG
>>>> ---------------
>>>> 000001e7 662e0f0197f8ff lgdt cs:[bx-8]
>>>>
>>>> 000001ee ff db 0xff
>>>>
>>>> 000001ef ff66b9 jmp word ptr [bp-0047]
>>>>
>>>> 000001f2 800000 add byte ptr [bx+si], 0x0
>>>>
>>>> 000001f5 c00f32 ror byte ptr [bx], 0x32
>>>>
>>>> ---------------
>>>> It is happen because Clang don't like expressions like (SavedGdt - L_Base)
>>>> This must be replaced by constants, or the toolset must use another ASM
>>>> compiler.
>>>> This is a reason why Ovmf by XCLANG is not working.
>>>>
>>>> Sergey
>>>> ------------------------------------------------------------------------------
>>>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
>>>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
>>>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
>>>> MVPs and experts. SALE $99.99 this month only -- learn more at:
>>>> http://p.sf.net/sfu/learnmore_122412_______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
>>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
>>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
>>> MVPs and experts. SALE $99.99 this month only -- learn more at:
>>> http://p.sf.net/sfu/learnmore_122412_______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>
>> ------------------------------------------------------------------------------
>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
>> MVPs and experts. ON SALE this month only -- learn more at:
>> http://p.sf.net/sfu/learnnow-d2d_______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel