ARM64 Port Status

Oooh, nice!!

2 Likes

Congratulations, itā€™s exciting to see this port show some signs of life on real hardware! :smiley:

I think we have done this for x86 vs x86_64 as well. Or we can simply mover these UART drivers outside of arch-specific directories if they are used by more than one architecture.

Indeed this makes sense for NXP devices, which often are historically PPC ones and then they just replaced the CPU with an ARM core, keeping all other parts largely identical.

4 Likes

Maybe these are just non-arch specific drivers under the DTB tree?

1 Like

Is code on git repository the latest, or is there some newer branch for arm64 port?

From my experiments to start this on qemu:

  • needed to add config_manager stub to get it to compile (src/add-ons/kernel/bus_managers/config_manager/arch/arm64/config_manager_arch.c)
  • need to run qemu with -cpu max, as atomics from ARMv8.2 are required
  • loader didnā€™t like the generated kernel ELF, needed to replace linker scripts guts (src/system/ldscripts/arm64/kernel.ld) with these taken from arm/riscv
  • now it refuses to jump to kernel because stack isnā€™t mapped correctly. after enabling some debug code (and initializing pl011 to have any output after ExitBootServices), final output looks like this:
kernel:
  text: 0x80000000, 0x196000
  data: 0x801a5000, 0x7b000
  entry: 0x80086dc0
Converted bootloader address 0x0000000041374000 in region 0x41374000-0x41379000 to 0xffff000002454000
Kernel stack at 0xffff000002454000
System provided memory map:
  phys: 0x40000000-0x41374000, virt: 0x0-0x1374000, size = 0x1374000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x41374000-0x439e7000, virt: 0x0-0x2673000, size = 0x2673000, type: LoaderData (0x2), attr: 0x8
  phys: 0x439e7000-0x43a40000, virt: 0x0-0x59000, size = 0x59000, type: LoaderCode (0x1), attr: 0x8
  phys: 0x43a40000-0x43ac0000, virt: 0x0-0x80000, size = 0x80000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x43ac0000-0x43ad0000, virt: 0x0-0x10000, size = 0x10000, type: ACPIReclaimMemory (0x9), attr: 0x8
  phys: 0x43ad0000-0x43ad1000, virt: 0x0-0x1000, size = 0x1000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x43ad1000-0x43ad3000, virt: 0x0-0x2000, size = 0x2000, type: LoaderData (0x2), attr: 0x8
  phys: 0x43ad3000-0x43b00000, virt: 0x0-0x2d000, size = 0x2d000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x43b00000-0x43b40000, virt: 0x0-0x40000, size = 0x40000, type: RuntimeServicesCode (0x5), attr: 0x8000000000000008
  phys: 0x43b40000-0x43cb0000, virt: 0x0-0x170000, size = 0x170000, type: RuntimeServicesData (0x6), attr: 0x8000000000000008
  phys: 0x43cb0000-0x43d00000, virt: 0x0-0x50000, size = 0x50000, type: RuntimeServicesCode (0x5), attr: 0x8000000000000008
  phys: 0x43d00000-0x44000000, virt: 0x0-0x300000, size = 0x300000, type: ReservedMemoryType (0x0), attr: 0x8
  phys: 0x44000000-0x44020000, virt: 0x0-0x20000, size = 0x20000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x44020000-0x44060000, virt: 0x0-0x40000, size = 0x40000, type: RuntimeServicesCode (0x5), attr: 0x8000000000000008
  phys: 0x44060000-0x44100000, virt: 0x0-0xa0000, size = 0xa0000, type: RuntimeServicesData (0x6), attr: 0x8000000000000008
  phys: 0x44100000-0x441f0000, virt: 0x0-0xf0000, size = 0xf0000, type: RuntimeServicesCode (0x5), attr: 0x8000000000000008
  phys: 0x441f0000-0x441f4000, virt: 0x0-0x4000, size = 0x4000, type: LoaderData (0x2), attr: 0x8
  phys: 0x441f4000-0x44b91000, virt: 0x0-0x99d000, size = 0x99d000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x44b91000-0x470e8000, virt: 0x0-0x2557000, size = 0x2557000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x470e8000-0x470ec000, virt: 0x0-0x4000, size = 0x4000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x470ec000-0x474d0000, virt: 0x0-0x3e4000, size = 0x3e4000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x474d0000-0x47560000, virt: 0x0-0x90000, size = 0x90000, type: RuntimeServicesCode (0x5), attr: 0x8000000000000008
  phys: 0x47560000-0x47570000, virt: 0x0-0x10000, size = 0x10000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x47570000-0x47690000, virt: 0x0-0x120000, size = 0x120000, type: RuntimeServicesData (0x6), attr: 0x8000000000000008
  phys: 0x47690000-0x476a8000, virt: 0x0-0x18000, size = 0x18000, type: ConventionalMemory (0x7), attr: 0x8
  phys: 0x476a8000-0x476ca000, virt: 0x0-0x22000, size = 0x22000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x476ca000-0x47710000, virt: 0x0-0x46000, size = 0x46000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x47710000-0x47ed8000, virt: 0x0-0x7c8000, size = 0x7c8000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x47ed8000-0x47ee0000, virt: 0x0-0x8000, size = 0x8000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x47ee0000-0x47fe1000, virt: 0x0-0x101000, size = 0x101000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x47fe1000-0x47ffb000, virt: 0x0-0x1a000, size = 0x1a000, type: BootServicesCode (0x3), attr: 0x8
  phys: 0x47ffb000-0x48000000, virt: 0x0-0x5000, size = 0x5000, type: BootServicesData (0x4), attr: 0x8
  phys: 0x4000000-0x8000000, virt: 0x0-0x4000000, size = 0x4000000, type: MMIO (0xb), attr: 0x8000000000000001
  phys: 0x9010000-0x9011000, virt: 0x0-0x1000, size = 0x1000, type: MMIO (0xb), attr: 0x8000000000000001
Efi loader symbols offset: 0x439e7000:
Mapping Code & Data
map 0x41374000 --> 0x41374000, len=0x2673000, flags=0x60c
Range already covered in current MMU
map 0x439e7000 --> 0x439e7000, len=0x59000, flags=0x60c
Range already covered in current MMU
map 0x43ad1000 --> 0x43ad1000, len=0x2000, flags=0x60c
Range already covered in current MMU
map 0x441f0000 --> 0x441f0000, len=0x4000, flags=0x60c
Range already covered in current MMU
Mapping EFI_MEMORY_RUNTIME
map 0x43b00000 --> 0x43b00000, len=0x40000, flags=0x60c
Range already covered in current MMU
map 0x43b40000 --> 0x43b40000, len=0x170000, flags=0x60c
Range already covered in current MMU
map 0x43cb0000 --> 0x43cb0000, len=0x50000, flags=0x60c
Range already covered in current MMU
map 0x44020000 --> 0x44020000, len=0x40000, flags=0x60c
Range already covered in current MMU
map 0x44060000 --> 0x44060000, len=0xa0000, flags=0x60c
Range already covered in current MMU
map 0x44100000 --> 0x44100000, len=0xf0000, flags=0x60c
Range already covered in current MMU
map 0x474d0000 --> 0x474d0000, len=0x90000, flags=0x60c
Range already covered in current MMU
map 0x47570000 --> 0x47570000, len=0x120000, flags=0x60c
Range already covered in current MMU
map 0x4000000 --> 0x4000000, len=0x4000000, flags=0x60c
Range already covered in current MMU
map 0x9010000 --> 0x9010000, len=0x1000, flags=0x60c
Range already covered in current MMU
Mapping "next" regions
map 0xffff000002454000 --> 0x41374000, len=0x5000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 413712a0
map 0xffff000002444000 --> 0x41379000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 41371220
map 0xffff000002440000 --> 0x41389000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 41371200
map 0xffff000002438000 --> 0x4138d000, len=0x8000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 413711c0
map 0xffff00000242b000 --> 0x41395000, len=0xd000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 41371158
map 0xffff00000241b000 --> 0x413a2000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 413710d8
map 0xffff000002409000 --> 0x413b2000, len=0x12000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372090
Level 3, Processing desc 41371000 indexing 41371048
map 0xffff0000023f9000 --> 0x413c4000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370fc8
Level 3, Processing desc 41371000 indexing 41371000
map 0xffff0000023a1000 --> 0x413d4000, len=0x58000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370d08
map 0xffff000002397000 --> 0x4142c000, len=0xa000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370cb8
map 0xffff000002391000 --> 0x41436000, len=0x6000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370c88
map 0xffff000002370000 --> 0x4143c000, len=0x21000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370b80
map 0xffff000002360000 --> 0x4145d000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370b00
map 0xffff00000233b000 --> 0x4146d000, len=0x25000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413709d8
map 0xffff000002333000 --> 0x41492000, len=0x8000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370998
map 0xffff000002323000 --> 0x4149a000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370918
map 0xffff000002309000 --> 0x414aa000, len=0x1a000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370848
map 0xffff000002303000 --> 0x414c4000, len=0x6000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370818
map 0xffff0000022fc000 --> 0x414ca000, len=0x7000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413707e0
map 0xffff0000022f7000 --> 0x414d1000, len=0x5000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413707b8
map 0xffff0000022f3000 --> 0x414d6000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370798
map 0xffff0000022ee000 --> 0x414da000, len=0x5000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370770
map 0xffff0000022ea000 --> 0x414df000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370750
map 0xffff0000022da000 --> 0x414e3000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413706d0
map 0xffff0000022d3000 --> 0x414f3000, len=0x7000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370698
map 0xffff0000022bb000 --> 0x414fa000, len=0x18000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413705d8
map 0xffff0000022ab000 --> 0x41512000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370558
map 0xffff000002295000 --> 0x41522000, len=0x16000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413704a8
map 0xffff00000227f000 --> 0x41538000, len=0x16000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413703f8
map 0xffff00000226f000 --> 0x4154e000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370378
map 0xffff000002258000 --> 0x4155e000, len=0x17000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413702c0
map 0xffff000002242000 --> 0x41575000, len=0x16000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370210
map 0xffff000002231000 --> 0x4158b000, len=0x11000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370188
map 0xffff00000222c000 --> 0x4159c000, len=0x5000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370160
map 0xffff000002229000 --> 0x415a1000, len=0x3000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370148
map 0xffff000002225000 --> 0x415a4000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370128
map 0xffff00000221f000 --> 0x415a8000, len=0x6000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413700f8
map 0xffff00000221b000 --> 0x415ae000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 413700d8
map 0xffff00000220b000 --> 0x415b2000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370058
map 0xffff000002207000 --> 0x415c2000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372088
Level 3, Processing desc 41370000 indexing 41370038
map 0xffff0000021fe000 --> 0x415c6000, len=0x9000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fff0
Level 3, Processing desc 41370000 indexing 41370000
map 0xffff0000021f2000 --> 0x415cf000, len=0xc000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136ff90
map 0xffff0000021d6000 --> 0x415db000, len=0x1bf9d, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136feb0
map 0xffff0000021c4000 --> 0x415f7000, len=0x117c0, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fe20
map 0xffff00000215b000 --> 0x41609000, len=0x69000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fad8
map 0xffff00000214d000 --> 0x41672000, len=0xe000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fa68
map 0xffff000002149000 --> 0x41680000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fa48
map 0xffff000002145000 --> 0x41684000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fa28
map 0xffff000002142000 --> 0x41688000, len=0x3000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136fa10
map 0xffff00000213f000 --> 0x4168b000, len=0x3000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f9f8
map 0xffff00000213d000 --> 0x4168e000, len=0x2000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f9e8
map 0xffff00000212d000 --> 0x41690000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f968
map 0xffff00000211e000 --> 0x416a0000, len=0xf000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f8f0
map 0xffff00000211c000 --> 0x416af000, len=0x2000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f8e0
map 0xffff00000210f000 --> 0x416b1000, len=0xd000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f878
map 0xffff00000210d000 --> 0x416be000, len=0x2000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f868
map 0xffff00000210b000 --> 0x43ad1000, len=0x2000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f858
map 0xffff0000020fb000 --> 0x416c0000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f7d8
map 0xffff0000020ca000 --> 0x416d0000, len=0x31000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f650
map 0xffff0000020c6000 --> 0x441f0000, len=0x4000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f630
map 0xffff0000020bb000 --> 0x41701000, len=0xb000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f5d8
map 0xffff0000020af000 --> 0x4170c000, len=0xc000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f578
map 0xffff00000209c000 --> 0x41718000, len=0x120c0, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f4e0
map 0xffff000002081000 --> 0x4172b000, len=0x1a280, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f408
map 0xffff000002043000 --> 0x41746000, len=0x3dda8, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f218
map 0xffff000002010000 --> 0x41784000, len=0x32628, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f080
map 0x80000000 --> 0x417b7000, len=0x220000, flags=0x60c
Level 0, Processing desc 47fff000 indexing 47fff000
Level 1, Processing desc 47ffe000 indexing 47ffe010
Level 2, Processing desc 4136e000 indexing 4136e000
Level 3, Processing desc 4136d000 indexing 4136d000
Level 3, Processing desc 4136c000 indexing 4136c000
map 0xffff000002000000 --> 0x419d7000, len=0x10000, flags=0x60c
Level 0, Processing desc 43ad0000 indexing 43ad0000
Level 1, Processing desc 41373000 indexing 41373000
Level 2, Processing desc 41372000 indexing 41372080
Level 3, Processing desc 4136f000 indexing 4136f000
map 0x9000000 --> 0x9000000, len=0x1000, flags=0x60000000000400
Range already covered in current MMU
gKernelArgs.arch_args.phys_pgdir     = 0x43ad0000
gKernelArgs.arch_args.vir_pgdir      = 0x00000030
gKernelArgs.arch_args.next_pagetable = 0xbc530000
Calling ExitBootServices. So long, EFI!
Switched to our own serial!
phys memory ranges:
    0x40000000-0x41374000, length 0x01374000
    0x43a40000-0x43ac0000, length 0x00080000
    0x43ad0000-0x43ad1000, length 0x00001000
    0x43ad3000-0x43b00000, length 0x0002d000
    0x44000000-0x44020000, length 0x00020000
    0x441f4000-0x474d0000, length 0x032dc000
    0x47560000-0x47570000, length 0x00010000
    0x47690000-0x48000000, length 0x00970000
allocated phys memory ranges:
    0x4136c000-0x439e7000, length 0x0267b000
    0x43ad0000-0x43ad3000, length 0x00003000
    0x441f0000-0x441f4000, length 0x00004000
allocated virt memory ranges:
    0x80000000-0x80220000, length 0x00220000
    0x02000000-0x02459000, length 0x00459000
Stack not accessible!

Not sure if something broke on qemu virt or some changes are not upstreamed yet?

3 Likes

This is temporary. config_manager isnā€™t used on any building platform, so we should not need this one. Cleanup needed.

My raw setup looks like this:
Note: on Debian use QEMU from backports to not have a ancient one.

qemu-system-aarch64 -m 256M -cpu cortex-a57 -M virt -bios QEMU_EFI.fd \
	-device virtio-gpu-pci -device qemu-xhci \
	-usb -device usb-kbd -device usb-tablet \
	-display gtk,grab-on-hover=on,zoom-to-fit=off \
	-net none -no-reboot -serial stdio \
	-drive file=fat:rw:disk,format=raw \
	-drive file=haiku-bootstrap.image #,media=cdrom
#	-nic user,model=virtio-net-pci 
#	-serial file:debug.log
#-monitor stdio \

# For info on exceptions
#	-d int \

I see I have changed the linker scripts but not commited.
When I left off, the MMU to enter kernel wasnā€™t working, so probably wanted to test first.Loading the kernel worked on my machine at least. Iā€™ll take a look if I should commit something unless @oruizdorantes already has some WIP. I think MMU code is not in tree yet either? (For arm64 code we can commit WIP and refine code as we go, so donā€™t be afraid to submit improvements even before they are fully done.)

I think those parts are not in tree yet and I left just before this so sync with @oruizdorantes if you want to collaborate, or perhaps just submit smaller pull request and we can coordinate there.

No it is just a work in progress. If you are interested in helping out there are lots of things to doā€¦

2 Likes

Definitively there is work pending to be pushed. I am currently cleaning up 3 commits, addressing some of the spotted points:

  1. Kernel Linker: Together with @davidkaroly identified the problem. I ended up locally as you, replacing with the the RiscV linker (but judging your MMU mapping output I think you missed changing as well the base address to the virtual base). Additionally there was previous work from @tqh on that file and that replacement would end up replacing his workā€¦ (continue down)
  2. Addressing the QEMU machine: Contrary to the usual, we could say the NxP S32G port is more advanced than QEMU port. Based on some tests by @davidkaroly, my impression is that QEMU machine is executing the EFI loader in EL1, (contrary to uboot in EL2). There is code to confirm this hypothesis, dump key registers and initial steps to address this context. (As reminder: the current code that reaches and prints from the kernel is only known to work in a uboot/efi scenario which delegates us in EL2ā€¦ in the mentioned NxP device)
  3. DTB & UART code exposed in my previous post here.

I will rush this week to have the PR in gerrit for 2 & 3.

We should have (1) and (2) in place before. Particularly in your output, this:

map 0x80000000 --> 0x417b7000, len=0x220000, flags=0x60c

is not expected, This would be the kernel mapping, and the virtual @ should be 0xffffffff80000000

Kernel loading stopped working after the GCC changes, but (1) fixes it. Changes in (1) are isolated to (2) and (3) there should be no conflicts, apart form the header( OUTPUT_FORMAT, OUTPUT_ARCH), this is my diff from the riscv5 linker:

<   . = 0x80000000 + SIZEOF_HEADERS;
---
>   . = 0xFFFFFFFF80000000 + SIZEOF_HEADERS;

This is good information, qemu can deal with ARMv8.2.
I need to compile locally with ARMv8 because I test on real A53.

Hmmm A57 should fail too as atomics from ARMv8.2 are required

Yes, the MMU code is in the tree (all these Level 0,1,2,3 prints in the output would be involved), but I am afraid the code as it is, will not handle the situation that already is in EL1, therefore the need of (2).

In summary, wait me for (2) and (3), I can go ahead for (1) as well but needs review, and then we will be all in sync.

In any case @milek7 welcome! The fact you have sorted out many of the problems is very promising!

4 Likes

I wonder where the atomics part is needed. For zstd I think it was 32 (or16?) bit floating point that was the culprit. So maybe we have been talking about apples and oranges?

Iā€™ll take a look and see if there is anything weird with the build flagsā€¦
Looks like everything is shaping up otherwise, so no need for me to commit anything I had.

Everywhere atomic instristics are used, eg. without -cpu max it blows up at ldaddal in src/system/boot/loader/partitions.cpp:118.

Ah, that explains the difference. Specs say that:

On AArch64 UEFI shall execute as 64-bit code at either EL1 or EL2, depending on whether or not virtualization is available at OS load time.

So it is possible to make qemu start loader in EL2 by enabling virtualization support in emulated machine: -M virt,virtualization=on. Now it gets into the kernel :slight_smile:

Switched to our own serial!
phys memory ranges:
    0x40000000-0x41373000, length 0x01373000
    0x43a40000-0x43ac0000, length 0x00080000
    0x43ad0000-0x43ad1000, length 0x00001000
    0x43ad3000-0x43b00000, length 0x0002d000
    0x44000000-0x44020000, length 0x00020000
    0x441f4000-0x474d0000, length 0x032dc000
    0x47560000-0x47570000, length 0x00010000
    0x47690000-0x48000000, length 0x00970000
allocated phys memory ranges:
allocated virt memory ranges:
    0xffff000002000000-0xffff000002459000, length 0x00459000
    0xffffffff80000000-0xffffffff80221000, length 0x00221000
Entering kernel!
Welcome to kernel debugger output!
Haiku revision: hrev55948+dirty, debug level: 2
INIT: init CPU
INIT: init interrupts
INIT: init VM
PANIC: error allocating early page!

Welcome to Kernel Debugging Land...
Running on CPU 0
Current thread pointer is 0xffffffff801f51c0, which is an address we can't read from.

2 Likes

What OS do you use to build the image with?
Haiku, Mac OS or Linux? Iā€™m thinking it might be a Mac OS or Haiku issue since they can use their own compilers and not the cross-compiler like I do.

Or maybe this is a gcc11 thing as I stayed on gcc8?

1 Like

Yes, it might be that old gcc donā€™t emit these instructions.

Current gcc config and old one looks similar, the only change was unrelated IIRC:

and old:

There might still be changes in common aarch64 config though. Will check the haiku tree next.

Ooh nice. Another question then is what UEFI firmware you are using? I use EDK2 based one that is in Debian repo. Perhaps the firmware is compiled with more optimisations in your case?

The reasoning was analyzed in this PR

My first initial work did not reproduce the problem, those instructions were not generated. During that period two things happened:

  1. gcc8->gcc11 transition.
  2. archFlags for arm64 went from undefined to ā€œarchFlags += -march=armv8.2-a+fp16;ā€ I guess that happened here

I cannot tell the order but the LDADDAL instructions would end up in the build as soon as the second point happens. So the ā€œAtomicsā€ problem has no explicit relation with zstd, is a side effect of introducing armv8.2

After knowing QEMU can deal with ARMv8.2, The problem only affects people(me) who test in <ARMv8.2 CPUs who can compile with:

archFlags += -march=armv8-a -mno-outline-atomics

So in theory I should at some point hit the same problem @tqh faced(thanks for the detailed description btw) then I would be able to propose something.

No, the conflicting code is in our side, the stack call looked like:

    boot::Partition::Partition
    add_partitions_for
    add_partitions_for
    get_boot_file_system
    main
    efi_main
3 Likes

Yes, that was the reason.

Due to the gcc bug I had to do something. As I did not want to focus on fixing gcc I picked armv8.2a as it adds half-precision floating point data processing: Arm architecture Armv8.2-a evolution and delivery

But clean builds I did after that still loaded the kernel in QEMU, so not sure if QEMU was being nice or something.

2 Likes

That is very interesting! Despite the output you get is different than mine you got to the same point. Happy to see the code works :slight_smile:

Some questions though:

  • Have you applied the ā€œ0xFFFFFFFF80000000ā€ suggestion in the linker?
  • Have you enabled as well in the Kernel side? You must have relevant changes in: system/kernel/arch/arm64/arch_debug_console.cpp is it?
3 Likes

Yes, I missed that previously.

Yup, otherwise I wouldnā€™t have any kernel output.

Though to proceed further I would need to learn more about Haiku and ARMv8 virtual memory, and Iā€™m not sure I want to jump into that rabbit hole at this momentā€¦

2 Likes

About that EL1/2, itā€™s just that TCR wasnā€™t configured when booting from EL1, I moved arch_mmu_setup_EL1() to be called in both cases and modified it like that:

	// Possibly inherit TCR from EL2
	uint64 tcr;
	if (arch_exception_level() == 2)
		tcr = READ_SPECIALREG(TCR_EL2);
	else
		tcr = READ_SPECIALREG(TCR_EL1);

Now it works both when booted from EL1 and EL2. (though we probably should write full TCR config there instead of relying on whatever EFI left?)

I hooked up that early page alloc and got a little bit further in boot

gKernelArgs.arch_args.phys_pgdir     = 0x41295000
gKernelArgs.arch_args.vir_pgdir      = 0x00000030
gKernelArgs.arch_args.next_pagetable = 0xbed6b000
Current Exception Level EL1
MMU Enabled, Translation Table @ 47fff000 Granularity 4KB, bits 48
Calling ExitBootServices. So long, EFI!
Boot services terminated.
Configuring TCR_EL1: 580103510
Already at EL1.
phys memory ranges:
    0x40000000-0x41296000, length 0x01296000
    0x43a68000-0x43b00000, length 0x00098000
    0x44000000-0x44020000, length 0x00020000
    0x441f4000-0x474d0000, length 0x032dc000
    0x47560000-0x47570000, length 0x00010000
    0x47690000-0x48000000, length 0x00970000
allocated phys memory ranges:
    0x4128c000-0x43a0f000, length 0x02783000
    0x441f0000-0x441f4000, length 0x00004000
allocated virt memory ranges:
    0xffff000002000000-0xffff00000255b000, length 0x0055b000
    0xffffffff80000000-0xffffffff80222000, length 0x00222000
Entering kernel!
Welcome to kernel debugger output!
Haiku revision: hrev55948+dirty, debug level: 2
INIT: init CPU
INIT: init interrupts
INIT: init VM
vm_init: entry
mark_page_range_in_use(0x0, 0x40000): start page is before free list
reserve_boot_loader_ranges()
reserve_boot_loader_ranges(): Skipping range: 0xffffffff80000000, 2236416
create_anonymous_area [1] page structures: size 0x280000
create_anonymous_area [1] slab area: size 0x800000
PANIC: out of memory
Welcome to Kernel Debugging Land...
Running on CPU 0
Current thread pointer is 0xffffffff801f61c0, which is an address we can't read from.

If nobody else is currently working on hooking up the rest of VM code I might try to do that.

9 Likes

It is confusing that simple change actually worked, that meant you already have as well a MMU configurationā€¦ and also implies that it is being changed on the fly :face_with_open_eyes_and_hand_over_mouth:

Changing an active EL1 MMU while in EL1 vs Changing an inactive EL1 MMU configuration while in EL2.

No next step defined from my side, my focus now is to make current changes to the tree.

I would like to have a look on your current changes as wellā€¦ maybe we could merge your PL011 work with the pending LINFlex to agilizeā€¦

If getting inside the kernel please let me remark the following reference:

3 Likes

I donā€™t have any changes in pl011, just reused things from arch/arm.

I did play around a bit with vm mapping. I will push the code somewhere after I clean it up somewhat.

Calling ExitBootServices. So long, EFI!
Boot services terminated.
Configuring TCR_EL1: 580103510
Already at EL1.
phys memory ranges:
    0x40000000-0x41291000, length 0x01291000
    0x43a68000-0x43b00000, length 0x00098000
    0x44000000-0x44020000, length 0x00020000
    0x441f4000-0x474d0000, length 0x032dc000
    0x47560000-0x47570000, length 0x00010000
    0x47690000-0x48000000, length 0x00970000
allocated phys memory ranges:
    0x41286000-0x43a0f000, length 0x02789000
    0x441f0000-0x441f4000, length 0x00004000
allocated virt memory ranges:
    0xffff000002000000-0xffff00000255d000, length 0x0055d000
    0xffffff0000000000-0xffffff8000000000, length 0x8000000000
    0xffffffff80000000-0xffffffff80225000, length 0x00225000
Entering kernel!
Welcome to kernel debugger output!
Haiku revision: hrev55948+1+dirty, debug level: 2
INIT: init CPU
INIT: init interrupts
INIT: init VM
arch_vm_translation_map_init
vm config: MMFR1: 10211120, TCR: 580103510
TTBR0: 47fff000, TTBR1: 41290000
T0SZ: 16, T1SZ: 16, TG0: 0, TG1: 2, MAIR: ffbb4400
arch_vm_init
pulling page ffffff00441f5000
pulling page ffffff00443f6000
pulling page ffffff00445f7000
pulling page ffffff00447f8000
pulling page ffffff00449f9000
pulling page ffffff0044bfa000
mark_page_range_in_use(0x0, 0x40000): start page is before free list
VMSAv8TranslationMap
reserve_boot_loader_ranges(): Skipping range: 0xffffff0000000000, 549755813888
reserve_boot_loader_ranges(): Skipping range: 0xffffffff80000000, 2248704
arch_vm_translation_map_init_post_area
arch_vm_init_post_area
arch_vm_set_memory_type
INIT: init driver_settings
INIT: init notification services
INIT: init teams
INIT: init ELF loader
INIT: init modules
INIT: init semaphores
INIT: init interrupts post vm
INIT: init system info
INIT: init SMP
INIT: init timer
INIT: init real time clock
allocate_commpage_entry(2, 24) -> 0x0000000000000200
INIT: init condition variables
INIT: init VM semaphores
arch_vm_init_end
arch_vm_translation_map_init_post_sem
INIT: init generic syscall
INIT: init scheduler
scheduler_init: found 1 logical cpu and 0 cache levels
scheduler switches: single core: true, cpu load tracking: false, core load tracking: false
scheduler: switching to low latency mode
INIT: init threads
INIT: init kernel daemons
INIT: init stack protector
INIT: init I/O interrupts
INIT: init VM threads
INIT: init DPC
INIT: init VFS
INIT: init swap support
INIT: init POSIX semaphores
INIT: spawning main2 thread
INIT: waking up AP cpus
INIT: exiting kernel startup
INIT: starting scheduler on cpu 0 and enabling interrupts
12 Likes