gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/platform/systrap/sysmsg/sysmsg_offsets.h (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 #ifndef THIRD_PARTY_GVISOR_PKG_SENTRY_PLATFORM_SYSTRAP_SYSMSG_SYSMSG_OFFSETS_H_ 16 #define THIRD_PARTY_GVISOR_PKG_SENTRY_PLATFORM_SYSTRAP_SYSMSG_SYSMSG_OFFSETS_H_ 17 18 // FAULT_OPCODE is the opcode of the invalid instruction that is used to replace 19 // the first byte of the syscall instruction. More details in the description 20 // for the pkg/sentry/platform/systrap/usertrap package. 21 #define FAULT_OPCODE 0x06 22 23 // The value for XCR0 is defined to xsave/xrstor everything except for PKRU and 24 // AMX regions. 25 // TODO(gvisor.dev/issues/9896): Implement AMX support. 26 // TODO(gvisor.dev/issues/10087): Implement PKRU support. 27 #define XCR0_DISABLED_MASK ((1 << 9) | (1 << 17) | (1 << 18)) 28 #define XCR0_EAX (0xffffffff ^ XCR0_DISABLED_MASK) 29 #define XCR0_EDX 0xffffffff 30 31 // LINT.IfChange 32 #define MAX_FPSTATE_LEN 3584 33 // Note: To be explicit, 2^12 = 4096; if ALLOCATED_SIZEOF_THREAD_CONTEXT_STRUCT 34 // is changed, make sure to change the code that relies on the bitshift. 35 #define ALLOCATED_SIZEOF_THREAD_CONTEXT_STRUCT 4096 36 #define THREAD_CONTEXT_STRUCT_BITSHIFT 12 37 // LINT.ThenChange(sysmsg.go) 38 39 // LINT.IfChange 40 41 // Define offsets in the struct sysmsg to use them in assembly files. 42 // Each offset has to have BUILD_BUG_ON in sighandler.c. 43 #define offsetof_sysmsg_self 0x0 44 #define offsetof_sysmsg_ret_addr 0x8 45 #define offsetof_sysmsg_syshandler 0x10 46 #define offsetof_sysmsg_syshandler_stack 0x18 47 #define offsetof_sysmsg_app_stack 0x20 48 #define offsetof_sysmsg_interrupt 0x28 49 #define offsetof_sysmsg_state 0x2c 50 #define offsetof_sysmsg_context 0x30 51 52 #define offsetof_thread_context_fpstate 0x0 53 #define offsetof_thread_context_fpstate_changed MAX_FPSTATE_LEN 54 #define offsetof_thread_context_ptregs 0x8 + MAX_FPSTATE_LEN 55 56 #define kTHREAD_STATE_NONE 0 57 #define kTHREAD_STATE_INTERRUPT 3 58 59 // LINT.ThenChange(sysmsg.h, sysmsg_lib.c) 60 61 #endif // THIRD_PARTY_GVISOR_PKG_SENTRY_PLATFORM_SYSTRAP_SYSMSG_SYSMSG_OFFSETS_H_