2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* File: mca.h
|
|
|
|
* Purpose: Machine check handling specific defines
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999, 2004 Silicon Graphics, Inc.
|
2008-01-06 18:11:57 -07: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-16 15:20:36 -07: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 00:22:53 -07:00
|
|
|
IA64_MCA_RENDEZ_CHECKIN_DONE = 0x1,
|
|
|
|
IA64_MCA_RENDEZ_CHECKIN_INIT = 0x2,
|
2007-05-18 15:17:17 -07:00
|
|
|
IA64_MCA_RENDEZ_CHECKIN_CONCURRENT_MCA = 0x3,
|
2005-04-16 15:20:36 -07: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 00:22:53 -07: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 01:08:11 -07:00
|
|
|
|
|
|
|
/* SAL to OS */
|
2009-05-22 13:49:49 -07: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 01:08:11 -07:00
|
|
|
|
|
|
|
/* common */
|
2009-05-22 13:49:49 -07:00
|
|
|
unsigned long sal_ra; /* Return address in SAL, physical */
|
|
|
|
unsigned long sal_gp; /* GP of the SAL - physical */
|
2005-09-11 00:22:53 -07:00
|
|
|
pal_min_state_area_t *pal_min_state; /* from R17. physical in asm, virtual in C */
|
2005-09-22 01:49:15 -07: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-22 13:49:49 -07:00
|
|
|
unsigned long prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */
|
|
|
|
unsigned long prev_IA64_KR_CURRENT_STACK;
|
2005-09-11 00:22:53 -07: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-22 13:49:49 -07:00
|
|
|
unsigned long isr;
|
|
|
|
unsigned long ifa;
|
|
|
|
unsigned long itir;
|
|
|
|
unsigned long iipa;
|
|
|
|
unsigned long iim;
|
|
|
|
unsigned long iha;
|
2006-04-07 01:08:11 -07:00
|
|
|
|
|
|
|
/* OS to SAL */
|
2009-05-22 13:49:49 -07:00
|
|
|
unsigned long os_status; /* OS status to SAL, enum below */
|
|
|
|
unsigned long context; /* 0 if return to same context
|
2005-09-11 00:22:53 -07:00
|
|
|
1 if return to new context */
|
[IA64] Save I-resources to ia64_sal_os_state
This is a patch related to this discussion.
http://www.spinics.net/lists/linux-ia64/msg07605.html
When INIT is sent, ip/psr/pfs register is stored to the I-resources
(iip/ipsr/ifs registers), and they are copied in the min-state save
area(pmsa_{iip,ipsr,ifs}).
Therefore, in creating pt_regs at ia64_mca_modify_original_stack(),
cr_{iip,ipsr,ifs} should be derived from pmsa_{iip,ipsr,ifs}. But
current code copies pmsa_{xip,xpsr,xfs} to cr_{iip,ipsr,ifs}
when PSR.ic is 0.
finish_pt_regs(struct pt_regs *regs, const pal_min_state_area_t *ms,
unsigned long *nat)
{
(snip)
if (ia64_psr(regs)->ic) {
regs->cr_iip = ms->pmsa_iip;
regs->cr_ipsr = ms->pmsa_ipsr;
regs->cr_ifs = ms->pmsa_ifs;
} else {
regs->cr_iip = ms->pmsa_xip;
regs->cr_ipsr = ms->pmsa_xpsr;
regs->cr_ifs = ms->pmsa_xfs;
}
It's ok when PSR.ic is not 0. But when PSR.ic is 0, this could be
a problem when we investigate kernel as the value of regs->cr_iip does
not point to where INIT really interrupted.
At first I tried to change finish_pt_regs() so that it uses always
pmsa_{iip,ipsr,ifs} for cr_{iip,ipsr,ifs}, but Keith Owens pointed out
it could cause another problem if I change it.
>The only problem I can think of is an MCA/INIT
>arriving while code like SAVE_MIN or SAVE_REST is executing. Back
>tracing at that point using pmsa_iip is going to be a problem, you have
>no idea what state the registers or stack are in.
I confirmed he was right, so I decided to keep it as-is and to
save pmsa_{iip,ipsr,ifs} to ia64_sal_os_state for debugging.
An attached patch is just adding new members into ia64_sal_os_state to
save pmsa_{iip,ipsr,ifs}.
Signed-off-by: Takao Indoh <indou.takao@jp.fujitsu.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2009-11-19 14:39:22 -07:00
|
|
|
|
|
|
|
/* I-resources */
|
|
|
|
unsigned long iip;
|
|
|
|
unsigned long ipsr;
|
|
|
|
unsigned long ifs;
|
2005-09-11 00:22:53 -07:00
|
|
|
};
|
2005-04-16 15:20:36 -07: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 00:22:53 -07: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-16 15:20:36 -07: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 00:22:53 -07:00
|
|
|
u64 mca_stack[KERNEL_STACK_SIZE/8];
|
2005-04-16 15:20:36 -07:00
|
|
|
u64 init_stack[KERNEL_STACK_SIZE/8];
|
2005-09-11 00:22:53 -07:00
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Array of physical addresses of each CPU's MCA area. */
|
|
|
|
extern unsigned long __per_cpu_mca[NR_CPUS];
|
|
|
|
|
2005-11-11 15:32:40 -07:00
|
|
|
extern int cpe_vector;
|
|
|
|
extern int ia64_cpe_irq;
|
2005-04-16 15:20:36 -07: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 00:22:53 -07: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-06 14:51:56 -07:00
|
|
|
extern void ia64_os_init_on_kdump(void);
|
2005-04-16 15:20:36 -07: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 00:22:53 -07:00
|
|
|
extern int ia64_reg_MCA_extension(int (*fn)(void *, struct ia64_sal_os_state *));
|
2005-04-16 15:20:36 -07:00
|
|
|
extern void ia64_unreg_MCA_extension(void);
|
2009-05-22 13:49:49 -07: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-06 14:51:56 -07:00
|
|
|
extern void ia64_set_psr_mc(void);
|
2007-09-01 00:36:26 -07:00
|
|
|
extern void ia64_mca_printk(const char * fmt, ...)
|
|
|
|
__attribute__ ((format (printf, 1, 2)));
|
2005-09-11 00:22:53 -07:00
|
|
|
|
2006-04-02 22:26:12 -07:00
|
|
|
struct ia64_mca_notify_die {
|
|
|
|
struct ia64_sal_os_state *sos;
|
|
|
|
int *monarch_cpu;
|
2008-04-17 01:00:37 -07:00
|
|
|
int *data;
|
2006-04-02 22:26:12 -07:00
|
|
|
};
|
|
|
|
|
2007-02-14 00:17:47 -07:00
|
|
|
DECLARE_PER_CPU(u64, ia64_mca_pal_base);
|
|
|
|
|
2005-09-11 00:22:53 -07: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-16 15:20:36 -07:00
|
|
|
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_IA64_MCA_H */
|