github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/runsc/boot/compat_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 package boot 16 17 import ( 18 "fmt" 19 20 "github.com/nicocha30/gvisor-ligolo/pkg/abi" 21 "github.com/nicocha30/gvisor-ligolo/pkg/sentry/arch" 22 rpb "github.com/nicocha30/gvisor-ligolo/pkg/sentry/arch/registers_go_proto" 23 "github.com/nicocha30/gvisor-ligolo/pkg/sentry/strace" 24 ) 25 26 const ( 27 // reportLimit is the max number of events that should be reported per 28 // tracker. 29 reportLimit = 100 30 syscallLink = "https://gvisor.dev/c/linux/arm64" 31 ) 32 33 // newRegs create a empty Registers instance. 34 func newRegs() *rpb.Registers { 35 return &rpb.Registers{ 36 Arch: &rpb.Registers_Arm64{ 37 Arm64: &rpb.ARM64Registers{}, 38 }, 39 } 40 } 41 42 func argVal(argIdx int, regs *rpb.Registers) uint64 { 43 arm64Regs := regs.GetArch().(*rpb.Registers_Arm64).Arm64 44 45 switch argIdx { 46 case 0: 47 return arm64Regs.R0 48 case 1: 49 return arm64Regs.R1 50 case 2: 51 return arm64Regs.R2 52 case 3: 53 return arm64Regs.R3 54 case 4: 55 return arm64Regs.R4 56 case 5: 57 return arm64Regs.R5 58 } 59 panic(fmt.Sprintf("invalid syscall argument index %d", argIdx)) 60 } 61 62 func setArgVal(argIdx int, argVal uint64, regs *rpb.Registers) { 63 arm64Regs := regs.GetArch().(*rpb.Registers_Arm64).Arm64 64 65 switch argIdx { 66 case 0: 67 arm64Regs.R0 = argVal 68 case 1: 69 arm64Regs.R1 = argVal 70 case 2: 71 arm64Regs.R2 = argVal 72 case 3: 73 arm64Regs.R3 = argVal 74 case 4: 75 arm64Regs.R4 = argVal 76 case 5: 77 arm64Regs.R5 = argVal 78 default: 79 panic(fmt.Sprintf("invalid syscall argument index %d", argIdx)) 80 } 81 } 82 83 func getSyscallNameMap() (strace.SyscallMap, bool) { 84 return strace.Lookup(abi.Linux, arch.ARM64) 85 } 86 87 func syscallNum(regs *rpb.Registers) uint64 { 88 arm64Regs := regs.GetArch().(*rpb.Registers_Arm64).Arm64 89 return arm64Regs.R8 90 } 91 92 func newArchArgsTracker(sysnr uint64) syscallTracker { 93 // currently, no arch specific syscalls need to be handled here. 94 return nil 95 }