mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:18:37 +00:00
x64_recomp: find qemu through QEMU_AARCH64 or PATH, not a contributor's home folder
This commit is contained in:
@ -32,7 +32,7 @@ of the x86-64 → arm64 groundwork.
|
||||
| Dispatch runtime | `tools/x64_recomp.py` `emit_rt` | `rt_dispatch` (guest pc → host pc through a generated table), `rt_mkflags` (NZCV+operands → canonical x86 EFLAGS; preserves NZCV), `rt_print` (semihosting result output) |
|
||||
| Verification | `tools/x64_recomp.py` `build_test_kernel`/`run_kernel` | flat kernel image → `qemu-system-aarch64 -M virt -cpu cortex-a53 -kernel -semihosting`; guest `ret` off the sentinel stack exits and prints `R=xxxxxxxx` (guest edi) |
|
||||
| PE census | `tools/recomp_census.py` | walks every `.pdata` function, decodes + translates it, reports coverage %, hazard mnemonics, indirect control flow, unwind-info flags |
|
||||
| Tests | `tests/test_x64_recomp.py`, `tests/test_recomp_census.py` | hand-built byte fixtures only; exec tests skip when qemu is absent |
|
||||
| Tests | `tests/test_x64_recomp.py`, `tests/test_recomp_census.py` | hand-built byte fixtures only; exec tests skip when qemu is absent (`QEMU_AARCH64` names the binary, else `qemu-system-aarch64` on `PATH`) |
|
||||
|
||||
### Translator contract (as implemented)
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ The qemu tests skip cleanly when qemu-system-aarch64 is not installed.
|
||||
python -I tests/test_x64_recomp.py
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
@ -27,12 +26,8 @@ if TOOLS_DIR not in sys.path:
|
||||
|
||||
import x64_recomp as x # noqa: E402
|
||||
|
||||
QEMU = os.environ.get(
|
||||
"QEMU_AARCH64",
|
||||
"/home/nolan/.nix-profile/bin/qemu-system-aarch64"
|
||||
if os.path.exists("/home/nolan/.nix-profile/bin/qemu-system-aarch64")
|
||||
else shutil.which("qemu-system-aarch64") or "")
|
||||
HAS_QEMU = bool(QEMU) and os.path.exists(QEMU)
|
||||
# The binary x64_recomp.run_kernel will start: QEMU_AARCH64, else qemu-system-aarch64 on PATH.
|
||||
HAS_QEMU = os.path.isfile(x.QEMU_BIN)
|
||||
|
||||
GUEST_VA = 0x46000000
|
||||
SCRATCH = 0x47100000 # inside the kernel image's RW RAM window, away from ctx/stack
|
||||
|
||||
@ -32,6 +32,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import struct
|
||||
import sys
|
||||
|
||||
@ -2557,11 +2558,9 @@ def build_test_kernel(code, guest_va, rw_base=KERNEL_RW, rx_base=KERNEL_BASE):
|
||||
return stub_bytes(entry_va) + img, tr
|
||||
|
||||
|
||||
QEMU_BIN = os.environ.get(
|
||||
"QEMU_AARCH64",
|
||||
"/home/nolan/.nix-profile/bin/qemu-system-aarch64"
|
||||
if os.path.exists("/home/nolan/.nix-profile/bin/qemu-system-aarch64")
|
||||
else "qemu-system-aarch64")
|
||||
# QEMU_AARCH64 names a binary that is not on PATH; otherwise the one on PATH, else the bare name for a clear error.
|
||||
QEMU_BIN = (os.environ.get("QEMU_AARCH64") or shutil.which("qemu-system-aarch64")
|
||||
or "qemu-system-aarch64")
|
||||
|
||||
|
||||
def run_kernel(code, guest_va=0x46000000, timeout=15):
|
||||
|
||||
Reference in New Issue
Block a user