pagetables

package
v0.0.0-...-23e6066 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pagetables provides a generic implementation of pagetables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a single node within a set of page tables.

func (*Node) PTEs

func (n *Node) PTEs() *PTEs

PTEs returns aligned PTE entries.

type Opts

type Opts struct {
	EnablePCID bool
}

Opts are pagetable options.

type PCIDs

type PCIDs struct {
	// contains filtered or unexported fields
}

PCIDs is a simple PCID database.

func NewPCIDs

func NewPCIDs() *PCIDs

NewPCIDs returns a new PCID set.

type PTE

type PTE uint64

PTE is a page table entry.

func (*PTE) Address

func (p *PTE) Address() uintptr

Address extracts the address. This should only be used if Valid returns true.

func (*PTE) Clear

func (p *PTE) Clear()

Clear clears this PTE, including super page information.

func (*PTE) Executable

func (p *PTE) Executable() bool

Executable returns true iff the page is executable.

func (*PTE) IsSuper

func (p *PTE) IsSuper() bool

IsSuper returns true iff this page is a super page.

func (*PTE) Set

func (p *PTE) Set(addr uintptr, write, execute bool, userAccessible bool)

Set sets this PTE value.

func (*PTE) SetSuper

func (p *PTE) SetSuper()

SetSuper sets this page as a super page.

The page must not be valid or a panic will result.

func (*PTE) User

func (p *PTE) User() bool

User returns true iff the page is user-accessible.

func (*PTE) Valid

func (p *PTE) Valid() bool

Valid returns true iff this entry is valid.

func (*PTE) Writeable

func (p *PTE) Writeable() bool

Writeable returns true iff the page is writable.

type PTEs

type PTEs [entriesPerPage]PTE

PTEs is a collection of entries.

type PageTables

type PageTables struct {
	// contains filtered or unexported fields
}

PageTables is a set of page tables.

func New

func New(t Translater, opts Opts) *PageTables

New returns new PageTables.

func (*PageTables) CR3

func (p *PageTables) CR3() uint64

CR3 returns the CR3 value for these tables.

This may be called in interrupt contexts.

func (*PageTables) FlushCR3

func (p *PageTables) FlushCR3() uint64

FlushCR3 returns the CR3 value that flushes the TLB.

This may be called in interrupt contexts.

func (*PageTables) Lookup

func (p *PageTables) Lookup(addr usermem.Addr) (physical uintptr, accessType usermem.AccessType)

Lookup returns the physical address for the given virtual address.

func (*PageTables) Map

func (p *PageTables) Map(addr usermem.Addr, length uintptr, user bool, at usermem.AccessType, physical uintptr) bool

Map installs a mapping with the given physical address.

True is returned iff there was a previous mapping in the range.

Precondition: addr & length must be aligned, their sum must not overflow.

func (*PageTables) New

func (p *PageTables) New() *PageTables

New returns a new set of PageTables derived from the given one.

This function should always be preferred to New if there are existing pagetables, as this function preserves architectural constraints relevant to managing multiple sets of pagetables.

func (*PageTables) Release

func (p *PageTables) Release()

Release releases this address space.

This must be called to release the PCID.

func (*PageTables) Unmap

func (p *PageTables) Unmap(addr usermem.Addr, length uintptr) bool

Unmap unmaps the given range.

True is returned iff there was a previous mapping in the range.

type Translater

type Translater interface {
	// TranslateToPhysical translates the given pointer object into a
	// "physical" address. We do not require that it translates back, the
	// reverse mapping is maintained internally.
	TranslateToPhysical(*PTEs) uintptr
}

Translater translates to guest physical addresses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL