Skip to content

Commit ae53fa1

Browse files
H. Peter Anvin (Intel)Ingo Molnar
authored andcommitted
x86/gsseg: Move load_gs_index() to its own new header file
GS is a special segment on x86_64, move load_gs_index() to its own new header file to simplify header inclusion. No change in functionality. Signed-off-by: H. Peter Anvin (Intel) <[email protected]> Signed-off-by: Xin Li <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent df729fb commit ae53fa1

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

arch/x86/include/asm/gsseg.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _ASM_X86_GSSEG_H
3+
#define _ASM_X86_GSSEG_H
4+
5+
#include <linux/types.h>
6+
7+
#include <asm/asm.h>
8+
#include <asm/cpufeature.h>
9+
#include <asm/alternative.h>
10+
#include <asm/processor.h>
11+
#include <asm/nops.h>
12+
13+
#ifdef CONFIG_X86_64
14+
15+
extern asmlinkage void asm_load_gs_index(u16 selector);
16+
17+
static inline void native_load_gs_index(unsigned int selector)
18+
{
19+
unsigned long flags;
20+
21+
local_irq_save(flags);
22+
asm_load_gs_index(selector);
23+
local_irq_restore(flags);
24+
}
25+
26+
#endif /* CONFIG_X86_64 */
27+
28+
#ifndef CONFIG_PARAVIRT_XXL
29+
30+
static inline void load_gs_index(unsigned int selector)
31+
{
32+
#ifdef CONFIG_X86_64
33+
native_load_gs_index(selector);
34+
#else
35+
loadsegment(gs, selector);
36+
#endif
37+
}
38+
39+
#endif /* CONFIG_PARAVIRT_XXL */
40+
41+
#endif /* _ASM_X86_GSSEG_H */

arch/x86/include/asm/mmu_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/tlbflush.h>
1313
#include <asm/paravirt.h>
1414
#include <asm/debugreg.h>
15+
#include <asm/gsseg.h>
1516

1617
extern atomic64_t last_mm_ctx_id;
1718

arch/x86/include/asm/special_insns.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,6 @@ static inline void native_wbinvd(void)
120120
asm volatile("wbinvd": : :"memory");
121121
}
122122

123-
extern asmlinkage void asm_load_gs_index(u16 selector);
124-
125-
static inline void native_load_gs_index(unsigned int selector)
126-
{
127-
unsigned long flags;
128-
129-
local_irq_save(flags);
130-
asm_load_gs_index(selector);
131-
local_irq_restore(flags);
132-
}
133-
134123
static inline unsigned long __read_cr4(void)
135124
{
136125
return native_read_cr4();
@@ -184,16 +173,6 @@ static inline void wbinvd(void)
184173
native_wbinvd();
185174
}
186175

187-
188-
static inline void load_gs_index(unsigned int selector)
189-
{
190-
#ifdef CONFIG_X86_64
191-
native_load_gs_index(selector);
192-
#else
193-
loadsegment(gs, selector);
194-
#endif
195-
}
196-
197176
#endif /* CONFIG_PARAVIRT_XXL */
198177

199178
static inline void clflush(volatile void *__p)

arch/x86/kernel/paravirt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <asm/special_insns.h>
3333
#include <asm/tlb.h>
3434
#include <asm/io_bitmap.h>
35+
#include <asm/gsseg.h>
3536

3637
/*
3738
* nop stub, which must not clobber anything *including the stack* to

arch/x86/kernel/signal_32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <asm/sigframe.h>
3232
#include <asm/sighandling.h>
3333
#include <asm/smap.h>
34+
#include <asm/gsseg.h>
3435

3536
#ifdef CONFIG_IA32_EMULATION
3637
#include <asm/ia32_unistd.h>

arch/x86/kernel/tls.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/ldt.h>
1313
#include <asm/processor.h>
1414
#include <asm/proto.h>
15+
#include <asm/gsseg.h>
1516

1617
#include "tls.h"
1718

0 commit comments

Comments
 (0)