A Rust library to manipulate AArch64 VMSA EL1 page tables.

Overview

aarch64 page table manipulation

crates.io page docs.rs page

This crate provides a library to manipulate EL1 page tables conforming to the AArch64 Virtual Memory System Architecture.

This is not an officially supported Google product.

License

Licensed under either of

at your option.

Contributing

If you want to contribute to the project, see details of how we accept contributions.

Comments
  • Add support for linear mapping

    Add support for linear mapping

    This required some refactoring because the methods on the Translation trait need to take self to know the offset, and so the Translation needs to be passed around to the various methods which access the page table. I've achieved this by adding it as a field on the PageTableWithLevel.

    To avoid duplicating code I've moved the common methods from IdMap out to a new shared struct called Mapping, which takes the Translation on construction. Translation is then implemented by IdTranslation and LinearTranslation, and IdMap becomes an alias for Mapping<IdTranslation>.

    Suggestions are welcome on better names.

    opened by qwandor 1
  • Avoid cloning Translation.

    Avoid cloning Translation.

    Rather than keeping a copy in each PageTableWithLevel we can just keep it in the RootTable and pass a reference around when needed.

    This is an alternative to #18.

    opened by qwandor 0
  • Fix bug with block mappings for non-identity map page tables

    Fix bug with block mappings for non-identity map page tables

    LinearMap and any other mapping which may have different alignment of virtual and physical addresses was incorrectly using block mappings in cases where the physical address didn't have the required alignment. The architecture requires that we only make block mappings when the physical addresses are aligned to the size of the block, so this fixes the code to do that, and adds a test.

    opened by qwandor 0
  • Prepare for more complex mapping schemes

    Prepare for more complex mapping schemes

    This PR makes the Translation trait responsible for allocating page tables. This should help make it possible to use more complex mapping schemes, and to construct page tables in a different context to where they are used. This also allows allows us to make the alloc dependency optional (as it's only used by IdMap and LinearMap, not the core pagetable code).

    TODO:

    • [x] What about freeing subtables? Currently this assumes they are allocated by the global allocator, as it uses that to free them.
    opened by qwandor 0
  • Implement useful traits for address types and `MemoryRegion`

    Implement useful traits for address types and `MemoryRegion`

    Adds addition and subtraction for VirtualAddress and PhysicalAddress, and conversion from Range<VirtualAddress> to MemoryRegion (with the same alignment logic as MemoryRegion::new).

    opened by qwandor 0
  • Fix bugs in Drop and Debug implementations for PageTable

    Fix bugs in Drop and Debug implementations for PageTable

    They would crash (segfault in tests) if there were any page mappings other than 0 because the Descriptor::subtable method incorrectly returned a reference to a subtable even if the descriptor was actually in a leaf level table, because the encoding of a page mapping in a leaf table is the same as the encoding of a subtable mapping at any other level.

    To avoid this it is necessary to know what level a PageTable is at, so I've added a new (internal) struct PageTableWithLevel which wraps a pointer to a PageTable. I've moved the methods from PageTable to PageTableWithLevel, which saves passing the level around.

    opened by qwandor 0
  • Fix width of formatted addresses, and add Debug implementation

    Fix width of formatted addresses, and add Debug implementation

    The length specified in the format string includes the "0x" at the start, so it should be two more than the number of digits we want. Implementing Debug is useful for being able to derive it on other types which contain a VirtualAddress or PhysicalAddress.

    opened by qwandor 0
  • Consider making `map_range` return an error for unsafe changes

    Consider making `map_range` return an error for unsafe changes

    In particular, any change which requires break-before-make shouldn't be made while the page table is active. This could check the state of previous_ttbr to determine whether it is active, pass it down into the walker code, and then return an error if some part of the change is invalid in that case.

    The problem is that part of the range being mapped might be fine and part might not be, so it might end up creating a partial mapping before realising that it should return an error. Rolling this back isn't safe either. We could do a first walk to check whether it is valid then a second to actually make the change, I guess, but that would introduce a runtime overhead in the normal case.

    opened by qwandor 0
Owner
Google
Google ❤️ Open Source
Google
🍊 WIP: Yet another implementation of MikanOS for aarch64 CPUs, written in Rust.

?? mikan Yet another implementation of MikanOS for aarch64 CPUs, written in Rust. MikanOS (uchan-nos/mikanos) was originally created by @uchan-nos, wh

Naoki Ikeguchi 2 Aug 16, 2022
Rust library for handling CHIP-8 configuration options

octopt octopt is a library for handling CHIP-8 configuration settings. It contains Rust data structures that aim to represent all possible CHIP-8 opti

Tobias V. Langhoff 3 Aug 7, 2022
NES emulator written in Rust to learn Rust

OxideNES A NES emulator in Rust. CPU should be accurate, PPU is mostly accurate, timing between the 2 is off for some corner cases and hardware qui

null 37 Nov 7, 2022
Chip8 emulator written in pure rust, using rust-sdl2 for graphics

Rust-8 chip8 emulator written in rust, using rust-sdl2 for graphics. Features Fully implemented all 35 original chip8 opcodes. This emulator does NOT

Chris Hinson 7 Dec 28, 2022
Commodore 64 emulator written in Rust

Rust64 - a C64 emulator written in Rust This is my attempt to study the Rust programming language and have fun at the same time. The goal is to presen

Krzysztof Kondrak 214 Dec 27, 2022
A Flash Player emulator written in Rust

website | demo | nightly builds | wiki Ruffle Ruffle is an Adobe Flash Player emulator written in the Rust programming language. Ruffle targets both t

Ruffle 11.2k Jan 8, 2023
A Game Boy research project and emulator written in Rust

Mooneye GB Mooneye GB is a Game Boy research project and emulator written in Rust. The main goals of this project are accuracy and documentation. Some

Joonas Javanainen 802 Dec 28, 2022
A Gameboy Emulator in Rust

RBoy A Gameboy Color Emulator written in Rust Implemented CPU All instructions correct All timings correct Double speed mode GPU Normal mode Color mod

Mathijs van de Nes 512 Dec 23, 2022
RGB (Rust Game Boy) is a simple emulator for the original game boy

RGB RGB (Rust Game Boy) is a simple emulator for the original game boy and the color game boy. Warning: This no longer compiles in the latest versions

Niven Achenjang 18 Dec 2, 2022
Full featured Cross-platform GameBoy emulator by Rust. Forever boys!.

Gameboy Full featured Cross-platform GameBoy emulator. Forever boys!. You can start a game with the following command, here with a built-in game "Boxe

Mohanson 1.2k Jan 2, 2023
RustBoyAdvance-NG is a Nintendo™ Game Boy Advance emulator and debugger, written in the rust programming language.

RustBoyAdvance-NG Nintendo GameBoy Advance ™ emulator and debugger, written in rust. WebAssembly Demo: https://michelhe.github.io/rustboyadvance-ng/ P

MishMish 510 Dec 30, 2022
An NES emulator written in Rust

Pinky Pinky is an NES emulator written in Rust completely from scratch based only on publicly available documentation. You can run it in your Web brow

Koute 709 Dec 23, 2022
NES emulator written in Rust

sprocketnes is an emulator for the Nintendo Entertainment System written in the Rust programming language. Its purpose is to serve as a technology dem

Patrick Walton 725 Dec 27, 2022
NES emulator in rust

NES emulator in Rust plastic is a NES emulator built from scratch using Rust. This is a personal project for fun and to experience emulating hardware

Amjad Alsharafi 27 Dec 15, 2022
ZX Spectrum emulator written in Rust

rustzx ZX Spectrum emulator which I writing in rust. I develop this project just for fun and for learning the basics of computer architecture. License

Vladislav Nikonov 162 Dec 27, 2022
Intel 8080 cpu emulator by Rust

i8080 i8080 is a emulator for Intel 8080 cpu. 8080 Programmers Manual 8080 opcodes [dependencies] i8080 = { git = "https://github.com/mohanson/i8080"

Mohanson 83 Dec 27, 2022
CHIP-8 emulator written in Rust

CHIP-8 emulator written in Rust. This is intended to be a project for gaining experience writing emulators and practice Rust.

Pedro Rodrigues 4 May 21, 2021
A CHIP-8 emulator for Rust in ~350 LOC

chip8 An implementation of the CHIP-8 for Rust in ~350 lines of code. What is CHIP-8? CHIP-8 is a virtual machine (along with a supporting programming

Daniel Gatis 8 Apr 23, 2022
Rudroid - Writing the World's worst Android Emulator in Rust 🦀

Rudroid - Writing the World's worst Android Emulator in Rust ?? Introduction Rudroid - this might arguably be one of the worst Android emulators possi

Chaithu 102 Dec 23, 2022