From: Sean Christopherson <seanjc@google.com>
To: Michal Luczaj <mhal@rbox.co>
Cc: Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: selftests: Use asserting kvm_ioctl() macros when getting ARM page sizes
Date: Fri, 4 Aug 2023 08:23:54 -0700 [thread overview]
Message-ID: <ZM0YCjDLGzEBWF/M@google.com> (raw)
In-Reply-To: <ae42db25-9c8c-3f27-9ccb-41644b135a8b@rbox.co>
On Fri, Aug 04, 2023, Michal Luczaj wrote:
> On 8/4/23 02:42, Sean Christopherson wrote:
> > Use kvm_ioctl() instead of open coding equivalent ioctl()+TEST_ASSERT()
> > calls when getting the support page sizes on ARM. The macro usage is a
> > little funky since the "kvm_fd" parameter implies an actual /dev/kvm fd,
> > but on the other hand the code is invoking KVM ioctl()s.
> >
> > Alternatively, the core utilities could expose a vm_open()+vm_close()
> > pair so that the ARM code could create a dummy, on-stack VM+vCPU pair and
> > use {vm,vcpu}_ioctl() as appropriate. But the odds of something breaking
> > due to oddball, partial usage of kvm_vm and kvm_vcpu structures is much
> > higher than realizing meaningful benefit from using {vm,vcpu}_ioctl().
>
> Since you're doing the cleanup, does mmio_warning_test qualify for the
> same (funky usage ahead)?
Hmm, I'm heavily leaning towards deleting that test entirely. It's almost
literally a copy+paste of the most basic syzkaller test, e.g. spawn a vCPU with
no backing memory and watch it die a horrible death. Unless I'm missing something,
the test is complete overkill too, e.g. I highly doubt the original KVM bug required
userspace to fork() and whatnot, but syzkaller spawns threads for everything and
so that got copied into the selftest.
And this stuff is just silly:
TEST_REQUIRE(host_cpu_is_intel);
TEST_REQUIRE(!vm_is_unrestricted_guest(NULL));
because crashing the VM doesn't require Intel, nor does it require !URG, those
just happened to be the conditions for the bug.
As much as I like having explicit testcases, adding a new selftest for every bug
that syzkaller finds is neither realistic nor productive. In other words, I think
we should treat syzkaller as being part of KVM's test infrastructure.
I'll send a patch to nuke the test.
> - kvm = open("/dev/kvm", O_RDWR);
> - TEST_ASSERT(kvm != -1, "failed to open /dev/kvm");
> - kvmvm = __kvm_ioctl(kvm, KVM_CREATE_VM, NULL);
> - TEST_ASSERT(kvmvm > 0, KVM_IOCTL_ERROR(KVM_CREATE_VM, kvmvm));
> - kvmcpu = ioctl(kvmvm, KVM_CREATE_VCPU, 0);
> - TEST_ASSERT(kvmcpu != -1, KVM_IOCTL_ERROR(KVM_CREATE_VCPU, kvmcpu));
> + kvm = open_path_or_exit(KVM_DEV_PATH, O_RDWR);
> + kvmvm = kvm_fd_ioctl(kvm, KVM_CREATE_VM, NULL);
> + kvmcpu = kvm_fd_ioctl(kvmvm, KVM_CREATE_VCPU, NULL);
>
> Side note, just in case this wasn't your intention: no kvm@ in cc.
Wasn't intentional, I was moving too fast at the end of the day and missed that
KVM wasn't Cc'd. Grr.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-08-04 15:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 0:42 [PATCH 0/4] KVM: selftests: ioctl() macro cleanups Sean Christopherson
2023-08-04 0:42 ` [PATCH 1/4] KVM: selftests: Drop the single-underscore ioctl() helpers Sean Christopherson
2023-08-04 0:42 ` [PATCH 2/4] KVM: selftests: Add helper macros for ioctl()s that return file descriptors Sean Christopherson
2023-08-04 16:46 ` Oliver Upton
2023-08-04 17:27 ` Sean Christopherson
2023-08-14 18:11 ` Sean Christopherson
2023-08-04 17:57 ` Colton Lewis
2023-08-04 18:33 ` Sean Christopherson
2023-08-04 0:42 ` [PATCH 3/4] KVM: selftests: Use asserting kvm_ioctl() macros when getting ARM page sizes Sean Christopherson
2023-08-04 14:58 ` Michal Luczaj
2023-08-04 15:23 ` Sean Christopherson [this message]
2023-08-04 0:42 ` [PATCH 4/4] KVM: selftests: Add logic to detect if ioctl() failed because VM was killed Sean Christopherson
2023-08-04 15:24 ` [PATCH 0/4] KVM: selftests: ioctl() macro cleanups Sean Christopherson
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=ZM0YCjDLGzEBWF/M@google.com \
--to=seanjc@google.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mhal@rbox.co \
--cc=oliver.upton@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).