Skip to content

Commit

Permalink
Merge branch 'upstream-edk2-platforms' into upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
kenlautner committed Jul 15, 2024
2 parents c84eb9d + b95a4bc commit e433c80
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ VTdSetAttribute (
//
// Force no IOMMU access attribute request recording before DMAR table is installed.
//
ASSERT_EFI_ERROR (EFI_NOT_READY);
return EFI_NOT_READY;
}
Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess);
Expand Down
11 changes: 3 additions & 8 deletions IntelSiliconPkg/Feature/VTd/IntelVTdCoreDxe/VtdReg.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,8 @@ PerpareCacheInvalidationInterface (
// Enable the queued invalidation interface through the Global Command Register.
// When enabled, hardware sets the QIES field in the Global Status Register.
//
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 |= B_GMCD_REG_QIE;
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) == 0);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface.\n"));
VtdLibSetGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);

VTdLogAddEvent (VTDLOG_DXE_QUEUED_INVALIDATION, VTD_LOG_QI_ENABLE, VtdUnitBaseAddress);

Expand Down Expand Up @@ -577,7 +572,7 @@ DumpVtdCapRegs (
IN VTD_CAP_REG *CapReg
)
{
DEBUG((DEBUG_INFO, " CapReg - 0x%x\n", CapReg->Uint64));
DEBUG((DEBUG_INFO, " CapReg - 0x%lx\n", CapReg->Uint64));
DEBUG((DEBUG_INFO, " ND - 0x%x\n", CapReg->Bits.ND));
DEBUG((DEBUG_INFO, " AFL - 0x%x\n", CapReg->Bits.AFL));
DEBUG((DEBUG_INFO, " RWBF - 0x%x\n", CapReg->Bits.RWBF));
Expand Down
9 changes: 2 additions & 7 deletions IntelSiliconPkg/Feature/VTd/IntelVTdCorePei/IntelVTdDmar.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ PerpareCacheInvalidationInterface (
// Enable the queued invalidation interface through the Global Command Register.
// When enabled, hardware sets the QIES field in the Global Status Register.
//
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 |= B_GMCD_REG_QIE;
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) == 0);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface.\n"));
VtdLibSetGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);

VTdLogAddEvent (VTDLOG_PEI_QUEUED_INVALIDATION, VTD_LOG_QI_ENABLE, VtdUnitBaseAddress);

Expand Down
41 changes: 19 additions & 22 deletions IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/IntelVTdDmar.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
#include <Ppi/IoMmu.h>
#include "IntelVTdDmarPei.h"

VOID
SetGlobalCommandRegisterBits (
IN UINTN VtdUnitBaseAddress,
IN UINT32 BitMask
);

VOID
ClearGlobalCommandRegisterBits (
IN UINTN VtdUnitBaseAddress,
IN UINT32 BitMask
);

/**
Flush VTD page table and context table memory.
Expand Down Expand Up @@ -58,6 +70,7 @@ FlushWriteBuffer (

if (CapReg.Bits.RWBF != 0) {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 = (Reg32 & 0x96FFFFFF); // Reset the one-shot bits
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_WBF);
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Expand Down Expand Up @@ -104,11 +117,7 @@ PerpareCacheInvalidationInterface (
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
if ((Reg32 & B_GSTS_REG_QIES) != 0) {
DEBUG ((DEBUG_INFO,"Queued Invalidation Interface was enabled.\n"));
Reg32 &= (~B_GSTS_REG_QIES);
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) != 0);
ClearGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);
MmioWrite64 (VtdUnitBaseAddress + R_IQA_REG, 0);
}

Expand Down Expand Up @@ -144,13 +153,8 @@ PerpareCacheInvalidationInterface (
// Enable the queued invalidation interface through the Global Command Register.
// When enabled, hardware sets the QIES field in the Global Status Register.
//
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 |= B_GMCD_REG_QIE;
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) == 0);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface.\n"));
SetGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);

return EFI_SUCCESS;
}
Expand All @@ -165,16 +169,9 @@ DisableQueuedInvalidationInterface (
IN VTD_UNIT_INFO *VTdUnitInfo
)
{
UINT32 Reg32;

if (VTdUnitInfo->EnableQueuedInvalidation != 0) {
Reg32 = MmioRead32 (VTdUnitInfo->VtdUnitBaseAddress + R_GSTS_REG);
Reg32 &= (~B_GMCD_REG_QIE);
MmioWrite32 (VTdUnitInfo->VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VTdUnitInfo->VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) != 0);
DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface.\n"));
ClearGlobalCommandRegisterBits (VTdUnitInfo->VtdUnitBaseAddress, B_GMCD_REG_QIE);

if (VTdUnitInfo->QiDescBuffer != NULL) {
FreePages(VTdUnitInfo->QiDescBuffer, EFI_SIZE_TO_PAGES (VTdUnitInfo->QiDescBufferSize));
Expand Down Expand Up @@ -206,7 +203,7 @@ QueuedInvalidationCheckFault (
if (FaultReg & (B_FSTS_REG_IQE | B_FSTS_REG_ITE | B_FSTS_REG_ICE)) {
IqercdReg.Uint64 = MmioRead64 (VTdUnitInfo->VtdUnitBaseAddress + R_IQERCD_REG);

DEBUG((DEBUG_ERROR, "Detect Queue Invalidation Error [0x%08x] - IQERCD [0x%016lx]\n", FaultReg, IqercdReg.Uint64));
DEBUG((DEBUG_ERROR, "VTD 0x%x Detect Queue Invalidation Error [0x%08x] - IQERCD [0x%016lx]\n", VTdUnitInfo->VtdUnitBaseAddress, FaultReg, IqercdReg.Uint64));

MmioWrite32 (VTdUnitInfo->VtdUnitBaseAddress + R_FSTS_REG, FaultReg);
return RETURN_DEVICE_ERROR;
Expand Down
1 change: 0 additions & 1 deletion IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ VTdSetAttribute (
//
// Force no IOMMU access attribute request recording before DMAR table is installed.
//
ASSERT_EFI_ERROR (EFI_NOT_READY);
return EFI_NOT_READY;
}
Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess);
Expand Down
44 changes: 21 additions & 23 deletions IntelSiliconPkg/Feature/VTd/IntelVTdDxe/VtdReg.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ VTD_UNIT_INFORMATION *mVtdUnitInformation;

BOOLEAN mVtdEnabled;

VOID
SetGlobalCommandRegisterBits (
IN UINTN VtdUnitBaseAddress,
IN UINT32 BitMask
);

VOID
ClearGlobalCommandRegisterBits (
IN UINTN VtdUnitBaseAddress,
IN UINT32 BitMask
);

/**
Flush VTD page table and context table memory.
Expand Down Expand Up @@ -47,6 +59,7 @@ FlushWriteBuffer (

if (mVtdUnitInformation[VtdIndex].CapReg.Bits.RWBF != 0) {
Reg32 = MmioRead32 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + R_GSTS_REG);
Reg32 = (Reg32 & 0x96FFFFFF); // Reset the one-shot bits
MmioWrite32 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_WBF);
do {
Reg32 = MmioRead32 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + R_GSTS_REG);
Expand Down Expand Up @@ -93,11 +106,7 @@ PerpareCacheInvalidationInterface (
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
if ((Reg32 & B_GSTS_REG_QIES) != 0) {
DEBUG ((DEBUG_ERROR,"Queued Invalidation Interface was enabled.\n"));
Reg32 &= (~B_GSTS_REG_QIES);
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) != 0);
ClearGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);
}

//
Expand Down Expand Up @@ -132,13 +141,8 @@ PerpareCacheInvalidationInterface (
// Enable the queued invalidation interface through the Global Command Register.
// When enabled, hardware sets the QIES field in the Global Status Register.
//
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 |= B_GMCD_REG_QIE;
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) == 0);
DEBUG ((DEBUG_INFO, "Enable Queued Invalidation Interface.\n"));
SetGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);

return EFI_SUCCESS;
}
Expand All @@ -153,19 +157,13 @@ DisableQueuedInvalidationInterface (
IN UINTN VtdIndex
)
{
UINT32 Reg32;
VTD_UNIT_INFORMATION *VTdUnitInfo;

VTdUnitInfo = &mVtdUnitInformation[VtdIndex];

if (VTdUnitInfo->EnableQueuedInvalidation != 0) {
Reg32 = MmioRead32 (VTdUnitInfo->VtdUnitBaseAddress + R_GSTS_REG);
Reg32 &= (~B_GMCD_REG_QIE);
MmioWrite32 (VTdUnitInfo->VtdUnitBaseAddress + R_GCMD_REG, Reg32);
DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface. GCMD_REG = 0x%x\n", Reg32));
do {
Reg32 = MmioRead32 (VTdUnitInfo->VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) != 0);
DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface.\n"));
ClearGlobalCommandRegisterBits (VTdUnitInfo->VtdUnitBaseAddress, B_GMCD_REG_QIE);

if (VTdUnitInfo->QiDescBuffer != NULL) {
FreePages(VTdUnitInfo->QiDescBuffer, EFI_SIZE_TO_PAGES (VTdUnitInfo->QiDescBufferSize));
Expand Down Expand Up @@ -198,7 +196,7 @@ QueuedInvalidationCheckFault (
if (FaultReg & (B_FSTS_REG_IQE | B_FSTS_REG_ITE | B_FSTS_REG_ICE)) {
IqercdReg.Uint64 = MmioRead64 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + R_IQERCD_REG);

DEBUG((DEBUG_ERROR, "Detect Queue Invalidation Error [0x%08x] - IQERCD [0x%016lx]\n", FaultReg, IqercdReg.Uint64));
DEBUG((DEBUG_ERROR, "VTD 0x%x Detect Queue Invalidation Error [0x%08x] - IQERCD [0x%016lx]\n", mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress, FaultReg, IqercdReg.Uint64));

MmioWrite32 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + R_FSTS_REG, FaultReg);
return RETURN_DEVICE_ERROR;
Expand Down Expand Up @@ -802,7 +800,7 @@ DumpVtdCapRegs (
IN VTD_CAP_REG *CapReg
)
{
DEBUG((DEBUG_INFO, " CapReg - 0x%x\n", CapReg->Uint64));
DEBUG((DEBUG_INFO, " CapReg - 0x%016lx\n", CapReg->Uint64));
DEBUG((DEBUG_INFO, " ND - 0x%x\n", CapReg->Bits.ND));
DEBUG((DEBUG_INFO, " AFL - 0x%x\n", CapReg->Bits.AFL));
DEBUG((DEBUG_INFO, " RWBF - 0x%x\n", CapReg->Bits.RWBF));
Expand Down Expand Up @@ -833,7 +831,7 @@ DumpVtdECapRegs (
IN VTD_ECAP_REG *ECapReg
)
{
DEBUG((DEBUG_INFO, " ECapReg - 0x%x\n", ECapReg->Uint64));
DEBUG((DEBUG_INFO, " ECapReg - 0x%016lx\n", ECapReg->Uint64));
DEBUG((DEBUG_INFO, " C - 0x%x\n", ECapReg->Bits.C));
DEBUG((DEBUG_INFO, " QI - 0x%x\n", ECapReg->Bits.QI));
DEBUG((DEBUG_INFO, " DT - 0x%x\n", ECapReg->Bits.DT));
Expand Down
1 change: 1 addition & 0 deletions IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/VtdReg.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ FlushWriteBuffer (

if (CapReg.Bits.RWBF != 0) {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 = (Reg32 & 0x96FFFFFF); // Reset the one-shot bits
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_WBF);
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define FIT_TYPE_0A_TXT_POLICY 0x0A
#define FIT_TYPE_0B_KEY_MANIFEST 0x0B
#define FIT_TYPE_0C_BOOT_POLICY_MANIFEST 0x0C
#define FIT_TYPE_0D_FSP_BOOT_MANIFEST 0x0D
#define FIT_TYPE_10_CSE_SECURE_BOOT 0x10
#define FIT_TYPE_2D_TXTSX_POLICY 0x2D
#define FIT_TYPE_2F_JMP_DEBUG_POLICY 0x2F
Expand Down
12 changes: 3 additions & 9 deletions IntelSiliconPkg/Library/IntelVTdPeiDxeLib/IntelVTdPeiDxeLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ VtdLibFlushWriteBuffer (

if (CapReg.Bits.RWBF != 0) {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 = (Reg32 & 0x96FFFFFF); // Reset the one-shot bits
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_WBF);
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Expand Down Expand Up @@ -1664,7 +1665,6 @@ VtdLibDisableQueuedInvalidationInterface (
IN UINTN VtdUnitBaseAddress
)
{
UINT32 Reg32;
QI_256_DESC QiDesc;

QiDesc.Uint64[0] = QI_IWD_TYPE;
Expand All @@ -1674,14 +1674,8 @@ VtdLibDisableQueuedInvalidationInterface (

VtdLibSubmitQueuedInvalidationDescriptor (VtdUnitBaseAddress, &QiDesc, TRUE);

Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
Reg32 &= (~B_GMCD_REG_QIE);
MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32);

DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface. [%x] GCMD_REG = 0x%x\n", VtdUnitBaseAddress, Reg32));
do {
Reg32 = MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG);
} while ((Reg32 & B_GSTS_REG_QIES) != 0);
DEBUG ((DEBUG_INFO, "Disable Queued Invalidation Interface. [%x]\n", VtdUnitBaseAddress));
VtdLibClearGlobalCommandRegisterBits (VtdUnitBaseAddress, B_GMCD_REG_QIE);

MmioWrite64 (VtdUnitBaseAddress + R_IQA_REG, 0);
}
Expand Down

0 comments on commit e433c80

Please sign in to comment.