github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/platform/kvm/kvm_arm64.go (about) 1 // Copyright 2019 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build arm64 16 17 package kvm 18 19 import ( 20 "github.com/SagerNet/gvisor/pkg/ring0" 21 "github.com/SagerNet/gvisor/pkg/sentry/arch" 22 ) 23 24 type kvmOneReg struct { 25 id uint64 26 addr uint64 27 } 28 29 // arm64HypercallMMIOBase is MMIO base address used to dispatch hypercalls. 30 var arm64HypercallMMIOBase uintptr 31 32 const KVM_NR_SPSR = 5 33 34 type userFpsimdState struct { 35 vregs [64]uint64 36 fpsr uint32 37 fpcr uint32 38 reserved [2]uint32 39 } 40 41 type userRegs struct { 42 Regs arch.Registers 43 sp_el1 uint64 44 elr_el1 uint64 45 spsr [KVM_NR_SPSR]uint64 46 fpRegs userFpsimdState 47 } 48 49 type exception struct { 50 sErrPending uint8 51 sErrHasEsr uint8 52 extDabtPending uint8 53 pad [5]uint8 54 sErrEsr uint64 55 } 56 57 type kvmVcpuEvents struct { 58 exception 59 rsvd [12]uint32 60 } 61 62 // updateGlobalOnce does global initialization. It has to be called only once. 63 func updateGlobalOnce(fd int) error { 64 physicalInit() 65 err := updateSystemValues(int(fd)) 66 ring0.Init() 67 return err 68 }