2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* File: mca.h
|
|
|
|
* Purpose: Machine check handling specific defines
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999, 2004 Silicon Graphics, Inc.
|
2008-01-07 09:11:57 +08:00
|
|
|
* Copyright (C) Vijay Chander <vijay@engr.sgi.com>
|
|
|
|
* Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
|
|
|
|
* Copyright (C) Russ Anderson <rja@sgi.com>
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_IA64_MCA_H
|
|
|
|
#define _ASM_IA64_MCA_H
|
|
|
|
|
|
|
|
#if !defined(__ASSEMBLY__)
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#include <asm/param.h>
|
|
|
|
#include <asm/sal.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/mca_asm.h>
|
|
|
|
|
|
|
|
#define IA64_MCA_RENDEZ_TIMEOUT (20 * 1000) /* value in milliseconds - 20 seconds */
|
|
|
|
|
|
|
|
typedef struct ia64_fptr {
|
|
|
|
unsigned long fp;
|
|
|
|
unsigned long gp;
|
|
|
|
} ia64_fptr_t;
|
|
|
|
|
|
|
|
typedef union cmcv_reg_u {
|
|
|
|
u64 cmcv_regval;
|
|
|
|
struct {
|
|
|
|
u64 cmcr_vector : 8;
|
|
|
|
u64 cmcr_reserved1 : 4;
|
|
|
|
u64 cmcr_ignored1 : 1;
|
|
|
|
u64 cmcr_reserved2 : 3;
|
|
|
|
u64 cmcr_mask : 1;
|
|
|
|
u64 cmcr_ignored2 : 47;
|
|
|
|
} cmcv_reg_s;
|
|
|
|
|
|
|
|
} cmcv_reg_t;
|
|
|
|
|
|
|
|
#define cmcv_mask cmcv_reg_s.cmcr_mask
|
|
|
|
#define cmcv_vector cmcv_reg_s.cmcr_vector
|
|
|
|
|
|
|
|
enum {
|
|
|
|
IA64_MCA_RENDEZ_CHECKIN_NOTDONE = 0x0,
|
2005-09-11 15:22:53 +08:00
|
|
|
IA64_MCA_RENDEZ_CHECKIN_DONE = 0x1,
|
|
|
|
IA64_MCA_RENDEZ_CHECKIN_INIT = 0x2,
|
2007-05-19 06:17:17 +08:00
|
|
|
IA64_MCA_RENDEZ_CHECKIN_CONCURRENT_MCA = 0x3,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Information maintained by the MC infrastructure */
|
|
|
|
typedef struct ia64_mc_info_s {
|
|
|
|
u64 imi_mca_handler;
|
|
|
|
size_t imi_mca_handler_size;
|
|
|
|
u64 imi_monarch_init_handler;
|
|
|
|
size_t imi_monarch_init_handler_size;
|
|
|
|
u64 imi_slave_init_handler;
|
|
|
|
size_t imi_slave_init_handler_size;
|
|
|
|
u8 imi_rendez_checkin[NR_CPUS];
|
|
|
|
|
|
|
|
} ia64_mc_info_t;
|
|
|
|
|
2005-09-11 15:22:53 +08:00
|
|
|
/* Handover state from SAL to OS and vice versa, for both MCA and INIT events.
|
|
|
|
* Besides the handover state, it also contains some saved registers from the
|
|
|
|
* time of the event.
|
|
|
|
* Note: mca_asm.S depends on the precise layout of this structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ia64_sal_os_state {
|
2006-04-07 16:08:11 +08:00
|
|
|
|
|
|
|
/* SAL to OS */
|
2009-05-23 04:49:49 +08:00
|
|
|
unsigned long os_gp; /* GP of the os registered with the SAL, physical */
|
|
|
|
unsigned long pal_proc; /* PAL_PROC entry point, physical */
|
|
|
|
unsigned long sal_proc; /* SAL_PROC entry point, physical */
|
|
|
|
unsigned long rv_rc; /* MCA - Rendezvous state, INIT - reason code */
|
|
|
|
unsigned long proc_state_param; /* from R18 */
|
|
|
|
unsigned long monarch; /* 1 for a monarch event, 0 for a slave */
|
2006-04-07 16:08:11 +08:00
|
|
|
|
|
|
|
/* common */
|
2009-05-23 04:49:49 +08:00
|
|
|
unsigned long sal_ra; /* Return address in SAL, physical */
|
|
|
|
unsigned long sal_gp; /* GP of the SAL - physical */
|
2005-09-11 15:22:53 +08:00
|
|
|
pal_min_state_area_t *pal_min_state; /* from R17. physical in asm, virtual in C */
|
2005-09-22 16:49:15 +08:00
|
|
|
/* Previous values of IA64_KR(CURRENT) and IA64_KR(CURRENT_STACK).
|
|
|
|
* Note: if the MCA/INIT recovery code wants to resume to a new context
|
|
|
|
* then it must change these values to reflect the new kernel stack.
|
|
|
|
*/
|
2009-05-23 04:49:49 +08:00
|
|
|
unsigned long prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */
|
|
|
|
unsigned long prev_IA64_KR_CURRENT_STACK;
|
2005-09-11 15:22:53 +08:00
|
|
|
struct task_struct *prev_task; /* previous task, NULL if it is not useful */
|
|
|
|
/* Some interrupt registers are not saved in minstate, pt_regs or
|
|
|
|
* switch_stack. Because MCA/INIT can occur when interrupts are
|
|
|
|
* disabled, we need to save the additional interrupt registers over
|
|
|
|
* MCA/INIT and resume.
|
|
|
|
*/
|
2009-05-23 04:49:49 +08:00
|
|
|
unsigned long isr;
|
|
|
|
unsigned long ifa;
|
|
|
|
unsigned long itir;
|
|
|
|
unsigned long iipa;
|
|
|
|
unsigned long iim;
|
|
|
|
unsigned long iha;
|
2006-04-07 16:08:11 +08:00
|
|
|
|
|
|
|
/* OS to SAL */
|
2009-05-23 04:49:49 +08:00
|
|
|
unsigned long os_status; /* OS status to SAL, enum below */
|
|
|
|
unsigned long context; /* 0 if return to same context
|
2005-09-11 15:22:53 +08:00
|
|
|
1 if return to new context */
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
IA64_MCA_CORRECTED = 0x0, /* Error has been corrected by OS_MCA */
|
|
|
|
IA64_MCA_WARM_BOOT = -1, /* Warm boot of the system need from SAL */
|
|
|
|
IA64_MCA_COLD_BOOT = -2, /* Cold boot of the system need from SAL */
|
|
|
|
IA64_MCA_HALT = -3 /* System to be halted by SAL */
|
|
|
|
};
|
|
|
|
|
2005-09-11 15:22:53 +08:00
|
|
|
enum {
|
|
|
|
IA64_INIT_RESUME = 0x0, /* Resume after return from INIT */
|
|
|
|
IA64_INIT_WARM_BOOT = -1, /* Warm boot of the system need from SAL */
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
enum {
|
|
|
|
IA64_MCA_SAME_CONTEXT = 0x0, /* SAL to return to same context */
|
|
|
|
IA64_MCA_NEW_CONTEXT = -1 /* SAL to return to new context */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Per-CPU MCA state that is too big for normal per-CPU variables. */
|
|
|
|
|
|
|
|
struct ia64_mca_cpu {
|
2005-09-11 15:22:53 +08:00
|
|
|
u64 mca_stack[KERNEL_STACK_SIZE/8];
|
2005-04-17 06:20:36 +08:00
|
|
|
u64 init_stack[KERNEL_STACK_SIZE/8];
|
2005-09-11 15:22:53 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Array of physical addresses of each CPU's MCA area. */
|
|
|
|
extern unsigned long __per_cpu_mca[NR_CPUS];
|
|
|
|
|
2005-11-12 06:32:40 +08:00
|
|
|
extern int cpe_vector;
|
|
|
|
extern int ia64_cpe_irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
extern void ia64_mca_init(void);
|
|
|
|
extern void ia64_mca_cpu_init(void *);
|
|
|
|
extern void ia64_os_mca_dispatch(void);
|
|
|
|
extern void ia64_os_mca_dispatch_end(void);
|
2005-09-11 15:22:53 +08:00
|
|
|
extern void ia64_mca_ucmc_handler(struct pt_regs *, struct ia64_sal_os_state *);
|
|
|
|
extern void ia64_init_handler(struct pt_regs *,
|
|
|
|
struct switch_stack *,
|
|
|
|
struct ia64_sal_os_state *);
|
[IA64] kexec: Make INIT safe while transition to
kdump/kexec kernel
Summary:
Asserting INIT on the beginning of kdump/kexec kernel will result
in unexpected behavior because INIT handler for previous kernel is
invoked on new kernel.
Description:
In panic situation, we can receive INIT while kernel transition,
i.e. from beginning of panic to bootstrap of kdump kernel.
Since we initialize registers on leave from current kernel, no
longer monarch/slave handlers of current kernel in virtual mode are
called safely. (In fact system goes hang as far as I confirmed)
How to Reproduce:
Start kdump
# echo c > /proc/sysrq-trigger
Then assert INIT while kdump kernel is booting, before new INIT
handler for kdump kernel is registered.
Expected(Desirable) result:
kdump kernel boots without any problem, crashdump retrieved
Actual result:
INIT handler for previous kernel is invoked on kdump kernel
=> panic, hang etc. (unexpected)
Proposed fix:
We can unregister these init handlers from SAL before jumping into
new kernel, however then the INIT will fallback to default behavior,
result in warmboot by SAL (according to the SAL specification) and
we cannot retrieve the crashdump.
Therefore this patch introduces a NOP init handler and register it
to SAL before leave from current kernel, to start kdump safely by
preventing INITs from entering virtual mode and resulting in warmboot.
On the other hand, in case of kexec that not for kdump, it also
has same problem with INIT while kernel transition.
This patch handles this case differently, because for kexec
unregistering handlers will be preferred than registering NOP
handler, since the situation "no handlers registered" is usual
state for kernel's entry.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Haren Myneni <hbabu@us.ibm.com>
Cc: kexec@lists.infradead.org
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2009-08-07 05:51:56 +08:00
|
|
|
extern void ia64_os_init_on_kdump(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
extern void ia64_monarch_init_handler(void);
|
|
|
|
extern void ia64_slave_init_handler(void);
|
|
|
|
extern void ia64_mca_cmc_vector_setup(void);
|
2005-09-11 15:22:53 +08:00
|
|
|
extern int ia64_reg_MCA_extension(int (*fn)(void *, struct ia64_sal_os_state *));
|
2005-04-17 06:20:36 +08:00
|
|
|
extern void ia64_unreg_MCA_extension(void);
|
2009-05-23 04:49:49 +08:00
|
|
|
extern unsigned long ia64_get_rnat(unsigned long *);
|
[IA64] kdump: Mask MCA/INIT on frozen cpus
Summary:
INIT asserted on kdump kernel invokes INIT handler not only on a
cpu that running on the kdump kernel, but also BSP of the panicked
kernel, because the (badly) frozen BSP can be thawed by INIT.
Description:
The kdump_cpu_freeze() is called on cpus except one that initiates
panic and/or kdump, to stop/offline the cpu (on ia64, it means we
pass control of cpus to SAL, or put them in spinloop). Note that
CPU0(BSP) always go to spinloop, so if panic was happened on an AP,
there are at least 2cpus (= the AP and BSP) which not back to SAL.
On the spinning cpus, interrupts are disabled (rsm psr.i), but INIT
is still interruptible because psr.mc for mask them is not set unless
kdump_cpu_freeze() is not called from MCA/INIT context.
Therefore, assume that a panic was happened on an AP, kdump was
invoked, new INIT handlers for kdump kernel was registered and then
an INIT is asserted. From the viewpoint of SAL, there are 2 online
cpus, so INIT will be delivered to both of them. It likely means
that not only the AP (= a cpu executing kdump) enters INIT handler
which is newly registered, but also BSP (= another cpu spinning in
panicked kernel) enters the same INIT handler. Of course setting of
registers in BSP are still old (for panicked kernel), so what happen
with running handler with wrong setting will be extremely unexpected.
I believe this is not desirable behavior.
How to Reproduce:
Start kdump on one of APs (e.g. cpu1)
# taskset 0x2 echo c > /proc/sysrq-trigger
Then assert INIT after kdump kernel is booted, after new INIT handler
for kdump kernel is registered.
Expected results:
An INIT handler is invoked only on the AP.
Actual results:
An INIT handler is invoked on the AP and BSP.
Sample of results:
I got following console log by asserting INIT after prompt "root:/>".
It seems that two monarchs appeared by one INIT, and one panicked at
last. And it also seems that the panicked one supposed there were
4 online cpus and no one did rendezvous:
:
[ 0 %]dropping to initramfs shell
exiting this shell will reboot your system
root:/> Entered OS INIT handler. PSP=fff301a0 cpu=0 monarch=0
ia64_init_handler: Promoting cpu 0 to monarch.
Delaying for 5 seconds...
All OS INIT slaves have reached rendezvous
Processes interrupted by INIT - 0 (cpu 0 task 0xa000000100af0000)
:
<<snip>>
:
Entered OS INIT handler. PSP=fff301a0 cpu=0 monarch=1
Delaying for 5 seconds...
mlogbuf_finish: printing switched to urgent mode, MCA/INIT might be dodgy or fail.
OS INIT slave did not rendezvous on cpu 1 2 3
INIT swapper 0[0]: bugcheck! 0 [1]
:
<<snip>>
:
Kernel panic - not syncing: Attempted to kill the idle task!
Proposed fix:
To avoid this problem, this patch inserts ia64_set_psr_mc() to mask
INIT on cpus going to be frozen. This masking have no effect if the
kdump_cpu_freeze() is called from INIT handler when kdump_on_init == 1,
because psr.mc is already turned on to 1 before entering OS_INIT.
I confirmed that weird log like above are disappeared after applying
this patch.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Haren Myneni <hbabu@us.ibm.com>
Cc: kexec@lists.infradead.org
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2009-08-07 05:51:56 +08:00
|
|
|
extern void ia64_set_psr_mc(void);
|
2007-09-01 15:36:26 +08:00
|
|
|
extern void ia64_mca_printk(const char * fmt, ...)
|
|
|
|
__attribute__ ((format (printf, 1, 2)));
|
2005-09-11 15:22:53 +08:00
|
|
|
|
2006-04-03 13:26:12 +08:00
|
|
|
struct ia64_mca_notify_die {
|
|
|
|
struct ia64_sal_os_state *sos;
|
|
|
|
int *monarch_cpu;
|
2008-04-17 16:00:37 +08:00
|
|
|
int *data;
|
2006-04-03 13:26:12 +08:00
|
|
|
};
|
|
|
|
|
2007-02-14 15:17:47 +08:00
|
|
|
DECLARE_PER_CPU(u64, ia64_mca_pal_base);
|
|
|
|
|
2005-09-11 15:22:53 +08:00
|
|
|
#else /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#define IA64_MCA_CORRECTED 0x0 /* Error has been corrected by OS_MCA */
|
|
|
|
#define IA64_MCA_WARM_BOOT -1 /* Warm boot of the system need from SAL */
|
|
|
|
#define IA64_MCA_COLD_BOOT -2 /* Cold boot of the system need from SAL */
|
|
|
|
#define IA64_MCA_HALT -3 /* System to be halted by SAL */
|
|
|
|
|
|
|
|
#define IA64_INIT_RESUME 0x0 /* Resume after return from INIT */
|
|
|
|
#define IA64_INIT_WARM_BOOT -1 /* Warm boot of the system need from SAL */
|
|
|
|
|
|
|
|
#define IA64_MCA_SAME_CONTEXT 0x0 /* SAL to return to same context */
|
|
|
|
#define IA64_MCA_NEW_CONTEXT -1 /* SAL to return to new context */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_IA64_MCA_H */
|