SmmProfileArch.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** @file
  2. IA-32 processor specific header file to enable SMM profile.
  3. Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _SMM_PROFILE_ARCH_H_
  7. #define _SMM_PROFILE_ARCH_H_
  8. #pragma pack (1)
  9. typedef struct _MSR_DS_AREA_STRUCT {
  10. UINT32 BTSBufferBase;
  11. UINT32 BTSIndex;
  12. UINT32 BTSAbsoluteMaximum;
  13. UINT32 BTSInterruptThreshold;
  14. UINT32 PEBSBufferBase;
  15. UINT32 PEBSIndex;
  16. UINT32 PEBSAbsoluteMaximum;
  17. UINT32 PEBSInterruptThreshold;
  18. UINT32 PEBSCounterReset[4];
  19. UINT32 Reserved;
  20. } MSR_DS_AREA_STRUCT;
  21. typedef struct _BRANCH_TRACE_RECORD {
  22. UINT32 LastBranchFrom;
  23. UINT32 LastBranchTo;
  24. UINT32 Rsvd0 : 4;
  25. UINT32 BranchPredicted : 1;
  26. UINT32 Rsvd1 : 27;
  27. } BRANCH_TRACE_RECORD;
  28. typedef struct _PEBS_RECORD {
  29. UINT32 Eflags;
  30. UINT32 LinearIP;
  31. UINT32 Eax;
  32. UINT32 Ebx;
  33. UINT32 Ecx;
  34. UINT32 Edx;
  35. UINT32 Esi;
  36. UINT32 Edi;
  37. UINT32 Ebp;
  38. UINT32 Esp;
  39. } PEBS_RECORD;
  40. #pragma pack ()
  41. #define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB)
  42. /**
  43. Update page table to map the memory correctly in order to make the instruction
  44. which caused page fault execute successfully. And it also save the original page
  45. table to be restored in single-step exception. 32-bit firmware does not need it.
  46. @param PageTable PageTable Address.
  47. @param PFAddress The memory address which caused page fault exception.
  48. @param CpuIndex The index of the processor.
  49. @param ErrorCode The Error code of exception.
  50. @param IsValidPFAddress The flag indicates if SMM profile data need be added.
  51. **/
  52. VOID
  53. RestorePageTableAbove4G (
  54. UINT64 *PageTable,
  55. UINT64 PFAddress,
  56. UINTN CpuIndex,
  57. UINTN ErrorCode,
  58. BOOLEAN *IsValidPFAddress
  59. );
  60. /**
  61. Create SMM page table for S3 path.
  62. **/
  63. VOID
  64. InitSmmS3Cr3 (
  65. VOID
  66. );
  67. /**
  68. Allocate pages for creating 4KB-page based on 2MB-page when page fault happens.
  69. **/
  70. VOID
  71. InitPagesForPFHandler (
  72. VOID
  73. );
  74. #endif // _SMM_PROFILE_ARCH_H_