lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aK4CJnNxB6omPufp@google.com>
Date: Tue, 26 Aug 2025 11:51:18 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Oliver Upton <oliver.upton@...ux.dev>
Cc: Marc Zyngier <maz@...nel.org>, Sebastian Ott <sebott@...hat.com>, 
	Paolo Bonzini <pbonzini@...hat.com>, Shuah Khan <shuah@...nel.org>, kvm@...r.kernel.org, 
	kvmarm@...ts.linux.dev, linux-kselftest@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

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@...gle.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ