Commit Graph

125 Commits

Author SHA1 Message Date
bjorn3 08c00a434d Update to the 2024 edition
On newer rustc versions let_chain is only allowed with the 2024 edition.
2025-09-10 15:37:19 +02:00
Jeremy Soller 63669069f4 Merge branch 'bump_fix' into 'master'
Fix a bump allocator error

See merge request redox-os/rmm!15
2024-10-22 21:26:17 +00:00
Andrey Turkin 91ccf4e6aa Fix a bump allocator error 2024-10-22 22:14:39 +03:00
Jeremy Soller edb3a87578 Merge branch 'riscv' into 'master'
Fixes and changes to make RISC-V paging work

See merge request redox-os/rmm!14
2024-09-24 12:51:39 +00:00
Andrey Turkin ed8bcfca1f Add write combining page flags where applicable 2024-09-24 08:26:02 +03:00
Andrey Turkin 192dd8283f RISC-V: implement TLB flush 2024-09-24 08:26:01 +03:00
Andrey Turkin f51cd00f00 Remove read/write flags from common PDE flags.
RISC-V convention marks PDE with no read/write/execute, so we can't have none of this flags set there. Remove their setting from PDE handling code and instead set them as appropriate in arch-specific defaults.

Also enable both readonly and readwrite flags to be non-zero (as long as their intersection completely masks both of them), as required for RISC-V PTE handling.
2024-09-24 08:24:18 +03:00
Andrey Turkin a96ea6f5f3 Allow physical address bits be anywhere in PTE entry
Before this commit, RMM assumed base physical address was presented in PTE as is, i.e. physical page address was shifted exactly to PAGE_SHIFT, so physical address can be extracted from PTE by simply masking off some bits and can be placed in PTE by simple addition/OR.

This is not the case for RISC-V which has 4Kb base page so 12 bits PAGE_SHIFT, yet physical page address is only shifted 10 bits in PTE.

This commit removes this assumption.

 NOTE: This commit changes meaning of constants:
 * ENTRY_ADDRESS_SIZE from "total physical size in bytes" to "total physical size in PAGES"
 * ENTRY_ADDRESS_MASK from "mask of physical bits in PTE" to "mask of physical bits starting at bit 0"
2024-09-23 08:47:27 +03:00
Andrey Turkin b7d3acf606 Separate leaf page and directory pages USER flag
This is required for RISC-V. Privileged spec says:

> For non-leaf PTEs, the D, A, and U bits are reserved for future standard use.
> Until their use is defined by a standard extension, they must be cleared by software
> for forward compatibility.

QEMU fails address translation if it sees any of these flags set on non-leaf page entry.
2024-09-23 08:47:23 +03:00
Jeremy Soller bb27f57228 Merge branch 'fix_bump' into 'master'
Fix bump allocator initialization

See merge request redox-os/rmm!13
2024-09-22 13:20:33 +00:00
4lDO2 d95ea6598f Fix bump allocator. 2024-09-22 10:27:06 +02:00
4lDO2 5f9a587968 Convert repr(packed) to repr(C, packed). 2024-09-08 20:48:05 +02:00
Jeremy Soller ea4cfb2cbf Merge branch 'fix' into 'master'
Revived tests

See merge request redox-os/rmm!12
2024-09-02 21:16:38 +00:00
Andrey Turkin 7c0995ee24 Revived tests
Also fixed debug build failure on i686, and reformatted the code
2024-07-12 21:10:37 +03:00
4lDO2 99fcfc5fae Skip insufficiently large bump alloc regions. 2024-04-11 22:02:44 +02:00
4lDO2 5e75df56c5 More BumpAllocator APIs. 2023-12-18 11:16:15 +01:00
4lDO2 ed455915ca Allow arbitrary bump allocation size. 2023-12-18 11:16:11 +01:00
Jeremy Soller d7d824552b Merge branch 'derive_hash_virtual_address' into 'master'
Derive Hash for VirtualAddress

See merge request redox-os/rmm!11
2023-12-13 00:10:02 +00:00
bjorn3 aad492f805 Derive Hash for VirtualAddress 2023-12-12 22:21:22 +01:00
Jeremy Soller a992ae89ed Merge branch 'mmu' into 'master'
Demand paging related improvements

See merge request redox-os/rmm!10
2023-08-01 13:51:37 +00:00
4lDO2 86aba2dbe5 Better VirtualAddress Debug impl. 2023-07-28 13:39:32 +02:00
4lDO2 b5937b7b91 Set aarch64 "not global" flag by default. 2023-07-28 13:38:39 +02:00
4lDO2 8e22e69c94 Add remap_with{,_full}. 2023-07-17 13:31:51 +02:00
4lDO2 0aa7fea250 Fix remap bug: require present before remapping. 2023-07-17 13:31:46 +02:00
Jeremy Soller eaab222011 Merge branch 'fix_is_global' into 'master'
Fix is_global.

See merge request redox-os/rmm!9
2023-07-16 16:36:55 +00:00
4lDO2 339984e49b Fix is_global. 2023-07-16 18:32:34 +02:00
Jeremy Soller e24e8485ba Merge branch 'aarch64-stuff' into 'master'
Add GLOBAL flag and prettify some stuff

See merge request redox-os/rmm!8
2023-06-12 12:12:09 +00:00
uuuvn d89e6008e8 Add GLOBAL flag and prettify some stuff 2023-06-12 10:23:40 +00:00
Jeremy Soller 7aeb9f0ac8 Remove rust-toolchain 2023-02-11 14:50:26 -07:00
Jeremy Soller 81b03cc693 Improve aarch64 tlb flushing 2022-08-28 09:19:07 -06:00
Jeremy Soller 27bb8e44dd Do not allow phys_to_virt overflow 2022-08-26 11:07:21 -06:00
Jeremy Soller 61ba2e6c8e Fix unmap_parents 2022-08-22 18:49:32 -06:00
Jeremy Soller 0d4ff5d4f3 Add functions for accessing mapper allocator 2022-08-21 13:20:44 -06:00
Jeremy Soller df733ed571 Use TableKind for most table operations 2022-08-20 13:00:48 -06:00
Jeremy Soller c5eb435d79 Match PHYS_OFFSET accross archs 2022-08-19 20:53:15 -06:00
Jeremy Soller e05868e1dc Improve aarch64 paging instructions 2022-08-19 19:52:00 -06:00
Jeremy Soller e9950ee6da Fix more warnings 2022-07-29 18:53:12 -06:00
Jeremy Soller 23d4995e50 Fix warnings 2022-07-29 18:37:37 -06:00
4lDO2 5700899e9a Merge branch 'migrate_kernel_to_rmm' into 'master'
Add necessary functionality for migrating kernel paging code to RMM

See merge request redox-os/rmm!6
2022-07-27 15:10:52 +00:00
4lDO2 9462df03e7 Add support for unmapping parents.
Currently, this uses a relatively naive method of simply scanning the
512 entries for the PRESENT flag. But, unless the optimizer cannot, it
can be reduced to calculating the bitwise OR of every entry and then
checking that.

If this turns out to be too slow, which it might be when unmapping lots
of pages, then we can (1) either fall back to using a counter like the
old paging code did, or even better (2) use the now-1:1 grants tree to
check if it became empty. Putting the grants code in RMM might be
suboptimal, so instead we can add "unmap_range" and have the kernel
paging code take the offset of the next grant, if any, and then possibly
unmap entire P1s/P2s/P3s -- whatever is in the page tables within that
range.

Note that I am fairly certain that method (1) was the cause of the
visually notorious orbital memory corruption bug.
2022-07-27 10:49:49 +02:00
4lDO2 229ae5da40 Add remaining interfaces to user RMM for user mem. 2022-07-27 10:49:49 +02:00
4lDO2 efc67a2012 Use wrapped flags for PageEntry. 2022-07-27 10:49:49 +02:00
4lDO2 fad6afa7d8 Flush on Drop, unless explicitly ignored. 2022-07-27 10:49:49 +02:00
4lDO2 7a209c83c9 Implement Debug for X8664Arch. 2022-07-27 10:49:49 +02:00
4lDO2 c847b1e2a8 Implement FrameAllocator for mutable refs of impls. 2022-07-27 10:49:49 +02:00
4lDO2 2f16dddf25 Add a page flusher trait. 2022-07-27 10:49:49 +02:00
Jeremy Soller 0944b17983 Add initial x86 32-bit support 2022-07-26 20:13:55 -06:00
Jeremy Soller ec284ca8e3 Update rust-toolchain 2022-07-26 19:01:42 -06:00
Jeremy Soller 507f7ccd4a Merge branch 'update-toolchain-2022' into 'master'
Update to latest toolchain.

See merge request redox-os/rmm!5
2022-03-23 18:06:11 +00:00
4lDO2 e2648005ba Update to latest toolchain. 2022-03-06 11:34:22 +01:00