Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lisa Wang" <wyihan@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC 4/9] KVM: selftests: TDX: Add TDX IO reads test
Date: Sat, 05 Dec 2026 00:47:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-250849@kernel.org> (raw)
In-Reply-To: <20261205-tdx-selftests-ii-v1-4-dd9f6b6fe20c@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] kvm: selftests: verify_td_io_read() checks TDVMCALL_IO_READ not
  KVM_EXIT_IO_IN
- [Low] kvm: selftests: verify_td_io_read() discards guest assertion
  details on abort
--

commit 2b167d8c50bb8e1dd04c5f860d25f676be69f9b2
Author: Sagi Shahar <sagis@google.com>

KVM: selftests: TDX: Add TDX IO reads test

This commit adds a tdx_io_read() helper and a verify_td_io_read() test
case that checks both a valid and an invalid guest IO read TDVMCALL.

> diff --git a/tools/testing/selftests/kvm/x86/tdx_vm_test.c b/tools/testing/selftests/kvm/x86/tdx_vm_test.c
> index 07bfaad422fe6..02b317371f61e 100644
> --- a/tools/testing/selftests/kvm/x86/tdx_vm_test.c
> +++ b/tools/testing/selftests/kvm/x86/tdx_vm_test.c
> @@ -66,6 +66,33 @@ TDX_TEST(verify_td_io_write, guest_io_write)
>  	TEST_ASSERT_EQ(get_ucall(vcpu, &uc), UCALL_DONE);
>  }
>  
> +static void guest_io_read(void)
> +{
> +	u64 data = 0, ret;
> +
> +	ret = tdx_io_read(TEST_IO_PORT, sizeof(TEST_IO_DATA_VALUE), &data);
> +	GUEST_ASSERT(!ret);
> +	GUEST_ASSERT_EQ(data, TEST_IO_DATA_VALUE);
> +	ret = tdx_io_read(TEST_IO_PORT, 8, &data);
> +	GUEST_ASSERT_EQ(ret, TDVMCALL_STATUS_INVALID_OPERAND);
> +	GUEST_DONE();
> +}
> +
> +TDX_TEST(verify_td_io_read, guest_io_read)
> +{
> +	struct ucall uc;
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_EQ(vcpu->run->exit_reason, KVM_EXIT_IO);
> +	TEST_ASSERT_EQ(vcpu->run->io.port, TEST_IO_PORT);
> +	TEST_ASSERT_EQ(vcpu->run->io.size, sizeof(TEST_IO_DATA_VALUE));
> +	TEST_ASSERT_EQ(vcpu->run->io.direction, TDVMCALL_IO_READ);

[Severity: Low]
Should this compare vcpu->run->io.direction against KVM_EXIT_IO_IN
instead of TDVMCALL_IO_READ?  KVM populates io.direction using the KVM
UAPI constants KVM_EXIT_IO_IN and KVM_EXIT_IO_OUT, whereas
TDVMCALL_IO_READ is the guest-side TDX hypercall encoding; the check
only passes because both happen to be 0.

> +	*(u32 *)((void *)vcpu->run + vcpu->run->io.data_offset) = TEST_IO_DATA_VALUE;
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_EQ(get_ucall(vcpu, &uc), UCALL_DONE);

[Severity: Low]
When one of the guest assertions in guest_io_read() fails, should
verify_td_io_read() handle UCALL_ABORT with REPORT_GUEST_ASSERT(uc)?
As written, uc is populated by get_ucall() but never read, so a guest
assertion failure only reports a raw enum mismatch instead of the
failing expression and values.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-tdx-selftests-ii-v1-0-dd9f6b6fe20c@google.com?part=4

  reply	other threads:[~2026-12-05  0:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  0:36 [PATCH RFC 0/9] TDX KVM selftests phase II Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 1/9] KVM: selftests: TDX: Add TDX_TEST() macro to tdx_vm_test Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 2/9] KVM: selftests: TDX: Add TDX IO writes test Lisa Wang
2026-12-05  0:48   ` sashiko-bot
2026-12-05  0:36 ` [PATCH RFC 3/9] KVM: selftests: TDX: Support single output in __tdvmcall() Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 4/9] KVM: selftests: TDX: Add TDX IO reads test Lisa Wang
2026-12-05  0:47   ` sashiko-bot [this message]
2026-12-05  0:36 ` [PATCH RFC 5/9] KVM: selftests: TDX: Add TDX MSR writes test Lisa Wang
2026-12-05  0:52   ` sashiko-bot
2026-12-05  0:36 ` [PATCH RFC 6/9] KVM: selftests: TDX: Add TDX MSR reads test Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 7/9] KVM: selftests: TDX: Add TDX MMIO writes test Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 8/9] KVM: selftests: TDX: Add TDX MMIO reads test Lisa Wang
2026-12-05  0:36 ` [PATCH RFC 9/9] KVM: selftests: TDX: Add TDX CPUID leaf 0x1 test Lisa Wang
2026-12-05  0:57   ` sashiko-bot

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-250849@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wyihan@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox