-
Notifications
You must be signed in to change notification settings - Fork 17
XTF on arm #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
XTF on arm #4
Changes from 5 commits
7c6454f
ff0017f
7b67c42
e110999
4bce24e
31e12f6
13eddf5
11bd786
0cb05ca
309fd29
fcdf8db
ea0093e
c14f7dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| *.pyc | ||
| *.pyo | ||
| *.swp | ||
| /arch/x86/*.lds | ||
| /arch/*/*.lds | ||
| /cscope.* | ||
| /dist/ | ||
| /docs/autogenerated/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,24 @@ Xen Test Framework | |
|
|
||
| Build requirements: | ||
| - GNU Make >= 3.81 | ||
| For x86: | ||
| - GNU compatible compiler, capable of: | ||
| -std=gnu99 | ||
| -m64 and -m32 | ||
| For arm64/arm32: | ||
| -when cross-compiling: | ||
| - GNU compatible cross-compiler toolchain for Aarch64/Aarch32 | ||
| -when building natively: | ||
| - GNU compatible toolchain for Aarch64/Aarch32 | ||
|
|
||
| To build XTF: | ||
| -for x86: | ||
| $ make | ||
| -for arm64 natively: | ||
| $ make ARCH=arm64 | ||
| -for arm64 when cross compiling: | ||
| $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- | ||
| -for arm32 natively: | ||
| $ make ARCH=arm32 | ||
| -for arm32 when cross compiling: | ||
| $ make ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabi- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (After the change is made to implement this, as discussed on Aug 17th:)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in #5 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| MAKEFLAGS += -rR | ||
| ROOT := $(abspath $(CURDIR)) | ||
| export ROOT | ||
|
|
||
| # $(xtfdir) defaults to $(ROOT) so development and testing can be done | ||
| # straight out of the working tree. | ||
|
|
@@ -19,7 +18,16 @@ endif | |
|
|
||
| xtftestdir := $(xtfdir)/tests | ||
|
|
||
| export DESTDIR xtfdir xtftestdir | ||
| # Supported architectures | ||
| SUPPORTED_ARCH := x86 arm64 arm32 | ||
| # Default architecture | ||
| ARCH ?= x86 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Discussed on the 17th Aug:) Switch this to default to the build host arch
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in #5 |
||
| # Check if specified architecture is supported | ||
| ifeq ($(filter $(ARCH),$(SUPPORTED_ARCH)),) | ||
| $(error Architecture '$(ARCH)' not supported) | ||
| endif | ||
|
|
||
| export ROOT DESTDIR ARCH xtfdir xtftestdir | ||
|
|
||
| ifeq ($(LLVM),) # GCC toolchain | ||
| CC := $(CROSS_COMPILE)gcc | ||
|
|
@@ -50,9 +58,16 @@ PYTHON ?= $(PYTHON_INTERPRETER) | |
|
|
||
| export CC LD CPP INSTALL INSTALL_DATA INSTALL_DIR INSTALL_PROGRAM OBJCOPY PYTHON | ||
|
|
||
| # Some tests are architecture specific. In this case we can have a list of tests | ||
| # supported by a given architecture in $(ROOT)/build/$(ARCH)/arch-tests.mk | ||
| -include $(ROOT)/build/$(ARCH)/arch-tests.mk | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think there could be a way to support having each test indicate its compatibility within the individual test Makefile instead? It will make it easier for maintaining downstream tests since it will avoid changes being needed in these arch-test lists. eg. something like: |
||
|
|
||
| # By default enable all the tests | ||
| TESTS ?= $(wildcard tests/*) | ||
|
|
||
| .PHONY: all | ||
| all: | ||
| @set -e; for D in $(wildcard tests/*); do \ | ||
| @set -e; for D in $(TESTS); do \ | ||
| [ ! -e $$D/Makefile ] && continue; \ | ||
| $(MAKE) -C $$D build; \ | ||
| done | ||
|
|
@@ -61,7 +76,7 @@ all: | |
| install: | ||
| @$(INSTALL_DIR) $(DESTDIR)$(xtfdir) | ||
| $(INSTALL_PROGRAM) xtf-runner $(DESTDIR)$(xtfdir) | ||
| @set -e; for D in $(wildcard tests/*); do \ | ||
| @set -e; for D in $(TESTS); do \ | ||
| [ ! -e $$D/Makefile ] && continue; \ | ||
| $(MAKE) -C $$D install; \ | ||
| done | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include <xtf/asm_macros.h> | ||
|
|
||
| #define ZIMAGE_MAGIC_NUMBER 0x016f2818 | ||
|
|
||
| .arm | ||
|
|
||
| /* | ||
| * Common register usage for assembly boot code | ||
| * | ||
| * r10 - DTB physical address (boot CPU only) | ||
| * r9 - Offset between PA and VA ( PA - VA) | ||
| */ | ||
| ENTRY(_start) | ||
| /* 8 NOPs that make the compressed kernel bootable on legacy ARM systems */ | ||
| .rept 8 | ||
| mov r0, r0 | ||
| .endr | ||
| b startup | ||
| /* Magic number used to identify this is an ARM Linux zImage */ | ||
| .word ZIMAGE_MAGIC_NUMBER | ||
| /* The address the zImage starts at (0 = relocatable) */ | ||
| .word 0 | ||
| /* The address the zImage ends at */ | ||
| .word (_end - _start) | ||
| startup: | ||
| /* Save DTB pointer */ | ||
| mov r10, r2 | ||
|
|
||
| /* Calculate where we are */ | ||
| ldr r0, =_start /* r0 := vaddr(_start) */ | ||
| adr r8, _start /* r8 := paddr(_start) */ | ||
| sub r9, r8, r0 /* r9 := phys-offset */ | ||
|
|
||
| /* Start an infinite loop */ | ||
| 1: b 1b |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include <xtf/asm_macros.h> | ||
| #include <xen/xen.h> | ||
|
|
||
| #define __HVC(imm16) .long \ | ||
| ((0xE1400070 | (((imm16) & 0xFFF0) << 4) | ((imm16) & 0x000F)) & 0xFFFFFFFF) | ||
|
|
||
| #define HYPERCALL_SIMPLE(hypercall) \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both .S was borrowed from Linux right? If so, that's fine because the license is not GPL. But please retain the copyright from the author. |
||
| ENTRY(hypercall_##hypercall) \ | ||
| mov r12, #__HYPERVISOR_##hypercall; \ | ||
| __HVC(XEN_HYPERCALL_TAG); \ | ||
| mov pc ,lr; \ | ||
| ENDFUNC(hypercall_##hypercall) | ||
|
|
||
| #define HYPERCALL0 HYPERCALL_SIMPLE | ||
| #define HYPERCALL1 HYPERCALL_SIMPLE | ||
| #define HYPERCALL2 HYPERCALL_SIMPLE | ||
| #define HYPERCALL3 HYPERCALL_SIMPLE | ||
| #define HYPERCALL4 HYPERCALL_SIMPLE | ||
|
|
||
| #define HYPERCALL5(hypercall) \ | ||
| ENTRY(hypercall_##hypercall) \ | ||
| stmdb sp!, {r4}; \ | ||
| ldr r4, [sp, #4]; \ | ||
| mov r12, #__HYPERVISOR_##hypercall; \ | ||
| __HVC(XEN_HYPERCALL_TAG); \ | ||
| ldm sp!, {r4}; \ | ||
| mov pc ,lr; \ | ||
| ENDFUNC(hypercall_##hypercall) | ||
|
|
||
| .text | ||
|
|
||
| HYPERCALL2(xen_version); | ||
| HYPERCALL3(console_io); | ||
| HYPERCALL3(grant_table_op); | ||
| HYPERCALL2(sched_op); | ||
| HYPERCALL2(event_channel_op); | ||
| HYPERCALL2(hvm_op); | ||
| HYPERCALL2(memory_op); | ||
| HYPERCALL2(physdev_op); | ||
| HYPERCALL3(vcpu_op); | ||
| HYPERCALL1(tmem_op); | ||
| HYPERCALL2(multicall); | ||
| HYPERCALL2(vm_assist); | ||
| HYPERCALL1(sysctl); | ||
| HYPERCALL1(domctl); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this hypercall list in any specific order?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wrappers were borrowed from Linux(with little modifications) and the list is not sorted. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include <xtf/asm_macros.h> | ||
|
|
||
| /* | ||
| * flush_dcache_range(start, end) | ||
| * - x0(start) - start address of a region | ||
| * - x1(end) - end address of a region | ||
| * Clobbers: x2, x3, x4 | ||
| */ | ||
| ENTRY(flush_dcache_range) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was difficult to understand whether the function would clean or just clean & invalidate the cache. How about renaming the function to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will rename it to clean_and_invalidate_dcache |
||
| /* Do not modify x0 */ | ||
| mov x4, x0 | ||
| /* Get the minimum D-cache line size */ | ||
| mrs x3, ctr_el0 | ||
| ubfm x3, x3, #16, #19 | ||
| mov x2, #4 | ||
| lsl x2, x2, x3 | ||
| sub x3, x2, #1 | ||
| bic x4, x4, x3 | ||
| /* Clean and invalidate D-cache line */ | ||
| 1: dc civac, x4 | ||
| add x4, x4, x2 | ||
| cmp x4, x1 | ||
| b.lo 1b | ||
| dsb sy | ||
| ret | ||
| ENDFUNC(flush_dcache_range) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #include <arch/page.h> | ||
| #include <xtf/asm_macros.h> | ||
| #include <xen/xen.h> | ||
|
|
||
| /* 1 if BE, 0 if LE */ | ||
| #define HEAD_FLAG_ENDIANNESS 0 | ||
| #define HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2) | ||
| #define HEAD_FLAG_PHYS_BASE 1 | ||
| #define HEAD_FLAGS ((HEAD_FLAG_ENDIANNESS << 0) | \ | ||
| (HEAD_FLAG_PAGE_SIZE << 1) | \ | ||
| (HEAD_FLAG_PHYS_BASE << 3)) | ||
|
|
||
| /* | ||
| * Print a string on the debug console | ||
| * | ||
| * Clobbers: x0, x1, x2, x3, x16 | ||
| */ | ||
| #define PRINT(s) \ | ||
| adr x2, 98f; \ | ||
| mov x1, #0; \ | ||
| 97: ldrb w3, [x2, x1]; \ | ||
| add x1, x1, #1; \ | ||
| cbnz w3, 97b; \ | ||
| mov x0, #CONSOLEIO_write; \ | ||
| mov x16, #__HYPERVISOR_console_io; \ | ||
| hvc #XEN_HYPERCALL_TAG; \ | ||
| .pushsection .rodata.str, "aMS", %progbits, 1; \ | ||
| 98: .asciz s; \ | ||
| .popsection | ||
|
|
||
| .section ".bss.page_aligned" | ||
| .p2align PAGE_SHIFT | ||
|
|
||
| .text | ||
| b _start /* branch to kernel start, magic */ | ||
| .long 0 /* Executable code */ | ||
| .quad 0x0 /* Image load offset from start of RAM */ | ||
| .quad _end - _start /* Effective Image size */ | ||
| .quad HEAD_FLAGS /* Informative flags, little-endian */ | ||
| .quad 0 /* reserved */ | ||
| .quad 0 /* reserved */ | ||
| .quad 0 /* reserved */ | ||
| .byte 0x41 /* Magic number, "ARM\x64" */ | ||
| .byte 0x52 | ||
| .byte 0x4d | ||
| .byte 0x64 | ||
| .long 0 /* reserved */ | ||
|
|
||
|
|
||
| /* Load a physical address of \sym to \xb */ | ||
| .macro load_paddr xb, sym | ||
| ldr \xb, =\sym | ||
| add \xb, \xb, x21 | ||
| .endm | ||
|
|
||
| /* | ||
| * Common register usage for assembly boot code | ||
| * | ||
| * x20 - DTB physical address (boot CPU only) | ||
| * x21 - Offset between PA and VA ( PA - VA) | ||
| * x30 - lr | ||
| */ | ||
| ENTRY(_start) | ||
| /* Save DTB pointer */ | ||
| mov x20, x0 | ||
|
|
||
| /* Calculate where we are */ | ||
| ldr x22, =_start /* x22 := vaddr(_start) */ | ||
| adr x21, _start /* x21 := paddr(_start) */ | ||
| sub x21, x21, x22 /* x21 := phys-offset */ | ||
|
|
||
| PRINT("- XTF booting -\n") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to make these messages only output for XTF debug configurations? At the moment, running a XTF test on Arm will generate different console output than running the same test on x86, which will make writing an architecture-independent parser more difficult.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I'm thinking of right now is adding DEBUG variable which by default will be set to =n. When specifying DEBUG=y on the command line when invoking make, those early prints should be executed. What do u think about it? I may need to discuss this with Andrew. |
||
|
|
||
| PRINT("- Zero BSS -\n") | ||
|
|
||
| load_paddr x0, __start_bss | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find a bit odd that the arm32 code and arm64 patches already diverge in this commit. I think it would be better if that code stay in par in each commit touch 32-bit and 64-bit. If you want to add more code for arm64, that's fine. But I would suggest to do it separately. |
||
| load_paddr x1, __end_bss | ||
|
|
||
| bl flush_dcache_range | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to document in the code why the flush is necessary.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will |
||
| 1: str xzr, [x0], #8 | ||
| cmp x0, x1 | ||
| b.lo 1b | ||
|
|
||
| /* Load BSS start address again as x0 has been modified in the upper loop */ | ||
| load_paddr x0, __start_bss | ||
| bl flush_dcache_range | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to document in the code why the flush is necessary.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will |
||
|
|
||
| /* Start an infinite loop */ | ||
| PRINT("- Infinite loop -\n") | ||
| 2: b 2b | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include <xtf/asm_macros.h> | ||
| #include <xen/xen.h> | ||
|
|
||
| #define HYPERCALL_SIMPLE(hypercall) \ | ||
| ENTRY(hypercall_##hypercall) \ | ||
| mov x16, #__HYPERVISOR_##hypercall; \ | ||
| hvc XEN_HYPERCALL_TAG; \ | ||
| ret; \ | ||
| ENDFUNC(hypercall_##hypercall) | ||
|
|
||
| #define HYPERCALL0 HYPERCALL_SIMPLE | ||
| #define HYPERCALL1 HYPERCALL_SIMPLE | ||
| #define HYPERCALL2 HYPERCALL_SIMPLE | ||
| #define HYPERCALL3 HYPERCALL_SIMPLE | ||
| #define HYPERCALL4 HYPERCALL_SIMPLE | ||
| #define HYPERCALL5 HYPERCALL_SIMPLE | ||
|
|
||
| .text | ||
|
|
||
| HYPERCALL2(xen_version); | ||
| HYPERCALL3(console_io); | ||
| HYPERCALL3(grant_table_op); | ||
| HYPERCALL2(sched_op); | ||
| HYPERCALL2(event_channel_op); | ||
| HYPERCALL2(hvm_op); | ||
| HYPERCALL2(memory_op); | ||
| HYPERCALL2(physdev_op); | ||
| HYPERCALL3(vcpu_op); | ||
| HYPERCALL1(tmem_op); | ||
| HYPERCALL2(multicall); | ||
| HYPERCALL2(vm_assist); | ||
| HYPERCALL1(sysctl); | ||
| HYPERCALL1(domctl); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments as for the 32-bit version
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check my comment for arm32 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * @file arch/arm/decode.c | ||
| * | ||
| * Helper routines for decoding arm architectural state. | ||
| */ | ||
| #include <xtf/lib.h> | ||
| #include <xtf/libc.h> | ||
|
|
||
| bool arch_fmt_pointer( | ||
| char **str_ptr, char *end, const char **fmt_ptr, const void *arg, | ||
| int width, int precision, unsigned int flags) | ||
| { | ||
| UNIMPLEMENTED(); | ||
| return false; | ||
| } | ||
|
|
||
| /* | ||
| * Local variables: | ||
| * mode: C | ||
| * c-file-style: "BSD" | ||
| * c-basic-offset: 4 | ||
| * tab-width: 4 | ||
| * indent-tabs-mode: nil | ||
| * End: | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ make ARCH=x86There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #5