VirtualBox

Changeset 107874 in vbox


Ignore:
Timestamp:
Jan 21, 2025 2:53:44 PM (2 weeks ago)
Author:
vboxsync
Message:

Devices/EFI/Firmware: Workaround clang generating instruction sequences we can't emulate right on arm64 now when the flash MMIO region is accessed because IEM is not implemented there.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

    r80721 r107874  
    5050  DebugLib
    5151  BaseLib
     52  IoLib # VBox: Added
    5253
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BaseMemoryLib/CopyMem.c

    r107872 r107874  
    1414#include "MemLibInternals.h"
    1515
    16 #if defined(VBOX) && defined(_MSC_VER)
    17 # pragma optimize("", off)
    18 #endif
     16#include <Library/IoLib.h>
     17
    1918
    2019/**
     
    5453      Source64      = (CONST UINT64 *)SourceBuffer;
    5554      while (Length >= 8) {
     55#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    5656        *(Destination64++) = *(Source64++);
     57#else
     58        MmioWrite64(Destination64, MmioRead64(Source64));
     59        Destination64++;
     60        Source64++;
     61#endif
    5762        Length            -= 8;
    5863      }
     
    6267      Source8      = (CONST UINT8 *)Source64;
    6368      while (Length-- != 0) {
     69#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    6470        *(Destination8++) = *(Source8++);
     71#else
     72        MmioWrite8(Destination8, MmioRead8(Source8));
     73        Destination8++;
     74        Source8++;
     75#endif
    6576      }
    6677    } else if (SourceBuffer < DestinationBuffer) {
     
    7889
    7990        while (Alignment-- != 0) {
     91#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    8092          *(--Destination8) = *(--Source8);
     93#else
     94          Destination8--;
     95          Source8--;
     96          MmioWrite8(Destination8, MmioRead8(Source8));
     97#endif
    8198          --Length;
    8299        }
     
    87104
    88105      while (Length > 0) {
     106#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    89107        *(--Destination64) = *(--Source64);
     108#else
     109        Destination64--;
     110        Source64--;
     111        MmioWrite64(Destination64, MmioRead64(Source64));
     112#endif
    90113        Length            -= 8;
    91114      }
     
    96119      Source32      = (CONST UINT32 *)SourceBuffer;
    97120      while (Length >= 4) {
     121#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    98122        *(Destination32++) = *(Source32++);
     123#else
     124        MmioWrite32(Destination32, MmioRead32(Source32));
     125        Destination32++;
     126        Source32++;
     127#endif
    99128        Length            -= 4;
    100129      }
     
    104133      Source8      = (CONST UINT8 *)Source32;
    105134      while (Length-- != 0) {
     135#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    106136        *(Destination8++) = *(Source8++);
     137#else
     138        MmioWrite8(Destination8, MmioRead8(Source8));
     139        Destination8++;
     140        Source8++;
     141#endif
    107142      }
    108143    } else if (SourceBuffer < DestinationBuffer) {
     
    120155
    121156        while (Alignment-- != 0) {
     157#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    122158          *(--Destination8) = *(--Source8);
     159#else
     160          Destination8--;
     161          Source8--;
     162          MmioWrite8(Destination8, MmioRead8(Source8));
     163#endif
    123164          --Length;
    124165        }
     
    129170
    130171      while (Length > 0) {
     172#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    131173        *(--Destination32) = *(--Source32);
     174#else
     175        Destination32--;
     176        Source32--;
     177        MmioWrite32(Destination32, MmioRead32(Source32));
     178#endif
    132179        Length            -= 4;
    133180      }
     
    138185      Source8      = (CONST UINT8 *)SourceBuffer;
    139186      while (Length-- != 0) {
     187#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    140188        *(Destination8++) = *(Source8++);
     189#else
     190        MmioWrite8(Destination8, MmioRead8(Source8));
     191        Destination8++;
     192        Source8++;
     193#endif
    141194      }
    142195    } else if (SourceBuffer < DestinationBuffer) {
     
    144197      Source8      = (CONST UINT8 *)SourceBuffer + (Length - 1);
    145198      while (Length-- != 0) {
     199#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    146200        *(Destination8--) = *(Source8--);
     201#else
     202        MmioWrite8(Destination8, MmioRead8(Source8));
     203        Destination8--;
     204        Source8--;
     205#endif
    147206      }
    148207    }
     
    151210  return DestinationBuffer;
    152211}
    153 
    154 #if defined(VBOX) && defined(_MSC_VER)
    155 # pragma optimize("", on)
    156 #endif
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c

    r105670 r107874  
    173173}
    174174
     175#if defined(VBOX) && defined(MDE_CPU_AARCH64)
     176static UINT16 NorFlashCalculateSum16 (
     177  IN      CONST UINT16  *Buffer,
     178  IN      UINTN         Length
     179  )
     180{
     181  UINT16  Sum;
     182  UINTN   Count;
     183  UINTN   Total;
     184
     185  ASSERT (Buffer != NULL);
     186  ASSERT (((UINTN)Buffer & 0x1) == 0);
     187  ASSERT ((Length & 0x1) == 0);
     188  ASSERT (Length <= (MAX_ADDRESS - ((UINTN)Buffer) + 1));
     189
     190  Total = Length / sizeof (*Buffer);
     191  for (Sum = 0, Count = 0; Count < Total; Count++) {
     192    Sum += MmioRead16((volatile UINT16 *)(Buffer + Count));
     193  }
     194
     195  return Sum;
     196}
     197#endif
     198
    175199/**
    176200  Check the integrity of firmware volume header.
     
    228252
    229253  // Verify the header checksum
     254#if !defined(VBOX) || !defined(MDE_CPU_AARCH64)
    230255  Checksum = CalculateSum16 ((UINT16 *)FwVolHeader, FwVolHeader->HeaderLength);
     256#else
     257  Checksum = NorFlashCalculateSum16 ((UINT16 *)FwVolHeader, FwVolHeader->HeaderLength);
     258#endif
    231259  if (Checksum != 0) {
    232260    DEBUG ((
     
    383411    }
    384412
     413#if !defined(VBOX) || !defined(MDE_CPU_AARCH64) /* MSVC/clang generate instructions on arm64 in debug builds not supported by IEM right now. */
    385414    DEBUG ((
    386415      DEBUG_VERBOSE,
     
    394423      VarState
    395424      ));
     425#endif
    396426
    397427    VarPadding = (4 - (VarEnd & 3)) & 3;
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