From: sashiko-bot@kernel.org
To: "Dennis Reußwig" <dennis@reusswig.codes>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 09/10] KVM: selftests: Add nested EPT mode-based execute control test
Date: Fri, 04 Dec 2026 00:07:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-248803@kernel.org> (raw)
In-Reply-To: <20261204-nested-sss-v1-9-57de06f58b2b@reusswig.codes>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] KVM: selftests: vmx_nested_mbec_test omits user-mode linear
address fetches
- [Low] KVM: selftests: vmx_nested_mbec_test lacks kselftest TAP and
skip reporting
--
commit d5eb6cc0d63627ad6ee5a99f17c015398b86328a
Author: Dennis Reußwig <dennis@reusswig.codes>
KVM: selftests: Add nested EPT mode-based execute control test
This commit adds a KVM x86 selftest that runs an L2 guest under L1 EPT
entries with varying supervisor and user execute permissions, with and
without mode-based execute control enabled, and checks the resulting
instruction fetches and EPT violation exit qualifications.
> diff --git a/tools/testing/selftests/kvm/x86/vmx_nested_mbec_test.c b/tools/testing/selftests/kvm/x86/vmx_nested_mbec_test.c
> new file mode 100644
> index 0000000000000..652b685466d57
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/x86/vmx_nested_mbec_test.c
[ ... ]
> +static void run_test(const struct mbec_test *t)
> +{
[ ... ]
> + /* A supervisor, executable mapping of the code page in L2's page tables. */
> + code_gpa = vm_phy_page_alloc(vm, MEM_REGION_DATA);
> + *(u8 *)addr_gpa2hva(vm, code_gpa) = 0xc3; /* RET */
> + virt_pg_map(vm, CODE_GVA, CODE_L2_GPA);
[Severity: Medium]
Should this test also exercise user-mode linear address fetches?
virt_pg_map() leaves PTE_USER_MASK clear at every L2 paging level, so
CODE_GVA is always a supervisor-mode linear address. Across tests[],
the fetch succeeds iff xs is set, and the only difference with mbec
enabled is EPT_VIOLATION_PROT_USER_EXEC on one case.
As a result, the test still passes if KVM fails to enable MBEC in
vmcs02, fails to translate EPT_VIOLATION_GVA_USER to PFERR_USER_MASK in
__vt_handle_ept_violation(), or never selects ~xu in
__update_permission_bitmask().
Since kvm_get_default_cr4() leaves X86_CR4_SMEP clear, setting
PTE_USER_MASK on all L2 paging levels for CODE_GVA would let L2 at
CPL 0 test user-mode linear address fetches without switching to
ring 3.
[ ... ]
> +int main(int argc, char *argv[])
> +{
> + bool has_mbec;
> + int i;
> +
> + TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
> + TEST_REQUIRE(kvm_cpu_has_ept());
> +
> + has_mbec = kvm_cpu_has_secondary_exec_control(SECONDARY_EXEC_MODE_BASED_EPT_EXEC);
> + if (!has_mbec)
> + pr_info("MBEC not offered to L1, running only the cases without MBEC\n");
> +
> + for (i = 0; i < ARRAY_SIZE(tests); i++) {
> + if (tests[i].mbec && !has_mbec)
> + continue;
> + run_test(&tests[i]);
> + }
> +
> + return 0;
> +}
[Severity: Low]
Could this report subtest results through kselftest.h instead of
pr_info() and a bare return 0?
When MBEC is not offered to L1 (such as on CPUs without MBEC or with
kvm_intel.mbec=0), all four MBEC cases are silently skipped and make
run_tests records an unconditional pass with no TAP skip status or
reason.
Using the kselftest.h wrappers already pulled in by test_util.h
(ksft_print_header(), ksft_set_plan(), ksft_test_result_pass(),
ksft_test_result_skip(), and ksft_finished()) would emit structured
pass and skip results for each subtest.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-nested-sss-v1-0-57de06f58b2b@reusswig.codes?part=9
next prev parent reply other threads:[~2026-12-04 0:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 23:49 [PATCH 00/10] KVM: nVMX: Supervisor shadow-stack control for nested EPT and CET with eVMCS Dennis Reußwig
2026-12-03 23:49 ` [PATCH 01/10] KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS Dennis Reußwig
2026-12-03 23:49 ` [PATCH 02/10] KVM: x86/mmu: Move TDP A/D tracking type to SPTE bits 56-57 Dennis Reußwig
2026-12-03 23:49 ` [PATCH 03/10] KVM: VMX: Report shadow-stack accesses in EPT violations as PFERR_SS Dennis Reußwig
2026-12-03 23:59 ` sashiko-bot
2026-12-03 23:49 ` [PATCH 04/10] KVM: x86/mmu: Handle the EPT supervisor shadow-stack bit like a write bit Dennis Reußwig
2026-12-04 0:16 ` sashiko-bot
2026-12-04 0:41 ` Dennis Reußwig
2026-12-03 23:49 ` [PATCH 05/10] KVM: nVMX: Shadow supervisor shadow-stack control of nested EPT Dennis Reußwig
2026-12-04 0:17 ` sashiko-bot
2026-12-04 0:41 ` Dennis Reußwig
2026-12-03 23:49 ` [PATCH 06/10] KVM: nVMX: Advertise supervisor shadow-stack control for " Dennis Reußwig
2026-12-04 0:13 ` sashiko-bot
2026-12-04 0:41 ` Dennis Reußwig
2026-12-03 23:49 ` [PATCH 07/10] KVM: selftests: Add helpers for nested EPT shadow-stack and MBEC tests Dennis Reußwig
2026-12-03 23:49 ` [PATCH 08/10] KVM: selftests: Add nested EPT supervisor shadow-stack test Dennis Reußwig
2026-12-04 0:00 ` sashiko-bot
2026-12-03 23:49 ` [PATCH 09/10] KVM: selftests: Add nested EPT mode-based execute control test Dennis Reußwig
2026-12-04 0:07 ` sashiko-bot [this message]
2026-12-03 23:49 ` [PATCH 10/10] KVM: selftests: Check VMX capabilities for CET in L2 with MBEC Dennis Reußwig
2026-12-04 0:10 ` sashiko-bot
2026-12-04 0:41 ` Dennis Reußwig
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=sashiko-outbox-248803@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dennis@reusswig.codes \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.