github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/sentry/platform/ptrace/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  package ptrace
    16  
    17  import (
    18  	"github.com/metacubex/gvisor/pkg/abi/linux"
    19  	pkgcontext "github.com/metacubex/gvisor/pkg/context"
    20  	"github.com/metacubex/gvisor/pkg/cpuid"
    21  	"github.com/metacubex/gvisor/pkg/sentry/arch"
    22  )
    23  
    24  // archContext is architecture-specific context.
    25  type archContext struct {
    26  	// fpLen is the size of the floating point state.
    27  	fpLen int
    28  }
    29  
    30  // init initializes the archContext.
    31  func (a *archContext) init(ctx pkgcontext.Context) {
    32  	fs := cpuid.FromContext(ctx)
    33  	fpLen, _ := fs.ExtendedStateSize()
    34  	a.fpLen = int(fpLen)
    35  }
    36  
    37  // floatingPointLength returns the length of floating point state.
    38  func (a *archContext) floatingPointLength() uint64 {
    39  	return uint64(a.fpLen)
    40  }
    41  
    42  // floatingPointRegSet returns the register set to fetch.
    43  func (a *archContext) floatingPointRegSet() uintptr {
    44  	return linux.NT_PRFPREG
    45  }
    46  
    47  func stackPointer(r *arch.Registers) uintptr {
    48  	return uintptr(r.Sp)
    49  }