All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Marc Zyngier <maz@kernel.org>, Sebastian Ott <sebott@redhat.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	kvm@vger.kernel.org,  kvmarm@lists.linux.dev,
	linux-kselftest@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: fix irqfd_test on arm64
Date: Tue, 26 Aug 2025 11:51:18 -0700	[thread overview]
Message-ID: <aK4CJnNxB6omPufp@google.com> (raw)
In-Reply-To: <aKzX152737nAo479@linux.dev>

On Mon, Aug 25, 2025, Oliver Upton wrote:
> On Mon, Aug 25, 2025 at 02:11:30PM -0700, Sean Christopherson wrote:
> > On Mon, Aug 25, 2025, Marc Zyngier wrote:
> > > On Mon, 25 Aug 2025 20:52:21 +0100,
> > > Sean Christopherson <seanjc@google.com> wrote:
> > > > Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()?  E.g.
> > > > could we create a v3 GIC when possible, and fall back to v2?  And then provide a
> > > > way for tests to express a hard v3 GIC dependency?
> > > 
> > > You can ask KVM what's available. Like an actual VMM does. There is no
> > > shortage of examples in the current code base.
> > 
> > Right, by "sane" I meant: is there a way to instantiate a supported GIC without
> > making it hard/painful to write tests, and without having to plumb in arm64
> > specific requirements to common APIs?
> > 
> > E.g. are there tests that use the common vm_create() APIs and rely on NOT having
> > a GIC?
> 
> Instead of stuffing a GIC in behind vm_create(), I'd rather we have a
> specific helper for creating a VM with an irqchip. There's tests in
> arm64 that rely on all this generic infrastructure and also need to
> select / dimension a GIC appropriately for the test.

I've no objection to arm64 providing an API for tests that need a specific GIC
configuration (I think it's a great idea), but I don't think that needs to be
mutually exclusive with having the common APIs instantiate _a_ GIC by default.

What if we use a global flag with thread local storage (because paranoia is
basically free, I think) to communicate that the test wants to create a v3 vGIC?

E.g.

---
static __thread bool vm_wants_custom_vgic;

void kvm_arch_vm_post_create(struct kvm_vm *vm)
{
	if (!vm_wants_custom_vgic) {
		<setup default vgic>
	}
}

struct kvm_vm *vm_create_with_vgic_v3(uint32_t nr_vcpus, void *guest_code,
				      uint32_t nr_irqs, struct kvm_vcpu **vcpus)
{
	TEST_ASSERT(!vm_wants_custom_vgic, "blah blah blah");
	vm_wants_custom_vgic = true;
	vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus)
	vm_wants_custom_vgic = false;

	vgic_v3_setup(vm, nr_vcpus, nr_irqs);
}

struct kvm_vm *vm_create_with_one_vcpu_and_vgic_v3(struct kvm_vcpu **vcpu,
						   void *guest_code,
						   uint32_t nr_irqs)
{
	struct kvm_vcpu *vcpus[1];
	struct kvm_vm *vm;

	vm = vm_create_with_vgic_v3(1, guest_code, nr_irqs, vcpus);

	*vcpu = vcpus[0];
	return vm;
}
---

> The majority of selftests don't even need an irqchip anyway.

But it's really, really nice for developers if they can assume a certain level of
configuration is done by the infrastructure, i.e. don't have worry about doing
what is effectively "basic" VM setup.

E.g. x86 selftests creates an IRQCHIP, sets up descriptor tables and exception
handlers, and a handful of other "basic" things, and that has eliminated soooo
much boilerplate code and the associated friction with having to know/discover
that e.g. sending IRQs in a test requires additional setup beyond the obvious
steps like wiring up a handler.

  reply	other threads:[~2025-08-26 18:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 15:52 [PATCH] KVM: selftests: fix irqfd_test on arm64 Sebastian Ott
2025-08-25 19:52 ` Sean Christopherson
2025-08-25 20:51   ` Marc Zyngier
2025-08-25 21:11     ` Sean Christopherson
2025-08-25 21:38       ` Oliver Upton
2025-08-26 18:51         ` Sean Christopherson [this message]
2025-08-26 19:24           ` Oliver Upton
2025-08-26 20:41             ` Sean Christopherson
2025-09-30 15:14               ` Sean Christopherson
2025-09-30 18:26                 ` Oliver Upton
2025-09-30 19:29                   ` 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=aK4CJnNxB6omPufp@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=sebott@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.