Home | History | Annotate | Download | only in arm32
History log of /src/sys/arch/arm/arm32/arm32_kvminit.c
RevisionDateAuthorComments
 1.69  02-Apr-2022  skrll Update to support EFI runtime outside the kernel virtual address space
by creating an EFI RT pmap that can be activated / deactivated when
required.

Adds support for EFI RT to ARM_MMU_EXTENDED (ASID) 32-bit Arm machines.

On Arm64 the usage of pmapboot_enter is reduced and the mappings are
created much later in the boot process -- now in cpu_startup_hook.
Backward compatiblity for KVA mapped RT from old bootaa64.efi is
maintained.

Adding support to other platforms should be easier as a result.
 1.68  21-Mar-2021  skrll -DKERNEL_BASE_VOFFSET= has annoyed me for the last time...

Introduce KERNEL_VOFFSET_RUNTIME which prevents the addition of
-DKERNEL_BASE_VOFFSET= to the command line and use it on the
__HAVE_GENERIC_START kernels which do runtime calculation of the
offset.
 1.67  12-Dec-2020  skrll branches: 1.67.2;
Move evbarm/fdt/fdt_memory.[ch] to sys/dev/fdt and simplify the api and
some operations. This allows other architectures to use it.
 1.66  30-Oct-2020  skrll branches: 1.66.2;
Retire arm_[di]sb in favour of the isb() and dsb(sy) macro invocations.
 1.65  28-Aug-2020  skrll Some KASAN fixes and tweaks

- don't access BSS variables when __md_early
- centralise the INIT_ARM_STACK_{SHIFT,SIZE} defines and create a new
INIT_ARM_TOTAL_STACK
- Only create L1PT entries in kasan_md_shadow_map_page if
arm32_kernel_vm_init hasn't created the L2PTs (and their L1PT entries)
- Add some comments to explain what's going on
 1.64  10-Jul-2020  skrll Add support for KASAN on ARMv[67]

Thanks to maxv for many pointers and reviews.
 1.63  03-Jul-2020  skrll Style and share a debug string
 1.62  03-Jul-2020  skrll Use howmany()
 1.61  03-Jul-2020  skrll Whitespace
 1.60  26-Jun-2020  skrll Avoid unbounded stack usage warning
 1.59  20-Jun-2020  skrll KNF #includes

Remove some unnecessary ones while I'm here.
 1.58  04-Feb-2020  skrll KNF
 1.57  04-Feb-2020  skrll grammar in a comment
 1.56  02-Feb-2020  skrll G/C L1_TABLE_SIZE_REAL
 1.55  08-May-2019  skrll branches: 1.55.4;
Really go back to pre-whitespace change (1.52) arm32_kernel_vm_init
 1.54  23-Apr-2019  skrll Revert the part of the previous Whitespace commit which clearly was
functional.

This will probably come back with other changes and a proper commit
message.
 1.53  17-Mar-2019  skrll Whitespace
 1.52  06-Feb-2019  skrll Make sure the start stacks are covered by the new translation tables.
They *might* get placed after ARM_BOOTSTRAP_LxPT by the linker.

AP startup uses VA sp in cpu_init_secondary_processor
 1.51  06-Feb-2019  skrll Misc style
 1.50  06-Feb-2019  skrll Slight update to comment and KNF it while I'm here
 1.49  04-Feb-2019  skrll Fix typo in VPRINTF
 1.48  13-Nov-2018  skrll On second/third thoughts we can use the pages before the kernel
everywhere.
 1.47  20-Oct-2018  skrll Clean up around cpu_ttb and fix a bunch of builds
 1.46  18-Oct-2018  skrll Provide generic start code that assumes the MMU is off and caches are
disabled as per the linux booting protocol for ARMv6 and ARMv7 boards.
u-boot image type should be changed to 'linux' for correct behaviour.

The new start code builds a minimal "bootstrap" L1PT with cached access
disabled and uses the same table for all processors. AP startup is
performed in less steps and more code is written in C.

The bootstrap tables and stack are placed into an (orphaned) section
"_init_memory" which is given to uvm when it is no longer used.

Various kernels have been converted to use this code and tested. Some
boards were provided by TNF. Thanks!

The GENERIC kernel now boots on boards using the TEGRA, SUNXI and EXYNOS
kernels. The GENERIC kernel will also work on RPI2 using u-boot.

Thanks to martin@ and aymeric@ for testing on parallella and nanosoc
respectively
 1.45  14-Oct-2018  skrll Use __nothing
 1.44  03-Aug-2018  skrll Provide and use kern_vtopdiff in KERN_{VTOPHYS,PHYSTOV}. A step towards
generic arm.
 1.43  31-Jul-2018  martin #ifdef VERBOSE_INIT_ARM some format strings only used in that case.
 1.42  31-Jul-2018  skrll Define and use VPRINTF
 1.41  10-Dec-2017  skrll branches: 1.41.2; 1.41.4;
FDTise RapberryPI support. Thanks for jmcneill for a lot of help with this.

The kernel image that the RPI firmware boots is now netbsd.img in the
kernel build directory.

XXX fdtbus_get_reg needs reworking
 1.40  06-Jul-2017  skrll Now that we can... mark kernel text as non-writable on MMUs that support
it.
 1.39  01-Jul-2017  skrll Report an error if compiled with MULTIPROCESSOR support but without
__HAVE_CPU_UAREA_ALLOC_IDLELWP
 1.38  24-Dec-2016  skrll Fix VERBOSE_INIT_ARM build
 1.37  25-Nov-2015  skrll branches: 1.37.2;
In the ARM_MMU_EXTENDED case make sure the kernel mappings are marked with
XN (eXecute Never) appropriately.

The XN logic is inconsistent and could do with changing to XN always set
and cleared for VM_PROT_EXECUTE (or the inverse) everywhere.
 1.36  25-Nov-2015  skrll Trailing whitespace.
 1.35  01-Jun-2015  matt pmap_directbase is a failed experiment, nuke it.
 1.34  30-May-2015  matt Support directmapped systems with >1GB that start memory at 0x80000000.
 1.33  04-May-2015  matt Deal with 2GB of ram or memory ending at or above 4GB.
 1.32  29-Oct-2014  skrll branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"
 1.31  24-Oct-2014  skrll Remove unnecessary #include
 1.30  23-May-2014  kiyohara branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.
 1.29  13-Apr-2014  matt When figuring out the physical size for direct-mapped systems, round up
to L1_SS_SIZE.
 1.28  11-Apr-2014  matt Add a kernel for the CUBIETRUCK (CUBIEBOARD3). Allow direct mapping of all
memory (but for now allow the memory mapped above KERNEL_BASE to used for
poolpages).
 1.27  05-Apr-2014  matt If using arm32_kvminit, don't bother mapping msgbuf since it's already mapped.
 1.26  01-Apr-2014  skrll branches: 1.26.2;
Remove unnecessary { } around code block. No functional change.
 1.25  28-Mar-2014  matt ARM_MMU_EXTENDED support.
 1.24  05-Mar-2014  matt rearrange some printfs.
when using the extended mmu, make sure to disable ttbr0 until there is an
activated pmap.
 1.23  03-Mar-2014  matt If we are going to map all of physical memory, we don't need to allocate
l2 page tables for the kernel.
 1.22  29-Aug-2013  riz branches: 1.22.2;
Fix typo: VERBOSE_INIT_ARM, not VERBOSE_ARM_INIT. From
Dennis Ferguson in PR#48163.
 1.21  22-Jun-2013  matt branches: 1.21.2;
Fix inverted logic for mapping exception vector.
 1.20  12-Jun-2013  matt Add a ARM_HAS_VBAR option which forces the use of the VBAR register. This
allows much code to deal with vector_page mappings to be eliminated. On a
BEAGLEBONE kernel, this saves 8KB of text and instructions that never have
to be executed. (The PJ4B has VBAR but doesn't implement the security
extensions it is part of so a method was needed to allow it use VBAR with
relying on the default test for the security extensions.)
 1.19  12-Jun-2013  matt Add support for the VBAR (vector base address register) to remap the vectors
into the kernel text segment. This register is available on arm1176 and
all cortex processors since they all have the arm security (trustzone)
extension. We avoid having to specially map either vector page (0x00000000
or 0xffff0000) and use VBAR to both to page0rel in the text segment. These
vector group differs from the normal page0, that since it's in the kernel,
it can branch directly to the exception routine, instead of loading the
address into the PC. This should result in a tiny improvement in speed since
we eliminate a TLB mapping the vector page and a load on every exception.

XXX Add __HAVE_ARM_TRUSTZONE cpp define and use that to eliminate all code
have to do with manipulating the vector page.
 1.18  27-Feb-2013  matt Actually use zero_p now that we pass it in.
 1.17  27-Feb-2013  matt Add a zero flag to valloc_pages so that we can *not* zero the msgbuf so it
will be preserved across boots.
 1.16  31-Dec-2012  matt Correct one of the kernel_size calculations.
 1.15  10-Dec-2012  matt if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.
 1.14  24-Oct-2012  skrll branches: 1.14.2; 1.14.4;
Compare pointer against NULL not 0.
 1.13  21-Oct-2012  matt Make sure when mapping all the kernel, start at KERNEL_BASE, not kernel_base.
 1.12  19-Oct-2012  skrll Make sure that start.S and machdep.c don't disagree wrt L1 page table
location during bootstrap.
 1.11  19-Oct-2012  skrll slop wasn't sloppy enough in the kernel_size calculation. Add in the L2
page tables required as well.

Should fix the dockstar boot problem reported by Andy Ruhl on port-arm.

http://mail-index.netbsd.org/port-arm/2012/09/20/msg001471.html
 1.10  19-Oct-2012  skrll Comments.
 1.9  19-Oct-2012  skrll Print the message buffer VAs and number of pages. Other minor cosmetics.
 1.8  17-Oct-2012  skrll Fix two off-by-one loops. Saves a whole two pages.
 1.7  15-Oct-2012  skrll More VERBOSE_INIT_ARM output tweaks.
 1.6  15-Oct-2012  skrll Typo in comment.
 1.5  15-Oct-2012  skrll Print the system vectors in order so I don't get confused.
 1.4  22-Sep-2012  matt Don't use an asm in pmap_activate to update the TTBR, use cpu_setttb instead
but add a second argument to it to indicate whether the TLB/caches need to be
flushed. Default cortex to pmap_needs_fixup = 1. But check the MMFR3 field
to see if the fixed can be skipped.
Use a cf_flag bit 0 to indicate whether the A9 L2 cache should disable (bit 0 = 1)
or enabeld (bit = 0).

With these changes, the A9 MMU can use traverse caches to do MMU tablewalks
Also, make sure all memory has the shareable bit for the A9.
 1.3  06-Sep-2012  matt branches: 1.3.2;
Before setting the new TTB wbinv the caches.
 1.2  05-Sep-2012  matt Print TTBR/TTBR1/TTBCR registers
 1.1  31-Aug-2012  matt Make cpu_reset, most of initarm and the kvm init code common.
Add MP hooks for cpu_need_resced
Add idlestck which is allocated in arm32_kvminit
 1.3.2.5  03-Dec-2017  jdolecek update from HEAD
 1.3.2.4  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.2.3  23-Jun-2013  tls resync from head
 1.3.2.2  25-Feb-2013  tls resync with head
 1.3.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.4.2  28-Nov-2012  matt Merge improved arm support (especially Cortex) from HEAD
including OMAP and BCM53xx support.
 1.14.4.1  24-Oct-2012  matt file arm32_kvminit.c was added on branch matt-nb6-plus on 2012-11-28 22:40:16 +0000
 1.14.2.5  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.4  23-Jan-2013  yamt sync with head
 1.14.2.3  16-Jan-2013  yamt sync with (a bit old) head
 1.14.2.2  30-Oct-2012  yamt sync with head
 1.14.2.1  24-Oct-2012  yamt file arm32_kvminit.c was added on branch yamt-pagecache on 2012-10-30 17:18:56 +0000
 1.21.2.1  18-May-2014  rmind sync with head
 1.22.2.4  13-Aug-2015  matt Make sure the amount of direct mapped memory doesn't cross over into the
mappable KVA range.
 1.22.2.3  24-Mar-2014  matt Make sure kernel starts on a page boundary.
 1.22.2.2  15-Feb-2014  matt Merge armv7 support from HEAD, specifically support for the BCM5301X
and BCM56340 evbarm kernels.
 1.22.2.1  29-Aug-2013  matt file arm32_kvminit.c was added on branch matt-nb5-mips64 on 2014-02-15 16:18:36 +0000
 1.26.2.1  10-Aug-2014  tls Rebase.
 1.30.2.1  09-Nov-2014  martin Pull up following revision(s) (requested by skrll in ticket #188):
sys/arch/arm/include/arm32/pmap.h: revision 1.136
sys/arch/arm/include/armreg.h: revision 1.100
sys/arch/arm/cortex/gic.c: revision 1.11
sys/arch/arm/arm32/db_interface.c: revision 1.54
sys/arch/arm/include/armreg.h: revision 1.101
sys/arch/arm/cortex/gic.c: revision 1.12
sys/arch/arm/arm32/arm32_machdep.c: revision 1.107
sys/arch/arm/arm/cpufunc_asm_armv7.S: revision 1.19
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.20
sys/arch/evbarm/conf/BPI: revision 1.5
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.21
sys/arch/arm/arm32/pmap.c: revision 1.306
sys/arch/arm/arm32/db_machdep.c: revision 1.22
sys/arch/arm/arm32/arm32_tlb.c: revision 1.3
sys/arch/arm/arm/undefined.c: revision 1.55
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.22
sys/arch/arm/arm32/pmap.c: revision 1.307
sys/arch/arm/arm32/arm32_tlb.c: revision 1.4
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.23
sys/arch/arm/arm32/arm32_tlb.c: revision 1.5
sys/arch/evbarm/conf/BPI: revision 1.8
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.24
sys/arch/arm/arm32/arm32_tlb.c: revision 1.6
sys/arch/arm/arm32/arm32_tlb.c: revision 1.7
sys/arch/evbarm/conf/CUBIETRUCK: revision 1.5
sys/arch/arm/pic/pic.c: revision 1.23
sys/arch/arm/pic/pic.c: revision 1.24
sys/arch/arm/pic/picvar.h: revision 1.11
sys/arch/arm/arm/cpufunc_asm_armv7.S: revision 1.20
sys/arch/arm/mainbus/cpu_mainbus.c: revision 1.16
sys/arch/arm/arm32/pmap.c: revision 1.298
sys/arch/arm/arm/cpufunc_asm_arm11.S: revision 1.17
sys/arch/arm/arm/cpufunc_asm_pj4b.S: revision 1.5
sys/arch/arm/arm32/pmap.c: revision 1.310
sys/arch/arm/arm32/pmap.c: revision 1.311
sys/arch/arm/arm32/arm32_kvminit.c: revision 1.32
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.19
sys/arch/arm/arm32/arm32_boot.c: revision 1.10
sys/arch/arm/arm/ast.c: revision 1.25
sys/arch/arm/include/armreg.h: revision 1.98
sys/uvm/pmap/pmap_tlb.c: revision 1.10
sys/arch/arm/arm32/arm32_boot.c: revision 1.8
sys/arch/arm/arm32/arm32_boot.c: revision 1.9
sys/arch/arm/arm/arm_machdep.c: revision 1.43
Various ARM MP fixes.
 1.32.2.4  28-Aug-2017  skrll Sync with HEAD
 1.32.2.3  05-Feb-2017  skrll Sync with HEAD
 1.32.2.2  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.32.2.1  06-Jun-2015  skrll Sync with HEAD
 1.37.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.41.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.41.4.1  10-Jun-2019  christos Sync with HEAD
 1.41.2.3  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.41.2.2  20-Oct-2018  pgoyette Sync with head
 1.41.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.4.1  29-Feb-2020  ad Sync with head.
 1.66.2.2  03-Apr-2021  thorpej Sync with HEAD.
 1.66.2.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.67.2.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed