ArmVirtPkg: Add library for Arm CCA initialisation in PEI

Add ArmCcaInitPeiLib library that performs the Arm CCA specific
initialisation in the PEI phase like configuring the system
memory as Protected RAM.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Sami Mujawar 2022-07-12 11:14:00 +01:00
parent eee6ed8b11
commit 15cf308276
4 changed files with 115 additions and 0 deletions

View file

@ -26,6 +26,7 @@
Include # Root include for the package
[LibraryClasses]
ArmCcaInitPeiLib|Include/Library/ArmCcaInitPeiLib.h
ArmCcaLib|Include/Library/ArmCcaLib.h
ArmCcaRsiLib|Include/Library/ArmCcaRsiLib.h
ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h

View file

@ -0,0 +1,30 @@
/** @file
Library that implements the Arm CCA helper functions.
Copyright (c) 2022 2026, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
- Rsi or RSI - Realm Service Interface
- IPA - Intermediate Physical Address
- RIPAS - Realm IPA state
**/
#pragma once
#include <Base.h>
/**
Configure the System Memory region as Protected RAM.
When a VMM creates a Realm, a small amount of DRAM (which contains the
firmware image) and the initial content is configured as Protected RAM.
The remaining System Memory is in the Protected Empty state. The firmware
must then initialise the remaining System Memory as Protected RAM before
it can be accessed.
**/
VOID
EFIAPI
ArmCcaConfigureSystemMemory (
VOID
);

View file

@ -0,0 +1,50 @@
/** @file
Library that implements the Arm CCA initialisation in PEI phase.
Copyright (c) 2022 2026, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Glossary:
- Rsi or RSI - Realm Service Interface
- IPA - Intermediate Physical Address
- RIPAS - Realm IPA state
**/
#include <PiPei.h>
#include <Library/ArmCcaLib.h>
#include <Library/ArmCcaRsiLib.h>
#include <Library/BaseLib.h>
/**
Configure the System Memory region as Protected RAM.
When a VMM creates a Realm, a small amount of DRAM (which contains the
firmware image) and the initial content is configured as Protected RAM.
The remaining System Memory is in the Protected Empty state. The firmware
must then initialise the remaining System Memory as Protected RAM before
it can be accessed.
**/
VOID
EFIAPI
ArmCcaConfigureSystemMemory (
VOID
)
{
RETURN_STATUS Status;
if (!ArmCcaIsRealm ()) {
return;
}
Status = ArmCcaRsiSetIpaState (
(UINT64 *)PcdGet64 (PcdSystemMemoryBase),
PcdGet64 (PcdSystemMemorySize),
RipasRam,
ARM_CCA_RIPAS_CHANGE_FLAGS_RSI_NO_CHANGE_DESTROYED
);
if (RETURN_ERROR (Status)) {
// Panic
CpuDeadLoop ();
}
}

View file

@ -0,0 +1,34 @@
## @file
# Library that implements the Arm CCA initialisation in PEI phase.
#
# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x0001001B
BASE_NAME = ArmCcaInitPeiLib
FILE_GUID = 9A8C3768-79ED-487E-8155-BBF4DD638296
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = ArmCcaInitPeiLib
[Sources]
ArmCcaInitPeiLib.c
[Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmCcaLib
ArmCcaRsiLib
BaseLib
[Pcd]
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize