@@ -32,30 +32,30 @@ groups = selftest
# Test SMP support
[selftest::smp]
file = selftest.flat
-smp = $(getconf _NPROCESSORS_CONF)
+smp = $(./arm/utils/kvm-query max_vcpu)
extra_params = -append 'smp'
groups = selftest
# TLB Torture Tests
[tlbflush::all_other]
file = tlbflush-test.flat
-smp = $(getconf _NPROCESSORS_CONF)
+smp = $(./arm/utils/kvm-query max_vcpu)
groups = tlbflush
[tlbflush::page_other]
file = tlbflush-test.flat
-smp = $(getconf _NPROCESSORS_CONF)
+smp = $(./arm/utils/kvm-query max_vcpu)
extra_params = -append 'page'
groups = tlbflush
[tlbflush::all_self]
file = tlbflush-test.flat
-smp = $(getconf _NPROCESSORS_CONF)
+smp = $(./arm/utils/kvm-query max_vcpu)
extra_params = -append 'self'
groups = tlbflush
[tlbflush::page_self]
file = tlbflush-test.flat
-smp = $(getconf _NPROCESSORS_CONF)
+smp = $(./arm/utils/kvm-query max_vcpu)
extra_params = -append 'page self'
groups = tlbflush
new file mode 100644
@@ -0,0 +1,41 @@
+/*
+ * kvm-query.c
+ *
+ * A simple utility to query KVM capabilities.
+ */
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <string.h>
+#include <stdio.h>
+
+#include <linux/kvm.h>
+
+int get_max_vcpu(void)
+{
+ int fd = open("/dev/kvm", O_RDWR);
+ if (fd>0) {
+ int ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
+ printf("%d\n", ret > 0 ? ret : 0);
+ close(fd);
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ for (int i=0; i<argc; i++) {
+ char *arg = argv[i];
+ if (strcmp(arg, "max_vcpu") == 0) {
+ return get_max_vcpu();
+ }
+ }
+
+ return -1;
+}
@@ -13,7 +13,9 @@ tests-common = $(TEST_DIR)/selftest.flat
tests-common += $(TEST_DIR)/spinlock-test.flat
tests-common += $(TEST_DIR)/tlbflush-test.flat
-all: test_cases
+utils-common = $(TEST_DIR)/utils/kvm-query
+
+all: test_cases utils
##################################################################
phys_base = $(LOADADDR)
@@ -58,6 +60,9 @@ FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
$(libeabi): $(eabiobjs)
$(AR) rcs $@ $^
+$(TEST_DIR)/utils/%: $(TEST_DIR)/utils/%.c
+ $(CC) -std=gnu99 -o $@ $^
+
arm_clean: libfdt_clean asm_offsets_clean
$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
$(TEST_DIR)/.*.d lib/arm/.*.d
@@ -69,6 +74,7 @@ tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
generated_files = $(asm-offsets)
test_cases: $(generated_files) $(tests-common) $(tests)
+utils: $(utils-common)
$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o