On 2/22/24 12:54, Gerd Hoffmann wrote:
> Move code to clear the page tables to a nasm macro.
> No functional change.
> 
> Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
> ---
>  OvmfPkg/ResetVector/Ia32/PageTables64.asm | 35 ++++++++++++-----------
>  1 file changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm 
> b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> index 6fec6f2beeea..378ba2feeb4f 100644
> --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> @@ -45,6 +45,24 @@ BITS    32
>  %define TDX_BSP         1
>  %define TDX_AP          2
>  
> +;
> +; For OVMF, build some initial page tables at
> +; PcdOvmfSecPageTablesBase - (PcdOvmfSecPageTablesBase + 0x6000).
> +;
> +; This range should match with PcdOvmfSecPageTablesSize which is
> +; declared in the FDF files.
> +;
> +; At the end of PEI, the pages tables will be rebuilt into a
> +; more permanent location by DxeIpl.
> +;
> +%macro ClearOvmfPageTables 0
> +    mov     ecx, 6 * 0x1000 / 4
> +    xor     eax, eax
> +.clearPageTablesMemoryLoop:
> +    mov     dword[ecx * 4 + PT_ADDR (0) - 4], eax
> +    loop    .clearPageTablesMemoryLoop
> +%endmacro
> +
>  ;
>  ; Modified:  EAX, EBX, ECX, EDX
>  ;

Ah, this made me read up on local labels:

https://www.nasm.us/xdoc/2.16.01/html/nasmdoc3.html#section-3.9

Should we rather call the label

  ..@clearPageTablesMemoryLoop

?

According to the documentation, that seems to be the safest / most
robust label type to be used inside macros.

Reviewed-by: Laszlo Ersek <ler...@redhat.com>

Thanks
Laszlo

> @@ -69,22 +87,7 @@ SetCr3ForPageTables64:
>      OneTimeCall   GetSevCBitMaskAbove31
>  
>  ClearOvmfPageTables:
> -    ;
> -    ; For OVMF, build some initial page tables at
> -    ; PcdOvmfSecPageTablesBase - (PcdOvmfSecPageTablesBase + 0x6000).
> -    ;
> -    ; This range should match with PcdOvmfSecPageTablesSize which is
> -    ; declared in the FDF files.
> -    ;
> -    ; At the end of PEI, the pages tables will be rebuilt into a
> -    ; more permanent location by DxeIpl.
> -    ;
> -
> -    mov     ecx, 6 * 0x1000 / 4
> -    xor     eax, eax
> -clearPageTablesMemoryLoop:
> -    mov     dword[ecx * 4 + PT_ADDR (0) - 4], eax
> -    loop    clearPageTablesMemoryLoop
> +    ClearOvmfPageTables
>  
>      ;
>      ; Top level Page Directory Pointers (1 * 512GB entry)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116080): https://edk2.groups.io/g/devel/message/116080
Mute This Topic: https://groups.io/mt/104506789/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to