Skip to content

Commit 41ef75c

Browse files
vegardingomolnar
authored andcommitted
x86/asm: Replace magic numbers in GDT descriptors, preparations
We'd like to replace all the magic numbers in various GDT descriptors with new, semantically meaningful, symbolic values. In order to be able to verify that the change doesn't cause any actual changes to the compiled binary code, I've split the change into two patches: - Part 1 (this commit): everything _but_ actually replacing the numbers - Part 2 (the following commit): _only_ replacing the numbers The reason we need this split for verification is that including new headers causes some spurious changes to the object files, mostly line number changes in the debug info but occasionally other subtle codegen changes. Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20231219151200.2878271-3-vegard.nossum@oracle.com
1 parent 016919c commit 41ef75c

5 files changed

Lines changed: 5 additions & 8 deletions

File tree

arch/x86/boot/pm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include "boot.h"
14+
#include <asm/desc_defs.h>
1415
#include <asm/segment.h>
1516

1617
/*

arch/x86/include/asm/desc_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct gate_struct {
144144

145145
typedef struct gate_struct gate_desc;
146146

147+
#ifndef _SETUP
147148
static inline unsigned long gate_offset(const gate_desc *g)
148149
{
149150
#ifdef CONFIG_X86_64
@@ -158,6 +159,7 @@ static inline unsigned long gate_segment(const gate_desc *g)
158159
{
159160
return g->segment;
160161
}
162+
#endif
161163

162164
struct desc_ptr {
163165
unsigned short size;

arch/x86/kernel/cpu/common.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,17 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
204204
* They code segments and data segments have fixed 64k limits,
205205
* the transfer segment sizes are set at run time.
206206
*/
207-
/* 32-bit code */
208207
[GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
209-
/* 16-bit code */
210208
[GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
211-
/* 16-bit data */
212209
[GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
213-
/* 16-bit data */
214210
[GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
215-
/* 16-bit data */
216211
[GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
217212
/*
218213
* The APM segments have byte granularity and their bases
219214
* are set at run time. All have 64k limits.
220215
*/
221-
/* 32-bit code */
222216
[GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
223-
/* 16-bit code */
224217
[GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
225-
/* data */
226218
[GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
227219

228220
[GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),

arch/x86/platform/pvh/head.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/elfnote.h>
1212
#include <linux/init.h>
1313
#include <linux/linkage.h>
14+
#include <asm/desc_defs.h>
1415
#include <asm/segment.h>
1516
#include <asm/asm.h>
1617
#include <asm/boot.h>

arch/x86/realmode/rm/reboot.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#include <linux/linkage.h>
3+
#include <asm/desc_defs.h>
34
#include <asm/segment.h>
45
#include <asm/page_types.h>
56
#include <asm/processor-flags.h>

0 commit comments

Comments
 (0)