From: Sean Christopherson <seanjc@google.com>
To: Hemanth Selam <hemanth.selam@gmail.com>
Cc: pbonzini@redhat.com, shuah@kernel.org, kvm@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: selftests: SEV: Verify unsupported VM types are rejected at creation
Date: Thu, 9 Jul 2026 13:21:05 -0700 [thread overview]
Message-ID: <alACsZ41RLIbBzfM@google.com> (raw)
In-Reply-To: <20260709174955.628913-2-hemanth.selam@gmail.com>
On Thu, Jul 09, 2026, Hemanth Selam wrote:
> @@ -73,19 +74,34 @@ static void test_init2_invalid(unsigned long vm_type, struct kvm_sev_init *init,
> kvm_vm_free(vm);
> }
>
> +static void test_create_invalid_type(unsigned long vm_type, const char *msg)
> +{
> + int fd = __kvm_ioctl(kvm_fd, KVM_CREATE_VM, (void *)vm_type);
> + int err = errno;
> +
> + /* Clean up before asserting; TEST_ASSERT() aborts on failure. */
Literally every test relies on the kernel to clean up fds on an early exit. I
see no reason for this to behave differently.
Also, Sashiko was wrong. If KVM_CREATE_VM fails with something other than EINVAL,
the assert will NOT fire, but fd will be < 0.
> + if (fd >= 0)
> + close(fd);
> +
> + TEST_ASSERT(fd < 0 && err == EINVAL,
> + "KVM_CREATE_VM should reject unsupported type (%s), got fd=%d errno=%d",
> + msg, fd, err);
test_assert logs the errno, no need to spit it out here as well.
> +}
> +
> void test_vm_types(void)
> {
> test_init2(KVM_X86_SEV_VM, &(struct kvm_sev_init){});
>
> - /*
> - * TODO: check that unsupported types cannot be created. Probably
> - * a separate selftest.
Heh, I agree with the comment: put this in a separate selftest. This doesn't
have anything to do with KVM_SEV_INIT2, and in fact doesn't even have anyting to
do with SEV+ or even x86. E.g. add a kvm_vm_types_test that attempts to create
all possible VM types, and asserts success/failure based on the output from
kvm_check_cap(KVM_CAP_VM_TYPES).
next prev parent reply other threads:[~2026-07-09 20:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 16:47 [PATCH v1 0/2] KVM: selftests: SEV: address two TODOs in the SEV tests Hemanth Selam
2026-07-09 16:47 ` [PATCH v1 1/2] KVM: selftests: SEV: Verify unsupported VM types are rejected at creation Hemanth Selam
2026-07-09 16:55 ` sashiko-bot
2026-07-09 16:47 ` [PATCH v1 2/2] KVM: selftests: SEV: Sanity check the launch measurement Hemanth Selam
2026-07-09 17:49 ` [PATCH v2 0/2] KVM: selftests: SEV: address two TODOs in the SEV tests Hemanth Selam
2026-07-09 17:49 ` [PATCH v2 1/2] KVM: selftests: SEV: Verify unsupported VM types are rejected at creation Hemanth Selam
2026-07-09 20:21 ` Sean Christopherson [this message]
2026-07-10 5:06 ` Hemanth Selam
2026-07-09 17:49 ` [PATCH v2 2/2] KVM: selftests: SEV: Sanity check the launch measurement Hemanth Selam
2026-07-10 5:04 ` [PATCH v3] KVM: selftests: Add a test for KVM_CREATE_VM VM type enforcement Hemanth Selam
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=alACsZ41RLIbBzfM@google.com \
--to=seanjc@google.com \
--cc=hemanth.selam@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/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.