All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zijun Hu <zijun.hu@oss.qualcomm.com>
To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Zijun Hu <zijun_hu@icloud.com>
Subject: [PATCH bluez 2/3] tools/test-runner: Support running on arm64 hosts
Date: Sun, 22 Nov 2026 02:34:21 -0800	[thread overview]
Message-ID: <20261122-tr_arm64-v1-2-4eccf35daeca@oss.qualcomm.com> (raw)
In-Reply-To: <20261122-tr_arm64-v1-0-4eccf35daeca@oss.qualcomm.com>

Add arm64 support by:
- Using qemu-system-aarch64 with the virt machine and the arm64 Image
- Passing -cpu max or host, as the default virt CPU is 32-bit
- Using earlycon and leaving out the x86-only options
- Warning when /dev/kvm is not accessible, as QEMU then falls back
  to TCG

Assisted-by: Claude:claude-opus-5-5
---
 doc/test-runner.rst |  5 ++++-
 tools/test-runner.c | 49 ++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/doc/test-runner.rst b/doc/test-runner.rst
index b5876e4f5108..4ff9d1b02c1b 100644
--- a/doc/test-runner.rst
+++ b/doc/test-runner.rst
@@ -21,17 +21,20 @@ OPTIONS
 :-m/--monitor: Start btmon
 :-l/--emulator[=num]: Start btvirt
 :-A/-audio[=path]: Start audio server
 :-u/--unix[=path]: Provide serial device
 :-U/--usb=<qemu_args>: Provide USB device
 :-P/--pcie=<qemu_args>: Provide PCIe device
 :-q/--qemu=<path>: QEMU binary
 :-H/--qemu-host-cpu: Use host CPU (requires KVM support)
-:-k/--kernel=<image>: Kernel image (bzImage) or User Mode Linux binary
+:-k/--kernel=<image>: Kernel image or source tree path:
+
+    | x86: bzImage or User Mode Linux binary
+    | arm64: Image
 :-F/--virtiofs[=<path>]: Path to virtiofsd, or no to disable virtio-fs
 :-T/--time-travel: Run a User Mode Linux kernel on simulated time, with
     btvirt as time travel calendar (default if the kernel supports it)
 :-R/--real-time: Run a User Mode Linux kernel on real time
 :-o/--option=<opt>: Additional argument passed to QEMU, or kernel
     parameter with User Mode Linux
 :-h/--help: Show help options
 
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 0bca31a46351..a2105977c1ee 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -128,20 +128,25 @@ static void strv_cleanup(struct strv *s)
 
 	for (i = 0; i < s->i; ++i)
 		free(s->strv[i]);
 
 	memset(s, 0, sizeof(*s));
 }
 
 static const char *qemu_table[] = {
+#if defined(__aarch64__)
+	"qemu-system-aarch64",
+	"/usr/bin/qemu-system-aarch64",
+#else
 	"qemu-system-x86_64",
 	"qemu-system-i386",
 	"/usr/bin/qemu-system-x86_64",
 	"/usr/bin/qemu-system-i386",
+#endif
 	NULL
 };
 
 static const char *find_qemu(void)
 {
 	int i;
 
 	for (i = 0; qemu_table[i]; i++) {
@@ -150,21 +155,26 @@ static const char *find_qemu(void)
 		if (!stat(qemu_table[i], &st))
 			return qemu_table[i];
 	}
 
 	return NULL;
 }
 
 static const char *kernel_table[] = {
+#if defined(__aarch64__)
+	"Image",
+	"arch/arm64/boot/Image",
+#else
 	"bzImage",
 	"arch/x86/boot/bzImage",
 	"vmlinux",
 	"arch/x86/boot/vmlinux",
 	"linux",
+#endif
 	NULL
 };
 
 /* A User Mode Linux kernel is an executable with the .uml.setup.init
  * section, through which it registers its command line options.
  */
 static bool is_uml_kernel(const char *path)
 {
@@ -420,16 +430,19 @@ static char *const qemu_envp[] = {
 
 static void check_virtualization(void)
 {
 #ifdef HAVE_GET_CPUID
 	unsigned int eax, ebx, ecx, edx;
 
 	if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & (1 << 5)))
 		printf("Found support for Virtual Machine eXtensions\n");
+#elif defined(__aarch64__)
+	if (access("/dev/kvm", R_OK | W_OK) < 0)
+		fprintf(stderr, "No access to /dev/kvm, falling back to TCG\n");
 #endif
 }
 
 #define PCI_DEVICES_PATH "/sys/bus/pci/devices"
 
 static char pcie_bdf[16];
 static char pcie_driver[64];
 
@@ -894,16 +907,18 @@ static void qemu_signal(int sig)
 	if (qemu_pid > 0)
 		kill(qemu_pid, sig);
 }
 
 static int start_qemu(void)
 {
 	char cwd[PATH_MAX/2], initcmd[PATH_MAX], testargs[PATH_MAX];
 	const char *fscmdline;
+	const char *earlycon;
+	const char *noacpi;
 	char cmdline[CMDLINE_MAX];
 	char *argv_strv[EXTRA_OPT_MAX + 64];
 	struct strv _cleanup_(strv_cleanup) argv = { argv_strv,
 							ARRAY_SIZE(argv_strv) };
 	struct rootfs _cleanup_(rootfs_cleanup) rootfs = {{0}};
 	int i, pos, status = 0;
 	pid_t pid;
 
@@ -933,54 +948,71 @@ static int start_qemu(void)
 	}
 
 	if (!virtiofsd)
 		fscmdline = "rootfstype=9p "
 				"rootflags=trans=virtio,version=9p2000.u";
 	else
 		fscmdline = "rootfstype=virtiofs root=/dev/root";
 
+#if defined(__aarch64__)
+	earlycon = "earlycon";
+	noacpi = "";
+#else
+	earlycon = "earlyprintk=serial";
+	/* PCIe passthrough requires ACPI and APIC for device enumeration
+	 * and MSI interrupts.
+	 */
+	noacpi = pcie_dev ? "" : "acpi=off pci=noacpi noapic";
+#endif
+
 	snprintf(cmdline, sizeof(cmdline),
-				"console=hvc0 earlyprintk=serial "
+				"console=hvc0 %s "
 				"no_hash_pointers=1 %s %s quiet ro init=%s "
 				"TESTHOME=%s TESTDBUS=%u TESTDAEMON=%u "
 				"TESTDBUSSESSION=%u XDG_RUNTIME_DIR=/run/user/0 "
 				"TESTMONITOR=%u TESTEMULATOR=%u TESTDEVS=%d "
 				"TESTAUTO=%u TESTAUDIO='%s' TESTARGS=\'%s\'",
+				earlycon,
 				fscmdline,
-				/* PCIe passthrough requires ACPI and APIC for
-				 * device enumeration and MSI interrupts.
-				 */
-				pcie_dev ? "" : "acpi=off pci=noacpi noapic",
+				noacpi,
 				initcmd, cwd, start_dbus, start_daemon,
 				start_dbus_session,
 				start_monitor, num_emulator, num_devs,
 				run_auto, audio_server ? audio_server : "",
 				testargs);
 
 	/* Make sure qemu_binary is not null */
 	if (!qemu_binary) {
 		fprintf(stderr, "No QEMU binary is set\n");
 		return EXIT_FAILURE;
 	}
 
 	strv_append(&argv, "%s", qemu_binary);
 	strv_concat(&argv, qemu_argv);
 
+#if defined(__aarch64__)
+	strv_append(&argv, "-machine");
+	strv_append(&argv, "virt,gic-version=max,accel=kvm:tcg");
+
+	strv_append(&argv, "-cpu");
+	strv_append(&argv, qemu_host_cpu ? "host" : "max");
+#else
 	/* Interrupt remapping is required to pass through a device using
 	 * MSI-X, which in turn needs the split irqchip.
 	 */
 	strv_append(&argv, "-machine");
 	strv_append(&argv, "type=q35,accel=kvm:tcg%s",
 			pcie_dev ? ",kernel-irqchip=split" : "");
 
 	if (qemu_host_cpu) {
 		strv_append(&argv, "-cpu");
 		strv_append(&argv, "host");
 	}
+#endif
 
 	strv_append(&argv, "-kernel");
 	strv_append(&argv, "%s", kernel_image);
 	strv_append(&argv, "-append");
 	strv_append(&argv, "%s", cmdline);
 
 	coverage_setup(&argv, cwd);
 
@@ -994,18 +1026,20 @@ static int start_qemu(void)
 	if (usb_dev) {
 		strv_append(&argv, "-device");
 		strv_append(&argv, "qemu-xhci");
 		strv_append(&argv, "-device");
 		strv_append(&argv, "%s", usb_dev);
 	}
 
 	if (pcie_dev) {
+#if !defined(__aarch64__)
 		strv_append(&argv, "-device");
 		strv_append(&argv, "intel-iommu,intremap=on");
+#endif
 		strv_append(&argv, "-device");
 		strv_append(&argv, "%s", pcie_dev);
 	}
 
 	if (!rootfs_setup(&rootfs, &argv))
 		return EXIT_FAILURE;
 
 	for (i = 0; i < num_extra_opts; ++i)
@@ -2193,18 +2227,19 @@ static void usage(void)
 		"\t-m, --monitor          Start btmon\n"
 		"\t-l, --emulator[=num]   Start btvirt\n"
 		"\t-A, --audio[=path]     Start audio server\n"
 		"\t-u, --unix[=path]      Provide serial device\n"
 		"\t-U, --usb <qemu_args>  Provide USB device\n"
 		"\t-P, --pcie <qemu_args> Provide PCIe device\n"
 		"\t-q, --qemu <path>      QEMU binary\n"
 		"\t-H, --qemu-host-cpu    Use host CPU (requires KVM support)\n"
-		"\t-k, --kernel <image>   Kernel bzImage, User Mode Linux\n"
-		"\t                       binary or source tree path\n"
+		"\t-k, --kernel <image>   Kernel image or source tree path,\n"
+		"\t                       x86: bzImage or User Mode Linux\n"
+		"\t                       arm64: Image\n"
 		"\t-F, --virtiofs[=<path>]  Virtiofsd path or 'no'\n"
 		"\t-T, --time-travel      Run User Mode Linux on simulated\n"
 		"\t                       time, with btvirt as calendar\n"
 		"\t                       (default if supported)\n"
 		"\t-R, --real-time        Run User Mode Linux on real time\n"
 		"\t-o, --option <opt>     Additional argument passed to QEMU,\n"
 		"\t                       or kernel parameter with User\n"
 		"\t                       Mode Linux\n"

-- 
2.34.1


  parent reply	other threads:[~2026-11-22 10:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 10:34 [PATCH bluez 0/3] tools/test-runner: Add arm64 host support Zijun Hu
2026-11-22 10:34 ` [PATCH bluez 1/3] doc/test-runner: s/CONFIG_BT_HCIBTINTEL_PCIE/CONFIG_BT_INTEL_PCIE/ Zijun Hu
2026-11-22 18:56   ` tools/test-runner: Add arm64 host support bluez.test.bot
2026-11-25  8:59   ` [PATCH bluez 1/3] doc/test-runner: s/CONFIG_BT_HCIBTINTEL_PCIE/CONFIG_BT_INTEL_PCIE/ Bastien Nocera
2026-11-25 10:43     ` Zijun Hu
2026-11-25 11:06       ` Bastien Nocera
2026-11-22 10:34 ` Zijun Hu [this message]
2026-11-22 16:24   ` [PATCH bluez 2/3] tools/test-runner: Support running on arm64 hosts Pauli Virtanen
2026-11-23  1:04     ` Zijun Hu
2026-11-23 14:45       ` Luiz Augusto von Dentz
2026-11-24  2:57         ` Zijun Hu
2026-11-24 15:20           ` Luiz Augusto von Dentz
2026-11-25  7:11             ` Zijun Hu
2026-11-25  9:04   ` Bastien Nocera
2026-11-25 10:46     ` Zijun Hu
2026-11-25 11:07       ` Bastien Nocera
2026-11-22 10:34 ` [PATCH bluez 3/3] tools/test-runner: Allow suppressing noisy bluetoothd debug output Zijun Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261122-tr_arm64-v1-2-4eccf35daeca@oss.qualcomm.com \
    --to=zijun.hu@oss.qualcomm.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=zijun_hu@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.