github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/sentry/platform/systrap/usertrap/usertrap_arm64.go (about)

     1  // Copyright 2020 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 usertrap
    19  
    20  import (
    21  	"github.com/nicocha30/gvisor-ligolo/pkg/context"
    22  	"github.com/nicocha30/gvisor-ligolo/pkg/hostarch"
    23  	"github.com/nicocha30/gvisor-ligolo/pkg/sentry/arch"
    24  	"github.com/nicocha30/gvisor-ligolo/pkg/sentry/memmap"
    25  	"github.com/nicocha30/gvisor-ligolo/pkg/usermem"
    26  )
    27  
    28  // trapNR is the maximum number of traps what can fit in the trap table.
    29  const trapNR = 256
    30  
    31  // trapSize is the size of one trap.
    32  const trapSize = 80
    33  
    34  // TrapTableSize returns the maximum size of a trap table.
    35  func TrapTableSize() uintptr {
    36  	return uintptr(trapNR * trapSize)
    37  }
    38  
    39  type memoryManager interface {
    40  	usermem.IO
    41  	MMap(ctx context.Context, opts memmap.MMapOpts) (hostarch.Addr, error)
    42  }
    43  
    44  // State represents the current state of the trap table.
    45  //
    46  // +stateify savable
    47  type State struct {
    48  }
    49  
    50  // New returns the new state structure.
    51  func New() *State {
    52  	return &State{}
    53  }
    54  
    55  func (*State) PatchSyscall(ctx context.Context, ac *arch.Context64, mm memoryManager) (restart bool, err error) {
    56  	return false /* restart */, nil
    57  }
    58  
    59  // HandleFault handles a fault on a patched syscall instruction.
    60  func (*State) HandleFault(ctx context.Context, ac *arch.Context64, mm memoryManager) error {
    61  	return nil
    62  }
    63  
    64  // PreFork does nothing on arm64 as syscall trapping is not supported.
    65  func (*State) PreFork() {
    66  }
    67  
    68  // PostFork does nothing on arm64 as syscall trapping is not supported.
    69  func (*State) PostFork() {
    70  }