Skip to content

Commit

Permalink
x86/idt: Split idt_data setup out of set_intr_gate()
Browse files Browse the repository at this point in the history
The code to setup idt_data is needed for early exception handling, but
set_intr_gate() can't be used that early because it has pv-ops in its
code path which don't work that early.

Split out the idt_data initialization part from set_intr_gate() so
that it can be used separately.

Signed-off-by: Joerg Roedel <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
joergroedel authored and suryasaimadhu committed Sep 7, 2020
1 parent a7de15d commit 4bed226
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions arch/x86/kernel/idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,24 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sy
}
}

static void init_idt_data(struct idt_data *data, unsigned int n,
const void *addr)
{
BUG_ON(n > 0xFF);

memset(data, 0, sizeof(*data));
data->vector = n;
data->addr = addr;
data->segment = __KERNEL_CS;
data->bits.type = GATE_INTERRUPT;
data->bits.p = 1;
}

static __init void set_intr_gate(unsigned int n, const void *addr)
{
struct idt_data data;

BUG_ON(n > 0xFF);

memset(&data, 0, sizeof(data));
data.vector = n;
data.addr = addr;
data.segment = __KERNEL_CS;
data.bits.type = GATE_INTERRUPT;
data.bits.p = 1;
init_idt_data(&data, n, addr);

idt_setup_from_table(idt_table, &data, 1, false);
}
Expand Down

0 comments on commit 4bed226

Please sign in to comment.