]> xenbits.xensource.com Git - people/julieng/boot-wrapper-aarch64.git/log
people/julieng/boot-wrapper-aarch64.git
8 years agoExplicitly clean linux-system.axf and xen-system.axf master xen
Christoffer Dall [Mon, 20 Jun 2016 15:09:34 +0000 (16:09 +0100)]
Explicitly clean linux-system.axf and xen-system.axf

When doing a make clean, only the output image currently configured to
build is being removed.  However, one would expect all build artifacts
to be removed when doing a 'make clean' and when switching between Xen
and Linux builds, it is easy to accidentally run an older build than
intended.  Simply hardcode the axf image file names.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
8 years agoXen: Select correct dom0 console
Ian Campbell [Mon, 20 Jun 2016 15:09:33 +0000 (16:09 +0100)]
Xen: Select correct dom0 console

If Xen is enabled, tell Dom0 to use the 'hvc0' console, and fall back to
the usual ttyAMA0 otherwise.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
8 years agoXen: Support adding DT nodes
Christoffer Dall [Mon, 20 Jun 2016 15:09:32 +0000 (16:09 +0100)]
Xen: Support adding DT nodes

Support adding xen,xen-bootargs node via --with-xen-bootargs to the
configure script and automatically add the Dom0 node to the DT as well.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
8 years agoSupport for building in a Xen binary
Christoffer Dall [Mon, 20 Jun 2016 15:09:31 +0000 (16:09 +0100)]
Support for building in a Xen binary

Add support for building a Xen binary which includes a Dom0 image and
the Dom0 command-line.

If the user specifies --with-xen=<Xen>, where Xen is an appropriate
AArch64 Xen binary, the build system will generate a xen-system.axf
instead of a linux-system.axf.

Original patch from Ian Campbell, but I modified most of it so all bugs
are probably mine.
[Andre: adapt to newest boot-wrapper branch, increase load address]

Cc: Ian Campbell <ijc@hellion.org.uk>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
8 years agoAdd AArch32 to the boot-wrapper
Jean-Philippe Brucker [Fri, 4 Dec 2015 12:43:20 +0000 (12:43 +0000)]
Add AArch32 to the boot-wrapper

This patch allows to build a 32-bit boot-wrapper, and create a complete
linux-system.axf for models that start in AArch32. Most of the code is a
simple translation of the AArch64 side.

We add an --aarch32-bw argument to ./configure, and bump the version to
0.2, to welcome this new architecture.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoProtect against overlapping with the 32-bit kernel
Jean-Philippe Brucker [Thu, 8 Oct 2015 09:08:18 +0000 (10:08 +0100)]
Protect against overlapping with the 32-bit kernel

This patch adds a guard in the linker script to abort the build when the
bootloader code overflows the 12k limit. Indeed, 32-bit Linux with LPAE
enabled puts its initial page tables between 0x80003000 and 0x80007fff.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAdd support for 32-bit kernel
Jean-Philippe Brucker [Tue, 22 Sep 2015 09:42:15 +0000 (10:42 +0100)]
Add support for 32-bit kernel

This patch adds an --enable-aarch32-kernel parameter to ./configure,
which enables dropping into AArch32 state at EL2. Notable differences
with AArch64 boot are:

* SCR.RW is set to 0, to declare all lower levels as AArch32,
* SPSR_EL2 has a 32-bit M[4:0] field,
* kernel parameters are different, but we can still put them into x0-x2,
  because those registers are mapped to r0-r2 (ARM ARM v8 D1.20.1)
* SCTLR.CP15BEN is set, to allow the Linux decompressor to keep using
  its legacy CP15 barriers.
* We also need to make sure MMU is disabled at EL1: hyp-stub in arm64
  resets SCTLR_EL1, but the 32-bit hyp-stub doesn't. Leaving SCTRL.M set
  would break hotplug when no hypervisor is present.
* PSCI function ID for CPU_ON differs.

We don't plan to support spin method on 32-bit. PSCI is automatically
enabled by ./configure, and this patch forbids disabling it.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAdd 32-bit compatibility to device-tree CPU nodes
Jean-Philippe Brucker [Wed, 23 Sep 2015 14:21:09 +0000 (15:21 +0100)]
Add 32-bit compatibility to device-tree CPU nodes

The 32-bit DT parser in Linux doesn't understand 'reg' properties with
two cells, in a CPU node. Since the boot-wrapper always sets the upper
bits to 0, we can restrict that size to one cell.

The parser also requires the device_type property to be present. This is
the case for arm64 as well, but it only fails when the patched device-tree
doesn't have any CPU node to begin with. Add device_type unconditionally.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAArch64: get rid of EL2 trampoline
Jean-Philippe Brucker [Wed, 18 May 2016 16:32:19 +0000 (17:32 +0100)]
AArch64: get rid of EL2 trampoline

There is no harm in initialising the platform from EL3, so we move the
call into the boot_common path of CPU0, and take the opportunity to
rename ns_init_system to init_platform. Caches and MMU are now disabled
at EL3, and we can also move cache maintenance in the initial boot path
of each CPU. This allows us to get rid of the EL2 layer, which makes
AArch32 kernel support possible.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoRemove MMU identity map setup
Jean-Philippe Brucker [Thu, 10 Dec 2015 19:28:24 +0000 (19:28 +0000)]
Remove MMU identity map setup

We have a few good reasons to leave MMU disabled at EL3:

* Translations defined by our static pages might alias with the kernel,
  leading to mismatched memory attributes and all kinds of pains.

* For legacy reasons, boot-wrapper accesses are not cached at the
  moment (SCTLR_EL3.C is unset)

* It feels cumbersome to enable the MMU for one small exclusive
  operation.

* Removing the static page tables also frees 4k of memory, which is
  quite welcome when loading a 32-bit kernel case, where we only have
  12k of bootloader RAM to play with.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoReplace exclusive accesses with a bakery lock
Jean-Philippe Brucker [Thu, 10 Dec 2015 19:24:59 +0000 (19:24 +0000)]
Replace exclusive accesses with a bakery lock

The commit prepares the removal of the MMU identity map, which was only
used for exclusive accesses (ldxr/stxr) in psci_cpu_on.

Instead of relying on exclusives, we assume that when stage-1
translation is disabled, all EL3 memory accesses have Device type, with
non-gathering and non-reordering attributes. This guarantees single-copy
atomicity of aligned halfword accesses, as per the ARM ARM.

We can thus switch to a less constrained (albeit bulkier) locking
mechanism. This patch implements Lamport's bakery lock, which doesn't
rely on atomic compare-and-swap primitives.

For bisectability, we remove the call to switch_to_idmap here.
Otherwise, the assertions made by the bakery lock code, regarding order
of accesses, are invalid. The rest of the code will be removed in a
subsequent patch.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAdd GCC library functions
Jean-Philippe Brucker [Thu, 17 Dec 2015 14:59:46 +0000 (14:59 +0000)]
Add GCC library functions

GCC might generate implicit calls to standard functions, for example
memcpy when copying a struct. Implement these functions upfront, to
ensure that GCC never uses some optimized version, which could do
unaligned device memory accesses. We only implement memcpy and memset
for the moment. The others (memmove, memcmp, ...) can be added in the
future if required.

We also add flags "-ffunction-sections", "-fdata-sections" to GCC, and
"--gc-sections" to ld, in order to avoid linking those functions into
the final image when they aren't used.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoRewrite cache flush in C
Jean-Philippe Brucker [Fri, 4 Dec 2015 17:28:18 +0000 (17:28 +0000)]
Rewrite cache flush in C

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoRewrite GIC drivers in C
Jean-Philippe Brucker [Fri, 4 Dec 2015 17:21:19 +0000 (17:21 +0000)]
Rewrite GIC drivers in C

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
[Mark: fold GICv3 and GICv2 patches for bisectability]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoRewrite platform initialisation in C
Jean-Philippe Brucker [Fri, 4 Dec 2015 17:16:34 +0000 (17:16 +0000)]
Rewrite platform initialisation in C

Add two assembly helpers for 32-bit MMIO accesses, and translate
platform initialisation to C. Since we can now add features without too
much pain, also output a string describing the boot-wrapper version.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAArch64: clean common.S
Jean-Philippe Brucker [Fri, 4 Dec 2015 16:42:42 +0000 (16:42 +0000)]
AArch64: clean common.S

Remove macro drop_el since its only user is now boot.S, and move all
defines to cpu.h.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoRewrite boot methods in C
Jean-Philippe Brucker [Tue, 1 Dec 2015 19:51:23 +0000 (19:51 +0000)]
Rewrite boot methods in C

This patch brings the boot-wrapper into the twenty-first century, by
introducing it to the C language. This change, along with the next few
patches, will greatly simplify the AArch32 port and overall maintenance.

The assembly side of PSCI now only contains basic dispatchers, for both
boot and SMC entries.

Initial boot flow:
asm _start boot.S
start_(no_)el3 psci.S or spin.S
C first_spin boot_common.c
spin boot_common.c
asm jump_kernel if CPU0 boot.S

CPU_ON flow:
asm smc_entry psci.S
C psci_cpu_on psci.c
asm smc_exit psci.S

CPU_OFF flow:
asm smc_entry psci.S
C psci_cpu_off psci.c
spin boot_common.c

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAArch64: factor CPU ID getters
Jean-Philippe Brucker [Fri, 4 Dec 2015 17:39:07 +0000 (17:39 +0000)]
AArch64: factor CPU ID getters

This patch adds a simple utility to read the current CPU ID from C or
assembly. The underlying objective of this seemingly useless change is
to provide a clean base for C helpers. It introduces two include paths:
include/ and arch/*/include/asm

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAArch64: add a small stack for each CPU
Jean-Philippe Brucker [Thu, 26 Nov 2015 17:49:41 +0000 (17:49 +0000)]
AArch64: add a small stack for each CPU

When rewriting some bits of the boot-wrapper in C, we will need tiny
per-CPU stacks. This patch reserves 256 bytes of stack for each CPU
defined in the CPU_IDS macro.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoAArch64: extract common utilities from PSCI
Jean-Philippe Brucker [Mon, 14 Dec 2015 19:39:46 +0000 (19:39 +0000)]
AArch64: extract common utilities from PSCI

Helpers find_logical_id and setup_vector, as well as the number of
expected CPUs, will be needed outside of PSCI during future refactoring
work. This patch puts them into utils.S, and moves the number of CPUs
one level up, in a macro defined by the Makefile.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoMove all sources to arch-specific folder
Jean-Philippe Brucker [Wed, 16 Sep 2015 15:18:05 +0000 (16:18 +0100)]
Move all sources to arch-specific folder

This patch moves all assembly to arch/aarch64.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoMake the linker script more generic
Jean-Philippe Brucker [Tue, 1 Dec 2015 19:51:56 +0000 (19:51 +0000)]
Make the linker script more generic

Attempt to make the linker script more flexible, by removing explicit
object names. We move boot code into a ".init" section, and let ld freely
reorganize the rest.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoClean up image layout
Jean-Philippe Brucker [Wed, 7 Oct 2015 18:20:43 +0000 (19:20 +0100)]
Clean up image layout

This patch moves page tables and vectors to their own section, in order
to avoid big alignment gaps in the middle of .text or .data. We also
remove all .org directives, as they are not needed.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoPass object files on the ld command line
Jean-Philippe Brucker [Thu, 26 Nov 2015 18:04:11 +0000 (18:04 +0000)]
Pass object files on the ld command line

The 32-bit linker struggles with INPUT directives in linker scripts, and
tends to include the whole ELF files instead of merging their sections.

Remove INPUT for object files and pass them as arguments to ld instead.
Also sneakily remove the orphan "BOOTLOADER" variable from Makefile.am,
since we're cleaning things up. It hasn't been used for a while.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
8 years agoClean up PSCI function IDs
Jean-Philippe Brucker [Fri, 22 Apr 2016 12:51:48 +0000 (13:51 +0100)]
Clean up PSCI function IDs

The boot-wrapper allows to boot secondary CPUs through a PSCI interface.
This implementation is incomplete, and only understands two SMC calls,
CPU_ON and CPU_OFF. Since PSCI versions >=0.2 require to implement a few
more functions (VERSION, SUSPEND, SYSTEM_OFF...), we implement PSCI 0.1,
which doesn't specify what SMC numbers to use. An implementation needs
to advertise its SMC numbers to the kernel through device-tree nodes.

Our current SMC numbers are inconsistent with the rest of the world:

                 |  B-W (0.1)   | U-boot (0.1) |     v0.2
  ---------------+--------------+--------------+--------------
         CPU_OFF |  0x84000001  |  0x95c1ba5f  |  0x84000002
  64-bit CPU_ON  |  0x84000002  |  0x95c1ba60  |  0xc4000003

This is a problem when testing systems like Jailhouse, that currently
don't read the device-tree but hard-code PSCI IDs. To align with the
rest of the world, switch to PSCI 0.2 IDs.

Note: this patch does *not* add PSCI 0.2 compatibility to the
boot-wrapper. We still advertise as 0.1.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years agobootwrapper: improve UART initialisation
Andre Przywara [Tue, 29 Jul 2014 16:18:51 +0000 (17:18 +0100)]
bootwrapper: improve UART initialisation

The PL011 spec requires that baud rate settings should be done by
writing both xBRD registers followed by a write to LCR_H (which we
skipped so far completely).[1]
So include the FBRD register write as well and set up the LCR_H
register to initialise the UART to 8N1.
Also skip the automatic RTS/CTS enablement, as this may not be
used by the peer (and the generic UART does not have it at all).

[1] ARM PL011 TRM, 3.3.7 (top of page 3-14)

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
10 years agoSet sctlr_el2 to predefined state for all CPUs
Vladimir Murzin [Fri, 8 Aug 2014 10:35:08 +0000 (11:35 +0100)]
Set sctlr_el2 to predefined state for all CPUs

Currently, sctlr_el2 is initialised only in the cold boot path, and even then
we didn't set the RES1 bits. So we're lucky the cold boot path ever worked
given most of the bits are UNKNOWN.

Lack of initialisation in the hot boot path leads to kernel crash while CPU is
hot-plugging and KVM is enabled:

root@genericarmv8:~# echo 0 > /sys/devices/system/cpu/cpu1/online
kvm: disabling virtualization on CPU1
CPU1: shutdown
root@genericarmv8:~# echo 1 > /sys/devices/system/cpu/cpu1/online
Kernel panic - not syncing: HYP panic:
PS:000003c9 PC:0000000080002394 ESR:0000000086000005
FAR:0000000080002394 HPFAR:          (null) PAR:          (null)
VCPU:          (null)

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.16.0-rc1+ #162
Call trace:
[<ffffffc0000880d8>] dump_backtrace+0x0/0x12c
[<ffffffc000088214>] show_stack+0x10/0x1c
[<ffffffc000472680>] dump_stack+0x74/0xc4
[<ffffffc00046f8ec>] panic+0xe4/0x21c
[<ffffffc00046f804>] mmu_memory_cache_alloc.part.25+0x34/0x38
[<ffffffc00008a26c>] cpu_psci_cpu_die+0x20/0x40
[<ffffffc00008e95c>] cpu_die+0x40/0x70
[<ffffffc0000852e0>] arch_cpu_idle_dead+0x8/0x14
[<ffffffc0000dca4c>] cpu_startup_entry+0x144/0x14c
[<ffffffc00008e7f0>] secondary_start_kernel+0x118/0x128

Initialise sctlr_el2 in the reset value just before dropping from EL3 for psci
and spin-table boot protocols.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years agoboot-wrapper: arm64: gicv3: skip GIC init if not available
Marc Zyngier [Wed, 6 Aug 2014 14:45:10 +0000 (15:45 +0100)]
boot-wrapper: arm64: gicv3: skip GIC init if not available

Rather than exploding very early on, just skip the GICv3 initialization
if no GICv3 CPU interface is reported available.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
[Mark: amend comment]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years agoconfigure: Fixes for --enable-xxx
Geoff Levand [Thu, 12 Jun 2014 00:12:56 +0000 (01:12 +0100)]
configure: Fixes for --enable-xxx

When the --enable-psci=no or --enable-gicv3=no form of configure option
was passed our configure script was setting the option to yes.  This
changes the logic slightly to fix the problem.

Signed-off-by: Geoff Levand <geoff@infradead.org>
[Mark: fit with exiting USE_FEATURE naming scheme, fix whitespace]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years agoMakefile: Add local perl module include path
Geoff Levand [Thu, 12 Jun 2014 00:12:56 +0000 (01:12 +0100)]
Makefile: Add local perl module include path

We recently added perl scripting to our makefile, but omitted adding the include
path of the local modules in the invocation of perl.  Fixes build errors like
these when building out of the source tree:

  Can't locate FDT.pm in @INC (you may need to install the FDT module)

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years agoboot-wrapper: arm64: add support for GICv3
Marc Zyngier [Thu, 24 Apr 2014 15:17:22 +0000 (16:17 +0100)]
boot-wrapper: arm64: add support for GICv3

Performs the minimal initialization required for GICv3 support.
Support can be enabled with --enable-gicv3.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
10 years ago.gitignore: add auto-generated `compile' file
Will Deacon [Thu, 24 Apr 2014 15:17:21 +0000 (16:17 +0100)]
.gitignore: add auto-generated `compile' file

Seems that something in autotools spits out a `compile' script, so add
this to .gitignore.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAllow DTB to be overridden
Mark Rutland [Tue, 15 Apr 2014 15:20:48 +0000 (16:20 +0100)]
Allow DTB to be overridden

Some platforms differ significantly enough from the RTSM VE platform
such the RTSM VE DTB is not a valid DTB for the platform. Now that we
have the appropriate logic for detecting device and memory base
addresses, there's no reason we can't allwo the user to arbittrarily
choose to use another DTB so long as the basics are present (memory, a
pl011, and V2M sysregs).

This patch adds a "--with-dtb" option to override the DTB to use. The
aformentioned base addresses are automatically dicovered at build time.
Where a required device is not present, the build will fail.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoDiscover memory from the DTB
Mark Rutland [Tue, 15 Apr 2014 15:02:02 +0000 (16:02 +0100)]
Discover memory from the DTB

In case the start of physical memory happens to be different on some
model variant, this patch adds the necessary tooling to detect the base
address of said memory and ensure that the kernel and wrapper get loaded
at appropriate addresses.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoDiscover device base addresses from the DTB
Mark Rutland [Tue, 15 Apr 2014 13:31:44 +0000 (14:31 +0100)]
Discover device base addresses from the DTB

The base addresses of various components can differ from one model to
another. As these addresses are currently hard-coded in the bootwrapper,
it is necessary to manually alter the bootwrapper for each variation.

This patch adds scripting to extract the (absolute / CPU) addresses of
various system components. With this change the bootwrapper build system
will automatically discover the addresses that need to be used.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd FDT perl module
Mark Rutland [Tue, 15 Apr 2014 13:38:15 +0000 (14:38 +0100)]
Add FDT perl module

There are various models (RTSM VE, FVP Base, Foundation) which the
booterapper is intended to function on, but differences between these
(be they static or configurable) are difficult to handle as the
bootwrapper currently has hard-coded base addresses.

We already have a platform description (the device tree blob) which must
contain the correct addresses for a real OS to function, and it would be
nice if we could extract the values out of the device tree rather than
redundantly describing them in the boot wrapper.

This patch adds a pure perl library for parsing and querying values from
a device tree blob. Scripts may use this library to extract addresses
and other values from the DT.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoFix maintainer-clean make target
Geoff Levand [Thu, 3 Apr 2014 23:07:01 +0000 (00:07 +0100)]
Fix maintainer-clean make target

Add the missing MAINTAINERCLEANFILES to makefile.am.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
11 years agocache.S: fix misleading comments
Mark Rutland [Thu, 20 Mar 2014 15:40:46 +0000 (15:40 +0000)]
cache.S: fix misleading comments

A couple of comments in cache.S are misleading. While they do not affect
the correctness of the code they do make it somewhat difficult to reason
about it:

CSSIDR_EL1[12:3] contains the associativity field, which is enconded as
one less than the total number of ways, (matching the maximum way index)
so the comment on line 40 is wrong.

Counting the leading zeros on a 32-bit register with the extracted
associativity field results in 32 - ceil(log2(max way index)), rather
than log2(ways) rounded down. Thus the comment on line 41 is also wrong.

This patch adjusts both comments to better reflect the code.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agofix SetWay bits alignment for DC op
Vladimir Murzin [Thu, 20 Mar 2014 11:01:32 +0000 (11:01 +0000)]
fix SetWay bits alignment for DC op

Althought comment is aligned with ARMv8 ARM implentation is different. In
fact, "set" is shifted by "shift" and "way" is shifted by "line size".

Correct this missalignment.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoModify cpu nodes to set the enable-method
Matthew Leach [Thu, 23 Jan 2014 17:29:31 +0000 (17:29 +0000)]
Modify cpu nodes to set the enable-method

When using PSCI, the enable-method property for each CPU node in the
DTB needs to be set to "psci". Add a script and Makefile.am rules so
that this is done automatically for the final pass through DTC.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[Mark: remove backticks, fix copyright date, use $(), fix indentation]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoIf enabled, add the PSCI node to the FDT
Matthew Leach [Thu, 23 Jan 2014 17:29:30 +0000 (17:29 +0000)]
If enabled, add the PSCI node to the FDT

PSCI requires a node to be inserted into the FDT. Do this for the user
automatically if PSCI is enabled.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[Mark: add missing "method" property, fix indentation]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAllow the passing of CPUIDs in the configure script
Matthew Leach [Thu, 23 Jan 2014 17:29:29 +0000 (17:29 +0000)]
Allow the passing of CPUIDs in the configure script

Add the --with-cpu-ids switch to the configure script to allow the
user to manually set the CPU IDs that are passed to PSCI.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[Mark: fix indentation]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoCheck for dtc in the kernel dir
Matthew Leach [Thu, 23 Jan 2014 17:29:28 +0000 (17:29 +0000)]
Check for dtc in the kernel dir

The dtc tool should also be checked for in the $KERN_DIR/scripts/dtc
directory as it is shipped with Linux.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd a PSCI configure option
Matthew Leach [Thu, 23 Jan 2014 17:29:27 +0000 (17:29 +0000)]
Add a PSCI configure option

The boot-wrapper can be build with or without support for
PSCI. Therefore add that as a configure option (which defaults to not
using PSCI) and set the appropriate options in the makefile.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[Mark: fix indentation]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd autotools configuration.
Matthew Leach [Thu, 23 Jan 2014 17:29:26 +0000 (17:29 +0000)]
Add autotools configuration.

This patch adds a basic auto-tools configuration environment for the
bootwrapper consisting of the configure.ac file and the Makefile.am
file.

The configure.ac file includes several options and checks:
  - Ensure that an AArch64 compiler is used.
  - Add the mandatory --with-kernel-dir option that sets KERN_DIR.
  - Check that the correct base dtb file exists in KERN_DIR.
  - Add an option, --with-initrd, that allows a user to specify an
    initrd file to embed in the image.
  - Check for a working dtc and set DTC to the full-path to the
    executable.
  - Create the necessary symbolic links to the relevant kernel files.

The Makefile.am file includes several changes:

- Use a prebuilt dtb rather than a dts, which is decompiled to inject
  the chosen node.
- Use the configured compiler tool names.
- Use the configured SED program rather than assuming it is in PATH.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[Mark: use dtb, add options, fix style issues, remove src/]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoMerge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot...
Mark Rutland [Tue, 4 Feb 2014 10:33:46 +0000 (10:33 +0000)]
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot-wrapper-aarch64.git

Unify upstream build system updates and PSCI support.

Conflicts:
Makefile

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd CFLAGS to makefile compile
Geoff Levand [Wed, 13 Nov 2013 20:36:58 +0000 (20:36 +0000)]
Add CFLAGS to makefile compile

From 8a5783e72029c1ecd26fb99130b48a470e13a8da Mon Sep 17 00:00:00 2001
From: Geoff Levand <geoff@infradead.org>
Date: Wed, 13 Nov 2013 12:26:01 -0800

Allow user to pass compiler flags on the make command line as
in 'make CFLAGS="-g"'.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
11 years agocache.S: fix max cache level detection
Mark Rutland [Tue, 2 Jul 2013 14:44:06 +0000 (15:44 +0100)]
cache.S: fix max cache level detection

Due to incorrect operands for an and, we treat the value of the Ctype1
field of clidr_el1 as if it were the LoC field.

Fix up the operands so we use LoC corretly.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd simple PSCI implementation
Mark Rutland [Mon, 11 Feb 2013 16:58:18 +0000 (16:58 +0000)]
Add simple PSCI implementation

This patch adds a simple PSCI implementation, only supporting CPU_ON and
CPU_OFF. As this does not communicate with any hardware power controller
(yet), CPUs spin in an internal pen, with a wfe to limit their polling
speed.

While the model brings up CPUs with caches invalidated, we enable caches
and the MMU to allow the use of exclusive operations in the bootwrapper,
and thus the cache may allocate entries while in EL3. As PSCI requires
that caches are invalid when executing from a CPU_ON entry point, the
caches must be cleaned and invalided when we drop to EL2. This cleaning
is performed in a shim in EL2 as this is simpler than enabling/disabling
caches and the MMU on each SMC.

The list of all CPU IDs (MPIDRS with non-aff bits masked out) in the
system must be provided in the Makefile as the comma-separated list
CPU_IDs, to enable the bootwrapper to differentiate CPUs and provide the
correct error messages if for example the OS attempts to power on a CPU
multiple times. If this list does not match the CPUs present, it may not
be possible to bring some CPUs online, and the PSCI implementation may
erroneously acknowledge power on requests for non-existent CPUs.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd code to clean and invalidate caches
Mark Rutland [Tue, 23 Apr 2013 13:50:14 +0000 (14:50 +0100)]
Add code to clean and invalidate caches

Linux expects to be handed a system with caches disabled and
invalidated. While the model currently brings CPUs up with caches
invalidated, we'll need to invalidate caches when leaving the
bootwrapper if we enable them within the bootwrapper (e.g. for the use
of exclusive operations), as lines may be allocated.

This patch adds code to invalidate the dcaches and icaches. It is not
yet called.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoFactor spin-table into its own file
Mark Rutland [Mon, 11 Feb 2013 16:24:17 +0000 (16:24 +0000)]
Factor spin-table into its own file

This patch factors out the spin-table boot protocol into its own file,
leaving boot.S to do all of the required EL3 initialisation, and calling
upon ns_init to perform EL2 initialisation.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoFactor out secure GIC initialisation
Mark Rutland [Thu, 25 Apr 2013 15:02:09 +0000 (16:02 +0100)]
Factor out secure GIC initialisation

Currently the bootwrapper still lumps together logically distinct pieces
of hardware initialisation, making porting to new platforms or adding
new features difficult. It would be nicer if we could separate some of
the functional units to make the code clearer and easier to extend.

To this end, this patch factors the secure GIC initialisation into its
own file. Additionally, the code is modified to route all interrupts to
the non-secure side, not just the first 64.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoFactor non-secure system initialisation
Mark Rutland [Mon, 11 Feb 2013 14:38:22 +0000 (14:38 +0000)]
Factor non-secure system initialisation

When we add PSCI, we'll want to share the same non-secure sysetem
initialisation code. As we're going to want to put spin-table and PSCI
implementations in separate files, it would be nice to have the
initialisation code in its own file, to make clear the separation
between early boot, platform interface code, and non-secure system
initialisation.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoTest all MPIDR affinity bits
Mark Rutland [Thu, 16 May 2013 10:07:41 +0000 (11:07 +0100)]
Test all MPIDR affinity bits

Currently we only test the Aff0 bits of the MPIDR to determine the
'primary' CPU. In multi-cluster systems, MPIDR.Aff{3,2,1} may not be
zero, and there may by multiple CPUs where MPIDR.Aff0 is zero. In these
systems we might determine that two cpus are the primary CPU.

This patch adds a MPIDR_ID_BITS mask, and uses it in all cases we test
the MPIDR, making this safe for multi-cluster systems. This doesn't
bring full support for multi-cluster systems, however, as they may
require additional hardware to be set up (e.g. CCI).

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAllow support of multiple assembly files
Mark Rutland [Mon, 11 Feb 2013 14:25:33 +0000 (14:25 +0000)]
Allow support of multiple assembly files

To support more complex functionality, it would be nice if we could
separate bits of the boot code into separate files.

This patch refactors the Makefile, allowing us to add more source files
later without having to add a new rule for each file. The defines we
pass to each object are also factored into separate lines for easier
modification in future.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoAdd CURRENTEL_EL3 #define
Mark Rutland [Fri, 8 Feb 2013 16:55:09 +0000 (16:55 +0000)]
Add CURRENTEL_EL3 #define

Add a CURRENTEL_EL3 #define to make tests against the value of CurrentEL
clearer.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoMove EL drop definition out of boot.S
Mark Rutland [Tue, 5 Feb 2013 17:27:46 +0000 (17:27 +0000)]
Move EL drop definition out of boot.S

PSCI needs to be able to drop cores to EL2 repeatedly, and it doesn't
make sense to always throw CPUs through the original boot path.

This patch changes the EL drop into a macro, and moves it to a common
file that can be used by different boot protocol / service
implementations. While doing so, the SPSR value used is split out to be
more legible.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agogitignore: ignore build files
Mark Rutland [Mon, 11 Feb 2013 16:58:54 +0000 (16:58 +0000)]
gitignore: ignore build files

Currently. we don't ignore several files produced during the build in
the .gitignore, which can make the output of git status very noisy.

Let's ignore all of the external dependencies we might add to the source
directory (dtc, *.dts{i,}, *.cpio.gz), and all of the files we'll
produce during the build (*.o, *.axf). Ignoring the general case of all
of these files should produce less churn in .gitignore in future, and we
can always add special exemptions if required.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoUse immediate offsets rather than post-increment
Mark Rutland [Mon, 7 Jan 2013 13:50:44 +0000 (13:50 +0000)]
Use immediate offsets rather than post-increment

When we set the GICD_IGROUPRn registers, we have a dangling
post-increment at the end which is never useful, being overwritten in
every path. As we're only writing to 3 registers, the offsets of which
can be represented in immediates, use movs with immediate offsets to
perform the writes.

Reported-by: Nigel Stephens <nigel.stephens@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
11 years agoRemove unnecessary ldr from boot wrapper
Mark Rutland [Thu, 20 Dec 2012 16:52:51 +0000 (16:52 +0000)]
Remove unnecessary ldr from boot wrapper

We currently do an ldr from GICC_CTLR to w0, then immediately overwrite
w0 with a mov. Reading the GICC_CTLR has no effect on the state of the
GIC, so there's no reason to do the ldr. It's also inconsistent with the
way we set the GICD_CTLR.

Fix this.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
12 years agoAllow CROSS_COMPILE override on the make command line
Christoffer Dall [Fri, 5 Apr 2013 00:23:14 +0000 (01:23 +0100)]
Allow CROSS_COMPILE override on the make command line

Signed-off-by: Christoffer Dall <cdall@cs.columbia.edu>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoUpdate README
Matthew Leach [Thu, 10 Jan 2013 10:58:48 +0000 (10:58 +0000)]
Update README

Change the DT files that are required as they have been re-named in
the kernel.

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoTidy up the kernel boot arguments
Catalin Marinas [Wed, 9 Jan 2013 15:44:45 +0000 (15:44 +0000)]
Tidy up the kernel boot arguments

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoEnable the CLCD output
Catalin Marinas [Fri, 4 Jan 2013 13:06:31 +0000 (13:06 +0000)]
Enable the CLCD output

This patch is to avoid setting the MUXFPGA configuration in the platform
code in the kernel. On real hardware, this function is handled by the
boot monitor.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoChange the FDT_SRC file to rtsm_ve-aemv8a.dts
Catalin Marinas [Wed, 21 Nov 2012 16:44:59 +0000 (16:44 +0000)]
Change the FDT_SRC file to rtsm_ve-aemv8a.dts

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoUse the DTC Power(TM) instead of sed to inject the chosen node
Pawel Moll [Wed, 21 Nov 2012 16:13:17 +0000 (16:13 +0000)]
Use the DTC Power(TM) instead of sed to inject the chosen node

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
12 years agoInitial version of the AArch64 Linux boot wrapper
Catalin Marinas [Wed, 2 Dec 2009 12:26:48 +0000 (12:26 +0000)]
Initial version of the AArch64 Linux boot wrapper

This boot wrapper contains the code for initialising the ARMv8 software
model before the Linux kernel can run (see
Documentation/arm64/booting.txt in the kernel tree for the Linux booting
requirements).

Running "make" creates a "linux-system.axf" ELF file that can be loaded
by the software model.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>