VirtualBox

Ignore:
Timestamp:
Nov 20, 2015 5:21:41 PM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: Fix page table location for amd64 after MEMFD had to be relocated because of OS X guests. The page table location must match the gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase PCD defined in OvmfPkgX64.fdf. Remove unused modifications in the old ResetVector code which now moved to OvmfPkg

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/ResetVector/Ia32/PageTables64.asm

    r58464 r58803  
    4545
    4646    ;
     47%ifdef VBOX
     48    ; For OVMF, build some initial page tables at 0x2000000-0x2006000.
     49    ; Required because we had to relocate MEMFD where the page table resides
     50    ; from 0x800000 to not interfere with certain OS X bootloaders.
     51%else
    4752    ; For OVMF, build some initial page tables at 0x800000-0x806000.
     53%endif
    4854    ;
    4955    ; This range should match with PcdOvmfSecPageTablesBase and
     
    5763    xor     eax, eax
    5864clearPageTablesMemoryLoop:
     65%ifdef VBOX
     66    mov     dword[ecx * 4 + 0x2000000 - 4], eax
     67%else
    5968    mov     dword[ecx * 4 + 0x800000 - 4], eax
     69%endif
    6070    loop    clearPageTablesMemoryLoop
    6171
     
    6373    ; Top level Page Directory Pointers (1 * 512GB entry)
    6474    ;
     75%ifdef VBOX
     76    mov     dword[0x2000000], 0x2001000 + PAGE_PDP_ATTR
     77%else
    6578    mov     dword[0x800000], 0x801000 + PAGE_PDP_ATTR
     79%endif
    6680
    6781    ;
    6882    ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)
    6983    ;
     84%ifdef VBOX
     85    mov     dword[0x2001000], 0x2002000 + PAGE_PDP_ATTR
     86    mov     dword[0x2001008], 0x2003000 + PAGE_PDP_ATTR
     87    mov     dword[0x2001010], 0x2004000 + PAGE_PDP_ATTR
     88    mov     dword[0x2001018], 0x2005000 + PAGE_PDP_ATTR
     89%else
    7090    mov     dword[0x801000], 0x802000 + PAGE_PDP_ATTR
    7191    mov     dword[0x801008], 0x803000 + PAGE_PDP_ATTR
    7292    mov     dword[0x801010], 0x804000 + PAGE_PDP_ATTR
    7393    mov     dword[0x801018], 0x805000 + PAGE_PDP_ATTR
     94%endif
    7495
    7596    ;
     
    82103    shl     eax, 21
    83104    add     eax, PAGE_2M_PDE_ATTR
     105%ifdef VBOX
     106    mov     [ecx * 8 + 0x2002000 - 8], eax
     107%else
    84108    mov     [ecx * 8 + 0x802000 - 8], eax
     109%endif
    85110    loop    pageTableEntriesLoop
    86111
     
    88113    ; Set CR3 now that the paging structures are available
    89114    ;
     115%ifdef VBOX
     116    mov     eax, 0x2000000
     117%else
    90118    mov     eax, 0x800000
     119%endif
    91120    mov     cr3, eax
    92121
  • trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm

    r58459 r58803  
    1414;------------------------------------------------------------------------------
    1515
    16 %ifdef VBOX
    17  %include "VBox/nasm.mac"
    18  %include "iprt/x86.mac"
    19 
    20  ;;
    21  ; Macro for filling in page table entries with EAX as base content.
    22  ;
    23  ; @param    %1  What to increment EAX with for each iteration.
    24  ; @param    %2  Start address.
    25  ; @param    %3  End address (exclusive).
    26  ; @uses     EAX, EBX, EFLAGS
    27  ;
    28  %macro FILL_ENTRIES 3
    29      mov     ebx, %2
    30  %%myloop:
    31      mov     [ebx], eax
    32      mov     dword [ebx + 4], 0
    33      add     eax, %1
    34      add     ebx, 8
    35      cmp     ebx, %3
    36      jb      %%myloop
    37  %endmacro
    38 
    39  ;;
    40  ; Macro for filling in page table entries with zeros.
    41  ;
    42  ; @param    %1 Start address.
    43  ; @param    %2  End address (exclusive).
    44  ; @uses     EAX, EBX, EFLAGS
    45  ;
    46  %macro ZERO_ENTRIES 2
    47      mov     ebx, %1
    48      xor     eax, eax
    49  %%myloop:
    50      mov     [ebx], eax
    51      mov     dword [ebx + 4], eax
    52      add     ebx, 8
    53      cmp     ebx, %2
    54      jb      %%myloop
    55  %endmacro
    56 
    57  ;;
    58  ; The address of the page tables.
    59  %define VBOX_PDPT_ADDR     (0x00800000 - 0x6000)
    60  %define VBOX_PDPTR_ADDR    (0x00800000 - 0x2000)
    61  %define VBOX_PML4_ADDR     (0x00800000 - 0x1000)
    62 
    63 %endif ; VBOX
    64 
    65 
    6616BITS    32
    6717
    6818;
    69 %ifndef VBOX
    7019; Modified:  EAX
    71 %else
    72 ; Modified:  EAX, EBX
    73 %endif
    7420;
    7521Transition32FlatTo64Flat:
    7622
    77 %ifndef VBOX
    78     mov     eax, ((ADDR_OF_START_OF_RESET_CODE & ~0xfff) - 0x1000)
    79 %else ; !VBOX
    80     ;
    81     ; Produce our own page table that does not reside in ROM, since the PGM
    82     ; pool code cannot quite cope with write monitoring ROM pages.
    83     ;
    84 
    85     ; First, set up page directories with 2MB pages for the first 4GB.
    86     mov     eax, ( X86_PDE4M_P | X86_PDE4M_A | X86_PDE4M_PS | X86_PDE4M_PCD | X86_PDE4M_RW | X86_PDE4M_D )
    87     FILL_ENTRIES X86_PAGE_2M_SIZE, VBOX_PDPT_ADDR, VBOX_PDPT_ADDR + 0x4000
    88 
    89     ; Second, set up page a directory pointer table with 4 entries pointing to
    90     ; the PTPDs we created above and the remainder as zeros.
    91     mov     eax, ( X86_PDPE_P | X86_PDPE_RW | X86_PDPE_A | X86_PDPE_PCD ) + VBOX_PDPT_ADDR
    92     FILL_ENTRIES X86_PAGE_4K_SIZE, VBOX_PDPTR_ADDR, VBOX_PDPTR_ADDR + 4*8
    93     ZERO_ENTRIES VBOX_PDPTR_ADDR + 4*8, VBOX_PDPTR_ADDR + 0x1000
    94 
    95     ; Third, set up a PML4 with the first entry pointing to the previous table.
    96     mov     dword [VBOX_PML4_ADDR], ( X86_PML4E_P | X86_PML4E_PCD | X86_PML4E_A | X86_PML4E_RW ) + VBOX_PDPTR_ADDR
    97     mov     dword [VBOX_PML4_ADDR + 4], 0
    98     ZERO_ENTRIES VBOX_PML4_ADDR + 1*8, VBOX_PML4_ADDR + 0x1000
    99 
    100     mov     eax, VBOX_PML4_ADDR
    101 %endif
    10223    OneTimeCall SetCr3ForPageTables64
    10324
  • trunk/src/VBox/Devices/EFI/Firmware/vbox-tools_def.txt

    r58522 r58803  
    354354*_*_*_NASM_PATH                = DEF(NASM_BIN)
    355355# NASMB uses NASM produce a .bin from a .nasmb NASM source file
    356 *_*_*_NASMB_FLAGS              = -f bin -D__YASM__ -DASM_FORMAT_BIN
    357 
     356*_*_*_NASMB_FLAGS              = -f bin -D__YASM__ -DASM_FORMAT_BIN -DVBOX
     357
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette