Jordan:
  I am ok to skip 'xor rax, rax'.
  I think NASM 2.07 better.   

Thanks
Liming
-----Original Message-----
From: Jordan Justen [mailto:jljus...@gmail.com] 
Sent: Tuesday, August 26, 2014 4:26 AM
To: edk2-devel@lists.sourceforge.net; Gao, Liming
Subject: Re: [edk2] [PATCH 5/8] MdePkg/BaseLib Thunk16: Replace X64 GAS Thunk16 
with NASM version

Liming,

I tested your changes with NASM 2.11, and they worked fine.

One question. I think the 'xor rax, rax' is not needed, so should we skip that? 
(I tested with and without it.)

I then tested NASM 2.03, which we had copied from VTF0 as the required minimum 
version. It built with your changes, but I found that the code produced by 2.03 
would not boot in OVMF.

I then tested NASM 2.07, and I found that it would boot fine.

All,

Should we require NASM 2.07 or newer rather than 2.03?

NASM 2.07 was released in July 2009. (NASM 2.03 was June 2008)

One other note, that is not particularly relevant, but NASM 2.07 was when NASM 
changed to the BSD license.

-Jordan

On Wed, Aug 20, 2014 at 5:46 PM, Gao, Liming <liming....@intel.com> wrote:
> Hi, I meet with the same issue. I verify it in my ubutu 12.04. GCC46, Nasm 
> 2.09. I meet with the build failure.
> 1) 0x10 is not power of two.
> 2) invalid combination of opcode and operands
>
>   I provide my patch that can pass build. Please help review it.
>
> diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm 
> b/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
> index 2e5a580..105238d 100644
> --- a/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
> +++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
> @@ -174,7 +174,7 @@ BITS    16
>
>  o32 retf                                ; transfer control to user code
>
> -ALIGN   0x10
> +ALIGN   16
>  _NullSegDesc    DQ      0
>  _16CsDesc:
>                  DW      -1
> diff --git a/MdePkg/Library/BaseLib/X64/Thunk16.nasm 
> b/MdePkg/Library/BaseLib/X64/Thunk16.nasm
> index 8858e74..e11bb24 100644
> --- a/MdePkg/Library/BaseLib/X64/Thunk16.nasm
> +++ b/MdePkg/Library/BaseLib/X64/Thunk16.nasm
> @@ -190,7 +190,7 @@ o32 lidt    [cs:bp + (_16Idtr - .Base)]
>
>  o32 retf                                ; transfer control to user code
>
> -ALIGN   0x8
> +ALIGN   8
>
>  CODE16  equ _16Code - $
>  DATA16  equ _16Data - $
> @@ -237,11 +237,12 @@ BITS    64
>      push    rsi
>      push    rdi
>
> -    mov     rbx, ds
> +    xor     rbx, rbx
> +    mov     ebx, ds
>      push    rbx          ; Save ds segment register on the stack
> -    mov     rbx, es
> +    mov     ebx, es
>      push    rbx          ; Save es segment register on the stack
> -    mov     rbx, ss
> +    mov     ebx, ss
>      push    rbx          ; Save ss segment register on the stack
>
>      push    fs
> @@ -307,11 +308,11 @@ BITS    64
>      pop     gs
>      pop     fs
>      pop     rbx
> -    mov     ss, rbx
> +    mov     ss, ebx
>      pop     rbx
> -    mov     es, rbx
> +    mov     es, ebx
>      pop     rbx
> -    mov     ds, rbx
> +    mov     ds, ebx
>
>      pop     rdi
>      pop     rsi
>
> -----Original Message-----
> From: Mike Maslenkin [mailto:miha...@parallels.com]
> Sent: Thursday, August 21, 2014 5:40 AM
> To: edk2-devel@lists.sourceforge.net
> Subject: Re: [edk2] [PATCH 5/8] MdePkg/BaseLib Thunk16: Replace X64 
> GAS Thunk16 with NASM version
>
> Hello Jordan !
> build -p  build -p IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
> -a X64
> told me about next errors:
>
> Building ... 
> /home/mg/sources/jljusten/edk2/MdePkg/Library/BaseReportStatusCodeLibN
> ull/BaseReportStatusCodeLibNull.inf [X64]
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:193: 
> error: segment alignment `0x8' is not power of two
> make: ***
> [/home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GC
> C47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.obj] Error 1
>
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:240: 
> error: invalid combination of opcode and operands
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:242: 
> error: invalid combination of opcode and operands
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:244: 
> error: invalid combination of opcode and operands
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:310: 
> error: invalid combination of opcode and operands
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:312: 
> error: invalid combination of opcode and operands
> /home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GCC
> 47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:314: 
> error: invalid combination of opcode and operands
> make: ***
> [/home/mg/sources/jljusten/edk2/Build/IntelFrameworkModuleAll/DEBUG_GC
> C47/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.obj] Error 1
>
> The last errors come from this
> +global ASM_PFX(InternalAsmThunk16)
> +ASM_PFX(InternalAsmThunk16):
> <skip>
>
>
> ^^^^^^^^^^^^^^^^^^^^^^^
>> +    push    rbx          ; Save ds segment register on the stack
>> +    mov     rbx, es
>> ^^^^^^^^^^^^^^^^^^^^^^^
>> +    push    rbx          ; Save es segment register on the stack
>> +    mov     rbx, ss
> ^^^^^^^^^^^^^^^^^^^^^^^
>> +    push    rbx          ; Save ss segment register on the stack
> <skip>
>
>> +    mov     ss, rbx
>> ^^^^^^^^^^^^^^^^^^^^^^^
>> +    pop     rbx
>> +    mov     es, rbx
> ^^^^^^^^^^^^^^^^^^^^^^^
>> +    pop     rbx
>> +    mov     ds, rbx
> ^^^^^^^^^^^^^^^^^^^^^^^
>
>
> Initially I used a NASM version used in our build system. Do not know 
> for where we got it but it reported itself as NASM version 2.09.04
>
> After that I installed a default NASM that comes with openSuSE 12.2:
> NASM version 2.09.08 compiled on Jun 16 2011
>
> I got same errors.
> So, please clarify which minimal version of NASM is required.
>
>
>
> ----------------------------------------------------------------------
> --------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ----------------------------------------------------------------------
> --------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to