mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kvm: prefault a root table page before switching into a user address space
The root table physical page has to be mapped to not fault in iret or sysret after switching into a user address space. sysret and iret are in the upper half that is global and so page tables of lower levels are already mapped. Fixes #5742 PiperOrigin-RevId: 371458644
This commit is contained in:
@@ -322,3 +322,12 @@ func (p *PageTables) Lookup(addr hostarch.Addr, findFirst bool) (virtual hostarc
|
||||
func (p *PageTables) MarkReadOnlyShared() {
|
||||
p.readOnlyShared = true
|
||||
}
|
||||
|
||||
// PrefaultRootTable touches the root table page to be sure that its physical
|
||||
// pages are mapped.
|
||||
//
|
||||
//go:nosplit
|
||||
//go:noinline
|
||||
func (p *PageTables) PrefaultRootTable() PTE {
|
||||
return p.root[0]
|
||||
}
|
||||
|
||||
@@ -351,6 +351,10 @@ func (c *vCPU) SwitchToUser(switchOpts ring0.SwitchOpts, info *arch.SignalInfo)
|
||||
// allocations occur.
|
||||
entersyscall()
|
||||
bluepill(c)
|
||||
// The root table physical page has to be mapped to not fault in iret
|
||||
// or sysret after switching into a user address space. sysret and
|
||||
// iret are in the upper half that is global and already mapped.
|
||||
switchOpts.PageTables.PrefaultRootTable()
|
||||
prefaultFloatingPointState(switchOpts.FloatingPointState)
|
||||
vector = c.CPU.SwitchToUser(switchOpts)
|
||||
exitsyscall()
|
||||
|
||||
Reference in New Issue
Block a user