Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ARM/AARCH64 Platforms to Use New ArmMmuLib Instances #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

os-d
Copy link
Contributor

@os-d os-d commented Oct 28, 2024

edk2 PR tianocore/edk2#6286 is updating ArmMmuLib instances to a SEC, PEI, and BASE version to support pre-allocating page table memory.

This commit makes the necessary changes in edk2-platforms to resolve the breaking change. This needs to be checked in after the edk2 PR is checked in.

Continuous-integration-options: PatchCheck.ignore-multi-package

@nhivp
Copy link
Member

nhivp commented Oct 29, 2024

The changes for Mt. Jade cause a crash. I'm unsure if you have any idea while I need to get more time to dig into it

add-symbol-file /edk2-ampere-tools/Build/Jade/DEBUG_GCC/AARCH64/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll 0xB9F17000
Loading driver at 0x000B9F16000 EntryPoint=0x000B9F1AB04 ArmCpuDxe.efi
PROGRESS CODE: V03040002 I0


Synchronous Exception at 0x0000000092020E00
PC 0x000092020E00
PC 0x0000B9F19FF8 (0x0000B9F16000+0x00003FF8) [ 1] ArmCpuDxe.dll
PC 0x0000B9F19DDC (0x0000B9F16000+0x00003DDC) [ 1] ArmCpuDxe.dll
PC 0x0000B9F19DDC (0x0000B9F16000+0x00003DDC) [ 1] ArmCpuDxe.dll
PC 0x0000B9F1A498 (0x0000B9F16000+0x00004498) [ 1] ArmCpuDxe.dll
PC 0x0000BF965EA0 (0x0000BF94B000+0x0001AEA0) [ 2] DxeCore.dll
PC 0x0000BF96676C (0x0000BF94B000+0x0001B76C) [ 2] DxeCore.dll
PC 0x0000BF95A3DC (0x0000BF94B000+0x0000F3DC) [ 2] DxeCore.dll
PC 0x0000BF965A14 (0x0000BF94B000+0x0001AA14) [ 2] DxeCore.dll
PC 0x0000B9F1AF28 (0x0000B9F16000+0x00004F28) [ 3] ArmCpuDxe.dll
PC 0x0000BF969BF4 (0x0000BF94B000+0x0001EBF4) [ 4] DxeCore.dll
PC 0x0000BF95C600 (0x0000BF94B000+0x00011600) [ 4] DxeCore.dll
PC 0x0000BF96C4C0 (0x0000BF94B000+0x000214C0) [ 4] DxeCore.dll
[ 1] /edk2-ampere-tools/Build/Jade/DEBUG_GCC/AARCH64/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll
[ 2] /edk2-ampere-tools/Build/Jade/DEBUG_GCC/AARCH64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll
[ 3] /edk2-ampere-tools/Build/Jade/DEBUG_GCC/AARCH64/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll
[ 4] /edk2-ampere-tools/Build/Jade/DEBUG_GCC/AARCH64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll

  X0 0x00000000BFF76E78   X1 0x00000000B9C01003   X2 0x00000000B9E00000   X3 0x0000000000000000
  X4 0x0000000092020E00   X5 0x00000000B9EC0000   X6 0x0040000000000400   X7 0xFF9F000000000B3F
  X8 0x000000009000070D   X9 0x0000000090000000  X10 0x0000000000000001  X11 0x0000000000000000
 X12 0x0000000000700000  X13 0x000000000000000E  X14 0x0000000000000000  X15 0x0000000000000000
 X16 0x00000000BF94AD90  X17 0x0000000005907E2C  X18 0x0000000000000000  X19 0x00000000B9E00000
 X20 0x0000000000000002  X21 0x00000000BFF76000  X22 0x0000000000000E78  X23 0x00000000001FFFFF
 X24 0x00000000B9EC0000  X25 0x00000000B9C01003  X26 0xFF9F000000000B3F  X27 0x0000000000000003
 X28 0x00000000BFF76E78   FP 0x00000000BF94A7A0   LR 0x00000000B9F19FF8

  V0 0x0000000000000000 0000000000000000   V1 0x0000000000000000 41A32F4579C98000
  V2 0x0000000000000000 4084D40000000000   V3 0x0000000000000000 0000000000000000
  V4 0x0000000000000000 0000000000000000   V5 0x0000000000000000 0000000000000000
  V6 0x0000000000000000 0000000000000000   V7 0x0000000000000000 0000000000000000
  V8 0x0000000000000000 0000000000000000   V9 0x0000000000000000 0000000000000000
 V10 0x0000000000000000 0000000000000000  V11 0x0000000000000000 0000000000000000
 V12 0x0000000000000000 0000000000000000  V13 0x0000000000000000 0000000000000000
 V14 0x0000000000000000 0000000000000000  V15 0x0000000000000000 0000000000000000
 V16 0x0000000000000000 0000000000000000  V17 0x0000000000000000 0000000000000000
 V18 0x0000000000000000 0000000000000000  V19 0x0000000000000000 0000000000000000
 V20 0x0000000000000000 0000000000000000  V21 0x0000000000000000 0000000000000000
 V22 0x0000000000000000 0000000000000000  V23 0x0000000000000000 0000000000000000
 V24 0x0000000000000000 0000000000000000  V25 0x0000000000000000 0000000000000000
 V26 0x0000000000000000 0000000000000000  V27 0x0000000000000000 0000000000000000
 V28 0x0000000000000000 0000000000000000  V29 0x0000000000000000 0000000000000000
 V30 0x0000000000000000 0000000000000000  V31 0x0000000000000000 0000000000000000

  SP 0x00000000BF94A7A0  ELR 0x0000000092020E00  SPSR 0x00000209  FPSR 0x00000010
 ESR 0x8600000E          FAR 0x0000000092020E00

 ESR : EC 0x21  IL 0x1  ISS 0x0000000E

Instruction abort: Permission fault, second level

Stack dump:
  00000BF94A6A0: 00000000BF94A840 00000000B9F19CD8 00000000BF94A820 00000000BF94A820
  00000BF94A6C0: 00000000BF94A7F0 00000000FFFFFFD0 00000000B9F1E1FF 0000000000000003
  00000BF94A6E0: 00000000B9E00000 00000000B9EC0000 0040000000000400 FF9F000000000B3F
  00000BF94A700: 00000000BF94A7A0 00000000B9F19DDC 00000000B9E00000 0000000000000002
  00000BF94A720: 00000000BFF76000 0000000000000E78 00000000001FFFFF 00000000B9EC0000
  00000BF94A740: 00000000B9C01000 FF9F000000000B3F 0000000000000003 00000000BFF76E78
  00000BF94A760: 00000000BFF76000 0040000000000400 00000000B9EC0000 00000000B9EC0000
  00000BF94A780: 00000000BF94A7A0 00000000B9F1F108 0040000000000403 0000000C00000001
> 00000BF94A7A0: 00000000BF94A840 00000000B9F19DDC 0000000090000000 0000000000000001
  00000BF94A7C0: 00000000BFFF1000 0000000000000010 000000003FFFFFFF 00000000B9EC0000
  00000BF94A7E0: 00000000BFF76000 FF9F000000000B3F 0000000000000002 00000000BFFF1010
  00000BF94A800: 0000000000000004 0040000000000400 0000000000000001 00000000B9EC0000
  00000BF94A820: 0000000190000000 00000000B9F1F108 0040000000000401 0000001500000001
  00000BF94A840: 00000000BF94A8E0 00000000B9F19DDC 0000000090000000 0000000000000000
  00000BF94A860: 00000000BFFFE000 0000000000000000 0000007FFFFFFFFF 00000000B9EC0000
  00000BF94A880: 00000000BFFF1000 FF9F000000000B3F 0000000000000001 00000000BFFFE000
ASSERT [ArmCpuDxe] /edk2/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c(340): ((BOOLEAN)(0==1))

@hrw
Copy link
Contributor

hrw commented Oct 30, 2024

edk2 at:

commit 70a9896fa8506c97c4e4ae5ad3371d0ef5f7e28f (HEAD -> mmu, origin/pr/6286)
Author: Taylor Beebe <[email protected]>
Date:   Wed Apr 24 14:43:57 2024 -0700

    ArmPkg: ArmMmuLib: Pre-Allocate Page Table Memory

edk2-platforms at:

commit e5978b036d47a0bf42539cf5d552e3051346fabd (HEAD -> mmu, origin/pr/235)
Author: Oliver Smith-Denny <[email protected]>
Date:   Mon Oct 28 16:04:32 2024 -0700

    Update ARM/AARCH64 Platforms to Use New ArmMmuLib Instances

System (QemuSbsa) crashed:

Loading driver at 0x101FBA24000 EntryPoint=0x101FBA2B79C RamDiskDxe.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 101FAD10718
ProtectUefiImageCommon - 0xFAD10240
  - 0x00000101FBA24000 - 0x000000000000D000
SetUefiImageMemoryAttributes - 0x00000101FBA24000 - 0x0000000000001000 (0x0000000000004008)
SetUefiImageMemoryAttributes - 0x00000101FBA25000 - 0x0000000000009000 (0x0000000000020008)
SetUefiImageMemoryAttributes - 0x00000101FBA2E000 - 0x0000000000003000 (0x0000000000004008)
InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 101FAD0FB18
InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 101FBA2EBE8
InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 101FBA2F2F4
InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 101FAD0E8B0
InstallProtocolInterface: AB38A0DF-6873-44A9-87E6-D4EB56148449 101FBA2F390
InstallProtocolInterface: 28A03FF4-12B3-4305-A417-BB1A4F94081E 101FAD0E898
Loading driver 42857F0A-13F2-4B21-8A23-53D3F714B840
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 101FAD0F840


Synchronous Exception at 0x0000000010017800
PC 0x000010017800
PC 0x0101FBAC84B0 (0x0101FBAC5000+0x000034B0) [ 1] ArmCpuDxe.dll
PC 0x0101FBAC8328 (0x0101FBAC5000+0x00003328) [ 1] ArmCpuDxe.dll
PC 0x0101FBAC8328 (0x0101FBAC5000+0x00003328) [ 1] ArmCpuDxe.dll
PC 0x0101FBAC8708 (0x0101FBAC5000+0x00003708) [ 1] ArmCpuDxe.dll
PC 0x0101FF814D14 (0x0101FF805000+0x0000FD14) [ 2] DxeCore.dll
PC 0x0101FF81ED44 (0x0101FF805000+0x00019D44) [ 2] DxeCore.dll
PC 0x0101FF807478 (0x0101FF805000+0x00002478) [ 2] DxeCore.dll
PC 0x0101FF818FC0 (0x0101FF805000+0x00013FC0) [ 2] DxeCore.dll
PC 0x0101FF80FFA0 (0x0101FF805000+0x0000AFA0) [ 2] DxeCore.dll
[ 1] /home/marcin/devel/linaro/sbsa-qemu/code/Build/SbsaQemu/DEBUG_GCC/AARCH64/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll
[ 2] /home/marcin/devel/linaro/sbsa-qemu/code/Build/SbsaQemu/DEBUG_GCC/AARCH64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll

  X0 0x00000101FFFFDE10   X1 0x00000101FAA04003   X2 0x00000101F85A0000   X3 0x0000000000000000
  X4 0x0000000010017800   X5 0x0000000000000003   X6 0x0000000000000400   X7 0xFF9F000000000B3F
  X8 0x00000101F85A0000   X9 0x0000000000000001  X10 0x00000101F85A0000  X11 0x00000101F85DFFFF
 X12 0x0000000000000000  X13 0x000000000002600E  X14 0x0000000000000000  X15 0x0000000000000000
 X16 0x00000101FBAC860C  X17 0x0000000000000000  X18 0x0000000000000000  X19 0x00000101F85A0000
 X20 0x0000000000000002  X21 0x00000101FFFFD000  X22 0x00000101FBACE000  X23 0x00000000001FFFFF
 X24 0x00000101F85E0000  X25 0x0000000000000400  X26 0xFF9F000000000B3F  X27 0x00000101FAA04003
 X28 0x00000101FAA04000   FP 0x00000101FF804970   LR 0x00000101FBAC84B0

  V0 0x0000000000000000 0000000000000000   V1 0x0000000000000000 0000000000000000
  V2 0x0000000000000000 0000000000000000   V3 0x0000000000000000 0000000000000000
  V4 0x0000000000000000 0000000000000000   V5 0x0000000000000000 0000000000000000
  V6 0x0000000000000000 0000000000000000   V7 0x0000000000000000 0000000000000000
  V8 0x0000000000000000 0000000000000000   V9 0x0000000000000000 0000000000000000
 V10 0x0000000000000000 0000000000000000  V11 0x0000000000000000 0000000000000000
 V12 0x0000000000000000 0000000000000000  V13 0x0000000000000000 0000000000000000
 V14 0x0000000000000000 0000000000000000  V15 0x0000000000000000 0000000000000000
 V16 0x0000000000000000 0000000000000000  V17 0x0000000000000000 0000000000000000
 V18 0x0000000000000000 0000000000000000  V19 0x0000000000000000 0000000000000000
 V20 0x0000000000000000 0000000000000000  V21 0x0000000000000000 0000000000000000
 V22 0x0000000000000000 0000000000000000  V23 0x0000000000000000 0000000000000000
 V24 0x0000000000000000 0000000000000000  V25 0x0000000000000000 0000000000000000
 V26 0x0000000000000000 0000000000000000  V27 0x0000000000000000 0000000000000000
 V28 0x0000002800000001 0000000000003C02  V29 0x4F52414E494C0004 0000002C43495041
 V30 0x00000101FF804BD0 00000101FF804BD0  V31 0xFFFFFF80FFFFFFD0 00000101FF804BA0

  SP 0x00000101FF804970  ELR 0x0000000010017800  SPSR 0x00000A09  FPSR 0x00000000
 ESR 0x8600000E          FAR 0x0000000010017800

 ESR : EC 0x21  IL 0x1  ISS 0x0000000E

Instruction abort: Permission fault, second level

Stack dump:
  00101FF804870: 00000101FF8049A0 00000000FFFFFFD0 00000101FF804A20 00000101FF812AE4
  00101FF804890: 00000101FF804A00 00000101FF804A00 00000101FF8049D0 00000000FFFFFFD0
  00101FF8048B0: 00000101FBACD01E 0000000000000003 00000101F85A0000 00000101F85E0000
  00101FF8048D0: 0000000000000400 FF9F000000000B3F 00000101FF804970 00000101FBAC8328
  00101FF8048F0: 00000101F85A0000 0000000000000002 00000101FFFFD000 0000000000000E10
  00101FF804910: 00000000001FFFFF 00000101F85E0000 0000000000000400 FF9F000000000B3F
  00101FF804930: 0000000000000000 00000101FAA04000 00000101FAA04EF8 00000101F85E0000
  00101FF804950: 0000000000000403 0000000C00000000 00000101FBACB8FD 0000000000000002
> 00101FF804970: 00000101FF804A00 00000101FBAC8328 00000101F85A0000 0000000000000001
  00101FF804990: 00000101FFFFE000 0000000000000038 000000003FFFFFFF 00000101F85E0000
  00101FF8049B0: 0000000000000400 FF9F000000000B3F 0000010200000000 00000101FFFFD000
  00101FF8049D0: 00000101FFFFDE10 00000101F85E0000 0000000000000401 0000001500000001
  00101FF8049F0: 00000101FBACB8FD 0000000000000003 00000101FF804A90 00000101FBAC8328
  00101FF804A10: 00000101F85A0000 0000000000000000 00000101FFFFF000 0000000000000010
  00101FF804A30: 0000007FFFFFFFFF 00000101F85E0000 0000000000000400 FF9F000000000B3F
  00101FF804A50: 0000018000000000 00000101FFFFE000 00000101FFFFE038 00000101F85E0000
ASSERT [ArmCpuDxe] DefaultExceptionHandler.c(340): ((BOOLEAN)(0==1))

I try to run code before review.

@os-d
Copy link
Contributor Author

os-d commented Oct 30, 2024

Thanks @nhivp and @hrw for testing this out. I do not have the ability or bandwidth to test all ARM/ARM64 platforms in edk2-platforms, so I appreciate you testing. This does work on ArmVirtPkg's various flavors. I will take a look at the failure, I'm assuming it is similar.

@hrw
Copy link
Contributor

hrw commented Oct 30, 2024

@os-d
Copy link
Contributor Author

os-d commented Oct 30, 2024

@hrw , using your blog + the build steps here, neither my edk2 PR + edk2-platforms PR nor master + master boots sbsa-qemu for me:

Loading driver at 0x1003BA76000 EntryPoint=0x1003BA788E0 SbsaQemuAcpiDxe.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 1003ACAD718
ProtectUefiImageCommon - 0x3ACAD840
  - 0x000001003BA76000 - 0x0000000000007000
SetUefiImageMemoryAttributes - 0x000001003BA76000 - 0x0000000000001000 (0x0000000000004008)
SetUefiImageMemoryAttributes - 0x000001003BA77000 - 0x0000000000005000 (0x0000000000020008)
SetUefiImageMemoryAttributes - 0x000001003BA7C000 - 0x0000000000001000 (0x0000000000004008)
GetCpuCount: We have 4 cpus.
GetMpidr: MPIDR for CPU0: = 0
GetMpidr: MPIDR for CPU1: = 1
GetMpidr: MPIDR for CPU2: = 2
GetMpidr: MPIDR for CPU3: = 3
GetCpuCount: We have 4 cpus.
GetCpuTopology: SIP_SVC_GET_CPU_TOPOLOGY call failed. We have no cpu topology information.

Something else I need to do? This is using the top of tree precompiled TF-A bins in edk2-non-osi.

@hrw
Copy link
Contributor

hrw commented Oct 31, 2024

@os-d what you got is due to use of old edk2-non-osi binaries as tianocore/edk2-non-osi@17c42d6 was pushed to add that SIP_SVC_GET_CPU_TOPOLOGY call.

@mgamal
Copy link

mgamal commented Nov 4, 2024

Tested on Arm Juno. No issues encountered on my end.

@os-d
Copy link
Contributor Author

os-d commented Nov 5, 2024

@os-d what you got is due to use of old edk2-non-osi binaries as tianocore/edk2-non-osi@17c42d6 was pushed to add that SIP_SVC_GET_CPU_TOPOLOGY call.

@hrw , I did a fresh clone of edk2-non-osi for this and it is at 889f9c90de53e7c8729d1f449b8781a5477f0df4, from Oct 17, and I see the commit you are referencing in git log, but I still get the error.

I also tried building a fresh clone of TF-A (commit dddded141458fe1ff8fcbf8f3080dbf20953e7a4 from Nov 1) and added a custom print to make sure that my TF-A was getting loaded and it is:

NOTICE: Booting os-d Firmware

But I still get the same error.

I'm still probably doing something wrong, but I don't know what it is :)

@os-d
Copy link
Contributor Author

os-d commented Nov 8, 2024

@hrw , I was able to repro the issue by commenting out the call to TF-A to get the cpu topology. I fixed the issue, I was linking ArmMmuPeiLib into your platform (and most of the others) when previously they were using ArmMmuBaseLib. I fixed the linkage. Can you and @nhivp please confirm this fixes your issue? QemuSbsa boots to shell for me now.

edk2 PR tianocore/edk2#6286 is updating
ArmMmuLib instances to a SEC, PEI, and BASE version to support
pre-allocating page table memory.

This commit makes the necessary changes in edk2-platforms to
resolve the breaking change.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <[email protected]>
Copy link
Member

@nhivp nhivp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with booting to Linux. Looks good to me. Thanks for fixing it.

Copy link
Contributor

@hrw hrw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SbsaQemu works.

Copy link
Contributor

@samimujawar samimujawar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this patch.
For Platform/ARM/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants