rust-osdev / rust-osdev/x86_64

Adding new mappings in pagetable doesn't require TLB flushes

Open
#587 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
940
Forks
157
Avg merge
1d 10h
Merged PRs (30d)
3

Description

Currently, MappedPageTable and similar facilities always return MapperFlush when mapping a new page, and return a error is a mapping already exist.

According to Intel specifications, adding new mappings to a pagetable doesn't require a TLB flush.

If a paging-structure entry is modified to change the P flag from 0 to 1, no invalidation is necessary. This is
because no TLB entry or paging-structure cache entry is created with information from a paging-structure entry
in which the P flag is 0.

Although, for that to be correct, we still need to ensure that the pagetable entry is actually written at the end of the mapping function (currently, this is somehow enforced by the expected tlb flush that does inline asm invlpg without the nomem attribute), otherwise the compiler is allowed to do surprising reordering of the pagetable modification to e.g after the use of the mapping we're looking to make.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace MappedPageTable and similar mapping facilities, focusing on the MapperFlush return path and the handling of already-existing mappings. Read the cited Intel paging specification and inspect how the page-table write is ordered relative to later mapping use. Done means new mappings no longer require a TLB flush while existing mappings still produce an error and the write is safely ordered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.