mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
KVM: arm64: selftests: Add helper to check for VGICv3 support
Introduce a proper predicate for probing VGICv3 by performing a 'test' creation of the device on a dummy VM. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
parent
a5022da5f9
commit
b712afa7a1
|
|
@ -184,6 +184,8 @@ struct kvm_vm *test_vm_create(void)
|
|||
unsigned int i;
|
||||
int nr_vcpus = test_args.nr_vcpus;
|
||||
|
||||
TEST_REQUIRE(kvm_supports_vgic_v3());
|
||||
|
||||
vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus);
|
||||
|
||||
vm_init_descriptor_tables(vm);
|
||||
|
|
@ -205,7 +207,6 @@ struct kvm_vm *test_vm_create(void)
|
|||
|
||||
test_init_timer_irq(vm);
|
||||
gic_fd = vgic_v3_setup(vm, nr_vcpus, 64);
|
||||
__TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3");
|
||||
|
||||
/* Make all the test's cmdline args visible to the guest */
|
||||
sync_global_to_guest(vm, test_args);
|
||||
|
|
|
|||
|
|
@ -952,7 +952,6 @@ static void test_vm_create(struct kvm_vm **vm, struct kvm_vcpu **vcpu,
|
|||
|
||||
test_init_timer_irq(*vm, *vcpu);
|
||||
gic_fd = vgic_v3_setup(*vm, 1, 64);
|
||||
__TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3");
|
||||
|
||||
sync_global_to_guest(*vm, test_args);
|
||||
sync_global_to_guest(*vm, CVAL_MAX);
|
||||
|
|
@ -1042,6 +1041,8 @@ int main(int argc, char *argv[])
|
|||
/* Tell stdout not to buffer its content */
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
TEST_REQUIRE(kvm_supports_vgic_v3());
|
||||
|
||||
if (!parse_args(argc, argv))
|
||||
exit(KSFT_SKIP);
|
||||
|
||||
|
|
|
|||
|
|
@ -752,7 +752,6 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
|
|||
vcpu_args_set(vcpu, 1, args_gva);
|
||||
|
||||
gic_fd = vgic_v3_setup(vm, 1, nr_irqs);
|
||||
__TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3, skipping");
|
||||
|
||||
vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
|
||||
guest_irq_handlers[args.eoi_split][args.level_sensitive]);
|
||||
|
|
@ -802,6 +801,8 @@ int main(int argc, char **argv)
|
|||
int opt;
|
||||
bool eoi_split = false;
|
||||
|
||||
TEST_REQUIRE(kvm_supports_vgic_v3());
|
||||
|
||||
while ((opt = getopt(argc, argv, "hn:e:l:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
|
|
|
|||
|
|
@ -215,8 +215,6 @@ static void setup_test_data(void)
|
|||
static void setup_gic(void)
|
||||
{
|
||||
gic_fd = vgic_v3_setup(vm, test_data.nr_cpus, 64);
|
||||
__TEST_REQUIRE(gic_fd >= 0, "Failed to create GICv3");
|
||||
|
||||
its_fd = vgic_its_setup(vm);
|
||||
}
|
||||
|
||||
|
|
@ -374,6 +372,8 @@ int main(int argc, char **argv)
|
|||
u32 nr_threads;
|
||||
int c;
|
||||
|
||||
TEST_REQUIRE(kvm_supports_vgic_v3());
|
||||
|
||||
while ((c = getopt(argc, argv, "hv:d:e:i:")) != -1) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
|
|
|
|||
|
|
@ -436,8 +436,6 @@ static void create_vpmu_vm(void *guest_code)
|
|||
vpmu_vm.vcpu = aarch64_vcpu_add(vpmu_vm.vm, 0, &init, guest_code);
|
||||
vcpu_init_descriptor_tables(vpmu_vm.vcpu);
|
||||
vpmu_vm.gic_fd = vgic_v3_setup(vpmu_vm.vm, 1, 64);
|
||||
__TEST_REQUIRE(vpmu_vm.gic_fd >= 0,
|
||||
"Failed to create vgic-v3, skipping");
|
||||
|
||||
/* Make sure that PMUv3 support is indicated in the ID register */
|
||||
dfr0 = vcpu_get_reg(vpmu_vm.vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1));
|
||||
|
|
@ -634,6 +632,7 @@ int main(void)
|
|||
uint64_t i, pmcr_n;
|
||||
|
||||
TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_PMU_V3));
|
||||
TEST_REQUIRE(kvm_supports_vgic_v3());
|
||||
|
||||
pmcr_n = get_pmcr_n_limit();
|
||||
for (i = 0; i <= pmcr_n; i++) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
((uint64_t)(flags) << 12) | \
|
||||
index)
|
||||
|
||||
bool kvm_supports_vgic_v3(void);
|
||||
int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs);
|
||||
|
||||
#define VGIC_MAX_RESERVED 1023
|
||||
|
|
|
|||
|
|
@ -15,6 +15,17 @@
|
|||
#include "gic.h"
|
||||
#include "gic_v3.h"
|
||||
|
||||
bool kvm_supports_vgic_v3(void)
|
||||
{
|
||||
struct kvm_vm *vm = vm_create_barebones();
|
||||
int r;
|
||||
|
||||
r = __kvm_test_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3);
|
||||
kvm_vm_free(vm);
|
||||
|
||||
return !r;
|
||||
}
|
||||
|
||||
/*
|
||||
* vGIC-v3 default host setup
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user