History log of /haiku/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp
Revision Date Author Comments
# b799d160 15-Jun-2023 David Karoly <karolyd577@gmail.com>

kernel/arm/paging: implement Modified Flag

* Introduce SWDBM flag similarly to the arm64 port
* Reuse TEX[2] for SWDBM flag which should be availble
to be used by the operating system if TEX remap
is enabled.
* Introduce SetAndClearPageTableEntryFlags for updating
accessed and modified flags atomically
* Startup sequence is handled similarly to accessed flag, i.e.
set Modified flag in initially mapped pages in bootloader and early map.
* Once the kernel initialization has progressed enough,
pages are mapped as read-only and modified flag handling is done
in the page fault handler.

Change-Id: I8f761e2c6325d1b91481abd569d5e8befded0761
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6518
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# f61fb770 30-May-2023 David Karoly <karolyd577@gmail.com>

kernel/arm: don't set Accessed Flag when initially mapping a page

Pages should not be marked as accessed when initially mapping them.

However, there's a short interval during kernel startup when new pages
are mapped but the fault handler is not installed yet.

Therefore, we set Accessed Flag to 1 in early_map.
Once the kernel initialization has progressed enough, we start mapping
new pages with Accessed Flag set to 0.

The chicken and egg problem of initially mapping the vector page is
tackled by preallocating the vector page in the boot loader.

Change-Id: Ie3be4f81812d7a090af57e8c79420598d16182b9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6450
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 0d5bde42 17-May-2023 David Karoly <karolyd577@gmail.com>

kernel/arm/paging: remove empty code block related to global pages

Change-Id: I2f8b9da371cb4e2e496e985035bda78b139ff8e4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6443
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 84745ade 10-May-2023 David Karoly <karolyd577@gmail.com>

kernel/arm/paging: use simplified permission model

Change-Id: Ie0ed357ee9ca5bee4c10c6cbf74eaba77acdd179
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6435
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: David Karoly <karolyd577@gmail.com>


# 3d79cd33 01-Sep-2022 David Karoly <karolyd577@gmail.com>

kernel/arm: set PXN for user memory

* set PXN for all page tables below KERNEL_BASE
* also set PXN for physical page mapper

PXN, Privileged execute-never

When the PXN bit is 1, a Permission fault is generated if the processor
is executing at PL1 and attempts to execute an instruction fetched from
the corresponding memory region.

Change-Id: I3056cbed151004ac9edfbc81ebeada328aeb603c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5607
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 83f755b5 23-Apr-2022 David Karoly <karolyd577@gmail.com>

kernel/arm: add memory barriers for page table ops

Introduce memory barriers according to ARMARM,
section G.5.3 TLB maintenance operations and barriers

Sequence for mapping memory in (both L1 and L2):
* DSB
* Invalidate i-cache (TODO)
* Insert new entry in page directory / page table
* DSB
* ISB

Sequence for mapping memory out:
* Remove page table entry
* DSB
* Invalidate TLB entry
* DSB
* ISB

Sequence for updating a page table entry:
* Update page table entry
* DSB
* Invalidate TLB entry
* Invalidate branch predictor (TODO)
* DSB
* ISB

Note: i-cache invalidation and branch predictor invalidation is
not implemented yet as this commit focuses on implementing memory
barriers.

Change-Id: I192fa80f6b43117236a4be6fa8c988afca90e015
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5241
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 745a40d7 23-Apr-2022 David Karoly <karolyd577@gmail.com>

kernel/arm: implement memory attributes

Set AP[2:0] and XN flags based on page attributes.
PXN is not implemented as it seems to be available only
in L1 descriptors on ARMv7.

Set TEX, B, C flags based on memoryType:
* B_MTR_UC is mapped to Strongly Ordered (TEX=0, B=0, C=0)
* B_MTR_WC is mapped to Shareable Device Memory (TEX=0, B=1, C=0)
* B_MTR_WT is mapped to Outer and Inner Write-Through, no Write-Allocate (TEX=0, B=0, C=1)
* B_MTR_WB is mapped to Outer and Inner Write-Back, no Write-Allocate (TEx=0, B=1, C=1)
* B_MTR_WP has no direct equivalent on the ARM so it's mapped as B_MTR_WB
* default is Write-Back

Implement ARMPagingMethod32Bit::AttributesToPageTableEntryFlags()
for mapping from page attributes to AP[2:0] and XN flags.

Implement ARMPagingMethod32Bit::PageTableEntryFlagsToAttributes()
for the reverse mapping used in Query() and QueryInterrupt()
i.e. recover page attributes from AP[2:0] and XN flags.

Implement ARMPagingMethod32Bit::MemoryTypeToPageTableEntryFlags()
fr mapping from memoryType to TEX, B, C flags.

Implement ARMVMTranslationMap32Bit::Protect() which used to be commented out.

Accessed and modified flags are not implemented yet, so no such
flags are returned from Query() and QueryInterrupt().

Also because of this, we just invalidate TLB on any call to Protect()
without checking whether the page has been accessed.

Change-Id: I027af5c02bd6218d9f92a58044aeb26373e1956b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5236
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# adc32659 22-Apr-2022 David Karoly <karolyd577@gmail.com>

arm: enable enforcing memory access permissions

Bootloader:
* set permissions to kernel read/write, no user access
for initially mapped memory areas
* set permissions to kernel read/write, no execute,
no user access for UART

Kernel:
* physical memory mapper uses kernel read/write mapping
with no-execute bit enabled
* all other pages are mapped as read/write/execute for
kernel and user
* proper access permissions and memory types to be
implemented later

Enforce memory access permissions by setting DACR to
client mode for domain #0, no access for other domains.

see ARM Architecture Reference Manual, section B3.7 Memory access control
and in particular the following subsections:
B3.7.1 Access permissions
B3.7.2 Execute-never restrictions on instruction fetching
B3.7.3 Domains, Short-descriptor format only

Change-Id: I8127b4c72dc516d013cb9751d80d6f3a9ec835e6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5233
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 9b592446 21-Apr-2022 David Karoly <karolyd577@gmail.com>

kernel/arm/paging: adjust page table entry flags

Map physical memory by default as Normal Memory,
Outer and Inner Write-Back, no Write-Allocate

This corresponds to the following flags:
TEX=0, B=1, C=1

AP flags are not filled in at this point
as access permissions are not enforced.

see also ARM Architecture Reference Manual, section B3.8.2,
Short-descriptor format memory region attributes, without TEX remap

Change-Id: I90bc95a8feb9f22583d41135f4cbd03489fd1b72
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5230
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# d283a8c5 27-Jan-2022 David Karoly <karolyd577@gmail.com>

kernel/arm: add range checking for early page tables

Change-Id: Ibbd367475482eb0cf839314014c8bf68612c5d6a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4891
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 9103470b 11-Jan-2022 David Karoly <karolyd577@gmail.com>

kernel/arm: don't require identity mapping of initial page tables

Remove the dependency on identity mapping for the initial page tables
used in MapEarly / _EarlyQuery.

The initial page tables have to satisfy the following conditions instead:
* the inital page tables shall be allocated in the same region as the initial page directory
* this region shall be mapped contiguously
* the page tables shall be mapped at a higher address than the page directory

Change-Id: I34854ef93826aa48f5d90582b52905e553f3d275
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4857
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 375c2129 20-Oct-2021 David Karoly <karolyd577@gmail.com>

kernel/arch/arm/paging: fix a few typos

Change-Id: Ia6c51f1d24f5a365564f127199df898c5531f274
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4640
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# ed04ffb5 26-Oct-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: keep all pages we've mapped during kernel startup

Don't just keep the page directory, but also the actual allocates
pages for the pagetables we've created.


# 1819aa71 07-Sep-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: sync up VM code with x86

No big functional reason for this, but rather keep it in sync now
then have to do lots of work later on, when there are major changes.
Once I have it fully fleshed out for ARM, I might take a look if
we can generalise it a little more, as there's lots of code
_exactly_ the same for both platforms (and other platforms in
progress using the same code).


# eea45d0a 06-Sep-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: cleanup of bootloader memory mapping

* Removes default mapping of a portion of the RAM (will be done
as needed)
* Passes on the page directory area to kernel, so on early vm init
the kernel can use the area for pagetable allocation.
* Leaves it to the platform to pass in physical memory range(s). This
will ultimately come from FDT.
* Fix long standing issue with allocation of the heap, potentially
causing other part of the bootloader to overwrite the heap.
* Implements pagetable allocator in kernel for early vm mapping.

This fixes the first PANIC seen, we now just get the same one later
on when the VM is up... more to come...


# d1f280c8 01-Apr-2012 Hamish Morrison <hamishm53@gmail.com>

Add support for pthread_attr_get/setguardsize()

* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
only.


# 760de9b2 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Tiny code style cleanup.


# fd6e3a11 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Use the existing ARM MMU definitions and remove duplicates.


# 50c463f4 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Header cleanup, rename macros for more consistency.


# f86b5828 06-Nov-2012 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: Cleanup of port support code.

This also implements the fault handler correctly now, and cleans up the
exception handling. Seems a lot more stable now, no unexpected panics or
faults happening anymore.


# 0e5d97e9 06-Nov-2012 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM/vm: small formatting change and trace fix.

Copy some minor changes over from the X86 paging implementation to keep
the two reasonably aligned. Smaller diff ;-)


# 3091264b 31-Oct-2010 François Revol <revol@free.fr>

s/Copyirght/Copyright/ unless it's a neologism from Ithamar :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39235 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c917cd62 30-Oct-2010 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

* ARM: Major VM work
- This is mostly a copy of the x86 32bit paging method and infrastructure, this was copied for two reasons:
1) It is the most complete VM arch
2) The first ARM PAE patches have landed on alkml, so we will have to deal with it in the future as well,
and this infrastructure has proven to be ready ;)
- No protection features, or dirty/accessed tracking yet
- Lots of #if 0

but....

It boots all the way up to init_modules() now, and then dies because of a lack of (ARM) ELF relocation implementation!

Since at this point the VM can be fully initialised, I'm going to focus on CPU exceptions next, so we can get KDL to trigger
when it happens, and I can actually debug from there ;)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39206 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed04ffb598349c5876905acb21ee898056c6b4a0 26-Oct-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: keep all pages we've mapped during kernel startup

Don't just keep the page directory, but also the actual allocates
pages for the pagetables we've created.


# 1819aa71eeea86d951569eaa05bbe9eedfbf222e 07-Sep-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: sync up VM code with x86

No big functional reason for this, but rather keep it in sync now
then have to do lots of work later on, when there are major changes.
Once I have it fully fleshed out for ARM, I might take a look if
we can generalise it a little more, as there's lots of code
_exactly_ the same for both platforms (and other platforms in
progress using the same code).


# eea45d0a329d51c5fcf8bf904316e7761aaaa96f 06-Sep-2014 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: cleanup of bootloader memory mapping

* Removes default mapping of a portion of the RAM (will be done
as needed)
* Passes on the page directory area to kernel, so on early vm init
the kernel can use the area for pagetable allocation.
* Leaves it to the platform to pass in physical memory range(s). This
will ultimately come from FDT.
* Fix long standing issue with allocation of the heap, potentially
causing other part of the bootloader to overwrite the heap.
* Implements pagetable allocator in kernel for early vm mapping.

This fixes the first PANIC seen, we now just get the same one later
on when the VM is up... more to come...


# d1f280c80529d5f0bc55030c2934f9255bc7f6a2 01-Apr-2012 Hamish Morrison <hamishm53@gmail.com>

Add support for pthread_attr_get/setguardsize()

* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
only.


# 760de9b200a5023e2f79e2ee04ba570869de7ae7 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Tiny code style cleanup.


# fd6e3a11e2e39e8a3e72914996a4b0d79d64c9df 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Use the existing ARM MMU definitions and remove duplicates.


# 50c463f4f1af22b46db3a4b7d1ead4a5e11bafa3 03-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Header cleanup, rename macros for more consistency.


# f86b5828486b661145eb15952ec14648c9bb8d9b 06-Nov-2012 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM: Cleanup of port support code.

This also implements the fault handler correctly now, and cleans up the
exception handling. Seems a lot more stable now, no unexpected panics or
faults happening anymore.


# 0e5d97e97e32eae4023d4223d6ac6527c76cabd7 06-Nov-2012 Ithamar R. Adema <ithamar@upgrade-android.com>

ARM/vm: small formatting change and trace fix.

Copy some minor changes over from the X86 paging implementation to keep
the two reasonably aligned. Smaller diff ;-)


# 3091264bb53e84341c9ac5a246d44363d8292353 31-Oct-2010 François Revol <revol@free.fr>

s/Copyirght/Copyright/ unless it's a neologism from Ithamar :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39235 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c917cd62618c2bfd683dba8bf34f96fb7bd37203 30-Oct-2010 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

* ARM: Major VM work
- This is mostly a copy of the x86 32bit paging method and infrastructure, this was copied for two reasons:
1) It is the most complete VM arch
2) The first ARM PAE patches have landed on alkml, so we will have to deal with it in the future as well,
and this infrastructure has proven to be ready ;)
- No protection features, or dirty/accessed tracking yet
- Lots of #if 0

but....

It boots all the way up to init_modules() now, and then dies because of a lack of (ARM) ELF relocation implementation!

Since at this point the VM can be fully initialised, I'm going to focus on CPU exceptions next, so we can get KDL to trigger
when it happens, and I can actually debug from there ;)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39206 a95241bf-73f2-0310-859d-f6bbb57e9c96