Skip to content

Commit db18da7

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/idt: Deinline setup functions
None of this is performance sensitive in any way - so debloat the kernel. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 485fa57 commit db18da7

File tree

2 files changed

+36
-44
lines changed

2 files changed

+36
-44
lines changed

arch/x86/include/asm/desc.h

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -390,44 +390,11 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
390390
desc->limit1 = (limit >> 16) & 0xf;
391391
}
392392

393-
static inline void _set_gate(int gate, unsigned type, const void *addr,
394-
unsigned dpl, unsigned ist, unsigned seg)
395-
{
396-
gate_desc s;
397-
398-
pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg);
399-
/*
400-
* does not need to be atomic because it is only done once at
401-
* setup time
402-
*/
403-
write_idt_entry(idt_table, gate, &s);
404-
}
405-
406-
static inline void set_intr_gate(unsigned int n, const void *addr)
407-
{
408-
BUG_ON(n > 0xFF);
409-
_set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
410-
}
393+
void set_intr_gate(unsigned int n, const void *addr);
394+
void alloc_intr_gate(unsigned int n, const void *addr);
411395

412396
extern unsigned long used_vectors[];
413397

414-
static inline void alloc_system_vector(int vector)
415-
{
416-
BUG_ON(vector < FIRST_SYSTEM_VECTOR);
417-
if (!test_bit(vector, used_vectors)) {
418-
set_bit(vector, used_vectors);
419-
} else {
420-
BUG();
421-
}
422-
}
423-
424-
#define alloc_intr_gate(n, addr) \
425-
do { \
426-
alloc_system_vector(n); \
427-
set_intr_gate(n, addr); \
428-
} while (0)
429-
430-
431398
#ifdef CONFIG_X86_64
432399
DECLARE_PER_CPU(u32, debug_idt_ctr);
433400
static inline bool is_debug_idt_enabled(void)

arch/x86/kernel/idt.c

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,16 @@ static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d)
212212
#endif
213213
}
214214

215-
static __init void
216-
idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size)
215+
static void
216+
idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys)
217217
{
218218
gate_desc desc;
219219

220220
for (; size > 0; t++, size--) {
221221
idt_init_desc(&desc, t);
222-
set_bit(t->vector, used_vectors);
223222
write_idt_entry(idt, t->vector, &desc);
223+
if (sys)
224+
set_bit(t->vector, used_vectors);
224225
}
225226
}
226227

@@ -233,7 +234,8 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size)
233234
*/
234235
void __init idt_setup_early_traps(void)
235236
{
236-
idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts));
237+
idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts),
238+
true);
237239
load_idt(&idt_descr);
238240
}
239241

@@ -242,7 +244,7 @@ void __init idt_setup_early_traps(void)
242244
*/
243245
void __init idt_setup_traps(void)
244246
{
245-
idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts));
247+
idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true);
246248
}
247249

248250
#ifdef CONFIG_X86_64
@@ -259,15 +261,15 @@ void __init idt_setup_traps(void)
259261
void __init idt_setup_early_pf(void)
260262
{
261263
idt_setup_from_table(idt_table, early_pf_idts,
262-
ARRAY_SIZE(early_pf_idts));
264+
ARRAY_SIZE(early_pf_idts), true);
263265
}
264266

265267
/**
266268
* idt_setup_ist_traps - Initialize the idt table with traps using IST
267269
*/
268270
void __init idt_setup_ist_traps(void)
269271
{
270-
idt_setup_from_table(idt_table, ist_idts, ARRAY_SIZE(ist_idts));
272+
idt_setup_from_table(idt_table, ist_idts, ARRAY_SIZE(ist_idts), true);
271273
}
272274

273275
/**
@@ -277,7 +279,7 @@ void __init idt_setup_debugidt_traps(void)
277279
{
278280
memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16);
279281

280-
idt_setup_from_table(debug_idt_table, dbg_idts, ARRAY_SIZE(dbg_idts));
282+
idt_setup_from_table(debug_idt_table, dbg_idts, ARRAY_SIZE(dbg_idts), false);
281283
}
282284
#endif
283285

@@ -289,7 +291,7 @@ void __init idt_setup_apic_and_irq_gates(void)
289291
int i = FIRST_EXTERNAL_VECTOR;
290292
void *entry;
291293

292-
idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts));
294+
idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
293295

294296
for_each_clear_bit_from(i, used_vectors, FIRST_SYSTEM_VECTOR) {
295297
entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
@@ -333,3 +335,26 @@ void idt_invalidate(void *addr)
333335

334336
load_idt(&idt);
335337
}
338+
339+
void set_intr_gate(unsigned int n, const void *addr)
340+
{
341+
struct idt_data data;
342+
343+
BUG_ON(n > 0xFF);
344+
345+
memset(&data, 0, sizeof(data));
346+
data.vector = n;
347+
data.addr = addr;
348+
data.segment = __KERNEL_CS;
349+
data.bits.type = GATE_INTERRUPT;
350+
data.bits.p = 1;
351+
352+
idt_setup_from_table(idt_table, &data, 1, false);
353+
}
354+
355+
void alloc_intr_gate(unsigned int n, const void *addr)
356+
{
357+
BUG_ON(test_bit(n, used_vectors) || n < FIRST_SYSTEM_VECTOR);
358+
set_bit(n, used_vectors);
359+
set_intr_gate(n, addr);
360+
}

0 commit comments

Comments
 (0)