| 440 | |
| 441 | |
| 442 | class ARM64QEMURunner(ARMEFIQEMURunner): |
| 443 | def __init__(self) -> None: |
| 444 | super().__init__() |
| 445 | |
| 446 | self.cmdline += ['console=ttyAMA0', 'earlycon'] |
| 447 | self.supports_efi = True |
| 448 | self.use_kvm = platform.machine() == 'aarch64' and self._have_dev_kvm_access() |
| 449 | |
| 450 | self._default_kernel_path = Path('arch/arm64/boot/Image.gz') |
| 451 | self._initrd_arch = 'arm64' |
| 452 | self._qemu_arch = 'aarch64' |
| 453 | |
| 454 | def _get_cpu_val(self) -> list[str]: |
| 455 | cpu = ['max'] |
| 456 | |
| 457 | self._set_qemu_path() |
| 458 | # See the two gitlab links below for more details |
| 459 | if (qemu_ver := self._get_qemu_ver_tuple()) >= (6, 2, 50): |
| 460 | self._set_kernel_vars() |
| 461 | kernel_ver = self._get_kernel_ver_tuple('gzip') |
| 462 | |
| 463 | # https://gitlab.com/qemu-project/qemu/-/issues/964 |
| 464 | if kernel_ver < (4, 16, 0): |
| 465 | cpu = ['cortex-a72'] |
| 466 | # https://gitlab.com/qemu-project/qemu/-/commit/69b2265d5fe8e0f401d75e175e0a243a7d505e53 |
| 467 | elif kernel_ver < (5, 12, 0): |
| 468 | cpu.append('lpa2=off') |
| 469 | |
| 470 | # https://lore.kernel.org/YlgVa+AP0g4IYvzN@lakrids/ |
| 471 | if 'max' in cpu and qemu_ver >= (6, 0, 0): |
| 472 | cpu.append('pauth-impdef=true') |
| 473 | |
| 474 | return cpu |
| 475 | |
| 476 | def run(self) -> None: |
| 477 | machine = ['virt', 'gic-version=max'] |
| 478 | |
| 479 | if not self.use_kvm: |
| 480 | cpu_val = self._get_cpu_val() |
| 481 | self._qemu_args += ['-cpu', ','.join(cpu_val)] |
| 482 | |
| 483 | # Boot with VHE emulation, which allows the kernel to run at EL2. |
| 484 | # KVM does not emulate VHE, so this cannot be unconditional. |
| 485 | machine.append('virtualization=true') |
| 486 | |
| 487 | self._qemu_args += ['-machine', ','.join(machine)] |
| 488 | |
| 489 | if self.efi: |
| 490 | aavmf_locations = [ |
| 491 | Path('edk2/aarch64/QEMU_EFI.silent.fd'), # Fedora |
| 492 | Path('edk2/aarch64/QEMU_EFI.fd'), # Arch Linux (current) |
| 493 | Path('edk2-armvirt/aarch64/QEMU_EFI.fd'), # Arch Linux (old) |
| 494 | Path('qemu-efi-aarch64/QEMU_EFI.fd'), # Debian and Ubuntu |
| 495 | ] |
| 496 | self._setup_efi(aavmf_locations) |
| 497 | |
| 498 | super().run() |
| 499 |
nothing calls this directly
no outgoing calls
no test coverage detected