1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

Kernel: Use the GS segment for the per-CPU struct

Right now we're using the FS segment for our per-CPU struct. On x86_64
there's an instruction to switch between a kernel and usermode GS
segment (swapgs) which we could use.

This patch doesn't update the rest of the code to use swapgs but it
prepares for that by using the GS segment instead of the FS segment.
This commit is contained in:
Gunnar Beutner 2021-07-02 14:02:36 +02:00 committed by Andreas Kling
parent 42d197cde7
commit 52f9aaa823
8 changed files with 36 additions and 36 deletions

View file

@ -62,25 +62,25 @@ ALWAYS_INLINE u16 get_gs()
}
#endif
ALWAYS_INLINE u32 read_fs_u32(u32 offset)
ALWAYS_INLINE u32 read_gs_u32(u32 offset)
{
u32 val;
asm volatile(
"movl %%fs:%a[off], %k[val]"
"movl %%gs:%a[off], %k[val]"
: [val] "=r"(val)
: [off] "ir"(offset));
return val;
}
ALWAYS_INLINE FlatPtr read_fs_ptr(u32 offset)
ALWAYS_INLINE FlatPtr read_gs_ptr(u32 offset)
{
return read_fs_u32(offset);
return read_gs_u32(offset);
}
ALWAYS_INLINE void write_fs_u32(u32 offset, u32 val)
ALWAYS_INLINE void write_gs_u32(u32 offset, u32 val)
{
asm volatile(
"movl %k[val], %%fs:%a[off]" ::[off] "ir"(offset), [val] "ir"(val)
"movl %k[val], %%gs:%a[off]" ::[off] "ir"(offset), [val] "ir"(val)
: "memory");
}