From: Like Xu <like.xu.linux@gmail.com>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Cc: jiaqiyan@google.com, kvmarm@lists.linux.dev,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/3] KVM: selftests: arm64: Make sea_to_user skip cleanly
Date: Tue, 18 Aug 2026 19:29:17 +0800 [thread overview]
Message-ID: <20260818112920.26252-1-likexu@tencent.com> (raw)
This series hardens the arm64 sea_to_user selftest so that it reports a
clean skip on hosts that cannot actually run it, instead of aborting or
silently passing.
The test drives a real recoverable memory UER through APEI EINJ and
expects the guest to consume the poison and exit to userspace with
KVM_EXIT_ARM_SEA. That relies on host and firmware support that is not
present everywhere, and each unmet dependency is now turned into a skip:
- EINJ injection is driven directly through debugfs, and an unusable
EINJ (not built, no firmware support, or not running as root) is
classified from errno and skipped rather than mishandled.
- Guest memory is backed by 1GB hugepages; with an empty pool the test
now skips up front instead of failing an mmap() with -ENOMEM.
- Some firmware only arms EINJ poison as part of the trigger step that
notrigger=1 skips, so nothing consumable is left for the guest to
read. That case is detected and skipped rather than reported as a
spurious KVM_EXIT_MMIO failure.
Tested on an arm64 host with CONFIG_ACPI_APEI_EINJ: on a platform whose
firmware places no consumable poison under notrigger=1 the test now
skips cleanly, and the earlier -ENOMEM and abort paths are gone.
v1 [1] was a single patch doing only the 1GB hugepage check. Following
Marc's review [2], it is expanded into a series that also fixes the EINJ
handling the test depends on.
Test Results:
Case 1 (echo 0 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages):
# timeout set to 120
# selftests: kvm: sea_to_user
# Random seed: 0x6b8b4567
# 1..0 # SKIP - Requirement not met: get_free_hugepages(backing_page_size) >= VM_MEM_SIZE
ok 1 selftests: kvm: sea_to_user # SKIP
# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
Case 2 (rmmod einj):
# selftests: kvm: sea_to_user
# Random seed: 0x6b8b4567
# # Mapped 0x40000 pages: gva=0x80000000 to gpa=0xff80000000
# # Before EINJect: data=0xbaadcafe
# # EINJ_GVA=0x81234bad, einj_gpa=0xff81234bad, einj_hva=0xffff41234bad, einj_hpa=0x42c1234bad
# 1..0 # SKIP need CONFIG_ACPI_APEI_EINJ and firmware EINJ support
ok 1 selftests: kvm: sea_to_user # SKIP
# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
Case 3 (modprobe einj):
# selftests: kvm: sea_to_user
# Random seed: 0x6b8b4567
# # Mapped 0x40000 pages: gva=0x80000000 to gpa=0xff80000000
# # Before EINJect: data=0xbaadcafe
# # EINJ_GVA=0x81234bad, einj_gpa=0xff81234bad, einj_hva=0xffff41234bad, einj_hpa=0x42c1234bad
# # 0x10 > /sys/kernel/debug/apei/einj/error_type - done
# # 0x2 > /sys/kernel/debug/apei/einj/flags - done
# # 0x42c1234bad > /sys/kernel/debug/apei/einj/param1 - done
# # 0xffffffffffffffff > /sys/kernel/debug/apei/einj/param2 - done
# # 0x1 > /sys/kernel/debug/apei/einj/notrigger - done
# # 0x1 > /sys/kernel/debug/apei/einj/error_inject - done
# # Memory UER EINJected
# # SIGBUS (7) received, dumping siginfo...
# # si_signo=7, si_errno=0, si_code=128, si_addr=(nil)
# not ok 1 Exit with signal unhandled
ok 1 selftests: kvm: sea_to_user
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Changes since v1:
- New patch 1: drive EINJ injection directly through debugfs with
open()/write() instead of access()+popen(). Classify the open()
errno so an unprivileged run skips as "requires root" instead of
falsely reporting missing firmware EINJ, and report a genuine write
failure instead of the ambiguous "Failed... Success (0)".
- New patch 3: detect when notrigger=1 leaves no consumable poison and
skip cleanly, instead of exiting with a confusing KVM_EXIT_MMIO.
- Patch 2 is the original v1 change, unchanged.
Not yet addressed from [2]: dropping the hard 1GB-hugepage and 4kB
base-page requirements. Suggestions on an acceptable backing scheme are
welcome.
[1] https://lore.kernel.org/kvm/20260817080759.25601-1-likexu@tencent.com/
[2] https://lore.kernel.org/all/86y0le9cvz.wl-maz@kernel.org/
Like Xu (3):
KVM: selftests: arm64: Fix EINJ handling in sea_to_user
KVM: selftests: arm64: Skip sea_to_user without 1GB hugepages
KVM: selftests: arm64: Skip sea_to_user when EINJ places no poison
.../testing/selftests/kvm/arm64/sea_to_user.c | 75 +++++++++++++++----
.../testing/selftests/kvm/include/test_util.h | 1 +
tools/testing/selftests/kvm/lib/test_util.c | 15 ++++
3 files changed, 77 insertions(+), 14 deletions(-)
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-08-18 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 11:29 Like Xu [this message]
2026-08-18 11:29 ` [PATCH v2 1/3] KVM: selftests: arm64: Fix EINJ handling in sea_to_user Like Xu
2026-08-18 11:29 ` [PATCH v2 2/3] KVM: selftests: arm64: Skip sea_to_user without 1GB hugepages Like Xu
2026-08-18 11:36 ` sashiko-bot
2026-08-18 12:49 ` Like Xu
2026-08-18 11:29 ` [PATCH v2 3/3] KVM: selftests: arm64: Skip sea_to_user when EINJ places no poison Like Xu
2026-08-18 11:41 ` sashiko-bot
2026-08-18 12:50 ` Like Xu
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=20260818112920.26252-1-likexu@tencent.com \
--to=like.xu.linux@gmail.com \
--cc=jiaqiyan@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.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.