gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/platform/ptrace/ptrace_amd64.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 amd64 16 // +build amd64 17 18 package ptrace 19 20 import ( 21 "gvisor.dev/gvisor/pkg/abi/linux" 22 pkgcontext "gvisor.dev/gvisor/pkg/context" 23 "gvisor.dev/gvisor/pkg/cpuid" 24 "gvisor.dev/gvisor/pkg/sentry/arch" 25 ) 26 27 // archContext is architecture-specific context. 28 type archContext struct { 29 // fpLen is the size of the floating point state. 30 fpLen int 31 32 // useXsave indicates whether or not xsave is in use. 33 useXsave bool 34 } 35 36 // init initializes the archContext. 37 func (a *archContext) init(ctx pkgcontext.Context) { 38 fs := cpuid.FromContext(ctx) 39 fpLen, _ := fs.ExtendedStateSize() 40 useXsave := fs.UseXsave() 41 a.fpLen = int(fpLen) 42 a.useXsave = useXsave 43 } 44 45 // floatingPointLength returns the length of floating point state. 46 func (a *archContext) floatingPointLength() uint64 { 47 return uint64(a.fpLen) 48 } 49 50 // floatingPointRegSet returns the register set to fetch. 51 func (a *archContext) floatingPointRegSet() uintptr { 52 if a.useXsave { 53 return linux.NT_X86_XSTATE 54 } 55 return linux.NT_PRFPREG 56 } 57 58 func stackPointer(r *arch.Registers) uintptr { 59 return uintptr(r.Rsp) 60 } 61 62 // x86 use the fs_base register to store the TLS pointer which can be 63 // get/set in "func (t *thread) get/setRegs(regs *arch.Registers)". 64 // So both of the get/setTLS() operations are noop here. 65 66 // getTLS gets the thread local storage register. 67 func (t *thread) getTLS(tls *uint64) error { 68 return nil 69 } 70 71 // setTLS sets the thread local storage register. 72 func (t *thread) setTLS(tls *uint64) error { 73 return nil 74 }