Skip to content

Commit

Permalink
UefiCpuPkg: RISC-V: MMU: Introduce a PCD for SATP mode
Browse files Browse the repository at this point in the history
Introduce a PCD to control the maximum SATP mode that MMU allowed
to use. This PCD helps RISC-V platform set bare or minimum SATP mode
during bring up to debug memory map issue.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
Reviewed-by: Dhaval Sharma <dhaval@rivosinc.com>
Reviewed-by: Andrei Warkentin <andrei.warkentin@intel.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
  • Loading branch information
tphan-ventana authored and mergify[bot] committed Oct 17, 2023
1 parent a445e1a commit 772ec92
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion UefiCpuPkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define PTE_PPN_SHIFT 10
#define RISCV_MMU_PAGE_SHIFT 12

STATIC UINTN mModeSupport[] = { SATP_MODE_SV57, SATP_MODE_SV48, SATP_MODE_SV39 };
STATIC UINTN mModeSupport[] = { SATP_MODE_SV57, SATP_MODE_SV48, SATP_MODE_SV39, SATP_MODE_OFF };
STATIC UINTN mMaxRootTableLevel;
STATIC UINTN mBitPerLevel;
STATIC UINTN mTableEntryCount;
Expand Down Expand Up @@ -590,6 +590,10 @@ RiscVMmuSetSatpMode (
UINTN Index;
EFI_STATUS Status;

if (SatpMode > PcdGet32 (PcdCpuRiscVMmuMaxSatpMode)) {
return EFI_DEVICE_ERROR;
}

switch (SatpMode) {
case SATP_MODE_OFF:
return EFI_SUCCESS;
Expand Down
3 changes: 3 additions & 0 deletions UefiCpuPkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@

[LibraryClasses]
BaseLib

[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuRiscVMmuMaxSatpMode ## CONSUMES
8 changes: 8 additions & 0 deletions UefiCpuPkg/UefiCpuPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@
# @Prompt Access to non-SMRAM memory is restricted to reserved, runtime and ACPI NVS type after SmmReadyToLock.
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmRestrictedMemoryAccess|TRUE|BOOLEAN|0x3213210F

[PcdsFixedAtBuild.RISCV64]
## Indicate the maximum SATP mode allowed.
# 0 - Bare mode.
# 8 - 39bit mode.
# 9 - 48bit mode.
# 10 - 57bit mode.
gUefiCpuPkgTokenSpaceGuid.PcdCpuRiscVMmuMaxSatpMode|10|UINT32|0x60000021

[PcdsDynamic, PcdsDynamicEx]
## Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA.
# @Prompt The pointer to a CPU S3 data buffer.
Expand Down

0 comments on commit 772ec92

Please sign in to comment.