@@ -72,6 +72,8 @@ $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
$(TEST_DIR)/realmode.o: bits = $(if $(call cc-option,-m16,""),16,32)
+$(TEST_DIR)/access_test.elf: $(TEST_DIR)/access.o
+
$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o
$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o
@@ -9,7 +9,7 @@ cflatobjs += lib/x86/setjmp64.o
cflatobjs += lib/x86/intel-iommu.o
cflatobjs += lib/x86/usermode.o
-tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
+tests = $(TEST_DIR)/access_test.flat $(TEST_DIR)/apic.flat \
$(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
$(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
$(TEST_DIR)/pcid.flat $(TEST_DIR)/debug.flat \
@@ -1,9 +1,9 @@
-
#include "libcflat.h"
#include "desc.h"
#include "processor.h"
#include "asm/page.h"
#include "x86/vm.h"
+#include "access.h"
#define smp_id() 0
@@ -14,7 +14,7 @@ static _Bool verbose = false;
typedef unsigned long pt_element_t;
static int invalid_mask;
-static int page_table_levels;
+int page_table_levels;
#define PT_BASE_ADDR_MASK ((pt_element_t)((((pt_element_t)1 << 36) - 1) & PAGE_MASK))
#define PT_PSE_BASE_ADDR_MASK (PT_BASE_ADDR_MASK & ~(1ull << 21))
@@ -1069,7 +1069,7 @@ const ac_test_fn ac_test_cases[] =
check_effective_sp_permissions,
};
-static int ac_test_run(void)
+int ac_test_run()
{
ac_test_t at;
ac_pool_t pool;
@@ -1150,21 +1150,3 @@ static int ac_test_run(void)
return successes == tests;
}
-
-int main(void)
-{
- int r;
-
- printf("starting test\n\n");
- page_table_levels = 4;
- r = ac_test_run();
-
- if (this_cpu_has(X86_FEATURE_LA57)) {
- page_table_levels = 5;
- printf("starting 5-level paging test.\n\n");
- setup_5level_page_table();
- r = ac_test_run();
- }
-
- return r ? 0 : 1;
-}
new file mode 100644
@@ -0,0 +1,8 @@
+#ifndef X86_ACCESS_H
+#define X86_ACCESS_H
+
+int ac_test_run(void);
+
+extern int page_table_levels;
+
+#endif // X86_ACCESS_H
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,22 @@
+#include "libcflat.h"
+#include "processor.h"
+#include "x86/vm.h"
+#include "access.h"
+
+int main(void)
+{
+ int r;
+
+ printf("starting test\n\n");
+ page_table_levels = 4;
+ r = ac_test_run();
+
+ if (this_cpu_has(X86_FEATURE_LA57)) {
+ page_table_levels = 5;
+ printf("starting 5-level paging test.\n\n");
+ setup_5level_page_table();
+ r = ac_test_run();
+ }
+
+ return r ? 0 : 1;
+}
@@ -114,13 +114,13 @@ groups = vmexit
extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append tscdeadline_immed
[access]
-file = access.flat
+file = access_test.flat
arch = x86_64
extra_params = -cpu max
timeout = 180
[access-reduced-maxphyaddr]
-file = access.flat
+file = access_test.flat
arch = x86_64
extra_params = -cpu IvyBridge,phys-bits=36,host-phys-bits=off
timeout = 180
Move main out of access.c in preparation for running the test in L2. This allows access.c to be used as common code that will be included in a nested tests later in this series. Signed-off-by: Aaron Lewis <aaronlewis@google.com> --- x86/Makefile.common | 2 ++ x86/Makefile.x86_64 | 2 +- x86/access.c | 24 +++--------------------- x86/access.h | 8 ++++++++ x86/access_test.c | 22 ++++++++++++++++++++++ x86/unittests.cfg | 4 ++-- 6 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 x86/access.h create mode 100644 x86/access_test.c