VirtualBox

Ignore:
Timestamp:
Mar 31, 2025 11:31:09 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168237
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/SmmRelocationLib/AmdSmramSaveStateConfig.c

    r105670 r108794  
    22  Config SMRAM Save State for SmmBases Relocation.
    33
    4   Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
     4  Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
    55  Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
    66  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    99#include "InternalSmmRelocationLib.h"
    1010#include <Register/Amd/SmramSaveStateMap.h>
    11 
    12 #define EFER_ADDRESS  0XC0000080ul
    1311
    1412/**
     
    2422  )
    2523{
    26   UINT8   SmmSaveStateRegisterLma;
    27   UINT32  LMAValue;
     24  UINT8                   SmmSaveStateRegisterLma;
     25  MSR_IA32_EFER_REGISTER  Msr;
     26
     27  Msr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER);
    2828
    2929  SmmSaveStateRegisterLma = (UINT8)EFI_MM_SAVE_STATE_REGISTER_LMA_32BIT;
    3030
    31   LMAValue = (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA;
    32   if (LMAValue) {
     31  if (Msr.Bits.LMA) {
    3332    SmmSaveStateRegisterLma = (UINT8)EFI_MM_SAVE_STATE_REGISTER_LMA_64BIT;
    3433  }
     
    9291  UINT64                    OriginalInstructionPointer;
    9392  AMD_SMRAM_SAVE_STATE_MAP  *AmdCpuState;
     93  MSR_IA32_EFER_REGISTER    Msr;
    9494
    9595  AmdCpuState = (AMD_SMRAM_SAVE_STATE_MAP *)CpuState;
    9696
    97   if (GetMmSaveStateRegisterLma () == EFI_MM_SAVE_STATE_REGISTER_LMA_32BIT) {
    98     OriginalInstructionPointer = (UINT64)AmdCpuState->x86._EIP;
    99     AmdCpuState->x86._EIP      = (UINT32)NewInstructionPointer;
    100     //
    101     // Clear the auto HALT restart flag so the RSM instruction returns
    102     // program control to the instruction following the HLT instruction.
    103     //
    104     if ((AmdCpuState->x86.AutoHALTRestart & BIT0) != 0) {
    105       AmdCpuState->x86.AutoHALTRestart &= ~BIT0;
    106     }
     97  OriginalInstructionPointer = AmdCpuState->x64._RIP;
     98  Msr.Uint64                 = AmdCpuState->x64.EFER;
     99
     100  if (!Msr.Bits.LMA) {
     101    AmdCpuState->x64._RIP = NewInstructionPointer32;
    107102  } else {
    108     OriginalInstructionPointer = AmdCpuState->x64._RIP;
    109     if ((AmdCpuState->x64.EFER & LMA) == 0) {
    110       AmdCpuState->x64._RIP = (UINT32)NewInstructionPointer32;
    111     } else {
    112       AmdCpuState->x64._RIP = (UINT32)NewInstructionPointer;
    113     }
     103    AmdCpuState->x64._RIP = NewInstructionPointer;
     104  }
    114105
    115     //
    116     // Clear the auto HALT restart flag so the RSM instruction returns
    117     // program control to the instruction following the HLT instruction.
    118     //
    119     if ((AmdCpuState->x64.AutoHALTRestart & BIT0) != 0) {
    120       AmdCpuState->x64.AutoHALTRestart &= ~BIT0;
    121     }
     106  //
     107  // Clear the auto HALT restart flag so the RSM instruction returns
     108  // program control to the instruction following the HLT instruction.
     109  //
     110  if ((AmdCpuState->x64.AutoHALTRestart & BIT0) != 0) {
     111    AmdCpuState->x64.AutoHALTRestart &= ~BIT0;
    122112  }
    123113
Note: See TracChangeset for help on using the changeset viewer.

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