github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/abi/linux/ptrace_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  //go:build arm64
    16  // +build arm64
    17  
    18  package linux
    19  
    20  const (
    21  	//PSR bits
    22  	PSR_MODE_EL0t = 0x00000000
    23  	PSR_MODE_EL1t = 0x00000004
    24  	PSR_MODE_EL1h = 0x00000005
    25  	PSR_MODE_EL2t = 0x00000008
    26  	PSR_MODE_EL2h = 0x00000009
    27  	PSR_MODE_EL3t = 0x0000000c
    28  	PSR_MODE_EL3h = 0x0000000d
    29  	PSR_MODE_MASK = 0x0000000f
    30  
    31  	// AArch32 CPSR bits
    32  	PSR_MODE32_BIT = 0x00000010
    33  
    34  	// AArch64 SPSR bits
    35  	PSR_F_BIT      = 0x00000040
    36  	PSR_I_BIT      = 0x00000080
    37  	PSR_A_BIT      = 0x00000100
    38  	PSR_D_BIT      = 0x00000200
    39  	PSR_BTYPE_MASK = 0x00000c00
    40  	PSR_SSBS_BIT   = 0x00001000
    41  	PSR_PAN_BIT    = 0x00400000
    42  	PSR_UAO_BIT    = 0x00800000
    43  	PSR_DIT_BIT    = 0x01000000
    44  	PSR_TCO_BIT    = 0x02000000
    45  	PSR_V_BIT      = 0x10000000
    46  	PSR_C_BIT      = 0x20000000
    47  	PSR_Z_BIT      = 0x40000000
    48  	PSR_N_BIT      = 0x80000000
    49  )
    50  
    51  // PtraceRegs is the set of CPU registers exposed by ptrace. Source:
    52  // syscall.PtraceRegs.
    53  //
    54  // +marshal
    55  // +stateify savable
    56  type PtraceRegs struct {
    57  	Regs   [31]uint64
    58  	Sp     uint64
    59  	Pc     uint64
    60  	Pstate uint64
    61  }
    62  
    63  // InstructionPointer returns the address of the next instruction to be
    64  // executed.
    65  func (p *PtraceRegs) InstructionPointer() uint64 {
    66  	return p.Pc
    67  }
    68  
    69  // StackPointer returns the address of the Stack pointer.
    70  func (p *PtraceRegs) StackPointer() uint64 {
    71  	return p.Sp
    72  }
    73  
    74  // SetStackPointer sets the stack pointer to the specified value.
    75  func (p *PtraceRegs) SetStackPointer(sp uint64) {
    76  	p.Sp = sp
    77  }