Skip to content

Commit

Permalink
x86/entry: Cleanup idtentry_enter/exit
Browse files Browse the repository at this point in the history
Remove the temporary defines and fixup all references.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20200722220520.855839271@linutronix.de
  • Loading branch information
Thomas Gleixner committed Jul 24, 2020
1 parent bdcd178 commit a27a0a5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 31 deletions.
6 changes: 3 additions & 3 deletions arch/x86/entry/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs)
{
struct pt_regs *old_regs;
bool inhcall;
idtentry_state_t state;
irqentry_state_t state;

state = idtentry_enter(regs);
state = irqentry_enter(regs);
old_regs = set_irq_regs(regs);

instrumentation_begin();
Expand All @@ -266,7 +266,7 @@ __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs)
instrumentation_end();
restore_inhcall(inhcall);
} else {
idtentry_exit(regs, state);
irqentry_exit(regs, state);
}
}
#endif /* CONFIG_XEN_PV */
33 changes: 14 additions & 19 deletions arch/x86/include/asm/idtentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

#include <asm/irq_stack.h>

/* Temporary defines */
typedef irqentry_state_t idtentry_state_t;
#define idtentry_enter irqentry_enter
#define idtentry_exit irqentry_exit

/**
* DECLARE_IDTENTRY - Declare functions for simple IDT entry points
* No error code pushed by hardware
Expand Down Expand Up @@ -45,21 +40,21 @@ typedef irqentry_state_t idtentry_state_t;
* The macro is written so it acts as function definition. Append the
* body with a pair of curly brackets.
*
* idtentry_enter() contains common code which has to be invoked before
* arbitrary code in the body. idtentry_exit() contains common code
* irqentry_enter() contains common code which has to be invoked before
* arbitrary code in the body. irqentry_exit() contains common code
* which has to run before returning to the low level assembly code.
*/
#define DEFINE_IDTENTRY(func) \
static __always_inline void __##func(struct pt_regs *regs); \
\
__visible noinstr void func(struct pt_regs *regs) \
{ \
idtentry_state_t state = idtentry_enter(regs); \
irqentry_state_t state = irqentry_enter(regs); \
\
instrumentation_begin(); \
__##func (regs); \
instrumentation_end(); \
idtentry_exit(regs, state); \
irqentry_exit(regs, state); \
} \
\
static __always_inline void __##func(struct pt_regs *regs)
Expand Down Expand Up @@ -101,12 +96,12 @@ static __always_inline void __##func(struct pt_regs *regs, \
__visible noinstr void func(struct pt_regs *regs, \
unsigned long error_code) \
{ \
idtentry_state_t state = idtentry_enter(regs); \
irqentry_state_t state = irqentry_enter(regs); \
\
instrumentation_begin(); \
__##func (regs, error_code); \
instrumentation_end(); \
idtentry_exit(regs, state); \
irqentry_exit(regs, state); \
} \
\
static __always_inline void __##func(struct pt_regs *regs, \
Expand Down Expand Up @@ -161,7 +156,7 @@ __visible noinstr void func(struct pt_regs *regs)
* body with a pair of curly brackets.
*
* Contrary to DEFINE_IDTENTRY_ERRORCODE() this does not invoke the
* idtentry_enter/exit() helpers before and after the body invocation. This
* irqentry_enter/exit() helpers before and after the body invocation. This
* needs to be done in the body itself if applicable. Use if extra work
* is required before the enter/exit() helpers are invoked.
*/
Expand Down Expand Up @@ -197,15 +192,15 @@ static __always_inline void __##func(struct pt_regs *regs, u8 vector); \
__visible noinstr void func(struct pt_regs *regs, \
unsigned long error_code) \
{ \
idtentry_state_t state = idtentry_enter(regs); \
irqentry_state_t state = irqentry_enter(regs); \
\
instrumentation_begin(); \
irq_enter_rcu(); \
kvm_set_cpu_l1tf_flush_l1d(); \
__##func (regs, (u8)error_code); \
irq_exit_rcu(); \
instrumentation_end(); \
idtentry_exit(regs, state); \
irqentry_exit(regs, state); \
} \
\
static __always_inline void __##func(struct pt_regs *regs, u8 vector)
Expand All @@ -229,7 +224,7 @@ static __always_inline void __##func(struct pt_regs *regs, u8 vector)
* DEFINE_IDTENTRY_SYSVEC - Emit code for system vector IDT entry points
* @func: Function name of the entry point
*
* idtentry_enter/exit() and irq_enter/exit_rcu() are invoked before the
* irqentry_enter/exit() and irq_enter/exit_rcu() are invoked before the
* function body. KVM L1D flush request is set.
*
* Runs the function on the interrupt stack if the entry hit kernel mode
Expand All @@ -239,15 +234,15 @@ static void __##func(struct pt_regs *regs); \
\
__visible noinstr void func(struct pt_regs *regs) \
{ \
idtentry_state_t state = idtentry_enter(regs); \
irqentry_state_t state = irqentry_enter(regs); \
\
instrumentation_begin(); \
irq_enter_rcu(); \
kvm_set_cpu_l1tf_flush_l1d(); \
run_on_irqstack_cond(__##func, regs, regs); \
irq_exit_rcu(); \
instrumentation_end(); \
idtentry_exit(regs, state); \
irqentry_exit(regs, state); \
} \
\
static noinline void __##func(struct pt_regs *regs)
Expand All @@ -268,15 +263,15 @@ static __always_inline void __##func(struct pt_regs *regs); \
\
__visible noinstr void func(struct pt_regs *regs) \
{ \
idtentry_state_t state = idtentry_enter(regs); \
irqentry_state_t state = irqentry_enter(regs); \
\
instrumentation_begin(); \
__irq_enter_raw(); \
kvm_set_cpu_l1tf_flush_l1d(); \
__##func (regs); \
__irq_exit_raw(); \
instrumentation_end(); \
idtentry_exit(regs, state); \
irqentry_exit(regs, state); \
} \
\
static __always_inline void __##func(struct pt_regs *regs)
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kernel/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ EXPORT_SYMBOL_GPL(kvm_read_and_reset_apf_flags);
noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token)
{
u32 reason = kvm_read_and_reset_apf_flags();
idtentry_state_t state;
irqentry_state_t state;

switch (reason) {
case KVM_PV_REASON_PAGE_NOT_PRESENT:
Expand All @@ -243,7 +243,7 @@ noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token)
return false;
}

state = idtentry_enter(regs);
state = irqentry_enter(regs);
instrumentation_begin();

/*
Expand All @@ -264,7 +264,7 @@ noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token)
}

instrumentation_end();
idtentry_exit(regs, state);
irqentry_exit(regs, state);
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static noinstr bool handle_bug(struct pt_regs *regs)

DEFINE_IDTENTRY_RAW(exc_invalid_op)
{
idtentry_state_t state;
irqentry_state_t state;

/*
* We use UD2 as a short encoding for 'CALL __WARN', as such
Expand All @@ -255,11 +255,11 @@ DEFINE_IDTENTRY_RAW(exc_invalid_op)
if (!user_mode(regs) && handle_bug(regs))
return;

state = idtentry_enter(regs);
state = irqentry_enter(regs);
instrumentation_begin();
handle_invalid_op(regs);
instrumentation_end();
idtentry_exit(regs, state);
irqentry_exit(regs, state);
}

DEFINE_IDTENTRY(exc_coproc_segment_overrun)
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ handle_page_fault(struct pt_regs *regs, unsigned long error_code,
DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
{
unsigned long address = read_cr2();
idtentry_state_t state;
irqentry_state_t state;

prefetchw(&current->mm->mmap_lock);

Expand Down Expand Up @@ -1412,11 +1412,11 @@ DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
* code reenabled RCU to avoid subsequent wreckage which helps
* debugability.
*/
state = idtentry_enter(regs);
state = irqentry_enter(regs);

instrumentation_begin();
handle_page_fault(regs, error_code, address);
instrumentation_end();

idtentry_exit(regs, state);
irqentry_exit(regs, state);
}

0 comments on commit a27a0a5

Please sign in to comment.