History log of /fuchsia/zircon/kernel/arch/arm64/start.S
Revision Date Author Comments
# 83c7dfde 02-Sep-2018 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Tighten up kernel entry assembly a bit

Test: CQ
Change-Id: I5935069c4a5265e8880d727311e0a06b54d19171


# bb9e3313 07-May-2018 Thomas Garnier <thgarnie@google.com>

[kernel][kaslr] Create static relocation

Add static relocation for x64 and arm64 using the kernel_relocated_base
global variable. Add the DISABLE_KASLR option. Remove any dependency to
KERNEL_BASE when __code_start should be used. Change symbolize script to
dump kaslr offset and correctly show static addresses. Adapt gdb script
to identify KASLR relocation at early boot or if attached later.

x64 specific:
- Simplify page table to use kernel_relocated_base
- Fix zedboot and multiboot dependencies on the static kernel base
- Ensure 16-bit boot path is relocated for secondary CPUs

SEC-31 #comment Add static relocation of the kernel module

Change-Id: I9acb0a53a82c2bbf9973921e4cfe60a1e03c7006


# 4da744fd 16-May-2018 Mike Voydanoff <voydanoff@google.com>

[kernel][arm64] Switch arm64 kernel platform code to use <zircon/boot/image.h>

Change-Id: Id3a35d7a50e4a3f18b613e5e52e567def2266057


# 811713f0 11-May-2018 Nick Maniscalco <maniscalco@google.com>

[kernel] Don't relocate kernel on secondary CPUs

This change fixes a bug that could cause corruption of global data
structures.

_start is the entrypoint for all CPUs. Prior to this change every CPU
would relocate and patch the kernel. Depending on the link layout the
fixup code may or may not overlap with the BSS.

If they do overlap, then the secondary CPUs may run off and begin
executing part of the BSS as if it were code. In one case this
resulted in secondary CPUs "fault looping".

If they don't overlap, then the result can be more subtle. Even though
the relocation offset is currently 0 (the kernel stays put), this can
lead to bugs because the fixup code is non-atomic. Imagine that one
CPU is writing to the data segment while a secondary CPU is relocating
the kernel. For example, CPU 0 is about to update a global variable
located at address A. Meanwhile, CPU 2, running the relocation code,
loads the value at A, adds 0, but before it can store it, CPU 0's
store completes. Now when CPU 2 completes its store it stomps what
CPU 0 wrote.

ZX-2140 #done

Change-Id: I90a58ca85866ca47cd2b82f131e0d5e661141793


# 1defcb2b 18-Apr-2018 Roland McGrath <mcgrathr@google.com>

[kernel] Use --emit-relocs to add self-fixups

SEC-31 #comment This applies relocations to the kernel.

Change-Id: I07b40308b768a56c889eeb9a9a89c0e897924617


# 5090ed4e 05-Apr-2018 Mike Voydanoff <voydanoff@google.com>

[arm64] Move Linux device tree parsing from kernel to the boot shim

The arm64 kernel now requires that x0 points to the bootdata on entry.
The boot shim parses the Linux device tree to find the bootdata
rather than the kernel doing this.
The boot shim is also now responsible for finding the kernel command line
and ram size in the device tree and passing this to the kernel via
additional bootdata records.

mexec and the hypervisor already pass bootdata to the kernel via x0,
so no changes were needed there.

Change-Id: I927930508566b5ae8f26acd053de7b4f040ee194


# 5313060d 24-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[arm64][build][kernel] arm64 kernel is now a bootdata container

Like the x64 kernel, the arm64 kernel is now packaged as a bootdata container.

Currently, all of our arm64 platforms except the hypervisor do not support this.
For those platforms we now have a shim that is prepended to the beginning of the kernel.
This shim checks to see if there are remaining bootdata items following the kernel.
If there are, the shim copies the kernel beyond the end of the bootdata
and executes executes it there. Otherwise it will jump to the kernel in place.

We also add a new <board>-combo-bootdata.bin build file, which contains
the kernel and all of the bootdata packaged in a single file.
This is now being used on the vim, vim2 and hikey960 targets.
However we cannot use the combo-bootdata on gauss, qemu and odroidc2,
so on those platforms we add the shim to their kernel and boot with a
separate bootdata passed as the ramdisk.

In this change we also add --header and --header-align options to mkbootfs,
which prepend an optional binary header to the beginning of the mkbootfs output.
Strictly speaking we could have done this using "cat" instead,
but having this option in mkbootfs eliminates the need for temporary files
and would be simpler to use in the Fuchsia build system.

Change-Id: I9fa572318158043e7b22c5ad944f33a23053abd3


# 67cef195 28-Feb-2018 Mike Voydanoff <voydanoff@google.com>

[kernel][arm64] Remove KERNEL_LOAD_OFFSET build variable and header.S

Targets that now need a header with load offset will
prepend that to the kernel as a separate target specific build step

It is no longer needed for any of our arm64 targets except odroid-c2,
which will be fixed in a following CL.

Change-Id: Ic981d73fac52b053f790819faac99d2402e6ca61


# 176d3dcd 28-Feb-2018 Mike Voydanoff <voydanoff@google.com>

[kernel][arm64] Remove obsolete uefi boot path

Change-Id: I24ff3d490bcb54764abd0b89bf754478dcf53f72


# 26778e67 24-Feb-2018 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Remove unused register aliases

"index" is now an AArch64 assembler mnemonic, so it can't be
a register alias. But this and a few other aliases declared were
not actually being used anyway.

Change-Id: I3cc507e817d65391e658bef63911945ed96fde17


# b1271f7f 22-Jan-2018 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64][qemu] remove old FDT reservation, dynamically reserve based on where it actually is

Change-Id: I89865ae698816fe90c906e7bc175d7203d3dd0ea


# 9e92e216 29-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64][efi] add a separate efi entry point

This avoids situations where garbage is passed in via x1

Change-Id: I1c6abb4c717f4e709d1275e8a3c58e9f36ddcd42


# 98a4a0d7 27-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64][efi] spiff up the EFI boot path to allocate the ramdisk and kernel wherever it wants

Instead of hard coding the address of the kernel load spot and ramdisk,
ask efi to allocate a block of memory large enough to hold the ramdisk +
kernel and copy both of them there.

This means the kernel will run at an arbitrary physical address, but
this is okay.

Also properly exit boot services

Change-Id: Ic297694bd125369d293501d690fd75cd383fbd16


# c1932bc5 16-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel] remove most uses of MEMBASE + KERNEL_LOAD_OFFSET

These two variables are almost always used when code wants to know the
kernel's physical load address. Add some code to simply save the kernel
load location at boot time and use that instead.
Also standardized the use of linker script defined variables into a
common header and format.

Change-Id: Iccde557d1082d39167a53b0fdc5f23289d81f200


# 7177a347 13-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm] use the peripheral memory map from the mdi, remove the use of mmu_initial_map

Multiple smaller changes here that were too hard to split:
-Switch arm code to mapping the peripheral map based on the mdi
-Construct a peripheral map reserve region after the fact when the vm comes up
-Remove the mmu_initial_map for both arm and x86
-Construct the physmap reserve region from the physmap #defines instead of the table
-Change arm start.S to map the first 512GB of physical space for the physmap

Change-Id: I345c521f38fde88cfabffbdaae6331e6b8ebd323


# a962dcda 13-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm] update the boot-mmu code to handle large pages and being used after the kernel has gone virtual

Change-Id: Ifa0eef2c70d92fd7c225c8a123aa32391b30d198


# 74563334 30-Nov-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] fix a little assembly bug that may cause the stack guard var to be written to the wrong spot

Change-Id: Ifd7bccf64a9eac87ec4b53d16b2808f29be66e94


# bc8b5069 27-Nov-2017 Gurjant Kalsi <gkalsi@google.com>

[arm64] Only save the boot EL for the primary core.

Primary and secondary cores might boot at different ELs.

During mexec, the primary may come in at EL1 whereas the secondaries will
start in EL2. This change prevents the secondaries from overwriting the
boot EL saved by the primary core.

Change-Id: I866fc73dc66666bd07052b514f34ca1e59ebf63a


# ef6c47be 20-Oct-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] move bss initialization earlier, remove prebss

-Turns out we were already initializing the data cache early on, so
there's no real downside to zeroing out bss on the first cpu just after
enabling data cache but before setting up in the mmu.

Change-Id: Iad3f6e0b8a78ddaf4b627673264053c717635190


# 63364cd5 19-Oct-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arch] remove KERNEL_LOAD_OFFSET from the kernel link address

-ARM64 kernels are now linked to run precisely at -4GB with no load
offset baked into the address.
-bake KERNEL_LOAD_OFFSET into KERNEL_BASE for x86 so that the initial
mmu table setup still works.
-remove PHYS_HEADER_LOAD_OFFSET which is no longer used

Change-Id: I33b293653346afbfc9aeaae5d2a433ef3a4be0b1


# d54624b7 14-Oct-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] Move the kernel run address out of the Big Kernel Map

-Added code in early boot to remap wherever the kernel was loaded to
approximately -4GB (KERNEL_LOAD_OFFSET still applies)
-Simplfy the mmu_initial_mapping stuff a bit, remove the DYNAMIC flag,
which wasn't used.
-Fix up the boot allocator very early in arm64 to figure out where
physical memory is.

ZX-1238 # Done

Change-Id: Ib43eb9288c79e01253c5c4499278e2fe83602bd1


# d382da70 13-Oct-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][bootalloc] move the boot time allocator into the BKM, instead of relying on pages off the end of the kernel

-In prep for relocating the kernel to different places in kernel space
without having to have the pages immediately after it also mapped.
-This is sort of a step back in safety/security since we're now going to
hold pointers into the BKM, but the longer term goal is to remove the
boot allocator altogether.

Change-Id: I9aa81ae1677a81070ec2f232d63aac91f4ac9e78


# 07166ed7 13-Oct-2017 Roland McGrath <mcgrathr@google.com>

[kernel] Consolidate kernel linker script

There is much more that's the same than that's different between
the architectures. Maintaining a single linker script that works
for both is easier than keeping two in synch.

Change-Id: I0655919e3f7dc5f8788d47bbe733f444c87ec97b


# 1cfccac5 15-Sep-2017 Eric Holland <hollande@google.com>

[arm64] Clean up fastboot headers

Change-Id: Iac558cfcb7c8baa75ef08debf0ed1b48d89f5747


# f3e2126c 12-Sep-2017 Roland McGrath <mcgrathr@google.com>

[zx] Magenta -> Zircon

The Great Renaming is here!

Change-Id: I3229bdeb2a3d0e40fb4db6fec8ca7d971fbffb94


# e1490736 01-Sep-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][vm] move kernel/kernel/vm to just kernel/vm

Change-Id: I8f724a9f8a61415712661d1fdd3dc4e1c70cf620


# a403d857 25-Aug-2017 Eric Holland <hollande@google.com>

[arm64][efi] Support reloc/boot from efi

Change-Id: I40de15f4cdcda4878aa6b4af2b6b03daaebf1a60


# 6a0ae3c7 25-Jun-2017 Doug Evans <dje@google.com>

[kernel][assembler] Add .cfi_startproc, .cfi_endproc directives

... and switch to using .debug_frame from .eh_frame.

Some functions don't really need .cfi directives, e.g. during early boot.
These functions are marked with FUNCTION_LABEL instead of FUNCTION
as now all uses of FUNCTION require a corresponding END_FUNCTION.

MG-870 #comment baby steps

Change-Id: I3c7d182ca91b2f705100880282477bfe930c6633


# 13440c40 13-Jun-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] Create a per cpu structure and use the x18 register to point to it

At the moment use it to store the oft-used current cpu number and
is-in-interrupt flag.

Change-Id: I3203358ca47a3b193ef7cb01356b67b50c74ff0f


# 95c00b39 21-Jun-2017 Doug Evans <dje@google.com>

[kernel][asm] Replace END with END_FUNCTION/END_DATA

MG-870 #comment baby steps

Change-Id: I1f1c2698c58612926e2fcfab8cfaed95833b7497


# d77d89b6 06-Jun-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][vm] restructure kernel vm headers and remove more legacy routines

Mostly unpack vm.h into a few separate headers.

No functional change

Change-Id: Ifd85506f49596d82a3a0e970fc911a34f3064d70


# c4b00c8a 01-Jun-2017 Travis Geiselbrecht <travisg@google.com>

[kernel] remove the WITH_SMP flag

Always build the kernel with full SMP support.

Change-Id: I105f8e4127a93113c795ae80e1dc4d4b0d43abe8


# c4e9e80f 22-May-2017 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Add movabs macro, use it instead of literal pools

The new macro encapsulates the magic sequence to materialize an
absolute symbol value into a register. Its use replaces all
remaining uses of literal pools.

Change-Id: Id4be5b86f4842bf391e89047c5dc8b4f56f85656


# bb077366 22-May-2017 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Add adr_global macro, use it

The new macro encapsulates the standard ADRP, ADD sequence for
materializing the address of a global symbol into a register.

Also change uses of a literal pool to materialize a normal address to
use adr_global. The remaining uses of load from literal pool should
be confined to the cases that need to load an unadjusted compile-time
constant rather than computing from the runtime PC.

Change-Id: I368b5544e008bfd0e10d3900184ccb7091031e98


# 6e5faa3e 23-May-2017 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Use movlit macro in place of literal pool for integer literals

The new macro makes it easy to load a literal integer value into
a register without resorting to using a literal pool.

Change-Id: I70da32b8dab6f8702e6be6e049a164e60200d20e


# 3f86d52d 28-Apr-2017 Gurjant Kalsi <gkalsi@google.com>

[arm64][platform] Convert arm64 platform to C++

Make build compile again by fixing all compile errors caused by
renaming generic-arm platform.c to platform.cpp

Change-Id: Ia68cf09bfb3a1ec3137eb30650c6ea6ef48d9e9b


# e3d60a3e 21-Apr-2017 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Build ARM64 kernel with -fsanitize=safe-stack

Change-Id: I953e5e19bf319e2047a467e64e3222808c07f9e3


# 2579bcc5 19-Apr-2017 Gurjant Kalsi <gkalsi@google.com>

[arm][mdi] Detect MDI or DT in ramdisk at boot

Some bootloaders may pass the DT as an argument to magenta whereas
others pass MDI directly.

We attempt to detect the type of boot structure passed and handle
it appropriately.

Change-Id: I2aca778b3fee9998cce5ae3afad9c3f059c6d247


# b15527db 05-Apr-2017 Eric Holland <hollande@google.com>

[kernel][arm64] save dt address from x0

Change-Id: I2e8512d0d695a50e73dd316900d0269b3f799538


# 9298d536 04-Apr-2017 Roland McGrath <mcgrathr@google.com>

[kernel] Get rid of lk_boot_args

On x86, these were wholly unused and just random register
values from previous assembly code were passed into lk_main.

On ARM64, these were copied back and forth from an ARM64-specific
global. So now just set the actually-used globals directly.

Change-Id: I245497e0d16ab1ff4f85f5b0e1b6cd5480191b24


# f5c850c3 02-Apr-2017 Roland McGrath <mcgrathr@google.com>

[kernel][arm64] Don't allocate SMP_MAX_CPUS times the boot CPU stack size; clean up bss

The preallocated kernel stack is used only for the stack of the
boot CPU's initial kernel thread. It doesn't need to have space
for a stack for each CPU. The symbols for this stack block also
don't need to be global or have obscure names.

Only the kernel translation table needs to be in prebss.
Put the initial kernel stack in normal .bss instead, and
don't point to it until after .bss is cleared.

Optimize .bss clearing to use 16-byte stores.

Change-Id: Id6cab05f95262bcde0a0b543e1f2952e1e31fb64


# 9b70d35d 08-Mar-2017 Mike Voydanoff <voydanoff@google.com>

[kernel][arm64] Clean up the way CPU IDs are managed

Remove SMP_CPU_CLUSTER_BITS, SMP_CPU_ID_BITS, SMP_CPU_CLUSTER_SHIFT
and SMP_CPU_ID_SHIFT #ifdefs

CPU topology (number of clusters and number of CPUs per cluster)
can now be specified programatically from platform.c.
Later this will be specified in the MDI data.

start.S no longer makes assumptions about CPU topology.

Change-Id: I563472c871bb40ee0b7cdf13e910be7d1495bcb4


# 94a8972e 20-Feb-2017 Petr Hosek <phosek@google.com>

[kernel] Mark .text.boot and .text.header as alloc and exec

This is necessary for lld which doesn't infer these flags from the
section name and later fails to merge these into .text.

Change-Id: I6a63e4db5e8f31dbcc53650962385525b5da6c9a


# 3dfbf35d 15-Feb-2017 Eric Holland <hollande@google.com>

[arm64][mp] Dynamically allocate initial stacks for mp

Change-Id: I7629e3b007677bec51fff6f7699a2c95e8d4f171


# 70ec2997 14-Feb-2017 Eric Holland <eric.holland@gmail.com>

[arm64] Save initial EL level for query by kernel

Change-Id: I19895d542c514f03da241f60492d2e3e0943c840


# aaa51660 07-Feb-2017 Eric Holland <eric.holland@gmail.com>

[arm64][mp] Fix cpu id reporting for clusters

Change-Id: I63106eccc648561ab79e225614f98f329835d040


# 9e93682a 06-Feb-2017 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] clean up some assembly a bit

Add size markings to some functions.
Remove an extraneous align in start.S that was wasting
some amount of memory.

Change-Id: I21b35f4fd51422518828c2df49b2368514d84750


# 6f1896e3 03-Feb-2017 George Kulakowski <kulakowski@google.com>

[arm64][linker] Mark prebss sections as @nobits

On the arm64 clang build, a couple prebss sections were being marked
as PROGBITS and hence explicitly splatted into the binary. This change
fixes the following warning:

./prebuilt/downloads/aarch64-elf-6.2.0-Linux-x86_64/bin/aarch64-elf-ld: warning: section `.bss' type changed to PROGBITS

as well as shaving 300-400k off the magenta.elf and magenta.bin sizes.

Change-Id: I0b459fa8d414aae129045b07b52cae317052f3f0


# b181a2ca 19-Jan-2017 Mike Voydanoff <voydanoff@google.com>

[arm64] Add optional header to start.S needed to make fastboot happy

Change-Id: I0c1a3f9a4c10cd3f0e9fe0244eff95e5fc7c1f96


# 0e208d8a 29-Nov-2016 Travis Geiselbrecht <travisg@google.com>

[kernel][arm64] enable user space cache operations, move some sctlr bit setting logic to C

This enables the full fuchsia user space to boot, since the dart runtime seems
to use user space I&D cache synchronization operations.

Should consider long term what the policy is on user space cache ops, but for now
just let them be used.

Change-Id: I93f8aba9ff7cc7cd0145597f2cfee822e7858fba


# ee3d6ee6 31-Oct-2016 Travis Geiselbrecht <travisg@google.com>

[kernel] remove the no-vm path

Remove the no-vm build, which hasn't worked for quite some time. Cleans up
some clutter in some of the boot code.

Change-Id: Ia11c531c19d167538838a47f92e5d5c38d8fec71


# 69482069 15-Sep-2016 Eric Holland <hollande@google.com>

[aarch64] Preserve kernel args on boot

Change-Id: Idb6feae8b71a973b02ce66ed72dcd34b697ad7f9


# 12c2b825 09-Sep-2016 Eric Holland <hollande@google.com>

[aarch64][cache] Invalidate caches at boot

Change-Id: If24e3a55bec31738f0867d65a6d0b611e401efe8


# 6d8379f3 31-Aug-2016 Eric Holland <hollande@google.com>

[aarc64] Pad context frame to prevent sp misalignment

context frame size should be a multiple of the sp alignment requirement
of 16 bytes, otherwise modifying the sp by the frame size can result
in misaligned stack pointers.

Change-Id: I644b8c75ad0672343177f24fb7911b74879d2045


# 8302993e 18-Aug-2016 Eric Holland <hollande@google.com>

[aarch64] clarifying comments for start.S

Change-Id: I483690b9ad2374978a2fb252f06e15ebb5582030


# a6078998 08-Aug-2016 Eric Holland <hollande@google.com>

[aarch64] Processor startup changes for cache sync and exception levels

Change-Id: Ibd408394c5727dabbd7abf1f8af31f8dc2a9205e


# 3edc247e 19-Jun-2016 Travis Geiselbrecht <travisg@google.com>

[kernel] move the userboot payload into a read only segment

Needed to fix some assembly code in arm64 that couldn't handle the additional
gap in the binary between .text and .data because of this.

Change-Id: Iea875fe1efd496ceca7836a515736d2c0e413051


# 53b9e1c8 15-Jun-2016 The Fuchsia Authors <authors@fuchsia.local>

[magenta] Initial commit