VirtualBox

Ignore:
Timestamp:
Oct 13, 2023 12:46:05 PM (17 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159497
Message:

Devices/EFI/Firmware&ArmPlatformPkg/PrePeiCore: Don't use the hardcoded temporary stack address but determine the start of the base RAM from the VBox Armv8 platform descriptor and use it for the initial stack now that the FDT is not located at the start of the RAM region anymore, bugref:10528

Location:
trunk/src/VBox/Devices/EFI/Firmware/ArmPlatformPkg/PrePeiCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S

    r99464 r101438  
    3939  bl    ASM_PFX(ArmPlatformIsPrimaryCore)
    4040
     41#ifndef VBOX
    4142  // Get the top of the primary stacks (and the base of the secondary stacks)
    4243  MOV64 (x1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))
     44#else
     45  //
     46  // The VirtualBox platform has the following layout:
     47  //
     48  //    0        128MiB            RAM size + 128MiB                                                                            -64KiB    Max phys address
     49  //    +----------+------------------------+-----------------------------+-------------+---------+----------+---------+-----------+------------+
     50  //    |   UEFI   |                        |                             |             |         |          |  Misc   |  FDT/ACPI |    VBox    |
     51  //    | firmware |        RAM ..... =>    |  Not assigned address space | <= PCI MMIO | PCI PIO | PCI ECAM |  MMIO   |   table   | Descriptor |
     52  //    |  region  |                        |                             |             |         |          | region  |   region  |   region   |
     53  //    +----------+------------------------+-----------------------------+-------------+---------+----------+---------+-----------+------------+
     54  //
     55  // In order to have as few as hardcoded addresses as possible in the firmware
     56  // VirtualBox installs a descriptor at the end of the physical address space
     57  // where all the other information is stored.
     58  //
     59  // First the start of the region is determined by reading the size of the
     60  // physical address space. From there the memory and stack is set up and
     61  // the C entry point is called.
     62  //
     63  // Note: Only the VBox descriptor and UEFI firmware region are at a fixed location.
     64  //       Everything else can float around freely in theory to give us the most flexibility.
     65  //
     66
     67  // Save the result from ArmPlatformIsPrimaryCore().
     68  mov x6, x0
     69
     70  // Get the number of physical address bits
     71  bl ASM_PFX(ArmGetPhysicalAddressBits)
     72
     73  //
     74  // Determine the start of the VBox descriptor region.
     75  //
     76  mov x1, #1
     77  lsl x1, x1, x0      // Determine first invalid address
     78  sub x1, x1, #65536  // Get at start of VBox descriptor region.
     79
     80  //
     81  // Get at the ram base and use the beginning as our temporary stack.
     82  //
     83  ldr x1, [x1, #16]
     84
     85  // Get the top of the primary stacks (and the base of the secondary stacks)
     86  add x1, x1, FixedPcdGet32(PcdCPUCorePrimaryStackSize)
     87
     88  // Restore the result from ArmPlatformIsPrimaryCore().
     89  mov x0, x6
     90#endif
    4391
    4492  // x0 is equal to 1 if I am the primary core
     
    82130_SetupPrimaryCoreStack:
    83131  mov   sp, x1
     132#ifndef VBOX
    84133  MOV64 (x8, FixedPcdGet64 (PcdCPUCoresStackBase))
     134#else
     135  sub   x8, x1, FixedPcdGet32(PcdCPUCorePrimaryStackSize)
     136#endif
    85137  MOV64 (x9, FixedPcdGet32 (PcdInitValueInTempStack) |\
    86138             FixedPcdGet32 (PcdInitValueInTempStack) << 32)
  • trunk/src/VBox/Devices/EFI/Firmware/ArmPlatformPkg/PrePeiCore/MainUniCore.c

    r99464 r101438  
    88
    99#include "PrePeiCore.h"
     10
     11#ifdef VBOX
     12# include <Library/VBoxArmPlatformLib.h>
     13#endif
    1014
    1115VOID
     
    3539  // the base of the primary core stack
    3640  PpiListSize      = ALIGN_VALUE (PpiListSize, CPU_STACK_ALIGNMENT);
     41#ifndef VBOX
    3742  TemporaryRamBase = (UINTN)PcdGet64 (PcdCPUCoresStackBase) + PpiListSize;
     43#else
     44  TemporaryRamBase = (UINTN)VBoxArmPlatformRamBaseStartGetPhysAddr() + PpiListSize;
     45#endif
    3846  TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;
    3947
  • trunk/src/VBox/Devices/EFI/Firmware/ArmPlatformPkg/PrePeiCore/PrePeiCore.c

    r99464 r101438  
    1414#include <Library/PrintLib.h>
    1515#include <Library/SerialPortLib.h>
     16
     17#ifdef VBOX
     18# include <Library/VBoxArmPlatformLib.h>
     19#endif
    1620
    1721#include "PrePeiCore.h"
     
    4347
    4448  // Copy the Common and Platform PPis in Temporary Memory
     49#ifndef VBOX
    4550  ListBase = PcdGet64 (PcdCPUCoresStackBase);
     51#else
     52  ListBase = (UINTN)VBoxArmPlatformRamBaseStartGetPhysAddr();
     53#endif
    4654  CopyMem ((VOID *)ListBase, gCommonPpiTable, sizeof (gCommonPpiTable));
    4755  CopyMem ((VOID *)(ListBase + sizeof (gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);
     
    94102    ArmEnableInstructionCache ();
    95103
     104#ifndef VBOX
    96105    InvalidateDataCacheRange (
    97106      (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),
    98107      PcdGet32 (PcdCPUCorePrimaryStackSize)
    99108      );
     109#else
     110    InvalidateDataCacheRange (
     111      (VOID *)(UINTN)VBoxArmPlatformRamBaseStartGetPhysAddr(),
     112      PcdGet32 (PcdCPUCorePrimaryStackSize)
     113      );
     114#endif
    100115  }
    101116
  • trunk/src/VBox/Devices/EFI/Firmware/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf

    r99464 r101438  
    3838  ArmPkg/ArmPkg.dec
    3939  ArmPlatformPkg/ArmPlatformPkg.dec
     40  VBoxPkg/VBoxPkg.dec               # VBox: Added
    4041
    4142[LibraryClasses]
     
    4950  PrintLib
    5051  SerialPortLib
     52  VBoxArmPlatformLib                # VBox: Added
    5153
    5254[Ppis]
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