From nobody Mon Sep 28 19:23:00 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE34E46A5F4 for ; Tue, 18 Aug 2026 11:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052570; cv=none; b=cs1pirVCspVoriRlGOlgXvi1D+fW8etID7b/f/SDeltd/KTS/np3CgFq+067sHsiMgCBjt4TYZYfHIMP396n3Q4rL1iEM9LRyldG3luDAxEcGgsQMEvCKChjgFK1u8hnGoriM/7Uzztns228p61tC7nWg4ctDHWmA6oorjib1A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052570; c=relaxed/simple; bh=PQS+rhRuPKHawTipTzrfvIQnxbml1r89m5PT9iaRz8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uWP5eIyJdmwR05J+Er+0wSdK2RVnRhsTD7tmZcdezgHhh+Kf5qP1hfipFzP+6YLDVKOkit7cAl9Ddh1DNiY0nVxSVn7xc5vgRHMA401gyzt2PZ/M3p0CHt7ZS5XjOGx0+Ie8xMmMjiXdUSmhea0pE7XNXrKMmM0fLCs1bwIunTo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X7yP79J7; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7yP79J7" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-38f620399a0so3907487a91.2 for ; Tue, 18 Aug 2026 04:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787052568; x=1787657368; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GjeuzllnPcqvxrpejMrz9/eK7KMKWWQACjRt8b0xaWE=; b=X7yP79J7tm2lSa3SwFW1Ttfr5xoGUNYF0OYf9LQW4lpbqYvpqw7Pu6ZVe/7u6qOSx3 THo4EaelIRPsHWS3FKF0MGc6TI9EoIX8URS52KRuuzAE26A6m71Kk66FmzSK8auR/q9h rzEErzmeAv51bg1L8rKIBql6XCv8Qg3gRdNqDF7sA7XEhsZGaCbmrRMNs1O7KBipY7TV Gb2OMn+g5Vde5KEqg96wyQg64DMJEUAXEs7ZWOyDLj8983M0LP2PTB13QEN639KpjrMt QDw9RVOldz11ZyzY8MSc8BlvZXHGaPyKrFbbntRjVMvrJ9pmqotYMmKJTNcXclC24mfx YfYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787052568; x=1787657368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GjeuzllnPcqvxrpejMrz9/eK7KMKWWQACjRt8b0xaWE=; b=DVivKe9f3oXzjNp+q647pYVxzs8fO6vYRaaNRqM70pUNfAQveSKMJcdsCSfEv151vi Qz2TT4vRCaWaPjrHSLo2zNYm1aTDmv4GYCOOFwbR8MLjxHffZJwe1bF8i95SKRZUyDtH slRB1s3fPDS9NIj7gdqwnsNS+f6PJY2twNPUV8DMxUaqQpYstuaQP544QI3M8r/u01q5 0BBnr9ftZtRcNKGJNPLFX3zpgJytddQeM+4xdQ47RrYS1+Mo44NU+48VUjTIZSt1bkzh fVcj8macK0TVwSrCb0rKP/49KcOwZQg8iOY7XQOiGDW0Piq4Uovwer2Bb4eXUmiPBjxq iP/g== X-Forwarded-Encrypted: i=1; AHgh+RrKOT1/13Pj0cIxtK9fAZzXgb3gmrDVGutF210jh/3sJCoQU6A9TyqEapX3yPf2Ru5Cf7o5Nff8+pMgYhk=@vger.kernel.org X-Gm-Message-State: AOJu0YyYT299XFullta0w9cw+MVj6v6prHbrC/hiXB7mBujwBIJ5DSQp xlLDSIU9Hjv9u6IGX2Dl+KmVhpJfVjF7nMNJWPzOArvZIBFEcSIS4h92 X-Gm-Gg: AR+sD10F7krwAnjX80LMeUiEqgNSWR742XoSZVXoLevgY1WuMk4TiMNhoqXY1c1RwPo FOCFq54AZhGUOuUZf6pI31c8HjwXYiKhGmfzg9BIJdBgpK+gsMNXLOoAqktYyYwzH9XmmjHZcNI K+Sr/dfDg5Gb4AiEi5dgUnaClxQwS3Pc1cfN8SGhgIgjicXftzE9CGRXf31cUgzP/OigDh70K09 6iZqipcX4+P4SKIbEBVUWkmRmciTuIuwtraQbu+ZpjUeDNV73XBMltRFTrt+BEejUASbdokE6tJ oclUfzGFRuoVDBRmOV3FPVH2gCeck2w2TjrGcFnacZMOz5wQkFvb7JuvmGfyxeFpdXOPRsJ+RY8 ipNeYAFz5Ea5n4hIBkpbs0ceEmW8G/w+i301N7+dVRh5xCVXR2nI0i5G2nYpmDt+HtbGWAA70IN /X17WhM2UZnpm8IKNRDlzePkZaUwwYaNhQEuq2FXnoqbSOG3vzoySFkC4kN2PnJeoJjkCSahJTF 9S9LQ59QTpW83+C X-Received: by 2002:a17:90b:5685:b0:38e:4cb:51f with SMTP id 98e67ed59e1d1-3955a799fcdmr11206957a91.11.1787052567884; Tue, 18 Aug 2026 04:29:27 -0700 (PDT) Received: from LIKEXU-MC4 ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39531e31a9dsm8423420a91.4.2026.08.18.04.29.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Aug 2026 04:29:27 -0700 (PDT) From: Like Xu X-Google-Original-From: Like Xu To: Marc Zyngier , Oliver Upton Cc: jiaqiyan@google.com, kvmarm@lists.linux.dev, Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] KVM: selftests: arm64: Fix EINJ handling in sea_to_user Date: Tue, 18 Aug 2026 19:29:18 +0800 Message-ID: <20260818112920.26252-2-likexu@tencent.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260818112920.26252-1-likexu@tencent.com> References: <20260818112920.26252-1-likexu@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sea_to_user drives EINJ injection through popen("echo ... > file"). A failed write is hidden behind the shell pipeline, so a botched injection is silently ignored and the test proceeds as if a poison were placed. Drive the debugfs interface directly so a write failure is reported rather than swallowed. The EINJ support probe is also unreliable. It checks the ACPI EINJ table with access(R_OK), but reading that table needs CAP_SYS_ADMIN, so the check gives a false negative for unprivileged runs and skips a test that could otherwise report a real problem. Probe by opening the debugfs injection interface instead and classify errno: absence means EINJ is not built or firmware lacks support, EACCES/EPERM means the test is not running as root -- both are skips -- while anything else is a genuine failure. The injection path is only reachable through debugfs; the kernel EINJ driver exposes no other interface, so the test must depend on it. Link: https://lore.kernel.org/kvm/86y0le9cvz.wl-maz@kernel.org/ Signed-off-by: Like Xu --- .../testing/selftests/kvm/arm64/sea_to_user.c | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kvm/arm64/sea_to_user.c b/tools/testin= g/selftests/kvm/arm64/sea_to_user.c index e96d8982c28b8..1c2a743ca8e23 100644 --- a/tools/testing/selftests/kvm/arm64/sea_to_user.c +++ b/tools/testing/selftests/kvm/arm64/sea_to_user.c @@ -81,25 +81,46 @@ static u64 translate_hva_to_hpa(unsigned long hva) =20 static void write_einj_entry(const char *einj_path, u64 val) { - char cmd[256] =3D {0}; - FILE *cmdfile =3D NULL; + char buf[32]; + int fd, len, ret; =20 - sprintf(cmd, "echo %#lx > %s", val, einj_path); - cmdfile =3D popen(cmd, "r"); + fd =3D open(einj_path, O_WRONLY); + if (fd < 0) + ksft_exit_fail_perror(einj_path); =20 - if (pclose(cmdfile) =3D=3D 0) - ksft_print_msg("echo %#lx > %s - done\n", val, einj_path); - else - ksft_exit_fail_perror("Failed to write EINJ entry"); + len =3D snprintf(buf, sizeof(buf), "%#lx\n", val); + ret =3D write(fd, buf, len); + if (ret !=3D len) + ksft_exit_fail_perror(einj_path); + + close(fd); + ksft_print_msg("%#lx > %s - done\n", val, einj_path); } =20 static void inject_uer(u64 hpa) { - if (access("/sys/firmware/acpi/tables/EINJ", R_OK) =3D=3D -1) - ksft_test_result_skip("EINJ table no available in firmware"); + int fd; =20 - if (access(EINJ_ETYPE, R_OK | W_OK) =3D=3D -1) - ksft_test_result_skip("EINJ module probably not loaded?"); + /* + * EINJ is exposed only through debugfs, and opening it tells us why it + * is unusable far more reliably than access()-ing the ACPI EINJ table: + * reading that table needs CAP_SYS_ADMIN, so access() gives a false + * negative for unprivileged runs. Open the injection interface and let + * errno say whether the test cannot run (skip) or genuinely failed. + */ + fd =3D open(EINJ_ETYPE, O_WRONLY); + if (fd < 0) { + switch (errno) { + case ENOENT: + ksft_exit_skip("need CONFIG_ACPI_APEI_EINJ and firmware EINJ support\n"= ); + case EACCES: + case EPERM: + ksft_exit_skip("EINJ requires running as root\n"); + default: + ksft_exit_fail_perror(EINJ_ETYPE); + } + } + close(fd); =20 write_einj_entry(EINJ_ETYPE, ERROR_TYPE_MEMORY_UER); write_einj_entry(EINJ_FLAGS, MASK_MEMORY_UER); --=20 2.50.1 (Apple Git-155) From nobody Mon Sep 28 19:23:00 2026 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC33E468C36 for ; Tue, 18 Aug 2026 11:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052573; cv=none; b=S+tKnG7370vILKLgmj7atnbjVtBE5Lt/GZouJLSTCLfT5eMfICtTkfQV9lthfEVzwCkF3Ksgtl2hKXSgCFaOXAXth1gQeYqu0qi07loGz46o+5d2TxAxWOalBelPK9D/fRb7qe2ePYrWfOgLrK+RqazNXKJquQvwfOIceBoPlrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052573; c=relaxed/simple; bh=zgB3+8JK5YhFAdN3TgJqt08umXKZZZGiuhUx5GAOPx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k6cIKf8O97T6een+02ti6roL03pfFqR9D8XdiUmWXR/mfVP53Z8Vdx82QuPKQV1RSqYWQkIBkho0ZUUXjmAfqYmpCPkdDIPAR1tYUhWQNDB37VzInampOrBVlblN9ivrdXU2USWLKyWSE8wZERR3WCXlLxcd4g5x8z9/ewIFGc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SWJ15eLd; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SWJ15eLd" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-38dcbade417so4485265a91.1 for ; Tue, 18 Aug 2026 04:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787052570; x=1787657370; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Uzcibn+mdIhChgrhZtZVfO5SLMtBxjTCSvRPL8WbSo4=; b=SWJ15eLd1LnmPLMJueNinYYTja78NGz8jChxNt4hGkuU6RzuAUUYdWGSrb5+TsvREU hqqsWZxjM9CV1u8n1TQ29gkD5HMVhJIdxKMUMR9uReFnG4xXYbw+bypHGaujESxd2zbo oYoFyyi+A35PeK5EM4GXv3qNkzsHOEFmUR6jvX+LhidManVHmivKGtR6Et6bSXgwpgwj 9CXH8DbK5oQUh7oEiNjaaudn/jBZzBLB71K7mBaXPcZwlj3+U00OyhXmy0jk+3ORHnoj PmtQddmPcSSkCltlsgqhgYXPZjLt2AIGY+g5dOtMykFfM7XxGTB9ze7FuepQcRYZkDH7 8kqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787052570; x=1787657370; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Uzcibn+mdIhChgrhZtZVfO5SLMtBxjTCSvRPL8WbSo4=; b=hYOOfYIQk4QYxjwRd5A0RRM2DU44TPHCIQoVgcK+jCxo14S1P9cYljfSq0CQO/vtMY e3uFueaw1iojEMtRj5SOQ8fY3qn4CnzMWsU+BkyWkp37Ab1rqvqK+A3Oho2nknX03zjq s8kWgAZTDELMHbytV34YdXT9xb/8Hg5jLmrZXVT87DyY9XJUMmN4uyUedEUKDcDBzXmu UniegUtkrXz/YB2MBFGWGPro5t/iGmdp+jwhS14diybDQ9TIqp+6k+8D2xZnCnanNeme fiCip7SeCASt3eYKfGic1vRmasPQ59jfTX0jfF1/td3y9ric6MoogAnQS6ITrhjOR6Oh 7cDA== X-Forwarded-Encrypted: i=1; AHgh+RozZ+a0Y5CN5QvuLFqnaxSJnpOxz8/tednZ55i+xXOgYMoQ7ddObpfY6wQPrp6AbQpXK62G86sSeleCFck=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw7YKtCfht+JwmWG5AtitT4RSSy9O8OQLOd8R9ipxCkE9KLKLH TL2X9ycsxlGH4h8C/ghdDVwIRVZKYokVd0TVs4z9I6yGzfSAd3E5RjvL X-Gm-Gg: AR+sD11RELYEQpFKb4x3IvsOoO8B6WetW281aEK6sxbxaY9g2RbACSkLFUZFqt9h8bB PUPwU2tPgRqS5HFdzH4MmuRPmjTJeVaZOX7Ex6Ubu9vIxPdAHdCxqkSs9z3CoJzoXRjcH74f+Yf 6l1mTQvJxMd5ck0zhCrt86RP9ftCNCylw0kL/w8gkhjDFquPRUmsF3IXPgY4ehIeVHuGfNQzLxN ZvCgCRjMO5LMGiQy4VxZ/lURh81mH3/ZHmwK+dTHY08XU2xlP+zO7fgmskGtKAfo82b172z3Bnk mkdPJjF437hpbcOsAML+KykSyFksrzoEfLwCWhgaqj4VyVLGIr4d+rEFCsyHAe3V9j/nBzwu4ey YJkkdYbXDpDK999KnF7o6mF/0uD0Zhka6fPSLpcQkXurtRJVSTP1OH8bI4iJx5R4WODq13tWOtm GCdGRGOhg+nZpArqk1UMPOVeNeeDXfQwjYqpw3AJwicZRBiTXRloynGia0iU5rtg+bzZUH1SR+0 Txi X-Received: by 2002:a17:90b:2802:b0:38e:9e9d:9209 with SMTP id 98e67ed59e1d1-3955aa42a2amr9926813a91.17.1787052570004; Tue, 18 Aug 2026 04:29:30 -0700 (PDT) Received: from LIKEXU-MC4 ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39531e31a9dsm8423420a91.4.2026.08.18.04.29.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Aug 2026 04:29:29 -0700 (PDT) From: Like Xu X-Google-Original-From: Like Xu To: Marc Zyngier , Oliver Upton Cc: jiaqiyan@google.com, kvmarm@lists.linux.dev, Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] KVM: selftests: arm64: Skip sea_to_user without 1GB hugepages Date: Tue, 18 Aug 2026 19:29:19 +0800 Message-ID: <20260818112920.26252-3-likexu@tencent.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260818112920.26252-1-likexu@tencent.com> References: <20260818112920.26252-1-likexu@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sea_to_user backs guest memory with 1GB hugepages but never checks that any are reserved. On a host with an empty pool it aborts instead of skipping: kvm_syscalls.h:68: mem !=3D MAP_FAILED, errno=3D12 (ENOMEM) not ok 1 selftests: kvm: sea_to_user # exit=3D254 The mmap() of the hugetlb region fails with -ENOMEM because no 1GB pages are available, and the test treats that as a hard failure even though it simply cannot run without the backing pages. Check the free 1GB hugepage count up front and skip cleanly when the host cannot satisfy the region. Signed-off-by: Like Xu Reviewed-by: Jiaqi Yan --- tools/testing/selftests/kvm/arm64/sea_to_user.c | 6 ++++++ tools/testing/selftests/kvm/include/test_util.h | 1 + tools/testing/selftests/kvm/lib/test_util.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/tools/testing/selftests/kvm/arm64/sea_to_user.c b/tools/testin= g/selftests/kvm/arm64/sea_to_user.c index 1c2a743ca8e23..7cf95da8e594d 100644 --- a/tools/testing/selftests/kvm/arm64/sea_to_user.c +++ b/tools/testing/selftests/kvm/arm64/sea_to_user.c @@ -281,6 +281,12 @@ static struct kvm_vm *vm_create_with_sea_handler(struc= t kvm_vcpu **vcpu) alignment =3D max(backing_page_size, guest_page_size); num_guest_pages =3D VM_MEM_SIZE / guest_page_size; =20 + /* + * The region is backed by 1GB hugepages; skip gracefully rather than + * failing with mmap() -ENOMEM if the host has none reserved. + */ + TEST_REQUIRE(get_free_hugepages(backing_page_size) >=3D VM_MEM_SIZE); + vm =3D __vm_create_with_one_vcpu(vcpu, num_guest_pages, guest_code); vm_init_descriptor_tables(vm); vcpu_init_descriptor_tables(*vcpu); diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testin= g/selftests/kvm/include/test_util.h index a56271c237ae9..0624922c2735d 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -168,6 +168,7 @@ struct vm_mem_backing_src_alias { bool thp_configured(void); size_t get_trans_hugepagesz(void); size_t get_def_hugetlb_pagesz(void); +size_t get_free_hugepages(size_t page_size); const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(u32 i); size_t get_backing_src_pagesz(u32 i); bool is_backing_src_hugetlb(u32 i); diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/se= lftests/kvm/lib/test_util.c index bab1bd2b775b6..29f9c1d60b1b7 100644 --- a/tools/testing/selftests/kvm/lib/test_util.c +++ b/tools/testing/selftests/kvm/lib/test_util.c @@ -222,6 +222,21 @@ size_t get_def_hugetlb_pagesz(void) TEST_FAIL("Error in reading /proc/meminfo"); } =20 +size_t get_free_hugepages(size_t page_size) +{ + char path[128]; + size_t free; + + snprintf(path, sizeof(path), + "/sys/kernel/mm/hugepages/hugepages-%zukB/free_hugepages", + page_size >> 10); + if (!test_sysfs_path(path)) + return 0; + + free =3D get_sysfs_val(path); + return free * page_size; +} + #define ANON_FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) #define ANON_HUGE_FLAGS (ANON_FLAGS | MAP_HUGETLB) =20 --=20 2.50.1 (Apple Git-155) From nobody Mon Sep 28 19:23:00 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D02D545DF67 for ; Tue, 18 Aug 2026 11:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052574; cv=none; b=pKPQKyQtYoHtYkWwKgd8mjiG3Fygydlx5rUQStn+0/IGtnQrMleuq+DHzblQt3d0MyRdJoATn+WHZGbuVvud/+kyi412Qw+hO0vNz8i0Gs+SqQVht+MtqutkxC2sn1mHNxnnMyKrE2M0gvcIjiefrxxz6QTP4uizyET3iyBVY/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787052574; c=relaxed/simple; bh=mqinjzXhUcoLMkqFncjy3awDJ9xmqF05YJhAD3a/vfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nP558W+PhxWhnYqtKQyLyvjZaoiYiT85wFUy1GTAt2At50apQPtlT3jW4iyV/08W2H5Z4t3dFrlDwz1hS32l1UwEPOPnvNuzG/qSbRnPUhUNwu+BW40tHB7y7HFzYRiX2Dvx3fzBBL5Vjj8S0eJ9IcHDCKCIBkIs4Xgn1GZuKP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cuwREm69; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cuwREm69" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-38125cebfdaso6503542a91.1 for ; Tue, 18 Aug 2026 04:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787052572; x=1787657372; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TgcDc4oA52oVFhPCIzepFvLDOjJcdq190pOOMughMV4=; b=cuwREm69rJGFqpr1qi+yBHSfPAEeGrax/0f/PliGaisIAu7P34cC9nb2hN5xhXgR0a Mk6BLcwmZtnsOqI5LO17kFITeL494tthEZWIdnSPCiSrs44kFRaVZdxWIqYud+UWkhcI Gy5H7BeaGqfXMs/E4Zu1Pq9asVOCX5S+pIS6oLgZ+1BTkSMNKbDxvf8rd7CtKXEdiKTp G0OdCg2YihddcltGdPqctJ1IdHD8zlVC0DCWWwa/NBuB3AIQOxizyYQzaSNnJDM7cIFk ZBaQKBDDkYYP3D+jxcxHNZAeJcl8EvSQeMp1FM/bSm9HbAkiovs56UGjvEi5B1whrkut K5hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787052572; x=1787657372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TgcDc4oA52oVFhPCIzepFvLDOjJcdq190pOOMughMV4=; b=qJlqwWb2BbTWEgyfNq1e9ruku+8qykb+4lNKfB7vFqctCyYMb9QlK0SYXcLDTYza1A qktCmhRpN+Q0EK3Kb8ZfUKHOvW+dC7QOH2AzQLh8pwvIScQ4UtJ4EJk6fk4r7xrxWk+L mAWuKj3Yke5fI4tzRTQwutyO8x4y6Nl363FWzUCjIFLSNq4XDQGvV1eK2MzOL7hFSJOi UannYVQKeMc8fbPj1Op+d6rVHbGR+8xTUjvCc227i2MFMmHHrz+T71Tjey2BMYggQ3dv HNuJJfaT3htXRFRa/NjTeWuFavivaK1GBilJTDLb9aY1rqbX45tKR0Mqa5DDPhDXAT1Q /H3w== X-Forwarded-Encrypted: i=1; AHgh+RqANzSJUz9yQbVHtJEhzZTN73MlHSlQVb0bBWkhCLgpjiSiA4a8TZagQqUvzWJ6j+z9XaP9nodp9VEtGiY=@vger.kernel.org X-Gm-Message-State: AOJu0YwfBSpeXzP17MG1Yz6Ex9Z0XC9NnQJGuFUAslvr58dYwdFci9bA nVWnqnOHCoQQ/LL9MU8OSKp5r//VqW+FsWzlgRDOmI2W0Bc4mu3sSSlz X-Gm-Gg: AR+sD10QP9/tRFhAVeZ8S/Gsjpt1enW0r7ORXEtGtjJtI98DNyoIDSGpUexyzRuSLSn C7cJDjuRHYO9JlEUvcNEEZCJXiPJyeHtW9K8zqLD0Pd8dZdIuhpwTL/J37+Iq/tDYu/jmeayfel uMT/QRAuVmzi+aXTj8EUqKaGcl3tYhgr9I3vGiq3sd5jGJj7onMHLrxCL128PrCYIO1iCkBiygb rFCht7pqZW+DAM78opSE1H6KtQ7n9JBClg6xFX8wCX9bzaBz4lS90Onf1XfT0wQTysdEnh14RLF /1pop1KoECr2sGQrmgnf/nla1mDem8vysorQJan2hMAUqxpUSt9e+JPnAEU1olbrQT46ZnmYJPq qEJ5kL8Y84UL30uqnQ5/Kk1aj2vPeXz0iX4ISYnyyKZLd0yI/XWzEWaB0xWp9ZQ0n5nWl2BeKYr 6j4Pk2EFkByMpsNLm3N5SVitUHshdEINJnF1DlUYznqL47kyvvYBkQmrmLKymZowH4gtCFqhEEY D46Vf+l6kn0Y5U= X-Received: by 2002:a17:90b:48ce:b0:390:b41a:b92b with SMTP id 98e67ed59e1d1-3933b6d05c3mr37501585a91.4.1787052572199; Tue, 18 Aug 2026 04:29:32 -0700 (PDT) Received: from LIKEXU-MC4 ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39531e31a9dsm8423420a91.4.2026.08.18.04.29.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Aug 2026 04:29:31 -0700 (PDT) From: Like Xu X-Google-Original-From: Like Xu To: Marc Zyngier , Oliver Upton Cc: jiaqiyan@google.com, kvmarm@lists.linux.dev, Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] KVM: selftests: arm64: Skip sea_to_user when EINJ places no poison Date: Tue, 18 Aug 2026 19:29:20 +0800 Message-ID: <20260818112920.26252-4-likexu@tencent.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260818112920.26252-1-likexu@tencent.com> References: <20260818112920.26252-1-likexu@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sea_to_user injects a memory UER with EINJ notrigger=3D1 and expects the guest to consume it and trap to KVM as an SEA. On some firmware the test aborts instead: arm64/sea_to_user.c:223: exit_reason =3D=3D (41) Wanted KVM exit reason: 41 (ARM_SEA), got: 6 (MMIO) notrigger=3D1 asks firmware to arm the poison without consuming it, but on these platforms the poison is only armed as part of the trigger step that notrigger skips, so nothing consumable is left in memory. The guest reads back the sentinel, no SEA occurs, and GUEST_FAIL fires. On arm64 a ucall is delivered as an MMIO write, which surfaces as the KVM_EXIT_MMIO above rather than a KVM bug. The file already documents that the test must be skipped when firmware cannot deliver a consumable error. Detect the guest abort that follows a missing SEA and skip, instead of failing on a firmware limitation the test cannot control. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Like Xu Reviewed-by: Jiaqi Yan --- .../testing/selftests/kvm/arm64/sea_to_user.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/arm64/sea_to_user.c b/tools/testin= g/selftests/kvm/arm64/sea_to_user.c index 7cf95da8e594d..d4af6e0eed288 100644 --- a/tools/testing/selftests/kvm/arm64/sea_to_user.c +++ b/tools/testing/selftests/kvm/arm64/sea_to_user.c @@ -215,13 +215,33 @@ static void run_vm(struct kvm_vm *vm, struct kvm_vcpu= *vcpu) =20 ksft_print_msg("Dump kvm_run info about KVM_EXIT_%s\n", exit_reason_str(run->exit_reason)); + + /* + * The guest's read of the injected location is expected to trap to KVM + * as an SEA. If it does not, the injected error was never placed as + * consumable poison: some firmware honours EINJ's notrigger request by + * arming the poison only as part of the (now skipped) trigger step, so + * nothing is left in memory for the guest to consume. The guest then + * reads back the sentinel value and reports it via GUEST_FAIL, which + * arm64 delivers as a ucall over MMIO (hence a KVM_EXIT_MMIO here). + * Treat that as "this platform cannot host the test" and skip, matching + * the requirement documented at the top of this file, rather than + * failing on a hardware/firmware limitation the test cannot control. + */ + if (run->exit_reason !=3D KVM_EXIT_ARM_SEA && + get_ucall(vcpu, &uc) =3D=3D UCALL_ABORT) { + ksft_print_msg("Guest consumed no SEA: %s", uc.buffer); + ksft_exit_skip("EINJ notrigger placed no consumable poison on this platf= orm\n"); + } + + TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_ARM_SEA); + + /* arm_sea holds valid data only for a KVM_EXIT_ARM_SEA exit. */ ksft_print_msg("kvm_run.arm_sea: esr=3D%#llx, flags=3D%#llx\n", run->arm_sea.esr, run->arm_sea.flags); ksft_print_msg("kvm_run.arm_sea: gva=3D%#llx, gpa=3D%#llx\n", run->arm_sea.gva, run->arm_sea.gpa); =20 - TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_ARM_SEA); - esr =3D run->arm_sea.esr; TEST_ASSERT_EQ(ESR_ELx_EC(esr), ESR_ELx_EC_DABT_LOW); TEST_ASSERT_EQ(esr & ESR_ELx_FSC_TYPE, ESR_ELx_FSC_EXTABT); --=20 2.50.1 (Apple Git-155)