Skip to content

Conversation

@orzelmichal
Copy link
Contributor

@orzelmichal orzelmichal commented Mar 17, 2022

This patch series adds arm support into XTF and creates a base for further implementation.
Support for arm64 mostly includes:

  • MMU
  • PV console
  • running test: example (Hello World)

Support for arm32 allows to run only a startup code.

This series was tested using qemu-system-aarch64 and FVP_Base_RevC-2xAEMvA with
XTF running as dom0 or domU.

Previous discussion on v1 can be found here:
#4

Major changes since v1:

  • rebase on top of current XTF master branch
  • fixed comments from v1
  • no non-MMU environment for arm64
  • no PL011 driver
  • no test-naming/xtf-runner modifications to make OSSTEST happy

Please review, comment, ask questions.

Currently XTF build system is strictly made up for x86.
Modify the build system so that it will be easier
to add other architectures to XTF in the future.
This is done by generalizing the common makefiles to be
architecture independent and creating architecture
specific makefiles.

ARCH variable behaviour:
By default ARCH is set to the host architecture where make is executed,
provided that it is supported by XTF.
In order to perform cross compilation, ARCH needs to be set to the target
architecture (when invoking make) e.g. ARCH=x86, together with specifying
cross compiler prefix e.g. CROSS_COMPILE=x86_64-linux-gnu-.

Introduce new variable called BASE_ARCH that contains the name
of the architecture devoided of information about bitness.
It may be that BASE_ARCH == ARCH for some architectures.
For example:
ARCH=x86, BASE_ARCH=x86
ARCH=arm{64,32}, BASE_ARCH=arm
ARCH=riscv{64,32}, BASE_ARCH=riscv

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add initial support to XTF for arm64/arm32 without
modifying existing XTF architecture.
Some of the files are just dummy files waiting to be properly
implemented step by step later on.

The purpose of this change is to add the initial code and minimal
set of files to support XTF on arm without modifying the existing
XTF design. This creates a base for further implementation.

Based-on-the-work-from: Julien Grall <julien@xen.org>
Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add BSS zeroing into arm64 startup code head.S and implement
a function clean_and_invalidate_dcache. Image protocol states
that the state of the cache for BSS region is not known as BSS
is not part of the loaded image. This is why it is required to
invalidate the cache before and after zeroing BSS.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add support for arm64/arm32 in the build system, modify
the common headers to be aware of the new architectures
and update the documentation.

Architecture can be set using: ARCH=arm64 or ARCH=arm32.

Currently only one test: tests/example is supported allowing
the startup code head.S to be executed ending up in an infinite
loop. Debug messages are printed using hypercall console_io.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Each architecture needs to define its own hypercall handling interface.
The hypercall handler should be named as follows:
hypercall_<hypercall_name>
e.g. hypercall_console_io

The reason for that is to have a standard way of calling hypercalls
in the common code.

Modify the common <xtf/hypercall.h> header to be architecture
independent and move x86 handlers to architecture specific code.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add the hypercall wrappers for arm64 and arm32 from Linux.
The hypercalls are defined in the assembly files hypercall.S and they
are specific to arm64/arm32.

The prototypes and higher level wrappers are defined in
arch/arm/include/arch/hypercall.h as they are common to both arm64
and arm32.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Improve the startup code for arm64 and implement the proper traps
handling for arm.

At this point it would be possible to jump to the C world. However
MMU and PV console support shall be done first.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add the following to the startup code head.S:
-setup boot page tables
-setup identity mapping
-enable MMU

MMU configuration:
-granularity: 4KB
-VA width: 39bit
-VA start: 0xffffff8000000000
-3 levels of lookup: L1->L2->2M blocks, L2->L3->4KB pages(fixmap)
-1GB identity mapping removed before jumping into C

Modify the arm64 environment from 64le to mmu64le to reflect that
it has MMU enabled.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Add macros to convert between frame numbers and address formats.
Add functions to store page table entry and setup fixmap.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Now, when everything is ready, get rid of infinite loop from the
startup code and jump to C world.

Because there is no PV console support added yet, use
hypercall_console_io to print messages using printk so that
we can see the results from running the hello-world test.

Result:
(d1) - XTF booting -
(d1) - Setup CPU -
(d1) - Setup page tables -
(d1) - Enable MMU -
(d1) - Zero BSS -
(d1) - Setup stack -
(d1) - Jump to C world-
(d1) --- Xen Test Framework ---
(d1) Environment: ARM64 LE MMU
(d1) Hello World
(d1) Test result: SUCCESS

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
... together with public header features.h storing
feature flags reported by XENVER_get_features.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
... so that we can connect to a guest console using xl console.

PV console should not be used when XTF is running as dom0. For that
purpose, implement a function is_initdomain that uses
hypercall xen_version to get Xen features and checks if bit
XENFEAT_dom0 is set.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant