diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-10-30 23:06:40 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-10-30 23:06:40 +0000 |
commit | 21183068596ef41bad15e8c08d8bf47b6e6ff1fb (patch) | |
tree | 04c8a079c6a636c5814dca6a6d508c530b895dbb /pkg/sentry/platform/kvm/machine_unsafe.go | |
parent | 213c251889907379fbd639160e05d6e2dc64c7ea (diff) | |
parent | ca933329fa46ce219b39f4cf8cba1754b36cc2c2 (diff) |
Merge release-20190806.1-348-gca93332 (automated)
Diffstat (limited to 'pkg/sentry/platform/kvm/machine_unsafe.go')
-rw-r--r-- | pkg/sentry/platform/kvm/machine_unsafe.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/sentry/platform/kvm/machine_unsafe.go b/pkg/sentry/platform/kvm/machine_unsafe.go index e00c7ae40..ed9433311 100644 --- a/pkg/sentry/platform/kvm/machine_unsafe.go +++ b/pkg/sentry/platform/kvm/machine_unsafe.go @@ -35,6 +35,30 @@ func entersyscall() //go:linkname exitsyscall runtime.exitsyscall func exitsyscall() +// setMemoryRegion initializes a region. +// +// This may be called from bluepillHandler, and therefore returns an errno +// directly (instead of wrapping in an error) to avoid allocations. +// +//go:nosplit +func (m *machine) setMemoryRegion(slot int, physical, length, virtual uintptr, flags uint32) syscall.Errno { + userRegion := userMemoryRegion{ + slot: uint32(slot), + flags: uint32(flags), + guestPhysAddr: uint64(physical), + memorySize: uint64(length), + userspaceAddr: uint64(virtual), + } + + // Set the region. + _, _, errno := syscall.RawSyscall( + syscall.SYS_IOCTL, + uintptr(m.fd), + _KVM_SET_USER_MEMORY_REGION, + uintptr(unsafe.Pointer(&userRegion))) + return errno +} + // mapRunData maps the vCPU run data. func mapRunData(fd int) (*runData, error) { r, _, errno := syscall.RawSyscall6( |