From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC97339C01E for ; Mon, 25 May 2026 06:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779690524; cv=none; b=bZwQ5UUTEkKWcJ/jHMez7k+7zRzmVgbLphoCB1om1SWJTyTgL2XtHZDiVb8jy+ozYYeEfQAcillHCxJzCd1x6ib3v38qryCawuMtbAyafbk/ylnWyCanOPZIGtqaFrYiPa6Za2s2BiWasUDUAInFU41Cvht6i80w/aVyWfrkDNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779690524; c=relaxed/simple; bh=z+FdkDPJqQMFpQ9S+75bwiqjIcMs1tm3tReEC2FAIug=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iccxEck9bBfSOiGY/V7ls6SjFWK9PX4HNLzlCcJUAS4mIK8yr7u88uOSlw5zNJrASdbsERP0gv7zaKxZ9hHBSuiLjj7AHsZE/GpsdOk1Zzjq6rU5T+fgRjSZfZf4r5HLQzfjVN4gH9MoKFnUIIj/GiY3XdNUw0evjTc+FTbhTdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tapMzdVl; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tapMzdVl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779690520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tYxwosLkp+8p8G15z4kXkSPo4todC1a7rfK+baWf0Ng=; b=tapMzdVlPtDDpbGp9ExBzdrIWJd5Y2uo8fnGLvCqnWZtlCYloM8DKKodK5W+vk8n8kh2zT bfsvelwOgxjow3PTKnfGN1YfC+4DEJwagn4PVMZlpiRhbPSa+9NbkpAWv3FaTpceQHBKZy McUhOyUC4DTF/o7X/PEECcln0mOrJ/Y= From: George Guo To: chenhuacai@kernel.org, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org Cc: kernel@xen0n.name, graf@amazon.com, shuah@kernel.org, loongarch@lists.linux.dev, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, George Guo Subject: [PATCH 7/7] selftests/kho: handle QEMU not exiting after kexec on LoongArch Date: Mon, 25 May 2026 14:28:10 +0800 Message-Id: <20260525062810.103367-8-dongtai.guo@linux.dev> In-Reply-To: <20260525062810.103367-1-dongtai.guo@linux.dev> References: <20260525062810.103367-1-dongtai.guo@linux.dev> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: George Guo On LoongArch, QEMU provides only a minimal EFI stub with no runtime services and no ACPI tables, so machine_restart() falls through to its infinite idle loop and QEMU never exits after kexec. Poll the serial output for the test verdict and kill QEMU once it appears, rather than waiting for QEMU to exit naturally. Signed-off-by: George Guo --- tools/testing/selftests/kho/vmtest.sh | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kho/vmtest.sh b/tools/testing/selftests/kho/vmtest.sh index a6ae9ac09595..3cb9674e4475 100755 --- a/tools/testing/selftests/kho/vmtest.sh +++ b/tools/testing/selftests/kho/vmtest.sh @@ -103,16 +103,37 @@ function run_qemu() { local qemu_cmd=$1 local cmdline=$2 local kernel=$3 + local arch=$4 local serial="$tmp_dir/qemu.serial" cmdline="$cmdline kho=on panic=-1" - $qemu_cmd -m 1G -smp 2 -no-reboot -nographic -nodefaults \ - -accel kvm -accel hvf -accel tcg \ - -serial file:"$serial" \ - -append "$cmdline" \ - -kernel "$kernel" \ - -initrd "$initrd" + local qemu_args=( + -m 1G -smp 2 -no-reboot -nographic -nodefaults + -accel kvm -accel hvf -accel tcg + -serial file:"$serial" + -append "$cmdline" + -kernel "$kernel" + -initrd "$initrd" + ) + + # On LoongArch, EFI runtime services are unavailable after kexec so + # machine_restart() hangs and QEMU never exits on its own. Run QEMU + # in the background, poll for the test result, then kill it. + if [[ "$arch" == "loongarch" ]]; then + $qemu_cmd "${qemu_args[@]}" & + local qemu_pid=$! + local timeout=100 + while ((timeout-- > 0)); do + grep -q "KHO restore succeeded\|KHO restore failed" \ + "$serial" 2>/dev/null && break + sleep 1 + done + kill "$qemu_pid" 2>/dev/null + wait "$qemu_pid" 2>/dev/null || true + else + $qemu_cmd "${qemu_args[@]}" + fi grep "KHO restore succeeded" "$serial" &> /dev/null || fail "KHO failed" } @@ -179,7 +200,7 @@ function main() { local kernel="$build_dir/arch/$arch/boot/$KERNEL_IMAGE" mkinitrd "$kernel" - run_qemu "$QEMU_CMD" "$KERNEL_CMDLINE" "$kernel" + run_qemu "$QEMU_CMD" "$KERNEL_CMDLINE" "$kernel" "$arch" ktap_test_pass "KHO succeeded" } -- 2.25.1