Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.pyc
*.pyo
*.swp
/arch/x86/*.lds
/arch/*/*.lds
/cscope.*
/dist/
/docs/autogenerated/
Expand Down
18 changes: 18 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ make ARCH=x86

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #5

-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-
Copy link
Contributor

Choose a reason for hiding this comment

The 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:)
Doc should indicate that if ARCH is not specified, that it will default to target the same architecture as the build host.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #5

23 changes: 19 additions & 4 deletions Makefile
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.
Expand All @@ -19,7 +18,16 @@ endif

xtftestdir := $(xtfdir)/tests

export DESTDIR xtfdir xtftestdir
# Supported architectures
SUPPORTED_ARCH := x86 arm64 arm32
# Default architecture
ARCH ?= x86
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
TEST-ARCHES := $(ALL_ARCHES)
like the TEST-ENVS variable.


# 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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ Tests for more generic areas are build multiple times into different
microkernels, to test the same functionality from different types of virtual
machine.

Currently there are 3 architectures available: x86, arm64 and arm32 although
only x86 is truly supported. Initial support for arm64 is added allowing to run
hello-world test. Support for arm32 allows to run startup code.
This creates a base for future implementation.

## The framework consists of:

* PV and HVM, 32 and 64 bit entry points
* Hypercall interface
* PV console driver (output)
* Common reporting framework
* Initial support for arm64 (hello-world test running)
* Initial support for arm32 (startup code running)

## TODO List:

Expand Down
35 changes: 35 additions & 0 deletions arch/arm/arm32/head.S
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
45 changes: 45 additions & 0 deletions arch/arm/arm32/hypercall.S
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) \
Copy link

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this hypercall list in any specific order?
If not, it should be sorted into an order (eg. alphabetical, or by ascending hypercall number).
A comment should be added to state what the order is, so that any future additions will be inserted into the correct place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HYPERCALL5(argo_op);
would be nice (or it can go in when a test that exercises Argo goes in).

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
It does not really matter what the order is. Preferable way is to insert additions at the end of list.
argo_op hypercall should be added together with public interface argo.h. So this should come together with a test.

26 changes: 26 additions & 0 deletions arch/arm/arm64/cache.S
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)
Copy link

Choose a reason for hiding this comment

The 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 clean_and_invalidate_dcache()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Loading