Home | History | Annotate | Download | only in arm32
History log of /src/sys/arch/arm/arm32/pmap.c
RevisionDateAuthorComments
 1.443  13-Apr-2024  skrll port-arm/58135: reproducible pmap KASSERT failure for armv7 with NFS root

Don't unconditionally set XN in pmap_clearbit - only set it if a mapping
exists VM_PROT_EXEC is being cleared.

I've simplified the #ifdefs in the patch from the PR.
 1.442  13-Apr-2024  skrll Restore a space I accidentally removed from a copyright with

$NetBSD: pmap.c,v 1.396 2020/03/13 16:14:18 skrll Exp $
 1.441  13-Dec-2023  rin arm: pmap: Fix clang build without DIAGNOSTIC
 1.440  12-Oct-2023  skrll Fix non-DIAGNOSTIC builds
 1.439  20-Apr-2023  skrll Provide a shared pmap_devmap implementation and convert all pmap_devmap
arrays to use DEVMAP_ENTRY{,_END}
 1.438  18-Dec-2022  skrll Appease KDASSERT / LOCKDEBUG.

Tested by mlelstv.
 1.437  03-May-2022  skrll branches: 1.437.4;
Catch up with aarch64 TTBR0 handling in pmap_{,de}activate_efirt and
kpreempt_{en,dis}able.
 1.436  09-Apr-2022  riastradh sys: Use membar_release/acquire around reference drop.

This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.
 1.435  02-Apr-2022  skrll Update to support EFI runtime outside the kernel virtual address space
by creating an EFI RT pmap that can be activated / deactivated when
required.

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

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

Adding support to other platforms should be easier as a result.
 1.434  19-Mar-2022  skrll Alight code re-organisation so it better matches the VPRINTF headings
it is under. NFCI.
 1.433  12-Mar-2022  riastradh sys: Membar audit around reference count releases.

If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

Thread A Thread B
obj->foo = 42; obj->baz = 73;
mumble(&obj->bar); grumble(&obj->quux);
/* membar_exit(); */ /* membar_exit(); */
atomic_dec -- not last atomic_dec -- last
/* membar_enter(); */
KASSERT(invariant(obj->foo,
obj->bar));
free_stuff(obj);

The memory barriers ensure that

obj->foo = 42;
mumble(&obj->bar);

in thread A happens before

KASSERT(invariant(obj->foo, obj->bar));
free_stuff(obj);

in thread B. Without them, this ordering is not guaranteed.

So in general it is necessary to do

membar_exit();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting. (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these. Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that. It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.
 1.432  02-Jan-2022  riastradh arm: Remove #ifdef DIAGNOSTIC now wrong after KASSERT change.

Objects in question aren't volatile here so access is flushable.
 1.431  01-Jan-2022  christos KASSERT now always uses the expression, so don't protect with DIAGNOSTIC
 1.430  26-Aug-2021  skrll Improve a comment
 1.429  24-Aug-2021  skrll Remove '\n' from UVMHIST format
 1.428  23-Mar-2021  skrll Another missing kpreempt_enable
 1.427  23-Mar-2021  skrll Re-enable kpreemption in an error path. Spotted by nat@
 1.426  14-Mar-2021  skrll branches: 1.426.2;
Sprinkle kpreempt_{dis,en}able ready for when preemption gets turned on.
 1.425  01-Feb-2021  skrll "as appropos" -> "as appropriate" in comments
 1.424  29-Jan-2021  skrll More debug
 1.423  24-Jan-2021  skrll More debug
 1.422  30-Oct-2020  skrll branches: 1.422.2;
Retire arm_[di]sb in favour of the isb() and dsb(sy) macro invocations.
 1.421  12-Aug-2020  skrll Whack-a-mole
 1.420  11-Aug-2020  skrll s/pmaphist/maphist/
 1.419  10-Aug-2020  skrll More UVMHIST_LOG and a new KASSERT
 1.418  10-Aug-2020  skrll In pmag_page_remove initilise pvp after taking the page lock
 1.417  10-Jul-2020  skrll Add support for KASAN on ARMv[67]

Thanks to maxv for many pointers and reviews.
 1.416  03-Jul-2020  skrll 1 page is enough for memhook now since the merge of the rmind-uvmplock
branch and the removal of sys/arch/arm/arm32/mem.c

The last users of memhook don't care about number of CPUs or page colours.
 1.415  21-Jun-2020  skrll Use howmany(). NFCI.
 1.414  27-May-2020  skrll KNF
 1.413  27-May-2020  skrll Remove duplicate #include
 1.412  21-Apr-2020  skrll There is no fast spoon^Wfast path in pmap_clearbit.

PR port-arm/55186: tests crash arm pmap

Tested by martin@
 1.411  19-Apr-2020  ad PR port-arm/55186: tests crash arm pmap

pmap_clearbit(): take execbits into account in the fastpath.
 1.410  19-Apr-2020  kre Give UVMHIST_LOG() the 6 args it requires. Unbreak builds.
 1.409  19-Apr-2020  skrll Fix typo in UVMHIST_LOG
 1.408  18-Apr-2020  skrll Remove PMAP_DEBUG by converting to UVMHIST
 1.407  17-Apr-2020  skrll Fix build after PV locking change
 1.406  17-Apr-2020  skrll Use UVMHIST_CALLARGS
 1.405  16-Apr-2020  ad With the right timing, V->P operations could change stuff behind the back of
callers working in the opposite direction - fix it. Tested by skrll@.
 1.404  14-Apr-2020  skrll Fix a comment. From ad@
 1.403  13-Apr-2020  chs slightly change and fix the semantics of pool_set*wat(), pool_sethardlimit()
and pool_prime() (and their pool_cache_* counterparts):

- the pool_set*wat() APIs are supposed to specify thresholds for the count of
free items in the pool before pool pages are automatically allocated or freed
during pool_get() / pool_put(), whereas pool_sethardlimit() and pool_prime()
are supposed to specify minimum and maximum numbers of total items
in the pool (both free and allocated). these were somewhat conflated
in the existing code, so separate them as they were intended.

- change pool_prime() to take an absolute number of items to preallocate
rather than an increment over whatever was done before, and wait for
any memory allocations to succeed. since pool_prime() can no longer fail
after this, change its return value to void and adjust all callers.

- pool_setlowat() is documented as not immediately attempting to allocate
any memory, but it was changed some time ago to immediately try to allocate
up to the lowat level, so just fix the manpage to describe the current
behaviour.

- add a pool_cache_prime() to complete the API set.
 1.402  29-Mar-2020  skrll branches: 1.402.2;
PTE_SYNC before TLB flush and no need to PTE_SYNC after an unmap.
 1.401  29-Mar-2020  skrll Support PMAP_FAULTINFO on arm
 1.400  23-Mar-2020  skrll Reduce #ifdefs
 1.399  14-Mar-2020  ad pmap_remove_all(): Return a boolean value to indicate the behaviour. If
true, all mappings have been removed, the pmap is totally cleared out, and
UVM can then avoid doing the work to call pmap_remove() for each map entry.
If false, either nothing has been done, or some helpful arch-specific voodoo
has taken place.
 1.398  13-Mar-2020  skrll Enhance the DIAGNOSTICs around pmap_grow_map
 1.397  13-Mar-2020  skrll Re-indent a function call. NFCI.
 1.396  13-Mar-2020  skrll Oops... remove a stray <space>
 1.395  13-Mar-2020  skrll Fixup some comments
 1.394  24-Feb-2020  ad Adjust for UVM locking changes
 1.393  23-Feb-2020  skrll type in comment
 1.392  12-Feb-2020  skrll Convert the DEBUG code in pmap_grow_map to DIAGNOSTIC
 1.391  12-Feb-2020  skrll Add a CTASSERT to pmap_grow_l2_bucket that PAGE_SIZE is a multiple of
L2_TABLE_SIZE_REAL.
 1.390  12-Feb-2020  skrll Add a KASERT that we're not overwriting anything in pmap_growkernel
 1.389  12-Feb-2020  skrll Minor changes to make pmap_grow_l2_bucket look more like
pmap_alloc_l2_bucket. NFCI.
 1.388  05-Feb-2020  skrll Fix the armv[67] memory attributes for uncached memory. Previously it was
mapped as strongly-ordered which meant that unaligned accesses would fault.

armv7_generic_bs_map now maps pages with PMAP_DEV which is treated as SO

bus_dma continues to use PMAP_NOCACHE as appropriate, but this now get
mapped to the correct memory attribute bits for armv[67]

DEVMAP_ENTRY usees a new flag PTE_DEV.

The workaround for the unaligned access faults is now removed.

XXX Other armv[67] boards bus_space implementations should be checked.
XXX There is scope to reduce the difference to aarch64
 1.387  02-Feb-2020  skrll More KNF
 1.386  02-Feb-2020  skrll Always call pmap_grow_map with a page aligned new VA. KASSERT that this
happenes.
 1.385  02-Feb-2020  skrll Always pmap_kenter_pa the page in pmap_grow_map regardless of how we got
it.
 1.384  02-Feb-2020  skrll KNF
 1.383  02-Feb-2020  skrll Fix comment
 1.382  25-Jan-2020  skrll A fix and an optimisation to pmap_l1tt_free
- in the !__HAVE_MM_MD_DIRECT_MAPPED_PHYS case pass UVM_KMF_WIRED so that
the mappings are removed and the KVA is released. Fixes the KASSERT
seen in the automated test runs.
- in the __HAVE_MM_MD_DIRECT_MAPPED_PHYS case we can work out pa much
easier than caling pmap_extract.
 1.381  19-Jan-2020  skrll Fix non-ARM_MMU_EXTENDED buildx
 1.380  18-Jan-2020  skrll Use 4K pages on ARM_MMU_EXTENDED platforms (all armv[67] except RPI) by
creating a new pool l1ttpl for the userland L1 translation table which
needs to be 8KB and 8KB aligned.

Limit the pool to maxproc and add hooks to allow the sysctl changing of
maxproc to adjust the pool.

This comes at a 5% performance penalty for build.sh -j8 kernel on a
Tegra TK1.
 1.379  18-Jan-2020  skrll Trailing whitespace
 1.378  17-Jan-2020  skrll Fix a bug introduced in 1.271 where pmap_grow_map would no longer map
the allocated page for the uvm.page_init_done == false case when
PMAP_STEAL_MEMORY is not defined.
 1.377  17-Jan-2020  skrll Typo in comment
 1.376  17-Jan-2020  skrll Update PMAP_STEAL_MEMORY code to uvm_hotplug
 1.375  31-Dec-2019  skrll branches: 1.375.2;
Improve a comment
 1.374  25-Sep-2019  skrll Convert a __CTASSERT into a KASSERT as L1_S_CACHE_MASK may not be a
compile time constant if ARM_NMMUS > 1
 1.373  23-Apr-2019  bouyer branches: 1.373.2;
Fix a deadlock between the pool and pmap codes:
- cpu0 grabs the kernel lock (e.g. from a non-MPSAFE interrupt) and
calls pool_get().
- cpu1 does a pool_get() on the same pool from MPSAFE code, which needs a
pool_page_alloc(), which ends up in pmap_extract_coherency().

So cpu0 holds the kernel_lock and wants the pool lock. cpu1 holds the pool
lock and wants the kernel_lock in pmap_extract_coherency().

The pmap code should not rely on kernel_lock. Intead make the
pmap_kernel()->pm_obj_lock a IPL_VM lock and use it as pmap lock
(thus dropping the pmap test pmap_{acquire,release}_pmap_lock()).
This needs to be a IPL_VM because unlike user pmaps, this can be locked
from interrupt context.

Add a IPL_NONE lock for pmap_growkernel(). We can't use
pmap_kernel()->pm_obj_lock here because pmap_grow_map() may sleep.

Make pmap_lock (which may be locked with pm_obj_lock held) a IPL_VM
lock in all case.

reorder a few things to not call pool_get()/pool_put() (which may sleep)
with pm_obj_lock held.

Patch initially posted to port-arm@ on April 19, improved patch (per
suggestions from Nick Hudson and Jason Thorpe) on April 21.
 1.372  23-Apr-2019  bouyer Don't try to aquire/release the pmap lock when in ddb.
Avoids a deadlock when entering ddb, or on "mach cpu n" ddb command
(the pmap lock may already be held by another CPU, which is halted when
entering ddb).
Posted to port-arm@ on April 19.
 1.371  28-Oct-2018  skrll Fix the comment near pmap_bootstrap itself as well
 1.370  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.369  14-Oct-2018  skrll Use __nothing
 1.368  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.367  28-Aug-2018  skrll Fix arguments to align and align_offset for pmap_l2ptp_cache, i.e.align
is now L2_TABLE_SIZE_REAL and align_offset is now 0. (There were
reversed previously)
 1.366  31-Jul-2018  skrll Define and use VPRINTF
 1.365  01-Apr-2018  ryo branches: 1.365.2;
Add initial support for ARMv8 (AARCH64) (by nisimura@ and ryo@)

- sys/arch/evbarm64 is gone and integrated into sys/arch/evbarm. (by skrll@)
- add support fdt. evbarm/conf/GENERIC64 fdt (bcm2837,sunxi,tegra) based generic 64bit kernel config. (by skrll@, jmcneill@)
 1.364  22-Jan-2018  skrll branches: 1.364.2;
Add PMAP_WRITE_COMBINE: to the list of flags supported by pmap_kenter_pa
 1.363  22-Jan-2018  skrll Trailing whitespace
 1.362  17-Jan-2018  skrll G/C ARM32_NEW_VM_LAYOUT
 1.361  01-Nov-2017  skrll Unwrap two lines. NFC.
 1.360  01-Nov-2017  skrll Fix a comment
 1.359  28-Oct-2017  pgoyette Update the kernhist(9) kernel history code to address issues identified
in PR kern/52639, as well as some general cleaning-up...

(As proposed on tech-kern@ with additional changes and enhancements.)

Details of changes:

* All history arguments are now stored as uintmax_t values[1], both in
the kernel and in the structures used for exporting the history data
to userland via sysctl(9). This avoids problems on some architectures
where passing a 64-bit (or larger) value to printf(3) can cause it to
process the value as multiple arguments. (This can be particularly
problematic when printf()'s format string is not a literal, since in
that case the compiler cannot know how large each argument should be.)

* Update the data structures used for exporting kernel history data to
include a version number as well as the length of history arguments.

* All [2] existing users of kernhist(9) have had their format strings
updated. Each format specifier now includes an explicit length
modifier 'j' to refer to numeric values of the size of uintmax_t.

* All [2] existing users of kernhist(9) have had their format strings
updated to replace uses of "%p" with "%#jx", and the pointer
arguments are now cast to (uintptr_t) before being subsequently cast
to (uintmax_t). This is needed to avoid compiler warnings about
casting "pointer to integer of a different size."

* All [2] existing users of kernhist(9) have had instances of "%s" or
"%c" format strings replaced with numeric formats; several instances
of mis-match between format string and argument list have been fixed.

* vmstat(1) has been modified to handle the new size of arguments in the
history data as exported by sysctl(9).

* vmstat(1) now provides a warning message if the history requested with
the -u option does not exist (previously, this condition was silently
ignored, with only a single blank line being printed).

* vmstat(1) now checks the version and argument length included in the
data exported via sysctl(9) and exits if they do not match the values
with which vmstat was built.

* The kernhist(9) man-page has been updated to note the additional
requirements imposed on the format strings, along with several other
minor changes and enhancements.

[1] It would have been possible to use an explicit length (for example,
uint64_t) for the history arguments. But that would require another
"rototill" of all the users in the future when we add support for an
architecture that supports a larger size. Also, the printf(3) format
specifiers for explicitly-sized values, such as "%"PRIu64, are much
more verbose (and less aesthetically appealing, IMHO) than simply
using "%ju".

[2] I've tried very hard to find "all [the] existing users of kernhist(9)"
but it is possible that I've missed some of them. I would be glad to
update any stragglers that anyone identifies.
 1.358  08-Oct-2017  flxd Revert attempt at tracking unmanaged mappings for VIVT as it was incomplete and
buggy. PR port-shark/52102
From skrll@. Tested by martin@ and me.
 1.357  06-Sep-2017  skrll Remove useless KASSERT - we can't assert !mutex_owned()
 1.356  02-Sep-2017  skrll Perform tracking of unmanaged mappings for VIVT and call vac_me_harder
as appropriate.

PR/52102 shark: ffs_newvnode panic when unpacking sets installing -current

Thanks to Felix Deichmann for bisecting the problem and testing the fix.
 1.355  02-Sep-2017  skrll KNF
 1.354  02-Sep-2017  skrll Remove an #ifdef PMAP_CACHE_VIVT that's inside #ifdef PMAP_CACHE_VIVT
already
 1.353  24-Aug-2017  jmcneill Do runtime detection of MP extensions to allow using a MULTIPROCESSOR
kernel on CPUs without the MP extensions feature (like Cortex-A8).
 1.352  27-Jul-2017  skrll Macro confusion - fortunately this has no functional change.
 1.351  27-Jul-2017  skrll Remove redundant test - the compiler realised anyway as we get same binary
output
 1.350  10-Jul-2017  skrll No need for '\n' in UVMHIST_LOG
 1.349  24-May-2017  skrll branches: 1.349.2;
Check the "Havard TLB" maintenance operations if the "Unified TLB"
maintenance opeations don't include invalidate by ASID. Some CPUs, e.g.
Cortex-A8, have Havard TLBs and report ASID operations this way.
 1.348  24-May-2017  skrll Move closer to the common pmap by using the same pmap_remove_all
optimisation where TLB flushes are avoided by clever ASID assignment.

pmap_remove_all_complete can now be removed.
 1.347  22-May-2017  skrll Indent comment to match code it's describing
 1.346  21-May-2017  skrll KNF
 1.345  17-Apr-2017  skrll Perform icache syncs for ARM_MMU_EXTENDED as well. This helps the PT_STEP
code in pr/52119 and probably other things.
 1.344  25-Feb-2017  christos fix unused.
 1.343  23-Feb-2017  skrll Fixup the compile time decisions around PMAP_{INCLUDE,NEEDS}_PTE_SYNC and
fix the options for xscale boards which require the code in
pmap_l2ptp_ctor marked as #ifndef PMAP_INCLUDE_PTE_SYNC.

Fix the typo (pte -> opte) in this code block and consistently use opte
elsewhere.

PR/51990: Regression data_abort_handler: data_aborts fsr=0x406 far=0xbfffeff5 on copyout in init
 1.342  23-Dec-2016  cherry branches: 1.342.2;
"Make NetBSD great again!"

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

Chuck Silvers - for multiple API reviews and feedback.
Nick Hudson - for testing on multiple architectures and bugfix patches.
Everyone who helped with boot testing.

KeK (http://www.kek.org.in) for hosting the primary developers.
 1.341  17-Dec-2016  flxd Fix typo "one the" and architecture where appropriate.
 1.340  04-Aug-2016  skrll provide and use 'ci' in pmap_remove_all_complete.
 1.339  03-Aug-2016  skrll Don't touch pm_onproc at all in pmap_{update,destroy} and adjust KASSERT
to suit.

Update to cover the PMAP_TLB_MAX > 1 case as well while I'm here.
 1.338  01-Aug-2016  skrll pm_remove_all needs handling in pmap_destroy as well as pmap_update
 1.337  29-Jul-2016  skrll more debug
 1.336  29-Jul-2016  skrll Simplify ARM_MMU_EXTENDED #ifdefs

No functional change
 1.335  14-Jul-2016  skrll branches: 1.335.2;
Adapt this to the recent sys/uvm/pmap/pmap_tlb.c changes. MP kernels
now don't trigger KASSERTs
 1.334  14-Jul-2016  skrll Spell PMAP_TLB_NEED_SHOOTDOWN correctly
 1.333  12-Jul-2016  skrll Fix harmless (?) typo
 1.332  14-Dec-2015  skrll Delete pmap_pmaps and its only user pmap_dump_all. The list wasn't
being updated in an MP-safe manner.
 1.331  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.330  13-Nov-2015  skrll Tweak the KASSERTs in pmap_update in the ARM_MMU_EXTENDED case - Lazy
updating is not done on the kernel pmap.

PR port-arm/50420: curcpu()->ci_pmap_cur != pm || pm->pm_pai[0].pai_asid == curcpu()->ci_pmap_asid_cur" failed
 1.329  13-Nov-2015  skrll Wrap long lines.
 1.328  11-Nov-2015  skrll Support pmap_pv_track and friends
 1.327  06-Nov-2015  skrll Trailing whitespace
 1.326  26-Jul-2015  matt KASSERT->KASSERTMSG
 1.325  09-Jun-2015  skrll Use armreg_auxctl_{read,write} instead of inline asm.

No functional change.
 1.324  01-Jun-2015  matt pmap_directbase is a failed experiment, nuke it.
 1.323  30-May-2015  matt Support directmapped systems with >1GB that start memory at 0x80000000.
 1.322  13-May-2015  skrll Use PDE_SYNC when syncing pdeps
 1.321  11-May-2015  matt Make sure nptes is a multiple of PAGE_SIZE / L2_S_SIZE.
 1.320  13-Apr-2015  matt Add pmap locking to pmap_kenter_pa/kremove
 1.319  11-Apr-2015  skrll #include "opt_arm_debug.h" for VERBOSE_INIT_ARM
 1.318  07-Apr-2015  matt Fix two bugs. pmap_is_cached fix for MULTIPROCESSOR (not just ASID on
local cpu -> any valid ASID on any cpu).
pmap_deactivate: update curcpu()->ci_pmap_cur_asid to KERNEL_PID too.
 1.317  25-Feb-2015  joerg Improve inline asm around dsb/dmb/isb:
- always use volatile and mark them as memory barrier
- use the common version from locore.h in all places not included from
userland
 1.316  10-Nov-2014  skrll branches: 1.316.2;
Update PTE_SYNC_CURRENT to add a dsb for armv7 - part of the
break-before-make fix.
 1.315  10-Nov-2014  skrll Remove an XXXNH comment.
 1.314  10-Nov-2014  skrll Remove an unnecessary flush that sneaked in as part of break-before-make
change.
 1.313  10-Nov-2014  skrll In pmap_fault_fixup re-instate the TLB flush for the shared L1 case that
occurs for non-ARM_MMU_EXTENDED kernels.

This fixes rump/rumpkern/t_sp:stress_killer on rpi which is currently
non-ARM_MMU_EXTENDED
 1.312  08-Nov-2014  matt When allocing a l1page, if a page isn't available, use uvm_wait to wait
for one to become available. Should fix PR/49364.
 1.311  07-Nov-2014  skrll The fixup debug message can report false positives on MULTIPROCESSOR, so
disable them there.
 1.310  07-Nov-2014  skrll In pmap_enter only flush the TLB if really necessary
 1.309  05-Nov-2014  skrll Fix typo in comment
 1.308  04-Nov-2014  matt pmap_tlb_flushD is for !ARM_MMU_EXTENDED only now
 1.307  29-Oct-2014  skrll Apply a bunch of break-before-make, i.e. set PTEs to zero, flush the TLB
(across all CPUs) and set new PTE value. Mostly from matt@ with some
updates from me.

Flush the branch predictor in pmap_update.
 1.306  29-Oct-2014  skrll In pmap_deactivate don't set TTBR with the ASID of the deactivated LWP -
use KERNEL_PID instead.

This is probably a no-op as TTBCR_S_PD0 should (still) be set at the time
of the call to cpu_setttb.
 1.305  25-Oct-2014  skrll Remove katelib.h and references to it.

{Read,Write}{Word,Byte} macros are provided in the files that still use
them. Someone(tm) should convert them to bus_space(9)
 1.304  20-Oct-2014  skrll Reduce code a little. Reviewed by gimpy.
 1.303  14-Oct-2014  skrll Typo in comment
 1.302  23-Sep-2014  matt Use right conditional for checking nG.
 1.301  23-Sep-2014  nonaka nG bit exists only in ARMv6 and above.
 1.300  21-Sep-2014  christos remove dead code
 1.299  05-Sep-2014  matt Don't nest structure definitions.
 1.298  30-Aug-2014  kiyohara It expects return value 'va != NULL' from uvm_km_alloc().
 1.297  13-Aug-2014  matt Fix for PR/49061
only kassert in pmap_kenter_pa if PMAP_CACHE_PIVT && !ARM_MMU_EXTENDED
 1.296  13-Aug-2014  matt Fix for PR/49107.
Make sure pmap_copy_page_xscale clears the ptes afters its done with them.
 1.295  25-Jul-2014  matt branches: 1.295.2;
PTE_SYNC_RANGE a newly allocated L1 page for ARM_MMU_EXTENDED
 1.294  15-Jun-2014  ozaki-r Add missing semicolon
 1.293  05-Jun-2014  matt Fix occupancy bug.
 1.292  30-Apr-2014  joerg pmap_is_current might be unused, tag it as such.
 1.291  22-Apr-2014  skrll Remove stray comment.
 1.290  22-Apr-2014  skrll Call pmap_free_l2_bucket for the kernel pmap so that l2b_occupancy is
updated. pmap_free_l2_bucket already deals with the kernel pmap properly.

ok matt@

Should fix the

panic: kernel debugging assertion "mappings <= l2b->l2b_occupancy" failed:
file "/usr/src/sys/arch/arm/arm32/pmap.c", line 3838

problem reported on port-arm by Joachim Thiemann
 1.289  22-Apr-2014  skrll Fix a format string to actually print the prot
 1.288  20-Apr-2014  matt Reduce resident_count by number of pages, not number of ptes.
 1.287  12-Apr-2014  matt KDASSERT -> KDASSERTMSG
 1.286  12-Apr-2014  skrll Trailing whitespace
 1.285  12-Apr-2014  skrll Fix typo and unbreak the build for various arm kernel builds.
 1.284  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.283  10-Apr-2014  matt Fix pasto.
 1.282  10-Apr-2014  matt Fix pmap_extract to deal with non-4KB pages.
 1.281  05-Apr-2014  skrll Add a missing pmap_release_page_lock
 1.280  02-Apr-2014  matt branches: 1.280.2;
Mark omd as diagused for the ARM_MMU_EXTENDED case.
 1.279  02-Apr-2014  skrll Fix non-DIAGNOSTIC build
 1.278  02-Apr-2014  matt Init the page_lock to IPL_VM iff VIPT && arm_cache_prefer_mask != 0 otherwise
use IPL_NONE. Don't bother with page_lock for KMPAGEs.
 1.277  02-Apr-2014  matt braces are your friends. use them.
 1.276  02-Apr-2014  matt Really fix locking this time.
 1.275  02-Apr-2014  matt Because vector_page might be 0, we have to process the entry L1pt.
Make sure to map the new l2 area after we've grown the kernel.
If msgbufaddr is set, don't alloc space for msgbuf.
 1.274  01-Apr-2014  matt For ARM_MMU_EXTENDED, if the page being mapped asked for EXEC but is not EXEC,
sync it.
 1.273  31-Mar-2014  matt tag a variable with __diagused
 1.272  30-Mar-2014  matt Fix debug code in fault_fixup
 1.271  30-Mar-2014  matt Make the ARM pmap use ASIDs, split TTBRs, and MP safe. This only happens for
ARMv6 or later CPUs. This means that on context switch that the TLBs and
caches no longer to cleaned/flushed. Also, eXecute Never (XN) protection has
been added so non-exec pages can not be run. Change the page size for ARMv6+
to be 8KB while allows a L1PT to be a normal page. This means that the L1PT
is not special. Use the XN support to only sync pages that are executed from.
 1.270  27-Feb-2014  joerg Member will never be null, so remove check.
 1.269  26-Feb-2014  matt Only track kenter_pa'ed pages if arm_cache_prefer_mask is non-zero.
 1.268  26-Feb-2014  matt Don't do ref/mod emulation for KENTRY pages.
l2pte_minidata -> l2pte_minidata_p
 1.267  26-Feb-2014  matt Move pmap_recent_user to ci->ci_pmap_lastuser and
pmap_previous_active_lwp to ci->ci_lastlwp. Fix some comments.
 1.266  26-Feb-2014  matt l2pte_valid -> l2pte_valid_p
 1.265  26-Feb-2014  matt Add support for PMAP_PTE to pmap_kenter_pa
 1.264  12-Sep-2013  kiyohara Fix VIVT cache operation. Tested on Kirkwood machines.
 1.263  18-Aug-2013  matt Include <arm/locore.h>
 1.262  03-Jul-2013  matt Add l2pte_set and l2pte_reset inlines to set/reset a pte. These will be
used to support > 4KB pages sizes.
Don't use >> L1_S_SHIFT, use L1_IDX() instead.
 1.261  03-Jul-2013  matt restore deleted conditional
 1.260  03-Jul-2013  matt Fix c&p error
 1.259  03-Jul-2013  matt Collapse multiple inlines and move repeated tests into them.
No functional change.
 1.258  03-Jul-2013  matt Add pmap_domain and pmap_l1_kva inlines.
 1.257  12-Jun-2013  matt branches: 1.257.2;
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.256  12-Jun-2013  matt If the vector_page is not ARM_VECTORS_{LOW,HIGH}, assume it's in kernel
text and don't do anything special to map it.
 1.255  11-May-2013  skrll Fix !DDB build.
 1.254  29-Mar-2013  matt Fix pmap_flush_page to also flush the secondary cache, if there is one.
This solves a bus_dma problem with DMA from uncached pages.
 1.253  13-Feb-2013  matt Some armv7 fixes for speculative tlb loads.
 1.252  04-Feb-2013  macallan support ARM32_MMAP_WRITECOMBINE for managed pages as well
 1.251  01-Feb-2013  matt cleanup PVF_WRITE & pvh_attrs interaction.
 1.250  31-Jan-2013  skrll Another typo in a comment.
 1.249  31-Jan-2013  skrll Typo in comment.
 1.248  19-Jan-2013  matt Switch from only UVM_PGA_STRAT_ONLY to UVM_PGA_STRAT_FALLBACK in
arm_pmap_alloc_poolpage.
 1.247  11-Jan-2013  matt Fix a bug in pmap_modify_pv where we didn't set PVF_WRITE on a page after
changing its mapping to writeable.
Add more KASSERTS
Don't go into DDB by default in pmap_fixup.
 1.246  11-Dec-2012  matt Fix C&P bug.
 1.245  11-Dec-2012  matt Fix c&p error.
 1.244  11-Dec-2012  matt Optimize pmap_{copy,zerp}_page_generic to understand that when all of memory
is always mapped that you don't have create mappings dynamically.
 1.243  10-Dec-2012  matt Change a KASSERT to a KASSERTMSG
 1.242  12-Nov-2012  skrll C99 types
 1.241  17-Oct-2012  matt Add a PMAP_NEEDS_ALLOC_POOLPAGE / PMAP_ALLOC_POOLPAGE hook so systems can
allocate pool pages from a specific VM freelist.
 1.240  17-Oct-2012  matt Need to set pmap_needs_pte_sync before calling PTE_SYNC
 1.239  17-Oct-2012  matt When setting pmap_needs_pte_sync to 1 be sure to sync pte that caused
the issue.
 1.238  26-Sep-2012  matt If we get a fault we shouldn't have, set pmap_needs_pte_sync and retry.
 1.237  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.236  02-Sep-2012  matt branches: 1.236.2;
Supersections are on armv6 too.
 1.235  30-Aug-2012  matt Teach pmap_extract about supersections.
 1.234  29-Aug-2012  matt Make all cortex and arm11 cpus uses writeback cached memories for pagetables
 1.233  29-Aug-2012  matt Support PMAP_NOCACHE in pmap_kenter_pa
 1.232  29-Aug-2012  matt Use the correct prot mask in vector_page_setprot
 1.231  27-Aug-2012  matt Use the correct (L1_S_PROT, not L2_S_PROT) macro for setting the protection
of the vector page. This fixes a nasty little bug that shows up on armv7
systems when the vector page physical address changes (bit 12 of the address
is cleared) and then any exception causes the system to hang.
 1.230  20-Aug-2012  matt Add support for mapping SuperSection on armv6 and armv7. These always
a domain of 0 so move the kernel from domain 15 to domain 0.
 1.229  13-Jul-2012  skrll Fix a KASSERT. From/OK'ed by matt@
 1.228  29-Jan-2012  he branches: 1.228.2;
Only declare helper variable which is only used in KASSERT() if
DIAGNOSTIC is defined, to avoid "variable defined but never used"
warning if DIAGNOSTIC isn't defined, and KASSERT() expands to
nothing.
 1.227  28-Jan-2012  matt Since we don't do MULTIPROCESSOR, and hence preemption, locking the pvlists
doesn't really matter.
 1.226  28-Jan-2012  matt Don't use simple locks.
 1.225  27-Jan-2012  para extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.224  01-Jul-2011  dyoung branches: 1.224.2; 1.224.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.223  30-Jun-2011  wiz dependant -> dependent
 1.222  12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.221  10-Mar-2011  bsh branches: 1.221.2;
Preliminary ARM11 MPCore support.

I have confirmed this commit doesn't affect existing evbarm kernels by
comparing binaries.
 1.220  28-Feb-2011  macallan implement arm32_pmap_flags() to allow mappings with write buffering enabled,
mostly for video memory
Tested on shark
 1.219  12-Nov-2010  uebayasi branches: 1.219.2; 1.219.4;
Put VM_PAGE_TO_MD() definition in one place. No functional changes.
 1.218  10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.217  03-Nov-2010  uebayasi Fix build of IXM1200 too. Pointed out by cegger, thanks.
 1.216  02-Nov-2010  uebayasi Fix build of XScale.
 1.215  30-Oct-2010  uebayasi Pass struct vm_page_md * where possible.

This causes 1% code increase, mainly because additional argument
(paddr_t) affects register usage. This will be fixed when per-page
data structure (struct vm_page) is redone, and physical address
can be retrieved from struct vm_page_md *.

Tested on (uncommitted) i.MX35 (ARM1136).
 1.214  16-Jun-2010  jmcneill PR port-arm/43299: Support added for igepv2/cortexa8/omap3530

Apply patch from PR, with build fixes. ok skrll, matt
 1.213  14-May-2010  cegger Move PMAP_KMPAGE to be used in pmap_kenter_pa flags argument.
'Looks good to me' gimpy@
 1.212  15-Feb-2010  skrll branches: 1.212.2;
Typo in comment.
 1.211  02-Jan-2010  he branches: 1.211.2;
Remove a shadowed and unused local declaration so that this builds again.
 1.210  01-Jan-2010  uebayasi Sprinkle assertions after calling pmap_get_l2_bucket().
 1.209  31-Dec-2009  uebayasi Use pmap_is_current() where appropriate. No functional changes.
 1.208  31-Dec-2009  uebayasi pmap_page_remove(): remove an unused local variable; no functional changes.
 1.207  31-Dec-2009  uebayasi Correct assertions for PMAP_CACHE_VIPT code; if page coloring is disabled
(arm_cache_prefer_mask == 0), pvh_attrs has never PVF_COLORED, so don't assert
it. No functional changes.
 1.206  28-Dec-2009  uebayasi Indent.
 1.205  28-Dec-2009  uebayasi Always name struct pv_entry * as pv, not pve. No binary change.
 1.204  27-Dec-2009  uebayasi Add write-through cache work-around for ARM11 as well as ARM9/ARM10. Analyzed
& tested on i.MX35 with help from Tsubai Masanari.
 1.203  28-Nov-2009  scw Apply some band-aid to pmap_activate() for PR kern/41058:

There's a corner case here which can leave turds in the cache as
reported in kern/41058. They're probably left over during tear-down and
switching away from an exiting process. Until the root cause is identified
and fixed, zap the cache when switching pmaps. This will result in a few
unnecessary cache flushes, but that's better than silently corrupting data.

Also remove an extraneous return statement in pmap_page_protect() which
crept in during the matt-armv6 merge.
 1.202  21-Nov-2009  rmind Use lwp_getpcb() on ARM (and acorn26/32), clean from struct user usage.
 1.201  07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.200  22-Oct-2009  rmind Simplify pmap_remove() a little by avoiding pmap_do_remove() layer, since
possibility to skip wired mappings is not needed anymore. Apart from that,
no functional differences are intended.
 1.199  21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.198  21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.197  15-Mar-2009  cegger ansify function definitions
 1.196  09-Mar-2009  nonaka avail_start and avail_end is paddr_t.
 1.195  08-Jan-2009  matt branches: 1.195.2;
When allocating a KMPAGE and it has multiple colors, make sure to flush them.
Add some more KASSERTs for multiple colors (or lack thereof).
 1.194  30-Dec-2008  matt Reclaim PVF_KNC in VIPT to be PVF_MULTCLR (page has multiple colors).
Track when a page is mapping in multiple colors and deal with the ramifications.
When a page's MOD attribute is cleared, clean it from the cache.
Fix a logic inversion.

With these changes, the TI SDP2420 H4 board can successfully natively build a
TISDP2420 kernel.
 1.193  10-Dec-2008  pooka Make kernel_pmap_ptr a const. Requested by steve_martin.
 1.192  09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

Bonus cosmetics round: move all the pmap_t pointer typedefs into
uvm_pmap.h.

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.191  19-Nov-2008  matt Allocate /dev/mem's page in pmap_init. Mark /dev/mem as MPSAFE. Ansify.
 1.190  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.189  04-Nov-2008  matt Use a mutex to control access DEV_MEM.
 1.188  04-Nov-2008  matt Protect some code with if (pg) { .. }
 1.187  28-Sep-2008  skrll branches: 1.187.2; 1.187.4; 1.187.8;
Typo in comment.
 1.186  14-Aug-2008  matt Now that we track pages used by any of the kernel memory allocators,
keep a count of them and export it as a sysctl node machdep.kmpages
 1.185  13-Aug-2008  matt Fix a few more corner cases. Always KMPAGE or pages with unmanaged writeable
kernel mappings as modified. Only ever set DIRTY bit is DMOD is true and
NC is false. Don't modify unmanaged mappings in pmap_clearbit.
 1.184  08-Aug-2008  dogcow fix "warning: 'npv' may be used uninitialized in this function"
 1.183  06-Aug-2008  matt Change pv_entries to use SLIST.

For VIPT caches, keep track of when pages are dirty so that their content
can be flushed back to main memory. This is done when the page is
read-only mapped by more than 1 color. Pages become when either their
modified bit gets set or an unmanaged writeable page is mapped. When
a page in unmapped or changed to read-only, run pmap_vac_me_harder in
case the page can be mapped read-only.

Thanks are given to Imre Deak for giving me the idea to assert for PVF_DIRTY.
 1.182  16-Jul-2008  matt Revamp bookkeeping for pages entered by pmap_kenter_pa. Keep track of them
on pvlists so that the cacheability can be properly tracked.
 1.181  09-Jul-2008  scw When dealing with 'cleanlist_idx == PMAP_REMOVE_CLEAN_LIST_SIZE' in
pmap_do_remove(), make sure to use PTE_SYNC() for each rolled-back
PTE on the list.

Fixes potential MMU inconsistencies on some ARM platforms where
page-tables are mapped write-back.
 1.180  03-Jul-2008  matt branches: 1.180.2;
Use the same login in pmap_kenter_pa when removing an unmamanged mapping
as in pmap_kremove (otherwise kro_mappings will become incorrect).
 1.179  03-Jul-2008  matt For armv6(VIPT), change the rules for mapping via kenter_pa. Allow readonly
pages to be mapped by different cache color indexes.
 1.178  24-Jun-2008  scw In pmap_deactivate(), if the process is exiting make sure the next call
to pmap_activate() performs a full MMU context-switch and cache flush,
which might otherwise be skipped.

Fixes ARM_LOW_VECTORS problem reported in PR port-arm/38950.
 1.177  17-Jun-2008  chris Fix two KASSERT(value | (C1|C2)) to KASSERT(value & (C1|C2)) so that it
tests for something, rather than always being true.

Pointed out by Andy Shevchenko in:
http://mail-index.netbsd.org/port-arm/2008/06/17/msg000255.html
 1.176  04-Jun-2008  ad branches: 1.176.2;
vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both.
 1.175  28-Apr-2008  martin branches: 1.175.2;
Remove clause 3 and 4 from TNF licenses
 1.174  27-Apr-2008  matt Merge kernel changes in matt-armv6 to HEAD.
 1.173  20-Apr-2008  scw branches: 1.173.2;
There's really no need to switch VM contexts within cpu_switchto() as
MI code always calls pmap_deactivate/pmap_activate on context switch.

Instead, just record the last active lwp (or NULL if it exited) and
defer switching VM context to pmap_activate(). This saves an additional
function call overhead in cpu_switchto().

While here, g/c unused cpuswitch.S local .Lblock_userspace_access.
 1.172  29-Mar-2008  chris branches: 1.172.2;
Fix LOCKDEBUG build on arm by:
* converting simple_{un}lock to mutex_enter/exit
* Using UVM_OBJ_INIT & DESTROY for the uvm_object in the pmap structure
 1.171  06-Jan-2008  matt branches: 1.171.6;
current_intr_depth is dead. Make sure we don't use it anymore.
 1.170  01-Jan-2008  chris Add support for kcore headers to arm32 kernel core dumps.

The kcore code is based on i386's kcore header handling.

Having an asm stub for dumpsys, to dump the registers onto the stack, and
then call the C code to do the memory dump is based on amd64's core dump
code.

This allows a successful core dump on cats.

Part of fixing PR cats/18026.
 1.169  08-Nov-2007  matt branches: 1.169.6;
Make this compile again.
 1.168  07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.167  17-Oct-2007  garbled branches: 1.167.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.166  10-Oct-2007  ad branches: 1.166.2;
Comment out references to spinlockmgr().
 1.165  15-Sep-2007  scw branches: 1.165.2;
ARM cpu_switchto() has been partially broken since yamt-idlelwp was merged
as its cache/tlb management smarts relied too heavily on pre-merge context-
switch behaviour. See PR kern/36548 for one manifestation of the breakage.

To address this:
- Ditch the shadow pmap variables in the PCB (pagedir, l1vec, dacr, cstate)
as it was too easy for them to get out of sync with the pmap.
- Re-write (and fix) the convoluted cpuswitch.S cache/tlb ASM code in C.
It's only slightly less efficient, but is much more readable/maintainable.
- Document cpufuncs.cf_context_switch() as being C-callable.
- pmap_activate() becomes a no-op if the lwp's vmspace is already active.
(Good performance win, since pmap_activate() is now invoked on every
context-switch, even though ARM's cpu_switchto() already does all the
grunt work)

XXX: Some CPU-specific armXX_context_switch() implementations (arm67,
arm7tdmi, arm8) always flush the I+D caches. This should not be necessary.
Someone with access to hardware (acorn32?) needs to deal with this.
 1.164  17-May-2007  yamt branches: 1.164.6; 1.164.8; 1.164.10; 1.164.12;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.163  09-Apr-2007  chris branches: 1.163.4;
In pmap_activate restore interrupts to their previous state rather than
always enabling them.

It's not clear if this actually caused any problems, but it seems safer
to restore to the previous state in case pmap_activate is ever called
with interrupts disabled.
 1.162  12-Mar-2007  ad branches: 1.162.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.161  04-Mar-2007  christos branches: 1.161.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.160  22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.159  21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.158  06-Jan-2007  christos branches: 1.158.2;
From Scott Allen in http://mail-index.netbsd.org/port-arm/2006/07/26/0000.html
I ran into a problem when I tried to set up a mapping that started at virtual
address 0xFFF00000 and was 0x00100000 long. In other words, the mapping
should have gone to the end of the 32 bit address space. The mapping was made
with no problem, but pmap_devmap_find_va() wouldn't find an address within the
mapping. For example, if I told it to find a mapping for 0x1000 bytes at
0xFFF01000, it would try to make sure that 0xFFF01000 was greater than
0xFFF00000 and that (0xFFF01000+0x1000) was less than (0xFFF00000+0x00100000).
However, that last expression (0xFFF00000+0x00100000) wrapped around to be
simply 0x00000000 so it wasn't found. This patch fixes this problem in
pmap_devmap_find_va() and pmap_devmap_find_pa() by subtracting one off of the
sizes to be compared, so in my example, (0xFFF01000+0x1000-1) will be less
than (0xFFF00000+0x00100000-1).
 1.157  24-Dec-2005  perry branches: 1.157.20; 1.157.24;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.156  10-Dec-2005  scw Implement pmap_collect() for arm32.
 1.155  08-Dec-2005  yamt use VM_PAGE_TO_PHYS macro.
 1.154  04-Jul-2005  bsh branches: 1.154.2;
The first step to support Intel PXA270.

kernel config option CPU_XSCALE_PXA2X0 is now obsoleted by
CPU_XSCALE_PXA250 and CPU_XSCALE_PXA270. If both of them are defined,
CPU is determined run-time.
 1.153  24-Jun-2005  scw In pmap_devmap_find_pa(), use 64-bit arithmetic to handle the case where
'pa + size' == 0x0. As in, if we're passed details of a region right at
the top of physical address space.

Otherwise we'll likely hit a false-positive due to 32-bit wrap-around.
 1.152  26-Apr-2005  scw Since pmap_page_remove() is called from pmap_page_protect(), don't modify
the current pmap's pm_cstate if we have to flush the TLB, as callers of
pmap_page_protect() are not required to invoke pmap_update() afterwards.

Otherwise we can end up with a pm_cstate which is inconsistent with reality
in the TLB, which can lead to future TLB flushes being erroneously skipped.
 1.151  01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.150  14-Jan-2005  joff branches: 1.150.2; 1.150.4;
Dont try freeing bootstrap pages with pool_page_free. Fixes kern/28869
 1.149  02-Jan-2005  chris Remove direct references to TAILQ internal structures.

No functional change, just tidying up code.
 1.148  03-Apr-2004  bsh pmap_pte_init_arm9() is necessary only when defined(CPU_ARM9) and defined(ARM9_CACHE_WRITE_THROUGH)
 1.147  18-Jan-2004  scw Fix ARM_VECTORS_LOW fallout caused by the recent reaper removal.

Just before removing the vector page mapping, switch to the kernel
pmap's L1/vector page mapping so as not to pull the rug out from
under ourselves.

To prevent the stale L1/vector page mapping from being restored by
cpu_switch, replace the relevant fields of the dying process' pcb
with those of lwp0's pcb.
 1.146  01-Nov-2003  jdolecek avoid stong words in comments
 1.145  29-Oct-2003  mycroft Whitespace.
 1.144  29-Oct-2003  mycroft The previous patch was wrong -- mcr does not output anything. Instead give a
junk input (it's not used when the last argument is 0).
 1.143  28-Oct-2003  scw Fix an uninitialised variable warning, reported by Shoichi Miyake
in port-arm/23293.
 1.142  26-Oct-2003  chris Fix up some unitialised variables.
 1.141  13-Oct-2003  scw On Xscale, define PMAP_UAREA() and use it to tweak uarea mappings so
they use the mini D$.

This results in a small performance boost on xscale platforms, since
flushing the main cache on a context switch won't affect the kernel
stack/pcb.
 1.140  05-Oct-2003  matt Add SA_SIGINFO support for ARM (from Chris Gilbert).
 1.139  21-Sep-2003  matt Change some type-punning detected by gcc 3.3.1 to (void *).
 1.138  06-Sep-2003  rearnsha Support for initializing ARM10 processors in write-through mode.
 1.137  23-Jun-2003  martin branches: 1.137.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.136  15-Jun-2003  thorpej Add another devmap routine that allows bootstrap code to register
a devmap reflecting mappings that are created by really early
bootstrap code before pmap_devmap_bootstrap() is called.
 1.135  15-Jun-2003  thorpej Replace the ad-hoc "section mapping table" for static device mappings
with a more generic "devmap" structure that can also handle mappings
made with large and small pages. Add new pmap routines to enter these
mappings during bootstrap (and "remember" the devmap), and routines to
look up the static mappings once the kernel is running.
 1.134  21-May-2003  thorpej Move the new pmap from arm32/pmap_new.c to arm32/pmap.c, fully replacing
the old.
 1.133  10-May-2003  thorpej Back out the following chagne:
http://mail-index.netbsd.org/source-changes/2003/05/08/0068.html

There were some side-effects that I didn't anticipate, and fixing them
is proving to be more difficult than I thought, do just eject for now.
Maybe one day we can look at this again.

Fixes PR kern/21517.
 1.132  08-May-2003  thorpej Simplify the way the bounds of the managed kernel virtual address
space is advertised to UVM by making virtual_avail and virtual_end
first-class exported variables by UVM. Machine-dependent code is
responsible for initializing them before main() is called. Anything
that steals KVA must adjust these variables accordingly.

This reduces the number of instances of this info from 3 to 1, and
simplifies the pmap(9) interface by removing the pmap_virtual_space()
function call, and removing two arguments from pmap_steal_memory().

This also eliminates some kludges such as having to burn kernel_map
entries on space used by the kernel and stolen KVA.

This also eliminates use of VM_{MIN,MAX}_KERNEL_ADDRESS from MI code,
this giving MD code greater flexibility over the bounds of the managed
kernel virtual address space if a given port's specific platforms can
vary in this regard (this is especially true of the evb* ports).
 1.131  22-Apr-2003  thorpej Some ARM32_PMAP_NEW-related cleanup:
* Define a new "MMU type", ARM_MMU_SA1. While the SA-1's MMU is basically
compatible with the generic, the SA-1 cache does not have a write-through
mode, and it is useful to know have an indication of this.
* Add a new PMAP_NEEDS_PTE_SYNC indicator, and try to evaluate it at
compile time. We evaluate it like so:
- If SA-1-style MMU is the only type configured -> 1
- If SA-1-style MMU is not configured -> 0
- Otherwise, defer to a run-time variable.
If PMAP_NEEDS_PTE_SYNC might evaluate to true (SA-1 only or run-time
check), then we also define PMAP_INCLUDE_PTE_SYNC so that e.g. assembly
code can include the necessary run-time support. PMAP_INCLUDE_PTE_SYNC
largely replaces the ARM32_PMAP_NEEDS_PTE_SYNC manual setting Steve
included with the original new pmap.
* In the new pmap, make pmap_pte_init_generic() check to see if the CPU
has a write-back cache. If so, init the PT cache mode to C=1,B=0 to get
write-through mode. Otherwise, init the PT cache mode to C=1,B=1.
* Add a new pmap_pte_init_arm8(). Old pmap, same as generic. New pmap,
sets page table cacheability to 0 (ARM8 has a write-back cache, but
flushing it is quite expensive).
* In the new pmap, make pmap_pte_init_arm9() reset the PT cache mode to
C=1,B=0, since the write-back check in generic gets it wrong for ARM9,
since we use write-through mode all the time on ARM9 right now. (What
this really tells me is that the test for write-through cache is less
than perfect, but we can fix that later.)
* Add a new pmap_pte_init_sa1(). Old pmap, same as generic. New pmap,
does generic initialization, then resets page table cache mode to
C=1,B=1, since C=1,B=0 does not produce write-through on the SA-1.
 1.130  01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.129  29-Mar-2003  bsh for Intel PXA2[15][05] processors, select write-back/write-through
cache based on CPU id. write-through on PXA2[15]0 B2 stepping and
earlier. write-back on C0 and C1 stepping (a.k.a PXA2[15]5 A0)

options XSCALE_CACHE_WRITE_{THROUGH,BACK} can override it.

for other XScale CPUs than PXA2xx, XSCALE_CACHE_WRITE_THROUGH works
same as before.
 1.128  27-Mar-2003  mycroft Remove references to variables that aren't used here.
 1.127  23-Mar-2003  chris Garbage collect pmap_map, the last (and only?) use has been removed.
 1.126  23-Feb-2003  thorpej Change pcb32_pagedir to a paddr_t (after all, it's used as a paddr_t
everywhere in the code).
 1.125  21-Feb-2003  chris Convert a few types into things that are more accurate, mostly:
int's to unsigned int/u_int where they shouldn't go negative.
int's to boolean_t's where they're being used as bools.

No real functional change (in the produced asm a few condition codes changed)
 1.124  17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.123  24-Nov-2002  chris Add a debug assert that wired pages provide protection flags in the flags
argument as well.

Also update a couple of debug messages to NPDEBUG.
 1.122  12-Nov-2002  chris Tweak a few minor things:
when looking to reenable caching, only do so if all the pages aren't already
cached.
Convert some ints to unsigned int. (scarily this actually shows the biggest
decrease in timing for my benchmark, I guess the compiler can optimise better)
 1.121  11-Nov-2002  chris gratuitous whitespace and de-__P'ing. No functional change.
 1.120  11-Nov-2002  chris A few minor tweaks.

Use pmap_free_pvs in pmap_remove, should save on the overhead of freeing
each pv on it's own.

Correctly set ptp when calling pmap_enter_pv, this adds more overhead, but
the effect is minimal. Timings show that it increases gmake's make configure
step from 2:07.90 to 2:08.90. I've more optimisations planned that should
negate this increase.
 1.119  11-Nov-2002  chris Remove unused pa variable (it's assigned but not used any more)
 1.118  27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.117  22-Sep-2002  chs rename the existing pmap_remove_all() here to pmap_page_remove()
(ala the x86 pmap) to avoid conflicting with the new pmap interface
function of the same name.
 1.116  05-Sep-2002  jdolecek whitespace fix past __KERNEL_RCSID()
 1.115  24-Aug-2002  thorpej In pmap_map_in_l1() and pmap_unmap_in_l1(), make sure that the VA
that is passed in is already aligned to a 4M super-section.
 1.114  24-Aug-2002  thorpej When we allocate a PTP, make sure the offset we specify is for
the 4M super-section that the PTP will map, not some random 1M
chunk of it. This gives the PTP hint code a much better chance
to working properly, and allows us to tidy up the code that
flushes a PTP from the cache in pmap_destroy().
 1.113  24-Aug-2002  thorpej Enable caching on kernel and user page tables. This saves having
to do uncached memory access during VM operations (which can be
quite expensive on some CPUs).

We currently write-back PTEs as soon as they're modified; there is
some room for optimization (to write them back in larger chunks).
For PTEs in the APTE space (i.e. PTEs for pmaps that describe another
process's address space), PTEs must also be evicted from the cache
complete (PTEs in PTE space will be evicted durint a context switch).
 1.112  22-Aug-2002  thorpej * Add PTE_SYNC() and PTE_SYNC_RANGE() macros. These don't actually do
anything yet.
* Use PTE_SYNC() and PTE_SYNC_RANGE() in some obvious places, i.e.
where vtopte() is used.
 1.111  21-Aug-2002  thorpej Use a pool cache for PT-PTs.
 1.110  21-Aug-2002  thorpej Do cached memory access to L1 tables, making sure to write-back the
cache after any L1 table modifications.
 1.109  13-Aug-2002  thorpej Add the brutal hack that allows us to limp along using the read/write
cache line allocation policy on XScale CPUs: in pmap_enter(), if the
pmap is the kernel pmap, clear the X-bit in the PTE, thus disabling
read/write-allocate for managed kernel mappings.

Yes, this is ugly. But it makes userland code run with r/w-allocate,
which is a huge improvement on systems with low core memory performance.
 1.108  10-Aug-2002  thorpej Tidy up pmap_clean_page() a little, and reenable some code that was
disabled previously: Skip cleaning mappings which are read-only, because
the pmap (now) does clean pages on a r/w -> r/o transition.
 1.107  10-Aug-2002  thorpej Clean up some warts in pmap_protect().
 1.106  09-Aug-2002  thorpej Add an XSCALE_CACHE_READ_WRITE_ALLOCATE option for people who
want to play fast-and-loose.
 1.105  09-Aug-2002  thorpej Add some code, conditional on PMAP_ALIAS_DEBUG, that can be used to
hunt for virtual aliases between managed (pmap_enter) and non-managed
(pmap_kenter_pa) mappings.
 1.104  06-Aug-2002  thorpej - pmap_remove(): unmap the PTEs *after* we have finished with the
page tables.
- pmap_enter(): if making a mapping for the same PA rw->ro, write-back
the cache before doing so.
- pmap_clearbit(): if revoking REF on a page, make sure to wbinv the
cache if the page has write permission, else inv the cache if the page's
PTE is valid (XXX we actually wbinv in this case, as well, due to lack
of idcache_inv_range()). Only flush the TLB if the PTE changed.
 1.103  31-Jul-2002  thorpej Overhaul how DMA ranges work in the ARM bus_dma implementation.

A new "arm32_dma_range" structure now describes a DMA window, with
a system address base, bus address base, and length. In addition to
providing info about which memory regions are legal for DMA, the new
structure provides address translation support, as well.

As before, if a tag does not list any ranges, then all addresses are
considered valid, and no DMA address translation is performed.

This allows us to remove a large chunk of code which was duplicated and
tweaked slightly (to do the address translation) from the stock ARM
bus_dma in the XScale IOP and ARM Integrator ports.

Test compiled on all ARM platforms, test booted on Intel IQ80321 and Shark.
 1.102  31-Jul-2002  thorpej Move the calls to uvm_page_physload() out of pmap_bootstrap() and
into platform-specific initialization code, giving platform-specific
code control over which free list a given chunk of memory gets put
onto.

Changes are essentially mechanical. Test compiled for all ARM
platforms, test booted on Intel IQ80321 and Shark.

Discussed some time ago on port-arm.
 1.101  30-Jul-2002  thorpej Move the uvm_setpagesize() call to platform-dependent code in preparation
for other changes to pmap_bootstrap().
 1.100  30-Jul-2002  thorpej Don't use pmap_kenter_pa() in pmap_map(); doing so causes an assertion
failure in pmap_kenter_pa().
 1.99  02-Jun-2002  drochner move initialization of the "struct pglist" returned by uvm_pglistalloc()
from the calling code into uvm_pglistalloc() itself for consistency
and easier error handling
 1.98  01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.97  14-May-2002  chris branches: 1.97.2; 1.97.4;
Implement scheduler lock protocol, this fixes PR arm/10863.

Also add correct locking when freeing pages in pmap_destroy (fix from potr)

This now means that arm32 kernels can be built with LOCKDEBUG enabled. (only tested on cats though)
 1.96  24-Apr-2002  thorpej * pmap_clean_page(): Clean up a comment.
* pmap_protect(): write back the range when doing a r/w -> r/o
transition. (Still leave the block concerned with this in
pmap_clean_page() disabled, for now.)
* pmap_pte_init_xscale(): Disable read/write-allocate for now, until
we figure out why sometimes cache lines of NULs get deposited into
file data. Also, make sure ECC protection of page table access is
disabled for now.
* xscale_setup_minidata(): Make sure the mini-data cache is configured
write-back with read/write-allocate.
 1.95  12-Apr-2002  thorpej Default all XScale core processors to the read/write-allocate write-back
cache mode. Add a new XSCALE_CACHE_WRITE_THROUGH option for people who
are paranoid about the cache-related errata (you *do* have to line up
the planets correctly to trip them, but having the option is useful).
 1.94  10-Apr-2002  thorpej On XScale processors where we use write-back caching, use are
read/write-allocate line allocation policy.

On the i80321, this improves nearly every lmbench benchmark, dramatically
so the ones that are sensitive to memory bandwidth (100-300% improvement
for these).
 1.93  10-Apr-2002  thorpej Add a new function, pmap_alloc_ptpt(), that allocates the PTPT and
maps it the way we want, rather than using uvm_km_zalloc() and playing
the "revoke cacheability" song-and-dance.
 1.92  10-Apr-2002  thorpej pmap_alloc_l1pt(): Just enter the mappings for the L1 table by
hand, rather than calling pmap_kenter_pa() and then revoking
cacheability in the PTE.
 1.91  10-Apr-2002  thorpej Use L2_S_CACHE_MASK in places where we revoke cacheability.
 1.90  10-Apr-2002  thorpej pmap_kenter_pa(): Obey the "prot" argument, rather than simply making
all mappings r/w (!!).
 1.89  10-Apr-2002  thorpej In pmap_copy_page_xscale(), put the source page in the mini-data
cache, as well. The mini-data cache is 2-way, so src and dst won't
clobber each other, and the smallness of the cache doesn't matter,
since we access each page once sequentially.

While we still have to do the initial clean of the source page, this
saves another 4K of main D$ pollution, and also means we don't have
to do 2 cache passes after the copy is complete (i.e. we can skip the
invalidation of the source page in the main cache, since it's no longer
there).
 1.88  10-Apr-2002  thorpej Add separate pmap_{zero,copy}_page() functions for generic ARM
vs. XScale. Use the mini-data cache for the destination on XScale,
thus saving tossing out 4K of possible-useful data from the main
data cache each time.

This significantly improves every test in lmbench.
 1.87  09-Apr-2002  thorpej * Move the code that cleans the XScale mini-data cache into its
own function.
* Add a new function which sets up the mini-data cache clean area
properly.
 1.86  09-Apr-2002  thorpej * Split pte_cache_mode into pte_l1_s_cache_mode, pte_l2_l_cache_mode,
and pte_l2_s_cache_mode. The cache-meaningful bits are different
for these descriptor types on some processor models.
* Add pte_*_cache_mask, corresponding to each above, which has a mask
of the cache-meangful bits, and define those for generic and XScale
MMU classes. Note, the L2_S_CACHE_MASK_xscale definition requires
use of the Extended Small Page L2 descriptor (the "X" bit overlaps
with AP bits otherwise).
 1.85  09-Apr-2002  thorpej Define 2 classes of ARM MMUs:
1. Generic (compatible with ARM6)
1. XScale (can be used as generic, but also has certainly nifty extensions).

Define abstract PTE bit defintions for each MMU class. If only one MMU
class is configured into the kernel (based on CPU_* options), then we
get the constants for that MMU class. Otherwise we indirect through
varaibles set up via set_cpufuncs().

XXX The XScale bits are currently the same as the generic bits. Baby steps.
 1.84  09-Apr-2002  thorpej L2_TYPE_S -> L2_S_PROTO
 1.83  09-Apr-2002  thorpej Use abstract names for the protection and PTE type bits in
L1 and L2 descriptors. This will allow us to support different
PTE layouts that enable the use of extensions on different
processor models.
 1.82  05-Apr-2002  thorpej Back-out rev 1.75 (pmap_extract() rewrite), and fix the (minor)
bug that revision intended to fix properly.
 1.81  05-Apr-2002  thorpej * Rewrite the 32-bit ARM pte.h based on the ARM architecture manual.
Significant cleanup, here, including better PTE bit names.
* Add XScale PTE extensions (ECC enable, write-allocate cache mode).
* Mechanical changes everywhere else to update for new pte.h. While
doing this, two bugs (as a result of typos) were fixed in

arm/arm32/bus_dma.c
evbarm/integrator/int_bus_dma.c
 1.80  04-Apr-2002  thorpej Eliminate a mask against PD_MASK.
 1.79  04-Apr-2002  thorpej There is no need to mask VAs and PAs w/ PG_FRAME to clear
the lower bits; UVM provides us page-aligned addresses for
everything. For the paranoid, we'll leave KDASSERT()'s in
that check for this if the kernel is built with DEBUG.

Low-hanging fruit that shaves some cycles.
 1.78  04-Apr-2002  thorpej Rename flags that are really part of the pv_entry/mdpage into
pmap.h and give them more descriptive names and better comments:
* PT_M -> PVF_MOD (page is modified)
* PT_H -> PVF_REF (page is referenced)
* PT_W -> PVF_WIRED (mapping is wired)
* PT_Wr -> PVF_WRITE (mapping is writable)
* PT_NC -> PVF_NC (mapping is non-cacheable; multiple mappings)
 1.77  04-Apr-2002  thorpej Catch a couple more vector page mapping manipulations.
 1.76  03-Apr-2002  thorpej Clean up handling of the vector page on 32-bit ARM systems:
* Don't refer to VA 0, instead refer to a new variable: vector_page
* Delete the old zero_page_*() functions, replacing them with a new
one: vector_page_setprot().
* When manipulating vector page mappings in user pmaps, only do so if
the vector page is below KERNEL_BASE (if it's above KERNEL_BASE, the
vector page is mapped by the kernel pmap).
* Add a new function, arm32_vector_init(), which takes the virtual
address of the vector page (which MUST be valid when the function
is called) and a bitmask of vectors the kernel is going to take
over, and performs all vector page initialization, including setting
the V bit in the CPU Control register ("relocate vectors to high
address"), if necessary.
 1.75  03-Apr-2002  reinoud Rototil and fix the pmap_extract function. It wouldn't even return data
when the part being quiried was mapped with a section (!) giving weird
results and had become a mess of goto's.

Complete rewrite and cleaned up the `goto'-jungle entirely ... ripped all
goto's. The resulting code is much better to read and might even have a
small performance gain.
 1.74  25-Mar-2002  thorpej Fix reporting of the kernel virtual address space range to UVM.
 1.73  25-Mar-2002  thorpej * Some cleanup.
* Delete the call to pmap_copy() in pmap.h
 1.72  25-Mar-2002  thorpej Clean up pmap_map_ptes() and pmap_unmap_ptes() a little, and add
a debug assertion that curproc is never NULL if mapping a non-current
pmap.
 1.71  25-Mar-2002  thorpej The target page of pmap_zero_page(), pmap_pageidlezero(), and
pmap_copy_page() will never have any mappings. Therefore, it
is unnecessary to do a cache clean for that page.

Add assertions in #ifdef DEBUG that assert this invariant.

This shaves some cycles off the frequently-called pmap_zero_page()
and pmap_copy_page() (no need to look up the dst page's vm_page
structure, and one less function call to clean the page).
 1.70  25-Mar-2002  thorpej * Fix use of pmap_curmaxkvaddr.
* Use the PTP hint in the pmap.
 1.69  25-Mar-2002  thorpej Move some private pmap data structures into pmap.c
 1.68  24-Mar-2002  thorpej Garbage-collect pmap_pte() (and good riddance!)
 1.67  24-Mar-2002  chris remove pointless pg = NULL in else part of if (pg != NULL)
 1.66  24-Mar-2002  thorpej pmap_enter(): Use pmap_map_ptes() correctly.
 1.65  24-Mar-2002  chris Update pmap_copy_page to only map in the src readonly and only invalidate it after the copy, no need for it to flush the wb.
 1.64  24-Mar-2002  thorpej pmap_allocpagedir(): Don't use pmap_pte(), and simplify a little.
 1.63  24-Mar-2002  thorpej pmap_handled_emulation(): Fix locking protocol botch.
XXX Should we traverse the PV list and enable all PTEs?
 1.62  24-Mar-2002  thorpej pmap_handled_emulation(): Use pmap_map_ptes() correctly.
 1.61  24-Mar-2002  thorpej pmap_modified_emulation(): Use pmap_map_ptes() correctly.
 1.60  24-Mar-2002  thorpej pmap_unwire(): Use pmap_map_ptes() correctly.
 1.59  24-Mar-2002  thorpej pmap_clearbit(): Use pmap_map_ptes() correctly.
 1.58  24-Mar-2002  thorpej Use pmap_is_curpmap() consistently.
 1.57  24-Mar-2002  thorpej Clean up the PTP allocation functions a bit.
 1.56  24-Mar-2002  thorpej * arm_byte_to_page() -> arm_btop()
* arm_page_to_byte() -> arm_ptob()
 1.55  24-Mar-2002  thorpej Remove some redundant tests in pmap_enter().
 1.54  23-Mar-2002  thorpej Garbage-collect the "pagehook" stuff.
 1.53  23-Mar-2002  thorpej * Rename PROCESS_PAGE_TBLS_BASE -> PTE_BASE
* Rename ALT_PAGE_TBLS_BASE -> APTE_BASE
* Garbage-collect PAGE_TABLE_SPACE_START
 1.52  08-Mar-2002  thorpej Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map). Try to deal with this:

* Group all information about the backend allocator for a pool in a
separate structure. The pool references this structure, rather than
the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
to become available, but will still fail if it cannot callocate KVA
space for the pages. If this happens, carefully drain all pools using
the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
some pages, and use that information to make draining easier and more
efficient.
* Get rid of PR_URGENT. There was only one use of it, and it could be
dealt with by the caller.

From art@openbsd.org.
 1.51  06-Mar-2002  chris Mostly style changes to stop us directly referencing tqh_first, and use TAILQ_FIRST instead. Based on rev 1.130 of the i386 pmap.c.
 1.50  05-Mar-2002  thorpej * Make pmap_is_{modified,referenced}() macros in pmap.h that just
test the attributes in the vm_page_md directly.
* Clean up pmap_clear_{modified,referenced}().
* Delete now-unused pmap_testbit().
 1.49  05-Mar-2002  thorpej Switch back to using vm_page_md (thanks chuq for finding the bug
in the code that made it unstable before!)
 1.48  03-Mar-2002  chris Implement pmap_growkernel for arm32 based ports.
Note that this has been compiled on some systems, cats, IQ80310, IPAQ, netwinder and shark (note that shark's build is currently broken due to other reasons), but only actually run on cats.
Shark doesn't make use of the functionality as I believe there has to be a correlation between OFW and the kernel tables so that calls into OFW work.
 1.47  22-Feb-2002  thorpej Change pmap_map_entry() to work like pmap_map_chunk(): take a pointer
to the L1 table and a virtual address, and no pointer to the L2 table.
The L2 table will be looked up by pmap_map_entry(), which will panic
if the there is no L2 table for the requested VA.

NOTE: IT IS EXTREMELY IMPORTANT THAT THE CORRECT VIRTUAL ADDRESS
BE PROVIDED TO pmap_map_entry()! Notably, the code that mapped
the kernel L2 tables into the kernel PT mapping L2 table were not
passing actual virtual addresses, but rather offsets into the range
mapped by the L2 table. I have fixed up all of these call sites,
and tested the resulting kernel on both an IQ80310 and a Shark.
Other portmasters should examine their pmap_map_entry() calls if
their new kernels fail.
 1.46  21-Feb-2002  thorpej Keep track of which kernel PTs are available during bootstrap,
and let pmap_map_chunk() lookup the correct one to use for the
current VA. Eliminate the "l2table" argument to pmap_map_chunk().

Add a second L2 table for mapping kernel text/data/bss on the
IQ80310 (fixes booting kernels with ramdisks).
 1.45  21-Feb-2002  thorpej In pmap_map_chunk(), if we can't use a section mapping, then
make sure that the L1 slot for the current VA points to an L2
table, and panic if it doesn't.
 1.44  21-Feb-2002  thorpej Always pass the L1 table to pmap_map_chunk(). This allows pmap_map_chunk()
to perform some error checking.
 1.43  21-Feb-2002  thorpej map_chunk() -> pmap_map_chunk(), and move it to pmap.c
 1.42  20-Feb-2002  thorpej map_pagetable() -> pmap_link_l2pt(), and move it to pmap.c
 1.41  20-Feb-2002  thorpej Collapse map_entry{,ro,nc}() into a single pmap_map_entry() that
takes a prot and a "cacheable" indicator.
 1.40  20-Feb-2002  thorpej Rename map_section() to pmap_map_section(), move it to pmap.c, and give it
an extra argument (prot - specifies protection of the mapping).
 1.39  06-Feb-2002  thorpej Back out all the vm_page_md changes. They are causing some
mysterious problems (a similar change to the i386 pmap causes
mysterious problems there, as well), and the issue needs to
be investigated more.
 1.38  06-Feb-2002  thorpej Efficiency tweaks, some made possible by vm_page_md.
 1.37  05-Feb-2002  thorpej Use vm_page_md rather than pmap_physseg. Saves lots of cycles in
common operations.
 1.36  25-Jan-2002  thorpej Overhaul of the ARM cache code. This is mostly a simplification
pass. Rather than providing a whole slew of cache operations that
aren't ever used, distill them down to some useful primitives:

icache_sync_all Synchronize I-cache
icache_sync_range Synchronize I-cache range

dcache_wbinv_all Write-back and Invalidate D-cache
dcache_wbinv_range Write-back and Invalidate D-cache range
dcache_inv_range Invalidate D-cache range
dcache_wb_range Write-back D-cache range

idcache_wbinv_all Write-back and Invalidate D-cache,
Invalidate I-cache
idcache_wbinv_range Write-back and Invalidate D-cache,
Invalidate I-cache range

Note: This does not yet include an overhaul of the actual asm files
that implement the primitives. Instead, we've provided a safe default
for each CPU type, and the individual CPU types can now be optimized
one at a time.
 1.35  20-Jan-2002  thorpej Some prototype cleanup.
 1.34  17-Jan-2002  thorpej Teach pmap_extract() about section mappings.
 1.33  05-Jan-2002  chris Make some of the arm32 files build with LOOSE_PROTOTYPES not set in the makefile. Turned up a few mismatched functions. Note that this isn't all of the arm32 files. Aim will be to get arm32 kernels built with LOOSE_PROTOTYPES not set.
 1.32  22-Nov-2001  thorpej Add cpu_cpwait() calls after TLB updates that are not expected to
be followed up by a pmap_update().
 1.31  19-Nov-2001  thorpej Implement pmap_update(). Currently it just calls cpu_cpwait(),
which ensures that TLB/cache operations have completed.
 1.30  03-Nov-2001  rearnsha branches: 1.30.2;
Replace most uses of pmap_pde_p with pmap_pde_page, since that is what
we need later in the code. This fixes a fatal kernel fault in
pmap_modified_emulation if a user application tries to access a kernel
address that is section-mapped.

Add a diagnostic that detects attempts to call pmap_kenter_pa with a
va that is section-mapped.
 1.29  01-Nov-2001  rearnsha When clearing the modified bit for modified emulation, don't turn
caching on for a page just because we are clearing the writable bit in
the PTE: this is incompatible with the way pmap_vac_me_harder works,
and the code in the modified emulation handler doesn't know about
recalculating the cachable attributes (nor should it, IMO).

Also, if we are invalidating a page, flush its TLB entry; for some
reason we were only doing this when clearing the Write or modified
bits.

These patches together seem to solve the random seg-faults that were
still occuring occasionally under heavy paging.
 1.28  18-Oct-2001  rearnsha branches: 1.28.2;
Add a comment describing the logic implemented by pmap_vac_me_harder.
 1.27  18-Oct-2001  rearnsha On processors that support both write-through and write-back cacheing
(eg ARM920), the mode in which the processor operates is governed by
the use of both the PT_C and PT_B bits:

PT_C=1,PT_B=1 -> Write-back
PT_C=1,PT_B=0 -> Write-through

To support this define pte_cache_mode (initialized to PT_C|PT_B) and
use that when enabling cacheing for a page.
 1.26  18-Oct-2001  rearnsha With a diagnostic kernel, printing out a message each time we fail
to allocate a L1 pt is often enough to bring the system to its knees:
so make the messages PDEBUG(0,...).

However, even with this step having more than a small number of
processes searching for a L1 pt can still be enough to bring the system
down, since they all run at high priority and sleep for very little time,
thus blocking out user code from completing. So implement an exponential
backoff when waiting for a page table, so that we don't hog the CPU when
memory is scarce.

Tested by running a make of the C compiler with "gnumake -j30" (and plenty
of swap space).
 1.25  18-Oct-2001  rearnsha Fix pmap_vac_me_harder to take into account pages that are mapped
into both kernel and user space.

Fixes port-arm32/13998.
 1.24  29-Sep-2001  chris Add a couple of simplelocks to make sure we call pagealloc with the uvm_object locked. Found while running a LOCKDEBUG kernel on cats.
 1.23  15-Sep-2001  chs a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
 1.22  13-Sep-2001  chris Sprinkle some static and inline into a couple of functions. Remove dead entries from pmap.h.
 1.21  13-Sep-2001  chris Update pmap_clearbit to flush the cache if the area is being made readonly. Also only do this and the tlb flush if the pmap is the current pmap.
 1.20  10-Sep-2001  chris Update the pmap following some comments from Chuck Silvers:
Remove some overzealous locking of HEAD_TO_MAP
Remove a potential deadlock in pmap_copy_page
Change alloc and free l1pt to use kenter/kremove.
Update pmap_map to use kenter (only actually used by dumpsys, so no matching kremove)
 1.19  10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

Currently this is a no-op on most platforms, so they should see no difference.

Reviewed by Jason.
 1.18  11-Aug-2001  chris branches: 1.18.2;
Fix compile without DIAGNOSTICs enabled
 1.17  11-Aug-2001  chris Checking a whole host of pmap changes:
Improved locking (not that we actually use it on a uniprocessor, but one day :)
Removed unneeded splvm's
tweaked pmap_clean_page code to only flush the cache if the page is mapped in the current pmap (based on diff from richard E)
Adopted pv entry allocation mechanism from i386.
Laid framework for returning ptp's when we've finished with them rather than holding onto them till the process exits.
ptp's are now allocated with a uvm object for the pmap, means that we can walk a list to free them off in pmap_release, until they get freed off by pmap_remove.

Also implemented a page zeroing function when the processor is idling. Note that hpcarm may wish to disable this.

I believe this code to be stable, if anyone has any problems please shout up.
 1.16  29-Jul-2001  chris Rework the pmap_release code to not have to walk the ptpt, it now uses a uvm_object to track the allocated vm_pages, this means it can free off the entries in the uvm_object.

Testing shows that it's about 5% faster on the make configure step for gmake.
 1.15  28-Jul-2001  chris A couple of tidy ups to pmap:
pmap_t -> struct pmap * in pmap.c and pmap.h
kernel_pmap -> pmap_kernel() everywhere.

Compiled and booted on riscpc and cats.
 1.14  08-Jul-2001  chs branches: 1.14.2;
clean up pmap_k{enter_pa,remove}():
a page is allowed to be mapped normally when k-mapped.
use UVM_PGA_ZERO to get zeroed pages rather than zeroing here.
 1.13  06-Jul-2001  chris Implement proper versions of kenter_pa and kremove, I've based them on versions provided by Richard E.
 1.12  25-Jun-2001  chris Improve the vac_me_harder function, it is now slightly faster, however pmap_enter_pv is also now slightly slower, so they appear to balance out.

Note that I've some ideas in the works on how to improve the pv handling, so the slow down is short term only.

Also added non-advertising licence and copyright to myself and richard.
 1.11  24-Jun-2001  chris Add a pmap_map_ptes function to map another process page table entries into the current pmap (similair to pmap_pte) but this allows multiple use of it, rather than repeated calls of pmap_pte for pte, map_ptes returns a pointer to the va where the entries were mapped so it can be reused ptes can be found by indexing into it.

Update some of the functions that use pmap_pte to pmap_map_ptes.

Note that there's a dummy macro for pmap_unmap_ptes, this is because at some point locking will be needed, so we need to be able to unlock them.

Performance gain seems to be minimal, however long term it should help improve things.

This is similair to the i386 pmap_map_ptes, however it's based on a version from Richard Earnshaw.
 1.10  22-Jun-2001  chris Use a pool to store pmap structs.
 1.9  26-May-2001  chs replace vm_page_t with struct vm_page *.
 1.8  25-Apr-2001  thorpej Garbage-collect pmap_page_index().
 1.7  24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.6  22-Apr-2001  thorpej Remove pmap_kenter_pgs(). It was never really adopted by
anything, and the interface itself wasn't as flexible as
callers would have probably liked.
 1.5  20-Apr-2001  toshii In pmap_allocpagedir(), check if uvm_km_zalloc of ptpt is successful,
and handle alloc failure case.
 1.4  15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.3  04-Mar-2001  matt branches: 1.3.2; 1.3.4;
more vm_offset_t/vm_size_t -> {p,v}{addr,size}_t changes
move pmap_* declarations to pmap.h. fix conflicts this
exposed (e.g different definitions for pmap_bootstrap).
 1.2  04-Mar-2001  matt Convert some vm_size_t to vsize_t/psize_t. Change vaddr_t to paddr_t
where appropriate.
 1.1  04-Mar-2001  matt Move from arm32/arm32. s/vm_offset_t/vaddr_t/g
 1.3.4.4  23-Apr-2001  bouyer Sync with HEAD.
 1.3.4.3  27-Mar-2001  bouyer Sync with HEAD.
 1.3.4.2  12-Mar-2001  bouyer Sync with HEAD.
 1.3.4.1  04-Mar-2001  bouyer file pmap.c was added on branch thorpej_scsipi on 2001-03-12 13:27:20 +0000
 1.3.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.3.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.14.2.9  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.14.2.8  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.7  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.2.6  16-Mar-2002  jdolecek Catch up with -current.
 1.14.2.5  11-Feb-2002  jdolecek Sync w/ -current.
 1.14.2.4  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.3  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.14.2.2  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.14.2.1  03-Aug-2001  lukem update to -current
 1.18.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.28.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.30.2.19  11-Dec-2002  thorpej Sync with HEAD.
 1.30.2.18  11-Nov-2002  nathanw Catch up to -current
 1.30.2.17  18-Oct-2002  nathanw Catch up to -current.
 1.30.2.16  17-Sep-2002  nathanw Catch up to -current.
 1.30.2.15  28-Aug-2002  wrstuden There is no 'p', there is only 'l'.
 1.30.2.14  27-Aug-2002  thorpej Sync with -current.
 1.30.2.13  13-Aug-2002  thorpej From trunk:

Add the brutal hack that allows us to limp along using the read/write
cache line allocation policy on XScale CPUs: in pmap_enter(), if the
pmap is the kernel pmap, clear the X-bit in the PTE, thus disabling
read/write-allocate for managed kernel mappings.

Yes, this is ugly. But it makes userland code run with r/w-allocate,
which is a huge improvement on systems with low core memory performance.
 1.30.2.12  13-Aug-2002  nathanw Catch up to -current.
 1.30.2.11  01-Aug-2002  nathanw Catch up to -current.
 1.30.2.10  02-Jul-2002  nathanw Several curlwp references here can revert to curproc.
 1.30.2.9  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.30.2.8  20-Jun-2002  nathanw Catch up to -current.
 1.30.2.7  17-Apr-2002  nathanw Catch up to -current.
 1.30.2.6  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.30.2.5  28-Feb-2002  nathanw Catch up to -current.
 1.30.2.4  11-Jan-2002  nathanw More catchup.
 1.30.2.3  08-Jan-2002  nathanw Catch up to -current.
 1.30.2.2  15-Nov-2001  thorpej Machine-dependent kernel mods for scheduler activations on
32-bit ARM processors. Kernel boots multi-user on an XScale,
but upcalls not yet tested.
 1.30.2.1  03-Nov-2001  thorpej file pmap.c was added on branch nathanw_sa on 2001-11-15 06:39:22 +0000
 1.97.4.6  14-Feb-2003  he Revert pull-up of revision 1.110 (requested by rearnsha in ticket #1170):
Revert cached memory access to L1 tables, this causes instability
on the release branch.
 1.97.4.5  07-Dec-2002  he Pull up revision 1.111 (requested by thorpej in ticket #714):
Use a pool cache for PT-PTs.
 1.97.4.4  07-Dec-2002  he Pull up revision 1.105 (requested by thorpej in ticket #714):
Add code, conditional on PMAP_ALIAS_DEBUG, which can be
used to hunt for virtual aliases between managed (pmap_enter)
and unmanaged (pmap_kenter_pa) mappings.
 1.97.4.3  21-Nov-2002  he Pull up revision 1.110 (requested by thorpej in ticket #712):
Do cached memory access to L1 tables, making sure to
write-back the cache after any L1 table modifications.
 1.97.4.2  16-Nov-2002  he Pull up revision 1.107 (requested by thorpej in ticket #662):
Clean up some warts in pmap_protect().
 1.97.4.1  31-Jul-2002  lukem Pull up revision 1.100 (requested by thorpej in ticket #587):
Don't use pmap_kenter_pa() in pmap_map(); doing so causes an assertion
failure in pmap_kenter_pa().
 1.97.2.2  30-Aug-2002  gehenna catch up with -current.
 1.97.2.1  14-Jul-2002  gehenna catch up with -current.
 1.137.2.7  11-Dec-2005  christos Sync with head.
 1.137.2.6  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.137.2.5  01-Apr-2005  skrll Sync with HEAD.
 1.137.2.4  17-Jan-2005  skrll Sync with HEAD.
 1.137.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.137.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.137.2.1  03-Aug-2004  skrll Sync with HEAD
 1.150.4.1  28-Jan-2005  yamt convert arch/arm to new apis.
 1.150.2.1  29-Apr-2005  kent sync with -current
 1.154.2.6  21-Jan-2008  yamt sync with head
 1.154.2.5  15-Nov-2007  yamt sync with head.
 1.154.2.4  27-Oct-2007  yamt sync with head.
 1.154.2.3  03-Sep-2007  yamt sync with head.
 1.154.2.2  26-Feb-2007  yamt sync with head.
 1.154.2.1  21-Jun-2006  yamt sync with head.
 1.157.24.1  21-Feb-2007  snj branches: 1.157.24.1.4;
Pull up following revision(s) (requested by matt in ticket #457):
sys/arch/arm/arm32/pmap.c: revision 1.158
From Scott Allan in http://mail-index.netbsd.org/port-arm/2006/07/26/0000.html
I ran into a problem when I tried to set up a mapping that started at
virtual address 0xFFF00000 and was 0x00100000 long. In other words, the
mapping should have gone to the end of the 32 bit address space. The
mapping was made with no problem, but pmap_devmap_find_va() wouldn't
find an address within the mapping. For example, if I told it to find a
mapping for 0x1000 bytes at 0xFFF01000, it would try to make sure that
0xFFF01000 was greater than 0xFFF00000 and that (0xFFF01000+0x1000) was
less than (0xFFF00000 +0x00100000). However, that last expression
(0xFFF00000+0x00100000) wrapped around to be simply 0x00000000 so it
wasn't found. This patch fixes this problem in pmap_devmap_find_va()
and pmap_devmap_find_pa() by subtracting one off of the
 1.157.24.1.4.3  10-Nov-2007  matt Refix thinko. (deal with non-page-aligned starts/lengths)
 1.157.24.1.4.2  10-Nov-2007  matt Fix thinko.
 1.157.24.1.4.1  10-Nov-2007  matt Add AT91 support from Sami Kantoluoto
Add TI OMAP2430 support from Marty Fouts @ Danger Inc
 1.157.20.1  12-Jan-2007  ad Sync with head.
 1.158.2.5  15-Apr-2007  yamt sync with head.
 1.158.2.4  29-Mar-2007  skrll Adapt arm32. Thanks to scw for helping out.

Tested on my cats (SA1)

XXX hydra should die. i've made some changes, but no guarantees.
 1.158.2.3  24-Mar-2007  yamt sync with head.
 1.158.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.158.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.161.2.6  03-Dec-2007  ad Sync with HEAD.
 1.161.2.5  19-Oct-2007  ad Sync with head.
 1.161.2.4  09-Oct-2007  ad Sync with head.
 1.161.2.3  27-May-2007  ad Sync with head.
 1.161.2.2  10-Apr-2007  ad Sync with head.
 1.161.2.1  13-Mar-2007  ad Sync with head.
 1.162.2.1  11-Jul-2007  mjf Sync with head.
 1.163.4.3  16-Oct-2007  garbled Sync with HEAD
 1.163.4.2  03-Oct-2007  garbled Sync with HEAD
 1.163.4.1  22-May-2007  matt Update to HEAD.
 1.164.12.10  04-Mar-2008  matt Fix a bug in pmap_flush_page which could nuke a PTE being used by
pmap_zero_page or pmap_copy_page.
 1.164.12.9  09-Jan-2008  matt sync with HEAD
 1.164.12.8  10-Nov-2007  matt Fix thinko. (need to deal non-page-aligned size/lengths)
 1.164.12.7  09-Nov-2007  matt Add pmap_icache_sync_range and change arm32_sync_icache to use it.
This will only invalidate va that have valid PTEs. This avoids cleaning
unneeded cache lines.
 1.164.12.6  09-Nov-2007  matt Make all the evbarm kernels build again. Fix lossage from rebase.
 1.164.12.5  08-Nov-2007  matt sync with -HEAD
 1.164.12.4  07-Nov-2007  matt Fix botched color assertion
 1.164.12.3  06-Nov-2007  matt sync with HEAD
 1.164.12.2  12-Oct-2007  matt Import TI OMAP 2430 and ARM11/ARMv6 support. Now on ARMv6, the cache is
no longer purged on context switches.
 1.164.12.1  29-Aug-2007  matt Use ci_intr_depth
 1.164.10.2  20-Jan-2008  chris Sync to HEAD.
 1.164.10.1  01-Jan-2008  chris Sync with HEAD.
 1.164.8.3  11-Nov-2007  joerg Sync with HEAD.
 1.164.8.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.164.8.1  02-Oct-2007  joerg Sync with HEAD.
 1.164.6.3  28-Feb-2008  rjs Sync with HEAD.
 1.164.6.2  26-Dec-2007  rjs Sync with HEAD.
 1.164.6.1  01-Nov-2007  rjs Sync with HEAD.
 1.165.2.1  14-Oct-2007  yamt sync with head.
 1.166.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.167.2.2  18-Feb-2008  mjf Sync with HEAD.
 1.167.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.169.6.2  08-Jan-2008  bouyer Sync with HEAD
 1.169.6.1  02-Jan-2008  bouyer Sync with HEAD
 1.171.6.7  17-Jan-2009  mjf Sync with HEAD.
 1.171.6.6  05-Oct-2008  mjf Sync with HEAD.
 1.171.6.5  28-Sep-2008  mjf Sync with HEAD.
 1.171.6.4  29-Jun-2008  mjf Sync with HEAD.
 1.171.6.3  05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.171.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.171.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.172.2.2  17-Jun-2008  yamt sync with head.
 1.172.2.1  18-May-2008  yamt sync with head.
 1.173.2.4  11-Aug-2010  yamt sync with head.
 1.173.2.3  11-Mar-2010  yamt sync with head
 1.173.2.2  04-May-2009  yamt sync with head.
 1.173.2.1  16-May-2008  yamt sync with head.
 1.175.2.3  10-Oct-2008  skrll Sync with HEAD.
 1.175.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.175.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.176.2.4  18-Jul-2008  simonb Sync with head.
 1.176.2.3  03-Jul-2008  simonb Sync with head.
 1.176.2.2  27-Jun-2008  simonb Sync with head.
 1.176.2.1  18-Jun-2008  simonb Sync with head.
 1.180.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.180.2.1  19-Oct-2008  haad Sync with HEAD.
 1.187.8.2  15-Feb-2014  matt Merge armv7 support from HEAD, specifically support for the BCM5301X
and BCM56340 evbarm kernels.
 1.187.8.1  21-Apr-2010  matt sync to netbsd-5
 1.187.4.1  03-Dec-2009  sborrill Pull up the following revisions(s) (requested by scw in ticket #1168):
sys/arch/arm/arm32/pmap.c: revision 1.203

Work-around a possible process exit corner case which can leave stale
data in the cache after a context-switch. Addresses kern/41058.
 1.187.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.187.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.195.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.211.2.23  15-Nov-2010  uebayasi Revert xmd(4).
 1.211.2.22  10-Nov-2010  uebayasi Fix thinko; make vm_physseg ptr swap really work.
 1.211.2.21  10-Nov-2010  uebayasi opt_xip.h isn't needed any more here.
 1.211.2.20  10-Nov-2010  uebayasi Always use VM_PHYSMEM_PTR().
 1.211.2.19  06-Nov-2010  uebayasi Sync with HEAD.
 1.211.2.18  31-Oct-2010  uebayasi We already have a flag PMAP_NOCACHE. s/PMAP_UNMANAGED/PMAN_NOCACHE/.
Pointed out by Chuck Silvers, thanks.
 1.211.2.17  31-Oct-2010  uebayasi More struct vm_page * -> struct vm_page_md * adjustments.
 1.211.2.16  30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.211.2.15  17-Aug-2010  uebayasi Sync with HEAD.
 1.211.2.14  07-Jul-2010  uebayasi Clean up; merge options DIRECT_PAGE into options XIP.
 1.211.2.13  31-May-2010  uebayasi Re-define the definition of "device page"; device pages are pages of
device memory. Pages which don't have vm_page (== can't be used for
generic use), but whose PV are tracked, are called "direct pages" from
now.
 1.211.2.12  30-Apr-2010  uebayasi Sync with HEAD.
 1.211.2.11  28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.211.2.10  27-Apr-2010  uebayasi Support PMAP_UNMANAGED in some pmaps.

(Others should be converted eventually, but no problem while managed
device page is not used.)
 1.211.2.9  25-Feb-2010  uebayasi A few more VM_PAGE_TO_MD().
 1.211.2.8  20-Feb-2010  uebayasi Fix \!DIAGNOSTIC build.
 1.211.2.7  10-Feb-2010  uebayasi Adjust previous.
 1.211.2.6  10-Feb-2010  uebayasi Replace all remaining pg->mdpage references with VM_PAGE_TO_MD(). Now struct
vm_page * is fully opaque.
 1.211.2.5  10-Feb-2010  uebayasi Fix previous again & use VM_PAGE_TO_MD() where appropriate.
 1.211.2.4  10-Feb-2010  uebayasi Convert pmap_enter() and pmap_vac_me_harder().
 1.211.2.3  10-Feb-2010  uebayasi Convert pmap_enter_pv().
 1.211.2.2  10-Feb-2010  uebayasi Convert pmap_remove_pv() / pmap_modify_pv() to take struct vm_page_md *.
 1.211.2.1  10-Feb-2010  uebayasi Start changing this to be ready for device page (XIP). The basic rule is
device pages don't have struct vm_page * objects. Instead per-page data
(mainly PV mappings) is rooted from the global struct vm_page_md array.

Convert 2 functions to take struct vm_page_md * instead of struct vm_page *.
 1.212.2.6  19-May-2011  rmind Implement sharing of vnode_t::v_interlock amongst vnodes:
- Lock is shared amongst UVM objects using uvm_obj_setlock() or getnewvnode().
- Adjust vnode cache to handle unsharing, add VI_LOCKSHARE flag for that.
- Use sharing in tmpfs and layerfs for underlying object.
- Simplify locking in ubc_fault().
- Sprinkle some asserts.

Discussed with ad@.
 1.212.2.5  21-Apr-2011  rmind sync with head
 1.212.2.4  05-Mar-2011  rmind sync with head
 1.212.2.3  03-Jul-2010  rmind sync with head
 1.212.2.2  30-May-2010  rmind sync with head
 1.212.2.1  16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.219.4.1  05-Mar-2011  bouyer Sync with HEAD
 1.219.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.221.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.224.6.1  18-Feb-2012  mrg merge to -current.
 1.224.2.5  22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.224.2.4  23-Jan-2013  yamt sync with head
 1.224.2.3  16-Jan-2013  yamt sync with (a bit old) head
 1.224.2.2  30-Oct-2012  yamt sync with head
 1.224.2.1  17-Apr-2012  yamt sync with head
 1.228.2.2  09-Feb-2013  riz Pull up following revision(s) (requested by msaitoh in ticket #803):
 1.251  01-Feb-2013  matt cleanup PVF_WRITE & pvh_attrs interaction.
 1.250  31-Jan-2013  skrll Another typo in a comment.
 1.249  31-Jan-2013  skrll Typo in comment.
 1.247  11-Jan-2013  matt Fix a bug in pmap_modify_pv where we didnt set PVF_WRITE on a page after
changing its mapping to writeable.
Add more KASSERTS
Dont go into DDB by default in pmap_fixup.
 1.243  10-Dec-2012  matt Change a KASSERT to a KASSERTMSG
 1.233  29-Aug-2012  matt Support PMAP_NOCACHE in pmap_kenter_pa
 1.232  29-Aug-2012  matt Use the correct prot mask in vector_page_setprot
 1.228.2.1  09-Aug-2012  jdc branches: 1.228.2.1.2;
Pull up revisions:
src/sys/arch/evbarm/dev/plcomreg.h revisions 1.2,1.3,1.4
src/sys/arch/evbarm/conf/INTEGRATOR revision 1.65
src/sys/arch/evbarm/dev/plcom.c revisions 1.34,1.35,1.36,1.37,1.38,1.39,1.40
src/sys/arch/evbarm/ifpga/plcom_ifpga.c revisions 1.12,1.13,1.14
src/sys/arch/evbarm/dev/plcomvar.h revisions 1.9,1.10,1.11
src/sys/arch/evbarm/ifpga/plcom_ifpgavar.h revision 1.2
src/sys/arch/arm/arm/cpufunc.c revisions 1.105,1.108
src/sys/arch/arm/arm32/cpu.c revision 1.79
src/sys/arch/arm/include/armreg.h revisions 1.49,1.54
src/sys/arch/arm/arm32/pmap.c revision 1.229
src/sys/arch/arm/arm32/arm32_machdep.c revision 1.77
src/sys/arch/arm/include/cpu.h revision 1.64
src/sys/arch/arm/arm/cpufunc_asm_arm1136.S revision 1.3
src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S revision 1.1
src/sys/arch/arm/conf/files.arm revision 1.106
src/sys/arch/arm/include/cpufunc.h revision 1.57
src/sys/dev/sdmmc/sdhc.c revisions 1.14,1.24
src/sys/dev/sdmmc/sdhcvar.h revisions 1.7,1.8
src/sys/arch/evbarm/ifpga/ifpgareg.h revision 1.4
src/sys/arch/evbarm/integrator/integrator_machdep.c revision 1.69
src/sys/arch/arm/broadcom/bcm2835_dma.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_emmc.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_intr.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_intr.h revision 1.1
src/sys/arch/arm/broadcom/bcm2835_obio.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_plcom.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_pm.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_pmvar.h revision 1.1
src/sys/arch/arm/broadcom/bcm2835_space.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835_tmr.c revision 1.1
src/sys/arch/arm/broadcom/bcm2835reg.h revision 1.1
src/sys/arch/arm/broadcom/bcm2835var.h revision 1.1
src/sys/arch/arm/broadcom/bcm_amba.h revision 1.1
src/sys/arch/arm/broadcom/files.bcm2835 revision 1.1
src/sys/arch/evbarm/Makefile revision 1.9
src/sys/arch/evbarm/conf/RPI revision 1.1
src/sys/arch/evbarm/conf/files.rpi revision 1.1
src/sys/arch/evbarm/conf/mk.rpi revision 1.1
src/sys/arch/evbarm/conf/std.rpi revision 1.1
src/sys/arch/evbarm/rpi/genassym.cf revision 1.1
src/sys/arch/evbarm/rpi/rpi.h revision 1.1
src/sys/arch/evbarm/rpi/rpi_machdep.c revision 1.1
src/sys/arch/evbarm/rpi/rpi_start.S revision 1.1,1.2
src/etc/etc.evbarm/Makefile.inc revision 1.28
(requested by skrll in ticket #454).

don't mix #define<TAB> and #define<SPACE> in a file.

avoid warning with options PLCOM_DEBUG for INTEGRATOR.

Rename register values. No functional change - same code before and after.

Existing names are prefixed with PL01X_ where they're common between the
PL010 and the PL011. The PL010_/PL011_ prefixes are added where they're
found only on the respective chips.

Replace the simple_lock with a kmutex_t. Update the locking to match
com(4) in the few places it didn't already.

DOH. Replace a line that got accidently deleted in the last commit.

device_t/softc split
struct device * -> device_t
struct cfdata * -> cfdata_t

Add the 'Z' to the 1176 cpu product name.

ok matt@

Fix locking botch introduced in 1.36.

Fix a KASSERT. From/OK'ed by matt@

Fix racy softint dispatch that lead to KASSERT(si->si_active) in
softint_execute

Discussed with matt@. "Looks good to me"

Add the documented ARM11[37]6 Auxiliary control register defines.

Add support for the ARM1176JZS

Add a flag for the lack of LED_ON in HOST_CTL (ti omap3 doesn't do that).

Provide a method for attachments to specify capabilites.

Add support for the PL011 to plcom. Pull across a bunch of fixes from
com(4) while I'm here and do some other tidyup.

Tested on a RaspberryPi.

PL010 not tested.

Initial commit of support for the RaspberryPI (www.raspberrypi.org)

This is enough for serial console via the gpio header pins and to get to
multiuser.

A huge thank you to Matt Thomas for all his help.

Add RPI to KERNEL_SETS

Remove #if 0 code.
 1.228.2.1.2.3  13-Feb-2013  matt Sync with HEAD
 1.228.2.1.2.2  07-Feb-2013  matt pullup pmap changes from HEAD
 1.228.2.1.2.1  28-Nov-2012  matt Merge improved arm support (especially Cortex) from HEAD
including OMAP and BCM53xx support.
 1.236.2.5  03-Dec-2017  jdolecek update from HEAD
 1.236.2.4  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.236.2.3  23-Jun-2013  tls resync from head
 1.236.2.2  25-Feb-2013  tls resync with head
 1.236.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.257.2.2  18-May-2014  rmind sync with head
 1.257.2.1  28-Aug-2013  rmind sync with head
 1.280.2.1  10-Aug-2014  tls Rebase.
 1.295.2.11  03-Jun-2017  snj Pull up following revision(s) (requested by skrll in ticket #1424):
sys/arch/arm/arm32/pmap.c: revision 1.345
Perform icache syncs for ARM_MMU_EXTENDED as well. This helps the PT_STEP
code in pr/52119 and probably other things.
 1.295.2.10  11-Mar-2017  snj fix fallout from ticket #1366: __nothing is nothing on netbsd-7
 1.295.2.9  11-Mar-2017  snj Pull up following revision(s) (requested by skrll in ticket #1366):
sys/arch/arm/include/arm32/pmap.h: 1.145
sys/arch/arm/arm32/pmap.c: 1.343, 1.344
sys/arch/evbarm/gumstix/gumstix_machdep.c: 1.58 via patch
Fixup the compile time decisions around PMAP_{INCLUDE,NEEDS}_PTE_SYNC and
fix the options for xscale boards which require the code in
pmap_l2ptp_ctor marked as #ifndef PMAP_INCLUDE_PTE_SYNC.
Fix the typo (pte -> opte) in this code block and consistently use opte
elsewhere.
PR/51990: Regression data_abort_handler: data_aborts fsr=0x406 far=0xbfffeff5 on copyout in init
--
fix unused.
--
Set xscale_cache_clean_addr appropriately and re-arrange default KVA
layout to allow direct map for all boards.
OVERO/DUOVERO/PEPPER aren't tested.
PR/52010: Regression: Gumstix Verdex is hanging in enabling cache + KASSERT ram_size
 1.295.2.8  26-Feb-2016  snj branches: 1.295.2.8.2;
Pull up following revision(s) (requested by skrll in ticket #1106):
sys/arch/arm/arm32/pmap.c: revision 1.332
Delete pmap_pmaps and its only user pmap_dump_all. The list wasn't
being updated in an MP-safe manner.
 1.295.2.7  27-May-2015  msaitoh Pull up following revision(s) (requested by skrll in ticket #805):
sys/arch/arm/include/arm32/pmap.h: revision 1.138
sys/arch/arm/arm/cpufunc.c: revision 1.151
sys/arch/arm/arm32/bus_dma.c: revision 1.90
sys/arch/arm/broadcom/bcm53xx_pax.c: revision 1.14
sys/arch/arm/arm32/bus_dma.c: revision 1.91
sys/arch/arm/samsung/exynos_space.c: revision 1.2
sys/arch/arm/arm32/db_machdep.c: revision 1.23
sys/arch/arm/allwinner/awin_space.c: revision 1.4
sys/arch/arm/include/rwlock.h: revision 1.9
sys/arch/arm/amlogic/amlogic_space.c: revision 1.2
sys/arch/arm/zynq/zynq_space.c: revision 1.2
sys/arch/arm/broadcom/bcm2835_space.c: revision 1.7
sys/arch/arm/arm32/pmap.c: revision 1.317
sys/arch/arm/include/locore.h: revision 1.19
sys/arch/arm/include/mutex.h: revision 1.20
sys/arch/arm/include/lock.h: revision 1.31
sys/arch/arm/include/lock.h: revision 1.32
sys/arch/arm/broadcom/bcmgen_space.c: revision 1.5
- Kill redundant semicolons.
- Indentation.
- Improve inline asm around dsb/dmb/isb:
- always use volatile and mark them as memory barrier
- use the common version from locore.h in all places not included from
userland
 1.295.2.6  26-May-2015  msaitoh Pull up following revision(s) (requested by skrll in ticket #800):
sys/arch/arm/arm32/pmap.c: revision 1.320
sys/arch/arm/arm32/pmap.c: revision 1.321
sys/arch/arm/arm32/pmap.c: revision 1.322
sys/arch/arm/arm32/pmap.c: revision 1.319
- include "opt_arm_debug.h" for VERBOSE_INIT_ARM
- Add pmap locking to pmap_kenter_pa/kremove
- Make sure nptes is a multiple of PAGE_SIZE / L2_S_SIZE.
- Use PDE_SYNC when syncing pdeps
 1.295.2.5  19-May-2015  snj Pull up following revision(s) (requested by joerg in ticket #777):
sys/arch/arm/arm32/pmap.c: revision 1.308
pmap_tlb_flushD is for !ARM_MMU_EXTENDED only now
 1.295.2.4  10-Apr-2015  snj Pull up following revision(s) (requested by skrll in ticket #669):
sys/arch/arm/arm32/pmap.c: revision 1.318
Fix two bugs. pmap_is_cached fix for MULTIPROCESSOR (not just ASID on
local cpu -> any valid ASID on any cpu).
pmap_deactivate: update curcpu()->ci_pmap_cur_asid to KERNEL_PID too.
 1.295.2.3  10-Nov-2014  martin Pull up following revision(s) (requested by skrll in ticket #209):
sys/arch/arm/pic/pic.c: revision 1.25
sys/arch/arm/arm/cpufunc_asm_armv7.S: revision 1.21
sys/arch/arm/arm32/pmap.c: revision 1.312
sys/arch/arm/arm32/bus_dma.c: revision 1.89
sys/arch/arm/arm32/pmap.c: revision 1.313
sys/arch/arm/arm32/pmap.c: revision 1.314
sys/arch/arm/arm32/pmap.c: revision 1.315
sys/arch/arm/arm32/pmap.c: revision 1.316
Include opt_multiprocessor.h
When allocing a l1page, if a page isn't available, use uvm_wait to wait
for one to become available. Should fix PR/49364.
Post a dmb before invalidating the cache in the post-{read,write}
operations to ensure that any/all cachelines brought in via speculation
are really flushed.
Ensure all memory operations are complete by before wfi. For example, the
cpu could have just been in uvm_pageidlezero.
In pmap_fault_fixup re-instate the TLB flush for the shared L1 case that
occurs for non-ARM_MMU_EXTENDED kernels.
This fixes rump/rumpkern/t_sp:stress_killer on rpi which is currently
non-ARM_MMU_EXTENDED
Remove an unnecessary flush that sneaked in as part of break-before-make
change.
Remove an XXXNH comment.
Update PTE_SYNC_CURRENT to add a dsb for armv7 - part of the
break-before-make fix.
 1.295.2.2  09-Nov-2014  martin Pull up following revision(s) (requested by skrll in ticket #188):
sys/arch/arm/include/arm32/pmap.h: revision 1.136
sys/arch/arm/include/armreg.h: revision 1.100
sys/arch/arm/cortex/gic.c: revision 1.11
sys/arch/arm/arm32/db_interface.c: revision 1.54
sys/arch/arm/include/armreg.h: revision 1.101
sys/arch/arm/cortex/gic.c: revision 1.12
sys/arch/arm/arm32/arm32_machdep.c: revision 1.107
sys/arch/arm/arm/cpufunc_asm_armv7.S: revision 1.19
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.20
sys/arch/evbarm/conf/BPI: revision 1.5
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.21
sys/arch/arm/arm32/pmap.c: revision 1.306
sys/arch/arm/arm32/db_machdep.c: revision 1.22
sys/arch/arm/arm32/arm32_tlb.c: revision 1.3
sys/arch/arm/arm/undefined.c: revision 1.55
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.22
sys/arch/arm/arm32/pmap.c: revision 1.307
sys/arch/arm/arm32/arm32_tlb.c: revision 1.4
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.23
sys/arch/arm/arm32/arm32_tlb.c: revision 1.5
sys/arch/evbarm/conf/BPI: revision 1.8
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.24
sys/arch/arm/arm32/arm32_tlb.c: revision 1.6
sys/arch/arm/arm32/arm32_tlb.c: revision 1.7
sys/arch/evbarm/conf/CUBIETRUCK: revision 1.5
sys/arch/arm/pic/pic.c: revision 1.23
sys/arch/arm/pic/pic.c: revision 1.24
sys/arch/arm/pic/picvar.h: revision 1.11
sys/arch/arm/arm/cpufunc_asm_armv7.S: revision 1.20
sys/arch/arm/mainbus/cpu_mainbus.c: revision 1.16
sys/arch/arm/arm32/pmap.c: revision 1.298
sys/arch/arm/arm/cpufunc_asm_arm11.S: revision 1.17
sys/arch/arm/arm/cpufunc_asm_pj4b.S: revision 1.5
sys/arch/arm/arm32/pmap.c: revision 1.310
sys/arch/arm/arm32/pmap.c: revision 1.311
sys/arch/arm/arm32/arm32_kvminit.c: revision 1.32
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.19
sys/arch/arm/arm32/arm32_boot.c: revision 1.10
sys/arch/arm/arm/ast.c: revision 1.25
sys/arch/arm/include/armreg.h: revision 1.98
sys/uvm/pmap/pmap_tlb.c: revision 1.10
sys/arch/arm/arm32/arm32_boot.c: revision 1.8
sys/arch/arm/arm32/arm32_boot.c: revision 1.9
sys/arch/arm/arm/arm_machdep.c: revision 1.43
Various ARM MP fixes.
 1.295.2.1  30-Oct-2014  martin Pull up following revision(s) (requested by maxv in ticket #165):
sys/arch/newsmips/stand/boot/netif_news.c: revision 1.9
sys/arch/mvme68k/stand/installboot/installboot.c: revision 1.19
sys/arch/arm/arm32/pmap.c: revision 1.300
sys/arch/amiga/dev/siop2.c: revision 1.43
sys/arch/amiga/amiga/disksubr.c: revision 1.62
sys/arch/news68k/news68k/bus_space.c: revision 1.13
sys/arch/amiga/dev/siop.c: revision 1.69
sys/arch/x86/x86/x86_autoconf.c: revision 1.72
Remove dead code in various places under arch/.
 1.295.2.8.2.1  13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.316.2.7  28-Aug-2017  skrll Sync with HEAD
 1.316.2.6  05-Feb-2017  skrll Sync with HEAD
 1.316.2.5  05-Oct-2016  skrll Sync with HEAD
 1.316.2.4  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.316.2.3  22-Sep-2015  skrll Sync with HEAD
 1.316.2.2  06-Jun-2015  skrll Sync with HEAD
 1.316.2.1  06-Apr-2015  skrll Sync with HEAD
 1.335.2.4  26-Apr-2017  pgoyette Sync with HEAD
 1.335.2.3  20-Mar-2017  pgoyette Sync with HEAD
 1.335.2.2  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.335.2.1  06-Aug-2016  pgoyette Sync with HEAD
 1.342.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.349.2.3  23-Apr-2019  martin Pull up following revision(s) (requested by bouyer in ticket #1246):

sys/arch/arm/arm32/pmap.c: revision 1.373 (via patch)

Fix a deadlock between the pool and pmap codes:

- cpu0 grabs the kernel lock (e.g. from a non-MPSAFE interrupt) and
calls pool_get().
- cpu1 does a pool_get() on the same pool from MPSAFE code, which needs a
pool_page_alloc(), which ends up in pmap_extract_coherency().

So cpu0 holds the kernel_lock and wants the pool lock. cpu1 holds the pool
lock and wants the kernel_lock in pmap_extract_coherency().

The pmap code should not rely on kernel_lock. Intead make the
pmap_kernel()->pm_obj_lock a IPL_VM lock and use it as pmap lock
(thus dropping the pmap test pmap_{acquire,release}_pmap_lock()).

This needs to be a IPL_VM because unlike user pmaps, this can be locked
from interrupt context.

Add a IPL_NONE lock for pmap_growkernel(). We can't use
pmap_kernel()->pm_obj_lock here because pmap_grow_map() may sleep.

Make pmap_lock (which may be locked with pm_obj_lock held) a IPL_VM
lock in all case.
reorder a few things to not call pool_get()/pool_put() (which may sleep)
with pm_obj_lock held.

Patch initially posted to port-arm@ on April 19, improved patch (per
suggestions from Nick Hudson and Jason Thorpe) on April 21.
 1.349.2.2  23-Apr-2019  martin Pull up following revision(s) (requested by bouyer in ticket #1245):

sys/arch/arm/arm32/pmap.c: revision 1.372

Don't try to aquire/release the pmap lock when in ddb.

Avoids a deadlock when entering ddb, or on "mach cpu n" ddb command
(the pmap lock may already be held by another CPU, which is halted when
entering ddb).

Posted to port-arm@ on April 19.
 1.349.2.1  02-Nov-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #335):
share/man/man9/kernhist.9: 1.5-1.8
sys/arch/acorn26/acorn26/pmap.c: 1.39
sys/arch/arm/arm32/fault.c: 1.105 via patch
sys/arch/arm/arm32/pmap.c: 1.350, 1.359
sys/arch/arm/broadcom/bcm2835_bsc.c: 1.7
sys/arch/arm/omap/if_cpsw.c: 1.20
sys/arch/arm/omap/tiotg.c: 1.7
sys/arch/evbarm/conf/RPI2_INSTALL: 1.3
sys/dev/ic/sl811hs.c: 1.98
sys/dev/usb/ehci.c: 1.256
sys/dev/usb/if_axe.c: 1.83
sys/dev/usb/motg.c: 1.18
sys/dev/usb/ohci.c: 1.274
sys/dev/usb/ucom.c: 1.119
sys/dev/usb/uhci.c: 1.277
sys/dev/usb/uhub.c: 1.137
sys/dev/usb/umass.c: 1.160-1.162
sys/dev/usb/umass_quirks.c: 1.100
sys/dev/usb/umass_scsipi.c: 1.55
sys/dev/usb/usb.c: 1.168
sys/dev/usb/usb_mem.c: 1.70
sys/dev/usb/usb_subr.c: 1.221
sys/dev/usb/usbdi.c: 1.175
sys/dev/usb/usbdi_util.c: 1.67-1.70
sys/dev/usb/usbroothub.c: 1.3
sys/dev/usb/xhci.c: 1.75
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: 1.34
sys/kern/kern_history.c: 1.15
sys/kern/kern_xxx.c: 1.74
sys/kern/vfs_bio.c: 1.275-1.276
sys/miscfs/genfs/genfs_io.c: 1.71
sys/sys/kernhist.h: 1.21
sys/ufs/ffs/ffs_balloc.c: 1.63
sys/ufs/lfs/lfs_vfsops.c: 1.361
sys/ufs/lfs/ulfs_inode.c: 1.21
sys/ufs/lfs/ulfs_vnops.c: 1.52
sys/ufs/ufs/ufs_inode.c: 1.102
sys/ufs/ufs/ufs_vnops.c: 1.239
sys/uvm/pmap/pmap.c: 1.37-1.39
sys/uvm/pmap/pmap_tlb.c: 1.22
sys/uvm/uvm_amap.c: 1.108
sys/uvm/uvm_anon.c: 1.64
sys/uvm/uvm_aobj.c: 1.126
sys/uvm/uvm_bio.c: 1.91
sys/uvm/uvm_device.c: 1.66
sys/uvm/uvm_fault.c: 1.201
sys/uvm/uvm_km.c: 1.144
sys/uvm/uvm_loan.c: 1.85
sys/uvm/uvm_map.c: 1.353
sys/uvm/uvm_page.c: 1.194
sys/uvm/uvm_pager.c: 1.111
sys/uvm/uvm_pdaemon.c: 1.109
sys/uvm/uvm_swap.c: 1.175
sys/uvm/uvm_vnode.c: 1.103
usr.bin/vmstat/vmstat.c: 1.219
Reorder to test for null before null deref in debug code
--
Reorder to test for null before null deref in debug code
--
KNF
--
No need for '\n' in UVMHIST_LOG
--
normalise a BIOHIST log message
--
Update the kernhist(9) kernel history code to address issues identified
in PR kern/52639, as well as some general cleaning-up...
(As proposed on tech-kern@ with additional changes and enhancements.)
Details of changes:
* All history arguments are now stored as uintmax_t values[1], both in
the kernel and in the structures used for exporting the history data
to userland via sysctl(9). This avoids problems on some architectures
where passing a 64-bit (or larger) value to printf(3) can cause it to
process the value as multiple arguments. (This can be particularly
problematic when printf()'s format string is not a literal, since in
that case the compiler cannot know how large each argument should be.)
* Update the data structures used for exporting kernel history data to
include a version number as well as the length of history arguments.
* All [2] existing users of kernhist(9) have had their format strings
updated. Each format specifier now includes an explicit length
modifier 'j' to refer to numeric values of the size of uintmax_t.
* All [2] existing users of kernhist(9) have had their format strings
updated to replace uses of "%p" with "%#jx", and the pointer
arguments are now cast to (uintptr_t) before being subsequently cast
to (uintmax_t). This is needed to avoid compiler warnings about
casting "pointer to integer of a different size."
* All [2] existing users of kernhist(9) have had instances of "%s" or
"%c" format strings replaced with numeric formats; several instances
of mis-match between format string and argument list have been fixed.
* vmstat(1) has been modified to handle the new size of arguments in the
history data as exported by sysctl(9).
* vmstat(1) now provides a warning message if the history requested with
the -u option does not exist (previously, this condition was silently
ignored, with only a single blank line being printed).
* vmstat(1) now checks the version and argument length included in the
data exported via sysctl(9) and exits if they do not match the values
with which vmstat was built.
* The kernhist(9) man-page has been updated to note the additional
requirements imposed on the format strings, along with several other
minor changes and enhancements.
[1] It would have been possible to use an explicit length (for example,
uint64_t) for the history arguments. But that would require another
"rototill" of all the users in the future when we add support for an
architecture that supports a larger size. Also, the printf(3)
format
specifiers for explicitly-sized values, such as "%"PRIu64, are much
more verbose (and less aesthetically appealing, IMHO) than simply
using "%ju".
[2] I've tried very hard to find "all [the] existing users of
kernhist(9)"
but it is possible that I've missed some of them. I would be glad
to
update any stragglers that anyone identifies.
--
For some reason this single kernel seems to have outgrown its declared
size as a result of the kernhist(9) changes. Bump the size.
XXX The amount of increase may be excessive - anyone with more detailed
XXX knowledge please feel free to further adjust the value
appropriately.
--
Misssed one cast of pointer --> uintptr_t in previous kernhist(9) commit
--
And yet another one. :(
--
Use correct mark-up for NetBSD version.
--
More improvements in grammar and readability.
--
Remove a stray '"' (obvious typo) and add a couple of casts that are
probably needed.
--
And replace an instance of "%p" conversion with "%#jx"
--
Whitespace fix. Give Bl tag table a width. Fix Xr.
 1.364.2.4  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.364.2.3  20-Oct-2018  pgoyette Sync with head
 1.364.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.364.2.1  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.365.2.4  21-Apr-2020  martin Sync with HEAD
 1.365.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.365.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.365.2.1  10-Jun-2019  christos Sync with HEAD
 1.373.2.2  27-Feb-2020  martin Pull up following revision(s) (requested by skrll in ticket #742):

sys/arch/arm/arm32/pmap.c: revision 1.388
sys/arch/arm/arm32/armv7_generic_space.c: revision 1.11
sys/arch/arm/arm/cpufunc.c: revision 1.176
sys/arch/arm/conf/Makefile.arm: revision 1.54 (via patch)
sys/arch/arm/include/arm32/pmap.h: revision 1.161

Fix the armv[67] memory attributes for uncached memory. Previously it was
mapped as strongly-ordered which meant that unaligned accesses would fault.
armv7_generic_bs_map now maps pages with PMAP_DEV which is treated as SO
bus_dma continues to use PMAP_NOCACHE as appropriate, but this now get
mapped to the correct memory attribute bits for armv[67]

DEVMAP_ENTRY usees a new flag PTE_DEV.

The workaround for the unaligned access faults is now removed.
XXX Other armv[67] boards bus_space implementations should be checked.
XXX There is scope to reduce the difference to aarch64
 1.373.2.1  10-Feb-2020  martin Pull up following revision(s) (requested by skrll in ticket #691):

sys/arch/arm/arm32/pmap.c: revision 1.383
sys/arch/arm/arm32/pmap.c: revision 1.385
sys/arch/arm/arm32/pmap.c: revision 1.386
sys/arch/arm/arm32/pmap.c: revision 1.387
sys/arch/arm/arm32/pmap.c: revision 1.374
sys/arch/arm/arm32/pmap.c: revision 1.375
sys/arch/arm/arm32/pmap.c: revision 1.376
sys/arch/arm/arm32/pmap.c: revision 1.377
sys/arch/arm/arm32/pmap.c: revision 1.378
sys/arch/arm/arm32/pmap.c: revision 1.379

Convert a __CTASSERT into a KASSERT as L1_S_CACHE_MASK may not be a
compile time constant if ARM_NMMUS > 1

Improve a comment

Update PMAP_STEAL_MEMORY code to uvm_hotplug

Typo in comment

Fix a bug introduced in 1.271 where pmap_grow_map would no longer map
the allocated page for the uvm.page_init_done == false case when
PMAP_STEAL_MEMORY is not defined.

Trailing whitespace

Fix comment

Always pmap_kenter_pa the page in pmap_grow_map regardless of how we got
it.

Always call pmap_grow_map with a page aligned new VA. KASSERT that this
happenes.

More KNF
 1.375.2.4  29-Feb-2020  ad Sync with head.
 1.375.2.3  29-Feb-2020  ad Sync with head.
 1.375.2.2  25-Jan-2020  ad Sync with head.
 1.375.2.1  17-Jan-2020  ad Sync with head.
 1.402.2.2  25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.402.2.1  20-Apr-2020  bouyer Sync with HEAD
 1.422.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.426.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.437.4.4  18-Apr-2024  martin Pull up following revision(s) (requested by skrll in ticket #666):

sys/arch/arm/arm32/pmap.c: revision 1.443

port-arm/58135: reproducible pmap KASSERT failure for armv7 with NFS root

Don't unconditionally set XN in pmap_clearbit - only set it if a mapping
exists VM_PROT_EXEC is being cleared.

I've simplified the #ifdefs in the patch from the PR.
 1.437.4.3  14-Dec-2023  martin Pull up following revision(s) (requested by rin in ticket #495):

sys/arch/arm/arm/smccc.c: revision 1.4
sys/arch/arm/arm32/pmap.c: revision 1.441

smccc: Adjust SMCCC_ARCH_ATTRIBUTE for clang/arm
Conditionally use
(1) __attribute__ ((target("arch=armv7ve")))
(2) __attribute__ ((target("armv7ve")))
for gcc and clang, respectively.

While gcc does not accept (2), clang accepts (1) but silently ignores it :(

arm: pmap: Fix clang build without DIAGNOSTIC
 1.437.4.2  14-Oct-2023  martin Pull up following revision(s) (requested by skrll in ticket #411):

sys/arch/evbarm/nslu2/nslu2_machdep.c: revision 1.41
sys/arch/evbarm/gumstix/gumstix_machdep.c: revision 1.75
sys/arch/evbarm/iq80321/iq80321_machdep.c: revision 1.66
sys/arch/iyonix/iyonix/iyonix_machdep.c: revision 1.34
sys/arch/zaurus/zaurus/machdep.c: revision 1.52
sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c: revision 1.41
sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c: revision 1.33
sys/arch/evbarm/iq80310/iq80310_machdep.c: revision 1.96
sys/arch/evbarm/adi_brh/brh_machdep.c: revision 1.53
sys/arch/arm/include/arm32/pmap.h: revision 1.177
sys/arch/evbarm/viper/viper_machdep.c: revision 1.34
sys/arch/evbarm/iyonix/iyonix_machdep.c: revision 1.5
sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c: revision 1.30
sys/arch/evbarm/hdl_g/hdlg_machdep.c: revision 1.35
sys/arch/arm/arm32/pmap.c: revision 1.440
sys/arch/evbarm/lubbock/lubbock_machdep.c: revision 1.45
sys/arch/evbarm/ixdp425/ixdp425_machdep.c: revision 1.47

Fix non-DIAGNOSTIC builds
 1.437.4.1  19-Dec-2022  martin Pull up following revision(s) (requested by skrll in ticket #4):

sys/arch/arm/arm32/pmap.c: revision 1.438
sys/arch/arm/arm/efi_machdep.c: revision 1.3

Appease KDASSERT / LOCKDEBUG.

Tested by mlelstv.

RSS XML Feed