Skip to content

Commit 0a7112a

Browse files
[LibOS] Change prefix from shim_ to libos_
This is the main part of the rename - changes prefix on everything in LibOS code. Signed-off-by: Borys Popławski <borysp@invisiblethingslab.com>
1 parent 7871759 commit 0a7112a

125 files changed

Lines changed: 2505 additions & 2491 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/devel/new-syscall.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ an actual syscall name. Additionally this function should return ``long``.
1616
Now you need to add an appropriate entry in the syscalls table in
1717
:file:`shim_table-$(ARCH).c`::
1818

19-
[__NR_sched_setaffinity] = (shim_fp)libos_syscall_sched_setaffinity
19+
[__NR_sched_setaffinity] = (libos_syscall_t)libos_syscall_sched_setaffinity
2020

2121
2. Implement system call
2222
------------------------

Documentation/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Table of Contents
106106
.. toctree::
107107
:caption: LibOS
108108

109-
libos/shim-init
109+
libos/libos-init
110110

111111
.. toctree::
112112
:caption: PAL
File renamed without changes.

common/include/callbacks.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
/*
55
* Defines a set of callbacks that the common library expects from environment it is linked into.
6-
* Currently, the common library expects `shim_`-prefixed callbacks from LibOS, `pal_`-prefixed
6+
* Currently, the common library expects `libos_`-prefixed callbacks from LibOS, `pal_`-prefixed
77
* callbacks from PAL, and not-prefixed callbacks from all other environments (e.g., PAL regression
88
* tests and non-Gramine programs). This header aliases the actual callback implementations, i.e.,
9-
* `shim_abort()` is aliased as `abort()` for use by the common library.
9+
* `libos_abort()` is aliased as `abort()` for use by the common library.
1010
*
1111
* Strictly speaking, current Gramine doesn't need different callback names for LibOS, PAL and
1212
* other environments. We introduce this notation for the future change where LibOS and PAL will be
@@ -23,11 +23,11 @@
2323
#include <stdint.h>
2424
#include <stdnoreturn.h>
2525

26-
#ifdef IN_SHIM
26+
#ifdef IN_LIBOS
2727

28-
#define _log shim_log
29-
#define abort shim_abort
30-
#define describe_location shim_describe_location
28+
#define _log libos_log
29+
#define abort libos_abort
30+
#define describe_location libos_describe_location
3131

3232
#elif IN_PAL
3333

common/include/spinlock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
#define DEBUG_SPINLOCKS
1515
#endif // DEBUG
1616

17-
#ifdef IN_SHIM
17+
#ifdef IN_LIBOS
1818
/* Forward declare, so this header stays standalone. */
1919
static inline unsigned int get_cur_tid(void);
2020

2121
#ifdef DEBUG_SPINLOCKS
22-
#define DEBUG_SPINLOCKS_SHIM
22+
#define DEBUG_SPINLOCKS_LIBOS
2323
#endif // DEBUG_SPINLOCKS
2424

25-
#endif // IN_SHIM
25+
#endif // IN_LIBOS
2626

2727
typedef struct {
2828
uint32_t lock;
29-
#ifdef DEBUG_SPINLOCKS_SHIM
29+
#ifdef DEBUG_SPINLOCKS_LIBOS
3030
unsigned int owner;
31-
#endif // DEBUG_SPINLOCKS_SHIM
31+
#endif // DEBUG_SPINLOCKS_LIBOS
3232
} spinlock_t;
3333

3434
/* The below macros are only needed for our own futex implementation (based on Futexes are Tricky)
@@ -51,7 +51,7 @@ typedef struct {
5151
*/
5252
#define INIT_SPINLOCK_UNLOCKED { .lock = SPINLOCK_UNLOCKED }
5353

54-
#ifdef DEBUG_SPINLOCKS_SHIM
54+
#ifdef DEBUG_SPINLOCKS_LIBOS
5555
static inline void debug_spinlock_take_ownership(spinlock_t* lock) {
5656
__atomic_store_n(&lock->owner, get_cur_tid(), __ATOMIC_RELAXED);
5757
}
@@ -67,7 +67,7 @@ static inline void debug_spinlock_take_ownership(spinlock_t* lock) {
6767
static inline void debug_spinlock_giveup_ownership(spinlock_t* lock) {
6868
__UNUSED(lock);
6969
}
70-
#endif // DEBUG_SPINLOCKS_SHIM
70+
#endif // DEBUG_SPINLOCKS_LIBOS
7171

7272

7373
/*!
@@ -166,7 +166,7 @@ static inline bool _spinlock_is_locked(spinlock_t* lock) {
166166
return __atomic_load_n(&lock->lock, __ATOMIC_SEQ_CST) != SPINLOCK_UNLOCKED;
167167
}
168168

169-
#ifdef DEBUG_SPINLOCKS_SHIM
169+
#ifdef DEBUG_SPINLOCKS_LIBOS
170170
static inline bool spinlock_is_locked(spinlock_t* lock) {
171171
if (!_spinlock_is_locked(lock)) {
172172
return false;
@@ -182,6 +182,6 @@ static inline bool spinlock_is_locked(spinlock_t* lock) {
182182
static inline bool spinlock_is_locked(spinlock_t* lock) {
183183
return _spinlock_is_locked(lock);
184184
}
185-
#endif // DEBUG_SPINLOCKS_SHIM
185+
#endif // DEBUG_SPINLOCKS_LIBOS
186186

187187
#endif // DEBUG_SPINLOCKS

libos/include/arch/x86_64/shim_internal-arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
#pragma once
44

5-
#define SHIM_ELF_HOST_MACHINE EM_X86_64
5+
#define LIBOS_ELF_HOST_MACHINE EM_X86_64

libos/include/arch/x86_64/shim_tcb-arch.h

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@
55
#include "pal.h"
66

77
/* adopt Linux x86-64 structs for FP layout: self-contained definition is needed for LibOS, so
8-
* define the exact same layout with `shim_` prefix; taken from
8+
* define the exact same layout with `libos_` prefix; taken from
99
* https://elixir.bootlin.com/linux/v5.9/source/arch/x86/include/uapi/asm/sigcontext.h */
10-
#define SHIM_FP_XSTATE_MAGIC1 0x46505853U
11-
#define SHIM_FP_XSTATE_MAGIC2 0x46505845U
12-
#define SHIM_FP_XSTATE_MAGIC2_SIZE (sizeof(SHIM_FP_XSTATE_MAGIC2))
13-
14-
#define SHIM_XSTATE_ALIGN 64
15-
16-
enum SHIM_XFEATURE {
17-
SHIM_XFEATURE_FP,
18-
SHIM_XFEATURE_SSE,
19-
SHIM_XFEATURE_YMM,
20-
SHIM_XFEATURE_BNDREGS,
21-
SHIM_XFEATURE_BNDCSR,
22-
SHIM_XFEATURE_OPMASK,
23-
SHIM_XFEATURE_ZMM_Hi256,
24-
SHIM_XFEATURE_Hi16_ZMM,
25-
SHIM_XFEATURE_PT,
26-
SHIM_XFEATURE_PKRU,
10+
#define LIBOS_FP_XSTATE_MAGIC1 0x46505853U
11+
#define LIBOS_FP_XSTATE_MAGIC2 0x46505845U
12+
#define LIBOS_FP_XSTATE_MAGIC2_SIZE (sizeof(LIBOS_FP_XSTATE_MAGIC2))
13+
14+
#define LIBOS_XSTATE_ALIGN 64
15+
16+
enum LIBOS_XFEATURE {
17+
LIBOS_XFEATURE_FP,
18+
LIBOS_XFEATURE_SSE,
19+
LIBOS_XFEATURE_YMM,
20+
LIBOS_XFEATURE_BNDREGS,
21+
LIBOS_XFEATURE_BNDCSR,
22+
LIBOS_XFEATURE_OPMASK,
23+
LIBOS_XFEATURE_ZMM_Hi256,
24+
LIBOS_XFEATURE_Hi16_ZMM,
25+
LIBOS_XFEATURE_PT,
26+
LIBOS_XFEATURE_PKRU,
2727
};
2828

29-
#define SHIM_XFEATURE_MASK_FP (1UL << SHIM_XFEATURE_FP)
30-
#define SHIM_XFEATURE_MASK_SSE (1UL << SHIM_XFEATURE_SSE)
31-
#define SHIM_XFEATURE_MASK_YMM (1UL << SHIM_XFEATURE_YMM)
32-
#define SHIM_XFEATURE_MASK_BNDREGS (1UL << SHIM_XFEATURE_BNDREGS)
33-
#define SHIM_XFEATURE_MASK_BNDCSR (1UL << SHIM_XFEATURE_BNDCSR)
34-
#define SHIM_XFEATURE_MASK_OPMASK (1UL << SHIM_XFEATURE_OPMASK)
35-
#define SHIM_XFEATURE_MASK_ZMM_Hi256 (1UL << SHIM_XFEATURE_ZMM_Hi256)
36-
#define SHIM_XFEATURE_MASK_Hi16_ZMM (1UL << SHIM_XFEATURE_Hi16_ZMM)
37-
#define SHIM_XFEATURE_MASK_PT (1UL << SHIM_XFEATURE_PT)
38-
#define SHIM_XFEATURE_MASK_PKRU (1UL << SHIM_XFEATURE_PKRU)
39-
40-
#define SHIM_XFEATURE_MASK_FPSSE (SHIM_XFEATURE_MASK_FP | SHIM_XFEATURE_MASK_SSE)
41-
#define SHIM_XFEATURE_MASK_AVX512 (SHIM_XFEATURE_MASK_OPMASK | SHIM_XFEATURE_MASK_ZMM_Hi256 \
42-
| SHIM_XFEATURE_MASK_Hi16_ZMM)
29+
#define LIBOS_XFEATURE_MASK_FP (1UL << LIBOS_XFEATURE_FP)
30+
#define LIBOS_XFEATURE_MASK_SSE (1UL << LIBOS_XFEATURE_SSE)
31+
#define LIBOS_XFEATURE_MASK_YMM (1UL << LIBOS_XFEATURE_YMM)
32+
#define LIBOS_XFEATURE_MASK_BNDREGS (1UL << LIBOS_XFEATURE_BNDREGS)
33+
#define LIBOS_XFEATURE_MASK_BNDCSR (1UL << LIBOS_XFEATURE_BNDCSR)
34+
#define LIBOS_XFEATURE_MASK_OPMASK (1UL << LIBOS_XFEATURE_OPMASK)
35+
#define LIBOS_XFEATURE_MASK_ZMM_Hi256 (1UL << LIBOS_XFEATURE_ZMM_Hi256)
36+
#define LIBOS_XFEATURE_MASK_Hi16_ZMM (1UL << LIBOS_XFEATURE_Hi16_ZMM)
37+
#define LIBOS_XFEATURE_MASK_PT (1UL << LIBOS_XFEATURE_PT)
38+
#define LIBOS_XFEATURE_MASK_PKRU (1UL << LIBOS_XFEATURE_PKRU)
39+
40+
#define LIBOS_XFEATURE_MASK_FPSSE (LIBOS_XFEATURE_MASK_FP | LIBOS_XFEATURE_MASK_SSE)
41+
#define LIBOS_XFEATURE_MASK_AVX512 (LIBOS_XFEATURE_MASK_OPMASK | LIBOS_XFEATURE_MASK_ZMM_Hi256 \
42+
| LIBOS_XFEATURE_MASK_Hi16_ZMM)
4343

4444
/* Bytes 464..511 in the 512B layout of the FXSAVE/FXRSTOR frame are reserved for SW usage. On
4545
* CPUs supporting XSAVE/XRSTOR, these bytes are used to extend the fpstate pointer in the
4646
* sigcontext, which includes the extended state information along with fpstate information. */
47-
struct shim_fpx_sw_bytes {
48-
uint32_t magic1; /*!< SHIM_FP_XSTATE_MAGIC1 (it is an xstate context) */
49-
uint32_t extended_size; /*!< g_shim_xsave_size + SHIM_FP_STATE_MAGIC2_SIZE */
47+
struct libos_fpx_sw_bytes {
48+
uint32_t magic1; /*!< LIBOS_FP_XSTATE_MAGIC1 (it is an xstate context) */
49+
uint32_t extended_size; /*!< g_libos_xsave_size + LIBOS_FP_STATE_MAGIC2_SIZE */
5050
uint64_t xfeatures; /*!< XSAVE features (feature bit mask, including FP/SSE/extended) */
51-
uint32_t xstate_size; /*!< g_shim_xsave_size (XSAVE area size as reported by CPUID) */
51+
uint32_t xstate_size; /*!< g_libos_xsave_size (XSAVE area size as reported by CPUID) */
5252
uint32_t padding[7]; /*!< for future use */
5353
};
5454

5555
/* 64-bit FPU frame (FXSAVE format, 512B total size) */
56-
struct shim_fpstate {
56+
struct libos_fpstate {
5757
uint16_t cwd;
5858
uint16_t swd;
5959
uint16_t twd;
@@ -67,76 +67,76 @@ struct shim_fpstate {
6767
uint32_t reserved2[12];
6868
union {
6969
uint32_t reserved3[12];
70-
struct shim_fpx_sw_bytes sw_reserved; /* potential extended state is encoded here */
70+
struct libos_fpx_sw_bytes sw_reserved; /* potential extended state is encoded here */
7171
};
7272
};
7373

74-
struct shim_xstate_header {
74+
struct libos_xstate_header {
7575
uint64_t xfeatures;
7676
uint64_t reserved1[2];
7777
uint64_t reserved2[5];
7878
};
7979

80-
struct shim_xstate {
81-
struct shim_fpstate fpstate; /* 512B legacy FXSAVE/FXRSTOR frame (FP and XMM regs) */
82-
struct shim_xstate_header xstate_hdr; /* 64B header for newer XSAVE/XRSTOR frame */
80+
struct libos_xstate {
81+
struct libos_fpstate fpstate; /* 512B legacy FXSAVE/FXRSTOR frame (FP and XMM regs) */
82+
struct libos_xstate_header xstate_hdr; /* 64B header for newer XSAVE/XRSTOR frame */
8383
/* rest is filled with extended regs (YMM, ZMM, ...) by HW + 4B of MAGIC2 value by SW */
84-
} __attribute__((aligned(SHIM_XSTATE_ALIGN)));
84+
} __attribute__((aligned(LIBOS_XSTATE_ALIGN)));
8585

86-
#define SHIM_TCB_GET(member) \
86+
#define LIBOS_TCB_GET(member) \
8787
({ \
88-
shim_tcb_t* tcb; \
88+
libos_tcb_t* tcb; \
8989
__typeof__(tcb->member) ret; \
9090
static_assert(sizeof(ret) == 8 || \
9191
sizeof(ret) == 4 || \
9292
sizeof(ret) == 2 || \
9393
sizeof(ret) == 1, \
94-
"SHIM_TCB_GET can be used only for " \
94+
"LIBOS_TCB_GET can be used only for " \
9595
"8, 4, 2, or 1-byte(s) members"); \
9696
__asm__("mov %%gs:%c1, %0\n" \
9797
: "=r"(ret) \
9898
: "i" (offsetof(PAL_TCB, libos_tcb) + \
99-
offsetof(shim_tcb_t, member)) \
99+
offsetof(libos_tcb_t, member)) \
100100
: "memory"); \
101101
ret; \
102102
})
103103

104-
#define SHIM_TCB_SET(member, value) \
104+
#define LIBOS_TCB_SET(member, value) \
105105
do { \
106-
shim_tcb_t* tcb; \
106+
libos_tcb_t* tcb; \
107107
static_assert(sizeof(tcb->member) == 8 || \
108108
sizeof(tcb->member) == 4 || \
109109
sizeof(tcb->member) == 2 || \
110110
sizeof(tcb->member) == 1, \
111-
"SHIM_TCB_SET can be used only for " \
111+
"LIBOS_TCB_SET can be used only for " \
112112
"8, 4, 2, or 1-byte(s) members"); \
113113
switch (sizeof(tcb->member)) { \
114114
case 8: \
115115
__asm__("movq %0, %%gs:%c1\n" \
116116
:: "ir"(value), \
117117
"i"(offsetof(PAL_TCB, libos_tcb) + \
118-
offsetof(shim_tcb_t, member)) \
118+
offsetof(libos_tcb_t, member)) \
119119
: "memory"); \
120120
break; \
121121
case 4: \
122122
__asm__("movl %0, %%gs:%c1\n" \
123123
:: "ir"(value), \
124124
"i"(offsetof(PAL_TCB, libos_tcb) + \
125-
offsetof(shim_tcb_t, member)) \
125+
offsetof(libos_tcb_t, member)) \
126126
: "memory"); \
127127
break; \
128128
case 2: \
129129
__asm__("movw %0, %%gs:%c1\n" \
130130
:: "ir"(value), \
131131
"i"(offsetof(PAL_TCB, libos_tcb) + \
132-
offsetof(shim_tcb_t, member)) \
132+
offsetof(libos_tcb_t, member)) \
133133
: "memory"); \
134134
break; \
135135
case 1: \
136136
__asm__("movb %0, %%gs:%c1\n" \
137137
:: "ir"(value), \
138138
"i"(offsetof(PAL_TCB, libos_tcb) + \
139-
offsetof(shim_tcb_t, member)) \
139+
offsetof(libos_tcb_t, member)) \
140140
: "memory"); \
141141
break; \
142142
} \

libos/include/generated-offsets.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
const char* generated_offsets_name = "LIBOS";
66

77
const struct generated_offset generated_offsets[] = {
8-
OFFSET_T(SHIM_TCB_OFF, PAL_TCB, libos_tcb),
9-
OFFSET_T(SHIM_TCB_LIBOS_STACK_OFF, shim_tcb_t, libos_stack_bottom),
10-
OFFSET_T(SHIM_TCB_SCRATCH_PC_OFF, shim_tcb_t, syscall_scratch_pc),
8+
OFFSET_T(LIBOS_TCB_OFF, PAL_TCB, libos_tcb),
9+
OFFSET_T(LIBOS_TCB_LIBOS_STACK_OFF, libos_tcb_t, libos_stack_bottom),
10+
OFFSET_T(LIBOS_TCB_SCRATCH_PC_OFF, libos_tcb_t, syscall_scratch_pc),
1111

1212
OFFSET_T(PAL_CONTEXT_FPREGS_OFF, struct PAL_CONTEXT, fpregs),
1313
OFFSET_T(PAL_CONTEXT_MXCSR_OFF, struct PAL_CONTEXT, mxcsr),
1414
OFFSET_T(PAL_CONTEXT_FPCW_OFF, struct PAL_CONTEXT, fpcw),
1515
OFFSET_T(PAL_CONTEXT_FPREGS_USED_OFF, struct PAL_CONTEXT, is_fpregs_used),
1616

17-
DEFINE(SHIM_XSTATE_ALIGN, SHIM_XSTATE_ALIGN),
17+
DEFINE(LIBOS_XSTATE_ALIGN, LIBOS_XSTATE_ALIGN),
1818
DEFINE(RED_ZONE_SIZE, RED_ZONE_SIZE),
1919

2020
OFFSET_END,

0 commit comments

Comments
 (0)