Skip to content

Commit 09b379d

Browse files
committed
kernel: declare non-global functions as static
Fixes `-Wmissing-prototypes` warnings on recent kernel builds.
1 parent cae67b6 commit 09b379d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

kernel/sgxstep.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ static uint32_t g_apic_lvtt_copy = 0x0, g_apic_tdcr_copy = 0x0;
6969
* NOTE: Linux's default `write_cr0/4` do not allow to change protected bits,
7070
* so we include our own here (must be called with interrupts off).
7171
*/
72-
inline void do_write_cr0(unsigned long val)
72+
static inline void do_write_cr0(unsigned long val)
7373
{
7474
asm volatile("mov %0, %%cr0" : : "r"(val));
7575
}
7676

77-
inline void do_write_cr4(unsigned long val)
77+
static inline void do_write_cr4(unsigned long val)
7878
{
7979
asm volatile("mov %0, %%cr4" : : "r"(val));
8080
}
@@ -84,7 +84,7 @@ inline void do_write_cr4(unsigned long val)
8484
*
8585
* NOTE: CR0.WP must be set before software can set CR4.CET
8686
*/
87-
void enable_write_protection(void)
87+
static void enable_write_protection(void)
8888
{
8989
unsigned long cr0, cr4;
9090

@@ -102,7 +102,7 @@ void enable_write_protection(void)
102102
*
103103
* NOTE: CR0.WP cannot be cleared as long as CR4.CET = 1
104104
*/
105-
void disable_write_protection(void)
105+
static void disable_write_protection(void)
106106
{
107107
unsigned long cr0, cr4;
108108

@@ -125,7 +125,7 @@ void disable_write_protection(void)
125125
* Copy original interrupt descriptor table (IDT) -- may be modified by
126126
* libsgxstep; will be auto restored when closing /dev/sgx-step.
127127
*/
128-
int save_idt(void)
128+
static int save_idt(void)
129129
{
130130
asm volatile ("sidt %0\n\t"
131131
:"=m"(g_idtr) :: );
@@ -143,7 +143,7 @@ int save_idt(void)
143143
* Save APIC timer configuration registers that may be modified by libsgxstep;
144144
* will be auto restored when closing /dev/sgx-step.
145145
*/
146-
int save_apic(void)
146+
static int save_apic(void)
147147
{
148148
g_apic_lvtt_copy = apic->read(APIC_LVTT);
149149
g_apic_tdcr_copy = apic->read(APIC_TDCR);
@@ -152,7 +152,7 @@ int save_apic(void)
152152
return 0;
153153
}
154154

155-
int step_open(struct inode *inode, struct file *file)
155+
static int step_open(struct inode *inode, struct file *file)
156156
{
157157
if (g_in_use)
158158
{
@@ -176,7 +176,7 @@ int step_open(struct inode *inode, struct file *file)
176176
* NOTE: the IDT virtual memory page is mapped write-protected by Linux, so we
177177
* have to disable CR0.WP temporarily here.
178178
*/
179-
void restore_idt(void)
179+
static void restore_idt(void)
180180
{
181181
unsigned long flags;
182182

@@ -202,7 +202,7 @@ void restore_idt(void)
202202
}
203203
}
204204

205-
void restore_apic(void)
205+
static void restore_apic(void)
206206
{
207207
int delta = 100;
208208

@@ -232,7 +232,7 @@ void restore_apic(void)
232232
* modifications made by user-space libsgxstep here to their original values,
233233
* such that everything runs again normally and Linux does not panic.
234234
*/
235-
int step_release(struct inode *inode, struct file *file)
235+
static int step_release(struct inode *inode, struct file *file)
236236
{
237237
restore_idt();
238238
restore_apic();
@@ -245,7 +245,7 @@ int step_release(struct inode *inode, struct file *file)
245245

246246
/* Convenience function when editing PTEs from user space (but normally not
247247
* needed, since SGX already flushes the TLB on enclave entry/exit) */
248-
long sgx_step_ioctl_invpg(struct file *filep, unsigned int cmd, unsigned long arg)
248+
static long sgx_step_ioctl_invpg(struct file *filep, unsigned int cmd, unsigned long arg)
249249
{
250250
uint64_t addr = ((invpg_t *) arg)->adrs;
251251

@@ -254,7 +254,7 @@ long sgx_step_ioctl_invpg(struct file *filep, unsigned int cmd, unsigned long ar
254254
return 0;
255255
}
256256

257-
long sgx_step_get_pt_mapping(struct file *filep, unsigned int cmd, unsigned long arg)
257+
static long sgx_step_get_pt_mapping(struct file *filep, unsigned int cmd, unsigned long arg)
258258
{
259259
address_mapping_t *map = (address_mapping_t*) arg;
260260
pgd_t *pgd = NULL;
@@ -314,7 +314,7 @@ long sgx_step_get_pt_mapping(struct file *filep, unsigned int cmd, unsigned long
314314
return 0;
315315
}
316316

317-
long sgx_step_ioctl_setup_isr_map(struct file *filep, unsigned int cmd, unsigned long arg)
317+
static long sgx_step_ioctl_setup_isr_map(struct file *filep, unsigned int cmd, unsigned long arg)
318318
{
319319
uint64_t nr_pinned_pages;
320320
setup_isr_map_t *data = (setup_isr_map_t*) arg;
@@ -354,7 +354,7 @@ long sgx_step_ioctl_setup_isr_map(struct file *filep, unsigned int cmd, unsigned
354354

355355
typedef long (*ioctl_t)(struct file *filep, unsigned int cmd, unsigned long arg);
356356

357-
long step_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
357+
static long step_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
358358
{
359359
char data[256];
360360
ioctl_t handler = NULL;

0 commit comments

Comments
 (0)