Skip to content

Commit afcd21d

Browse files
KAGA-KOKOsuryasaimadhu
authored andcommitted
x86/dumpstack/64: Use cpu_entry_area instead of orig_ist
The orig_ist[] array is a shadow copy of the IST array in the TSS. The reason why it exists is that older kernels used two TSS variants with different pointers into the debug stack. orig_ist[] contains the real starting points. There is no point anymore to do so because the same information can be retrieved using the base address of the cpu entry area mapping and the offsets of the various exception stacks. No functional change. Preparation for removing orig_ist. Cc: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Sean Christopherson <sean.j.christopherson@intel.com> Cc: x86-ml <x86@kernel.org> Link: https://lkml.kernel.org/r/20190414160144.974900463@linutronix.de
1 parent bf5882a commit afcd21d

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

‎arch/x86/kernel/dumpstack_64.c‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/bug.h>
1717
#include <linux/nmi.h>
1818

19+
#include <asm/cpu_entry_area.h>
1920
#include <asm/stacktrace.h>
2021

2122
static const char *exception_stack_names[N_EXCEPTION_STACKS] = {
@@ -25,11 +26,6 @@ static const char *exception_stack_names[N_EXCEPTION_STACKS] = {
2526
[ ESTACK_MCE ] = "#MC",
2627
};
2728

28-
static const unsigned long exception_stack_sizes[N_EXCEPTION_STACKS] = {
29-
[0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ,
30-
[ESTACK_DB] = DEBUG_STKSZ
31-
};
32-
3329
const char *stack_type_name(enum stack_type type)
3430
{
3531
BUILD_BUG_ON(N_EXCEPTION_STACKS != 4);
@@ -52,25 +48,44 @@ const char *stack_type_name(enum stack_type type)
5248
return NULL;
5349
}
5450

51+
struct estack_layout {
52+
unsigned int begin;
53+
unsigned int end;
54+
};
55+
56+
#define ESTACK_ENTRY(x) { \
57+
.begin = offsetof(struct cea_exception_stacks, x## _stack), \
58+
.end = offsetof(struct cea_exception_stacks, x## _stack_guard) \
59+
}
60+
61+
static const struct estack_layout layout[N_EXCEPTION_STACKS] = {
62+
[ ESTACK_DF ] = ESTACK_ENTRY(DF),
63+
[ ESTACK_NMI ] = ESTACK_ENTRY(NMI),
64+
[ ESTACK_DB ] = ESTACK_ENTRY(DB),
65+
[ ESTACK_MCE ] = ESTACK_ENTRY(MCE),
66+
};
67+
5568
static bool in_exception_stack(unsigned long *stack, struct stack_info *info)
5669
{
57-
unsigned long *begin, *end;
70+
unsigned long estacks, begin, end, stk = (unsigned long)stack;
5871
struct pt_regs *regs;
59-
unsigned k;
72+
unsigned int k;
6073

6174
BUILD_BUG_ON(N_EXCEPTION_STACKS != 4);
6275

76+
estacks = (unsigned long)__this_cpu_read(cea_exception_stacks);
77+
6378
for (k = 0; k < N_EXCEPTION_STACKS; k++) {
64-
end = (unsigned long *)raw_cpu_ptr(&orig_ist)->ist[k];
65-
begin = end - (exception_stack_sizes[k] / sizeof(long));
79+
begin = estacks + layout[k].begin;
80+
end = estacks + layout[k].end;
6681
regs = (struct pt_regs *)end - 1;
6782

68-
if (stack < begin || stack >= end)
83+
if (stk < begin || stk >= end)
6984
continue;
7085

7186
info->type = STACK_TYPE_EXCEPTION + k;
72-
info->begin = begin;
73-
info->end = end;
87+
info->begin = (unsigned long *)begin;
88+
info->end = (unsigned long *)end;
7489
info->next_sp = (unsigned long *)regs->sp;
7590

7691
return true;

0 commit comments

Comments
 (0)