mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
dcd39e09ff
commit
3a71670618
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
BmDma related function
|
BmDma related function
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -12,15 +12,7 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <PiDxe.h>
|
#include "DmaProtection.h"
|
||||||
|
|
||||||
#include <Protocol/IoMmu.h>
|
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
|
|
||||||
// TBD: May make it a policy
|
// TBD: May make it a policy
|
||||||
#define DMA_MEMORY_TOP MAX_UINTN
|
#define DMA_MEMORY_TOP MAX_UINTN
|
||||||
@ -76,6 +68,7 @@ IoMmuMap (
|
|||||||
MAP_INFO *MapInfo;
|
MAP_INFO *MapInfo;
|
||||||
EFI_PHYSICAL_ADDRESS DmaMemoryTop;
|
EFI_PHYSICAL_ADDRESS DmaMemoryTop;
|
||||||
BOOLEAN NeedRemap;
|
BOOLEAN NeedRemap;
|
||||||
|
EFI_TPL OriginalTpl;
|
||||||
|
|
||||||
if (NumberOfBytes == NULL || DeviceAddress == NULL ||
|
if (NumberOfBytes == NULL || DeviceAddress == NULL ||
|
||||||
Mapping == NULL) {
|
Mapping == NULL) {
|
||||||
@ -198,7 +191,9 @@ IoMmuMap (
|
|||||||
MapInfo->DeviceAddress = MapInfo->HostAddress;
|
MapInfo->DeviceAddress = MapInfo->HostAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);
|
||||||
InsertTailList (&gMaps, &MapInfo->Link);
|
InsertTailList (&gMaps, &MapInfo->Link);
|
||||||
|
gBS->RestoreTPL (OriginalTpl);
|
||||||
|
|
||||||
//
|
//
|
||||||
// The DeviceAddress is the address of the maped buffer below 4GB
|
// The DeviceAddress is the address of the maped buffer below 4GB
|
||||||
@ -233,6 +228,7 @@ IoMmuUnmap (
|
|||||||
{
|
{
|
||||||
MAP_INFO *MapInfo;
|
MAP_INFO *MapInfo;
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
|
EFI_TPL OriginalTpl;
|
||||||
|
|
||||||
DEBUG ((DEBUG_VERBOSE, "IoMmuUnmap: 0x%08x\n", Mapping));
|
DEBUG ((DEBUG_VERBOSE, "IoMmuUnmap: 0x%08x\n", Mapping));
|
||||||
|
|
||||||
@ -241,6 +237,7 @@ IoMmuUnmap (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);
|
||||||
MapInfo = NULL;
|
MapInfo = NULL;
|
||||||
for (Link = GetFirstNode (&gMaps)
|
for (Link = GetFirstNode (&gMaps)
|
||||||
; !IsNull (&gMaps, Link)
|
; !IsNull (&gMaps, Link)
|
||||||
@ -255,10 +252,12 @@ IoMmuUnmap (
|
|||||||
// Mapping is not a valid value returned by Map()
|
// Mapping is not a valid value returned by Map()
|
||||||
//
|
//
|
||||||
if (MapInfo != Mapping) {
|
if (MapInfo != Mapping) {
|
||||||
|
gBS->RestoreTPL (OriginalTpl);
|
||||||
DEBUG ((DEBUG_ERROR, "IoMmuUnmap: %r\n", EFI_INVALID_PARAMETER));
|
DEBUG ((DEBUG_ERROR, "IoMmuUnmap: %r\n", EFI_INVALID_PARAMETER));
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
RemoveEntryList (&MapInfo->Link);
|
RemoveEntryList (&MapInfo->Link);
|
||||||
|
gBS->RestoreTPL (OriginalTpl);
|
||||||
|
|
||||||
if (MapInfo->DeviceAddress != MapInfo->HostAddress) {
|
if (MapInfo->DeviceAddress != MapInfo->HostAddress) {
|
||||||
//
|
//
|
||||||
|
@ -478,7 +478,7 @@ InitializeDmaProtection (
|
|||||||
|
|
||||||
Status = gBS->CreateEventEx (
|
Status = gBS->CreateEventEx (
|
||||||
EVT_NOTIFY_SIGNAL,
|
EVT_NOTIFY_SIGNAL,
|
||||||
TPL_CALLBACK,
|
VTD_TPL_LEVEL,
|
||||||
AcpiNotificationFunc,
|
AcpiNotificationFunc,
|
||||||
NULL,
|
NULL,
|
||||||
&gEfiAcpi10TableGuid,
|
&gEfiAcpi10TableGuid,
|
||||||
@ -488,7 +488,7 @@ InitializeDmaProtection (
|
|||||||
|
|
||||||
Status = gBS->CreateEventEx (
|
Status = gBS->CreateEventEx (
|
||||||
EVT_NOTIFY_SIGNAL,
|
EVT_NOTIFY_SIGNAL,
|
||||||
TPL_CALLBACK,
|
VTD_TPL_LEVEL,
|
||||||
AcpiNotificationFunc,
|
AcpiNotificationFunc,
|
||||||
NULL,
|
NULL,
|
||||||
&gEfiAcpi20TableGuid,
|
&gEfiAcpi20TableGuid,
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
#define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))
|
#define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))
|
||||||
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))
|
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))
|
||||||
|
|
||||||
|
#define VTD_TPL_LEVEL TPL_NOTIFY
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is the initial max PCI DATA number.
|
// This is the initial max PCI DATA number.
|
||||||
// The number may be enlarged later.
|
// The number may be enlarged later.
|
||||||
|
@ -12,16 +12,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <PiDxe.h>
|
|
||||||
|
|
||||||
#include <Protocol/IoMmu.h>
|
|
||||||
#include <Protocol/PciIo.h>
|
|
||||||
|
|
||||||
#include <Library/IoLib.h>
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
|
|
||||||
#include "DmaProtection.h"
|
#include "DmaProtection.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,18 +296,22 @@ IoMmuSetAttribute (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PHYSICAL_ADDRESS DeviceAddress;
|
EFI_PHYSICAL_ADDRESS DeviceAddress;
|
||||||
UINTN NumberOfPages;
|
UINTN NumberOfPages;
|
||||||
|
EFI_TPL OriginalTpl;
|
||||||
|
|
||||||
|
OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);
|
||||||
|
|
||||||
Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);
|
Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);
|
||||||
if (EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
return Status;
|
Status = VTdSetAttribute (
|
||||||
|
This,
|
||||||
|
DeviceHandle,
|
||||||
|
DeviceAddress,
|
||||||
|
EFI_PAGES_TO_SIZE(NumberOfPages),
|
||||||
|
IoMmuAccess
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Status = VTdSetAttribute (
|
|
||||||
This,
|
gBS->RestoreTPL (OriginalTpl);
|
||||||
DeviceHandle,
|
|
||||||
DeviceAddress,
|
|
||||||
EFI_PAGES_TO_SIZE(NumberOfPages),
|
|
||||||
IoMmuAccess
|
|
||||||
);
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user