History log of /netbsd-current/sys/arch/arm/arm32/arm32_kvminit.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.67 12-Dec-2020 skrll

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.67 12-Dec-2020 skrll

Move evbarm/fdt/fdt_memory.[ch] to sys/dev/fdt and simplify the api and
some operations. This allows other architectures to use it.


Revision tags: thorpej-futex-base
# 1.66 30-Oct-2020 skrll

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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


Revision tags: thorpej-futex-base
# 1.66 30-Oct-2020 skrll

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.59 20-Jun-2020 skrll

KNF #includes

Remove some unnecessary ones while I'm here.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 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


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.55 08-May-2019 skrll

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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.56 02-Feb-2020 skrll

G/C L1_TABLE_SIZE_REAL


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.55 08-May-2019 skrll

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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.55 08-May-2019 skrll

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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.41 10-Dec-2017 skrll

branches: 1.41.2;
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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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.


Revision tags: isaki-audio2-base
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 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


Revision tags: pgoyette-compat-1020
# 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


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.41 10-Dec-2017 skrll

branches: 1.41.2;
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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.41 10-Dec-2017 skrll

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


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 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


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.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


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.39 01-Jul-2017 skrll

Report an error if compiled with MULTIPROCESSOR support but without
__HAVE_CPU_UAREA_ALLOC_IDLELWP


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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.38 24-Dec-2016 skrll

Fix VERBOSE_INIT_ARM build


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.37 25-Nov-2015 skrll

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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.32 29-Oct-2014 skrll

branches: 1.32.2;
Sprinkle #include "opt_multiprocessor.h"


# 1.31 24-Oct-2014 skrll

Remove unnecessary #include


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.30 23-May-2014 kiyohara

branches: 1.30.2;
Fix build failed with GUMSTIX(pxa2x0). build test only now.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 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.


Revision tags: riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 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.


Revision tags: yamt-pagecache-base8
# 1.16 31-Dec-2012 matt

Correct one of the kernel_size calculations.


Revision tags: yamt-pagecache-base7
# 1.15 10-Dec-2012 matt

if __HAVE_MM_MD_DIRECT_MAPPED_PHYS is defined, make sure mapallmem_p is true.


Revision tags: matt-nb6-plus-base matt-nb6-plus-nbase yamt-pagecache-base6
# 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