All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: ma.mandourr@gmail.com
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: selftests: Add test for nested VM-Exits while vectoring soft INTs
Date: Wed, 21 Oct 2026 04:45:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-179794@kernel.org> (raw)
In-Reply-To: <20261021042603.608292-3-ma.mandourr@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] KVM: selftests: standalone test duplicates nested_exceptions_test setup
--

commit 419533e2e5a5342a3cc80d072a4cecd9f800a093
Author: Mahmoud Abumandour <ma.mandourr@gmail.com>

KVM: selftests: Add test for nested VM-Exits while vectoring soft INTs

This commit adds a standalone KVM x86 selftest to verify that a nested
VM-Exit occurring while L2 vectors a software exception or interrupt reports
the instruction length in VM_EXIT_INSTRUCTION_LEN without modifying
VM_ENTRY_INSTRUCTION_LEN.

> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index 888a7530a2808..d5f8749413f27 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -140,6 +140,7 @@ TEST_GEN_PROGS_x86 += x86/vmx_exception_with_invalid_guest_state
>  TEST_GEN_PROGS_x86 += x86/vmx_msrs_test
>  TEST_GEN_PROGS_x86 += x86/vmx_invalid_nested_guest_state
>  TEST_GEN_PROGS_x86 += x86/vmx_nested_la57_state_test
> +TEST_GEN_PROGS_x86 += x86/vmx_soft_int_vectoring_test
>  TEST_GEN_PROGS_x86 += x86/apic_bus_clock_test
>  TEST_GEN_PROGS_x86 += x86/xapic_ipi_test
>  TEST_GEN_PROGS_x86 += x86/xapic_state_test
> diff --git a/tools/testing/selftests/kvm/x86/vmx_soft_int_vectoring_test.c b/tools/testing/selftests/kvm/x86/vmx_soft_int_vectoring_test.c
> new file mode 100644
> index 0000000000000..e74510c49938c
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/x86/vmx_soft_int_vectoring_test.c

[ ... ]

> +static void l1_guest_code(struct vmx_pages *vmx_pages)
> +{
> +	prepare_for_vmx_operation(vmx_pages);
> +	load_vmcs(vmx_pages);
> +	prepare_vmcs(vmx_pages, l2_guest_code);
> +
> +	/*
> +	 * Put every IDT entry beyond the limit so that vectoring any event in
> +	 * L2 generates #GP, and intercept #GP so that the VM-Exit occurs while
> +	 * the original event is being vectored.
> +	 */
> +	vmwrite(GUEST_IDTR_LIMIT, 0);
> +	vmwrite(EXCEPTION_BITMAP, BIT(GP_VECTOR));
> +	vmwrite(VM_ENTRY_INSTRUCTION_LEN, ENTRY_INSN_LEN);
> +
> +	vmlaunch();
> +	l1_assert_vectoring_exit("INT3", INTR_TYPE_SOFT_EXCEPTION | BP_VECTOR, 1);
> +
> +	vmresume();
> +	l1_assert_vectoring_exit("INTn", INTR_TYPE_SOFT_INTR | SOFT_INT_VECTOR, 2);
> +
> +	vmresume();
> +	GUEST_ASSERT_EQ(vmread(VM_EXIT_REASON), EXIT_REASON_VMCALL);
> +	GUEST_DONE();
> +}

[Severity: Medium]
This isn't a bug, but l1_guest_code() in
tools/testing/selftests/kvm/x86/vmx_soft_int_vectoring_test.c duplicates the
nested VMCS setup, empty GUEST_IDTR_LIMIT configuration, and GP_VECTOR
interception in EXCEPTION_BITMAP that l1_vmx_code() in
tools/testing/selftests/kvm/x86/nested_exceptions_test.c already sets up to
trigger nested VM-Exits during L2 event vectoring:

tools/testing/selftests/kvm/x86/nested_exceptions_test.c:l1_vmx_code() {
	prepare_for_vmx_operation(vmx);

	load_vmcs(vmx);

	prepare_vmcs(vmx, NULL);
	vmwrite(GUEST_IDTR_LIMIT, 0);
	...
	vmwrite(EXCEPTION_BITMAP, INTERCEPT_SS_GP_DF);
	...
}

Could the INT3 and INTn vectoring checks in l2_guest_code() and
l1_assert_vectoring_exit() be added to
tools/testing/selftests/kvm/x86/nested_exceptions_test.c instead of adding a
separate x86/vmx_soft_int_vectoring_test target to TEST_GEN_PROGS_x86 in
tools/testing/selftests/kvm/Makefile.kvm?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021042603.608292-1-ma.mandourr@gmail.com?part=2

      reply	other threads:[~2026-10-21  4:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  4:26 [PATCH 0/2] KVM: nVMX: Don't clobber VM-Entry instruction length on soft INTn exits ma.mandourr
2026-10-21  4:26 ` [PATCH 1/2] KVM: nVMX: Don't clobber VM-Entry instruction length when saving soft INTn ma.mandourr
2026-10-21  4:42   ` sashiko-bot
2026-10-21  4:26 ` [PATCH 2/2] KVM: selftests: Add test for nested VM-Exits while vectoring soft INTs ma.mandourr
2026-10-21  4:45   ` sashiko-bot [this message]

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-179794@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=ma.mandourr@gmail.com \
    --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.