From 99e4c8ea93fa0e98bc1bdb968e9d5bb42ff5d39c Mon Sep 17 00:00:00 2001 From: Chao Li Date: Tue, 27 Aug 2024 10:30:36 +0800 Subject: [PATCH] OvmfPkg/LoongArchVirt: Clear the PGD series registers Since the PGD series registers are in an unknown state when reset, some simulators will hang when restarting if these registers are not cleared, so they are cleared in this patch. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Bibo Mao Signed-off-by: Chao Li --- OvmfPkg/LoongArchVirt/Library/CpuMmuInitLib/CpuMmuInit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OvmfPkg/LoongArchVirt/Library/CpuMmuInitLib/CpuMmuInit.c b/OvmfPkg/LoongArchVirt/Library/CpuMmuInitLib/CpuMmuInit.c index be2d98cc9a..9091b70c01 100644 --- a/OvmfPkg/LoongArchVirt/Library/CpuMmuInitLib/CpuMmuInit.c +++ b/OvmfPkg/LoongArchVirt/Library/CpuMmuInitLib/CpuMmuInit.c @@ -141,6 +141,12 @@ ConfigureMemoryManagementUnit ( return EFI_UNSUPPORTED; } + // + // Clear PGD series registers. + // + CsrWrite (LOONGARCH_CSR_PGDL, 0x0); + CsrWrite (LOONGARCH_CSR_PGDH, 0x0); + PageTable = 0; while (MemoryTable->NumberOfPages != 0) { DEBUG ((