Skip to content

Commit a05d54c

Browse files
aeglsuryasaimadhu
authored andcommitted
x86/mce: Provide method to find out the type of an exception handler
Avoid a proliferation of ex_has_*_handler() functions by having just one function that returns the type of the handler (if any). Drop the __visible attribute for this function. It is not called from assembler so the attribute is not necessary. Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20201006210910.21062-3-tony.luck@intel.com
1 parent 41ce056 commit a05d54c

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

arch/x86/include/asm/extable.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ struct pt_regs;
2929
(b)->handler = (tmp).handler - (delta); \
3030
} while (0)
3131

32+
enum handler_type {
33+
EX_HANDLER_NONE,
34+
EX_HANDLER_FAULT,
35+
EX_HANDLER_UACCESS,
36+
EX_HANDLER_OTHER
37+
};
38+
3239
extern int fixup_exception(struct pt_regs *regs, int trapnr,
3340
unsigned long error_code, unsigned long fault_addr);
3441
extern int fixup_bug(struct pt_regs *regs, int trapnr);
35-
extern bool ex_has_fault_handler(unsigned long ip);
42+
extern enum handler_type ex_get_fault_handler_type(unsigned long ip);
3643
extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
3744

3845
#endif

arch/x86/kernel/cpu/mce/severity.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,13 @@ static struct severity {
225225
*/
226226
static int error_context(struct mce *m, struct pt_regs *regs)
227227
{
228+
enum handler_type t;
229+
228230
if ((m->cs & 3) == 3)
229231
return IN_USER;
230232

231-
if (mc_recoverable(m->mcgstatus) && ex_has_fault_handler(m->ip)) {
233+
t = ex_get_fault_handler_type(m->ip);
234+
if (mc_recoverable(m->mcgstatus) && t == EX_HANDLER_FAULT) {
232235
m->kflags |= MCE_IN_KERNEL_RECOV;
233236
return IN_KERNEL_RECOV;
234237
}

arch/x86/mm/extable.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,21 @@ __visible bool ex_handler_clear_fs(const struct exception_table_entry *fixup,
125125
}
126126
EXPORT_SYMBOL(ex_handler_clear_fs);
127127

128-
__visible bool ex_has_fault_handler(unsigned long ip)
128+
enum handler_type ex_get_fault_handler_type(unsigned long ip)
129129
{
130130
const struct exception_table_entry *e;
131131
ex_handler_t handler;
132132

133133
e = search_exception_tables(ip);
134134
if (!e)
135-
return false;
135+
return EX_HANDLER_NONE;
136136
handler = ex_fixup_handler(e);
137-
138-
return handler == ex_handler_fault;
137+
if (handler == ex_handler_fault)
138+
return EX_HANDLER_FAULT;
139+
else if (handler == ex_handler_uaccess)
140+
return EX_HANDLER_UACCESS;
141+
else
142+
return EX_HANDLER_OTHER;
139143
}
140144

141145
int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,

0 commit comments

Comments
 (0)