mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kvm: handle errors of applyVirtualRegions
PiperOrigin-RevId: 487845220
This commit is contained in:
@@ -445,7 +445,7 @@ func (c *vCPU) SwitchToUser(switchOpts ring0.SwitchOpts, info *linux.SignalInfo)
|
||||
func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) {
|
||||
// Map all the executable regions so that all the entry functions
|
||||
// are mapped in the upper half.
|
||||
applyVirtualRegions(func(vr virtualRegion) {
|
||||
if err := applyVirtualRegions(func(vr virtualRegion) {
|
||||
if excludeVirtualRegion(vr) || vr.filename == "[vsyscall]" {
|
||||
return
|
||||
}
|
||||
@@ -462,7 +462,9 @@ func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) {
|
||||
pagetables.MapOpts{AccessType: hostarch.Execute, Global: true},
|
||||
physical)
|
||||
}
|
||||
})
|
||||
}); err != nil {
|
||||
panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err))
|
||||
}
|
||||
for start, end := range m.kernel.EntryRegions() {
|
||||
regionLen := end - start
|
||||
physical, length, ok := translateToPhysical(start)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package kvm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -65,7 +66,7 @@ func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) {
|
||||
// physical regions form them.
|
||||
func archPhysicalRegions(physicalRegions []physicalRegion) []physicalRegion {
|
||||
rdRegions := []virtualRegion{}
|
||||
applyVirtualRegions(func(vr virtualRegion) {
|
||||
if err := applyVirtualRegions(func(vr virtualRegion) {
|
||||
if excludeVirtualRegion(vr) {
|
||||
return // skip region.
|
||||
}
|
||||
@@ -74,7 +75,9 @@ func archPhysicalRegions(physicalRegions []physicalRegion) []physicalRegion {
|
||||
if !vr.accessType.Write && vr.accessType.Read {
|
||||
rdRegions = append(rdRegions, vr)
|
||||
}
|
||||
})
|
||||
}); err != nil {
|
||||
panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err))
|
||||
}
|
||||
|
||||
// Add an unreachable region.
|
||||
rdRegions = append(rdRegions, virtualRegion{
|
||||
|
||||
@@ -60,13 +60,15 @@ func fillAddressSpace() (excludedRegions []region) {
|
||||
pSize -= reservedMemory
|
||||
|
||||
// Add specifically excluded regions; see excludeVirtualRegion.
|
||||
applyVirtualRegions(func(vr virtualRegion) {
|
||||
if err := applyVirtualRegions(func(vr virtualRegion) {
|
||||
if excludeVirtualRegion(vr) {
|
||||
excludedRegions = append(excludedRegions, vr.region)
|
||||
vSize -= vr.length
|
||||
log.Infof("excluded: virtual [%x,%x)", vr.virtual, vr.virtual+vr.length)
|
||||
}
|
||||
})
|
||||
}); err != nil {
|
||||
panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err))
|
||||
}
|
||||
|
||||
// Do we need any more work?
|
||||
if vSize < pSize {
|
||||
|
||||
Reference in New Issue
Block a user