2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2013-10-30 22:35:40 +08:00
|
|
|
/*
|
|
|
|
* Machine check exception handling.
|
|
|
|
*
|
|
|
|
* Copyright 2013 IBM Corporation
|
|
|
|
* Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#define pr_fmt(fmt) "mce: " fmt
|
|
|
|
|
2017-08-08 14:39:24 +08:00
|
|
|
#include <linux/hardirq.h>
|
2013-10-30 22:35:40 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/export.h>
|
2014-01-14 18:15:09 +08:00
|
|
|
#include <linux/irq_work.h>
|
2020-03-27 02:49:16 +08:00
|
|
|
#include <linux/extable.h>
|
2020-05-08 12:34:05 +08:00
|
|
|
#include <linux/ftrace.h>
|
2017-08-08 14:39:24 +08:00
|
|
|
|
|
|
|
#include <asm/machdep.h>
|
2013-10-30 22:35:40 +08:00
|
|
|
#include <asm/mce.h>
|
2019-02-26 16:51:07 +08:00
|
|
|
#include <asm/nmi.h>
|
2013-10-30 22:35:40 +08:00
|
|
|
|
|
|
|
static DEFINE_PER_CPU(int, mce_nest_count);
|
|
|
|
static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_event);
|
|
|
|
|
2013-10-30 22:35:49 +08:00
|
|
|
/* Queue for delayed MCE events. */
|
|
|
|
static DEFINE_PER_CPU(int, mce_queue_count);
|
|
|
|
static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_event_queue);
|
|
|
|
|
2017-09-29 12:26:55 +08:00
|
|
|
/* Queue for delayed MCE UE events. */
|
|
|
|
static DEFINE_PER_CPU(int, mce_ue_count);
|
|
|
|
static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT],
|
|
|
|
mce_ue_event_queue);
|
|
|
|
|
2014-01-14 18:15:09 +08:00
|
|
|
static void machine_check_process_queued_event(struct irq_work *work);
|
2019-08-20 16:13:46 +08:00
|
|
|
static void machine_check_ue_irq_work(struct irq_work *work);
|
2019-08-20 16:13:48 +08:00
|
|
|
static void machine_check_ue_event(struct machine_check_event *evt);
|
2017-09-29 12:26:55 +08:00
|
|
|
static void machine_process_ue_event(struct work_struct *work);
|
|
|
|
|
2016-01-06 08:45:50 +08:00
|
|
|
static struct irq_work mce_event_process_work = {
|
2014-01-14 18:15:09 +08:00
|
|
|
.func = machine_check_process_queued_event,
|
|
|
|
};
|
|
|
|
|
2019-08-20 16:13:46 +08:00
|
|
|
static struct irq_work mce_ue_event_irq_work = {
|
|
|
|
.func = machine_check_ue_irq_work,
|
|
|
|
};
|
|
|
|
|
2017-09-29 12:26:55 +08:00
|
|
|
DECLARE_WORK(mce_ue_event_work, machine_process_ue_event);
|
|
|
|
|
2020-07-09 21:51:41 +08:00
|
|
|
static BLOCKING_NOTIFIER_HEAD(mce_notifier_list);
|
|
|
|
|
|
|
|
int mce_register_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return blocking_notifier_chain_register(&mce_notifier_list, nb);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mce_register_notifier);
|
|
|
|
|
|
|
|
int mce_unregister_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return blocking_notifier_chain_unregister(&mce_notifier_list, nb);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mce_unregister_notifier);
|
|
|
|
|
2013-10-30 22:35:40 +08:00
|
|
|
static void mce_set_error_info(struct machine_check_event *mce,
|
|
|
|
struct mce_error_info *mce_err)
|
|
|
|
{
|
|
|
|
mce->error_type = mce_err->error_type;
|
|
|
|
switch (mce_err->error_type) {
|
|
|
|
case MCE_ERROR_TYPE_UE:
|
|
|
|
mce->u.ue_error.ue_error_type = mce_err->u.ue_error_type;
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_SLB:
|
|
|
|
mce->u.slb_error.slb_error_type = mce_err->u.slb_error_type;
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_ERAT:
|
|
|
|
mce->u.erat_error.erat_error_type = mce_err->u.erat_error_type;
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_TLB:
|
|
|
|
mce->u.tlb_error.tlb_error_type = mce_err->u.tlb_error_type;
|
|
|
|
break;
|
2017-02-28 10:00:48 +08:00
|
|
|
case MCE_ERROR_TYPE_USER:
|
|
|
|
mce->u.user_error.user_error_type = mce_err->u.user_error_type;
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_RA:
|
|
|
|
mce->u.ra_error.ra_error_type = mce_err->u.ra_error_type;
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_LINK:
|
|
|
|
mce->u.link_error.link_error_type = mce_err->u.link_error_type;
|
|
|
|
break;
|
2013-10-30 22:35:40 +08:00
|
|
|
case MCE_ERROR_TYPE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode and save high level MCE information into per cpu buffer which
|
|
|
|
* is an array of machine_check_event structure.
|
|
|
|
*/
|
|
|
|
void save_mce_event(struct pt_regs *regs, long handled,
|
|
|
|
struct mce_error_info *mce_err,
|
2017-09-29 12:26:53 +08:00
|
|
|
uint64_t nip, uint64_t addr, uint64_t phys_addr)
|
2013-10-30 22:35:40 +08:00
|
|
|
{
|
2015-05-12 11:23:59 +08:00
|
|
|
int index = __this_cpu_inc_return(mce_nest_count) - 1;
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
struct machine_check_event *mce = this_cpu_ptr(&mce_event[index]);
|
2013-10-30 22:35:40 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return if we don't have enough space to log mce event.
|
|
|
|
* mce_nest_count may go beyond MAX_MC_EVT but that's ok,
|
|
|
|
* the check below will stop buffer overrun.
|
|
|
|
*/
|
|
|
|
if (index >= MAX_MC_EVT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Populate generic machine check info */
|
|
|
|
mce->version = MCE_V1;
|
2013-12-16 13:16:24 +08:00
|
|
|
mce->srr0 = nip;
|
2013-10-30 22:35:40 +08:00
|
|
|
mce->srr1 = regs->msr;
|
|
|
|
mce->gpr3 = regs->gpr[3];
|
|
|
|
mce->in_use = 1;
|
2019-04-30 02:15:48 +08:00
|
|
|
mce->cpu = get_paca()->paca_index;
|
2013-10-30 22:35:40 +08:00
|
|
|
|
2016-08-09 13:09:13 +08:00
|
|
|
/* Mark it recovered if we have handled it and MSR(RI=1). */
|
|
|
|
if (handled && (regs->msr & MSR_RI))
|
2013-10-30 22:35:40 +08:00
|
|
|
mce->disposition = MCE_DISPOSITION_RECOVERED;
|
|
|
|
else
|
|
|
|
mce->disposition = MCE_DISPOSITION_NOT_RECOVERED;
|
2017-02-28 10:00:47 +08:00
|
|
|
|
|
|
|
mce->initiator = mce_err->initiator;
|
|
|
|
mce->severity = mce_err->severity;
|
2019-04-30 02:15:55 +08:00
|
|
|
mce->sync_error = mce_err->sync_error;
|
2019-04-30 02:16:02 +08:00
|
|
|
mce->error_class = mce_err->error_class;
|
2013-10-30 22:35:40 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Populate the mce error_type and type-specific error_type.
|
|
|
|
*/
|
|
|
|
mce_set_error_info(mce, mce_err);
|
|
|
|
|
|
|
|
if (!addr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (mce->error_type == MCE_ERROR_TYPE_TLB) {
|
|
|
|
mce->u.tlb_error.effective_address_provided = true;
|
|
|
|
mce->u.tlb_error.effective_address = addr;
|
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_SLB) {
|
|
|
|
mce->u.slb_error.effective_address_provided = true;
|
|
|
|
mce->u.slb_error.effective_address = addr;
|
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_ERAT) {
|
|
|
|
mce->u.erat_error.effective_address_provided = true;
|
|
|
|
mce->u.erat_error.effective_address = addr;
|
2017-02-28 10:00:48 +08:00
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_USER) {
|
|
|
|
mce->u.user_error.effective_address_provided = true;
|
|
|
|
mce->u.user_error.effective_address = addr;
|
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_RA) {
|
|
|
|
mce->u.ra_error.effective_address_provided = true;
|
|
|
|
mce->u.ra_error.effective_address = addr;
|
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_LINK) {
|
|
|
|
mce->u.link_error.effective_address_provided = true;
|
|
|
|
mce->u.link_error.effective_address = addr;
|
2013-10-30 22:35:40 +08:00
|
|
|
} else if (mce->error_type == MCE_ERROR_TYPE_UE) {
|
|
|
|
mce->u.ue_error.effective_address_provided = true;
|
|
|
|
mce->u.ue_error.effective_address = addr;
|
2017-09-29 12:26:53 +08:00
|
|
|
if (phys_addr != ULONG_MAX) {
|
|
|
|
mce->u.ue_error.physical_address_provided = true;
|
|
|
|
mce->u.ue_error.physical_address = phys_addr;
|
2019-08-20 16:13:50 +08:00
|
|
|
mce->u.ue_error.ignore_event = mce_err->ignore_event;
|
2017-09-29 12:26:55 +08:00
|
|
|
machine_check_ue_event(mce);
|
2017-09-29 12:26:53 +08:00
|
|
|
}
|
2013-10-30 22:35:40 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get_mce_event:
|
|
|
|
* mce Pointer to machine_check_event structure to be filled.
|
|
|
|
* release Flag to indicate whether to free the event slot or not.
|
|
|
|
* 0 <= do not release the mce event. Caller will invoke
|
|
|
|
* release_mce_event() once event has been consumed.
|
|
|
|
* 1 <= release the slot.
|
|
|
|
*
|
|
|
|
* return 1 = success
|
|
|
|
* 0 = failure
|
|
|
|
*
|
|
|
|
* get_mce_event() will be called by platform specific machine check
|
|
|
|
* handle routine and in KVM.
|
|
|
|
* When we call get_mce_event(), we are still in interrupt context and
|
|
|
|
* preemption will not be scheduled until ret_from_expect() routine
|
|
|
|
* is called.
|
|
|
|
*/
|
|
|
|
int get_mce_event(struct machine_check_event *mce, bool release)
|
|
|
|
{
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
int index = __this_cpu_read(mce_nest_count) - 1;
|
2013-10-30 22:35:40 +08:00
|
|
|
struct machine_check_event *mc_evt;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Sanity check */
|
|
|
|
if (index < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Check if we have MCE info to process. */
|
|
|
|
if (index < MAX_MC_EVT) {
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
mc_evt = this_cpu_ptr(&mce_event[index]);
|
2013-10-30 22:35:40 +08:00
|
|
|
/* Copy the event structure and release the original */
|
|
|
|
if (mce)
|
|
|
|
*mce = *mc_evt;
|
|
|
|
if (release)
|
|
|
|
mc_evt->in_use = 0;
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
/* Decrement the count to free the slot. */
|
|
|
|
if (release)
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
__this_cpu_dec(mce_nest_count);
|
2013-10-30 22:35:40 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_mce_event(void)
|
|
|
|
{
|
|
|
|
get_mce_event(NULL, true);
|
|
|
|
}
|
2013-10-30 22:35:49 +08:00
|
|
|
|
2019-08-20 16:13:46 +08:00
|
|
|
static void machine_check_ue_irq_work(struct irq_work *work)
|
|
|
|
{
|
|
|
|
schedule_work(&mce_ue_event_work);
|
|
|
|
}
|
2017-09-29 12:26:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue up the MCE event which then can be handled later.
|
|
|
|
*/
|
2019-08-20 16:13:48 +08:00
|
|
|
static void machine_check_ue_event(struct machine_check_event *evt)
|
2017-09-29 12:26:55 +08:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
index = __this_cpu_inc_return(mce_ue_count) - 1;
|
|
|
|
/* If queue is full, just return for now. */
|
|
|
|
if (index >= MAX_MC_EVT) {
|
|
|
|
__this_cpu_dec(mce_ue_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy(this_cpu_ptr(&mce_ue_event_queue[index]), evt, sizeof(*evt));
|
|
|
|
|
|
|
|
/* Queue work to process this event later. */
|
2019-08-20 16:13:46 +08:00
|
|
|
irq_work_queue(&mce_ue_event_irq_work);
|
2017-09-29 12:26:55 +08:00
|
|
|
}
|
|
|
|
|
2013-10-30 22:35:49 +08:00
|
|
|
/*
|
|
|
|
* Queue up the MCE event which then can be handled later.
|
|
|
|
*/
|
|
|
|
void machine_check_queue_event(void)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
struct machine_check_event evt;
|
|
|
|
|
|
|
|
if (!get_mce_event(&evt, MCE_EVENT_RELEASE))
|
|
|
|
return;
|
|
|
|
|
2015-05-12 11:23:59 +08:00
|
|
|
index = __this_cpu_inc_return(mce_queue_count) - 1;
|
2013-10-30 22:35:49 +08:00
|
|
|
/* If queue is full, just return for now. */
|
|
|
|
if (index >= MAX_MC_EVT) {
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
__this_cpu_dec(mce_queue_count);
|
2013-10-30 22:35:49 +08:00
|
|
|
return;
|
|
|
|
}
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
memcpy(this_cpu_ptr(&mce_event_queue[index]), &evt, sizeof(evt));
|
2014-01-14 18:15:09 +08:00
|
|
|
|
|
|
|
/* Queue irq work to process this event later. */
|
|
|
|
irq_work_queue(&mce_event_process_work);
|
2013-10-30 22:35:49 +08:00
|
|
|
}
|
2020-03-27 02:49:16 +08:00
|
|
|
|
|
|
|
void mce_common_process_ue(struct pt_regs *regs,
|
|
|
|
struct mce_error_info *mce_err)
|
|
|
|
{
|
|
|
|
const struct exception_table_entry *entry;
|
|
|
|
|
|
|
|
entry = search_kernel_exception_table(regs->nip);
|
|
|
|
if (entry) {
|
|
|
|
mce_err->ignore_event = true;
|
|
|
|
regs->nip = extable_fixup(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-29 12:26:55 +08:00
|
|
|
/*
|
|
|
|
* process pending MCE event from the mce event queue. This function will be
|
|
|
|
* called during syscall exit.
|
|
|
|
*/
|
|
|
|
static void machine_process_ue_event(struct work_struct *work)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
struct machine_check_event *evt;
|
|
|
|
|
|
|
|
while (__this_cpu_read(mce_ue_count) > 0) {
|
|
|
|
index = __this_cpu_read(mce_ue_count) - 1;
|
|
|
|
evt = this_cpu_ptr(&mce_ue_event_queue[index]);
|
2020-07-09 21:51:41 +08:00
|
|
|
blocking_notifier_call_chain(&mce_notifier_list, 0, evt);
|
2017-09-29 12:26:55 +08:00
|
|
|
#ifdef CONFIG_MEMORY_FAILURE
|
|
|
|
/*
|
|
|
|
* This should probably queued elsewhere, but
|
|
|
|
* oh! well
|
2019-08-20 16:13:50 +08:00
|
|
|
*
|
|
|
|
* Don't report this machine check because the caller has a
|
|
|
|
* asked us to ignore the event, it has a fixup handler which
|
|
|
|
* will do the appropriate error handling and reporting.
|
2017-09-29 12:26:55 +08:00
|
|
|
*/
|
|
|
|
if (evt->error_type == MCE_ERROR_TYPE_UE) {
|
2019-08-20 16:13:50 +08:00
|
|
|
if (evt->u.ue_error.ignore_event) {
|
|
|
|
__this_cpu_dec(mce_ue_count);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-09-29 12:26:55 +08:00
|
|
|
if (evt->u.ue_error.physical_address_provided) {
|
|
|
|
unsigned long pfn;
|
2013-10-30 22:35:49 +08:00
|
|
|
|
2017-09-29 12:26:55 +08:00
|
|
|
pfn = evt->u.ue_error.physical_address >>
|
|
|
|
PAGE_SHIFT;
|
2018-01-31 06:18:52 +08:00
|
|
|
memory_failure(pfn, 0);
|
2017-09-29 12:26:55 +08:00
|
|
|
} else
|
|
|
|
pr_warn("Failed to identify bad address from "
|
|
|
|
"where the uncorrectable error (UE) "
|
|
|
|
"was generated\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
__this_cpu_dec(mce_ue_count);
|
|
|
|
}
|
|
|
|
}
|
2013-10-30 22:35:49 +08:00
|
|
|
/*
|
|
|
|
* process pending MCE event from the mce event queue. This function will be
|
|
|
|
* called during syscall exit.
|
|
|
|
*/
|
2014-01-14 18:15:09 +08:00
|
|
|
static void machine_check_process_queued_event(struct irq_work *work)
|
2013-10-30 22:35:49 +08:00
|
|
|
{
|
|
|
|
int index;
|
2017-09-29 12:26:55 +08:00
|
|
|
struct machine_check_event *evt;
|
2013-10-30 22:35:49 +08:00
|
|
|
|
2017-04-19 00:38:17 +08:00
|
|
|
add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
|
|
|
|
|
2013-10-30 22:35:49 +08:00
|
|
|
/*
|
|
|
|
* For now just print it to console.
|
|
|
|
* TODO: log this error event to FSP or nvram.
|
|
|
|
*/
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
while (__this_cpu_read(mce_queue_count) > 0) {
|
|
|
|
index = __this_cpu_read(mce_queue_count) - 1;
|
2017-09-29 12:26:55 +08:00
|
|
|
evt = this_cpu_ptr(&mce_event_queue[index]);
|
2019-08-20 16:13:50 +08:00
|
|
|
|
|
|
|
if (evt->error_type == MCE_ERROR_TYPE_UE &&
|
|
|
|
evt->u.ue_error.ignore_event) {
|
|
|
|
__this_cpu_dec(mce_queue_count);
|
|
|
|
continue;
|
|
|
|
}
|
2019-02-21 10:40:20 +08:00
|
|
|
machine_check_print_event_info(evt, false, false);
|
powerpc: Replace __get_cpu_var uses
This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.
V2->V2
- Fix up to work against 3.18-rc1
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-10-22 04:23:25 +08:00
|
|
|
__this_cpu_dec(mce_queue_count);
|
2013-10-30 22:35:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-03 13:29:34 +08:00
|
|
|
void machine_check_print_event_info(struct machine_check_event *evt,
|
2019-02-21 10:40:20 +08:00
|
|
|
bool user_mode, bool in_guest)
|
2013-10-30 22:35:49 +08:00
|
|
|
{
|
2019-08-02 18:56:34 +08:00
|
|
|
const char *level, *sevstr, *subtype, *err_type, *initiator;
|
2019-04-30 02:15:48 +08:00
|
|
|
uint64_t ea = 0, pa = 0;
|
|
|
|
int n = 0;
|
|
|
|
char dar_str[50];
|
|
|
|
char pa_str[50];
|
2013-10-30 22:35:49 +08:00
|
|
|
static const char *mc_ue_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Instruction fetch",
|
|
|
|
"Page table walk ifetch",
|
|
|
|
"Load/Store",
|
|
|
|
"Page table walk Load/Store",
|
|
|
|
};
|
|
|
|
static const char *mc_slb_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Parity",
|
|
|
|
"Multihit",
|
|
|
|
};
|
|
|
|
static const char *mc_erat_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Parity",
|
|
|
|
"Multihit",
|
|
|
|
};
|
|
|
|
static const char *mc_tlb_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Parity",
|
|
|
|
"Multihit",
|
|
|
|
};
|
2017-02-28 10:00:48 +08:00
|
|
|
static const char *mc_user_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"tlbie(l) invalid",
|
2020-07-03 07:33:43 +08:00
|
|
|
"scv invalid",
|
2017-02-28 10:00:48 +08:00
|
|
|
};
|
|
|
|
static const char *mc_ra_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Instruction fetch (bad)",
|
2017-05-29 14:26:44 +08:00
|
|
|
"Instruction fetch (foreign)",
|
2017-02-28 10:00:48 +08:00
|
|
|
"Page table walk ifetch (bad)",
|
|
|
|
"Page table walk ifetch (foreign)",
|
|
|
|
"Load (bad)",
|
|
|
|
"Store (bad)",
|
|
|
|
"Page table walk Load/Store (bad)",
|
|
|
|
"Page table walk Load/Store (foreign)",
|
|
|
|
"Load/Store (foreign)",
|
|
|
|
};
|
|
|
|
static const char *mc_link_types[] = {
|
|
|
|
"Indeterminate",
|
|
|
|
"Instruction fetch (timeout)",
|
|
|
|
"Page table walk ifetch (timeout)",
|
|
|
|
"Load (timeout)",
|
|
|
|
"Store (timeout)",
|
|
|
|
"Page table walk Load/Store (timeout)",
|
|
|
|
};
|
2019-04-30 02:16:02 +08:00
|
|
|
static const char *mc_error_class[] = {
|
|
|
|
"Unknown",
|
|
|
|
"Hardware error",
|
|
|
|
"Probable Hardware error (some chance of software cause)",
|
|
|
|
"Software error",
|
|
|
|
"Probable Software error (some chance of hardware cause)",
|
|
|
|
};
|
2013-10-30 22:35:49 +08:00
|
|
|
|
|
|
|
/* Print things out */
|
|
|
|
if (evt->version != MCE_V1) {
|
|
|
|
pr_err("Machine Check Exception, Unknown event version %d !\n",
|
|
|
|
evt->version);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (evt->severity) {
|
|
|
|
case MCE_SEV_NO_ERROR:
|
|
|
|
level = KERN_INFO;
|
|
|
|
sevstr = "Harmless";
|
|
|
|
break;
|
|
|
|
case MCE_SEV_WARNING:
|
|
|
|
level = KERN_WARNING;
|
2019-04-30 02:15:55 +08:00
|
|
|
sevstr = "Warning";
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
2019-04-30 02:15:55 +08:00
|
|
|
case MCE_SEV_SEVERE:
|
2013-10-30 22:35:49 +08:00
|
|
|
level = KERN_ERR;
|
|
|
|
sevstr = "Severe";
|
|
|
|
break;
|
|
|
|
case MCE_SEV_FATAL:
|
|
|
|
default:
|
|
|
|
level = KERN_ERR;
|
|
|
|
sevstr = "Fatal";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-08-02 18:56:34 +08:00
|
|
|
switch(evt->initiator) {
|
|
|
|
case MCE_INITIATOR_CPU:
|
|
|
|
initiator = "CPU";
|
|
|
|
break;
|
|
|
|
case MCE_INITIATOR_PCI:
|
|
|
|
initiator = "PCI";
|
|
|
|
break;
|
|
|
|
case MCE_INITIATOR_ISA:
|
|
|
|
initiator = "ISA";
|
|
|
|
break;
|
|
|
|
case MCE_INITIATOR_MEMORY:
|
|
|
|
initiator = "Memory";
|
|
|
|
break;
|
|
|
|
case MCE_INITIATOR_POWERMGM:
|
|
|
|
initiator = "Power Management";
|
|
|
|
break;
|
|
|
|
case MCE_INITIATOR_UNKNOWN:
|
|
|
|
default:
|
|
|
|
initiator = "Unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-30 22:35:49 +08:00
|
|
|
switch (evt->error_type) {
|
|
|
|
case MCE_ERROR_TYPE_UE:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "UE";
|
2013-10-30 22:35:49 +08:00
|
|
|
subtype = evt->u.ue_error.ue_error_type <
|
|
|
|
ARRAY_SIZE(mc_ue_types) ?
|
|
|
|
mc_ue_types[evt->u.ue_error.ue_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.ue_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.ue_error.effective_address;
|
2013-10-30 22:35:49 +08:00
|
|
|
if (evt->u.ue_error.physical_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
pa = evt->u.ue_error.physical_address;
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_SLB:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "SLB";
|
2013-10-30 22:35:49 +08:00
|
|
|
subtype = evt->u.slb_error.slb_error_type <
|
|
|
|
ARRAY_SIZE(mc_slb_types) ?
|
|
|
|
mc_slb_types[evt->u.slb_error.slb_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.slb_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.slb_error.effective_address;
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_ERAT:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "ERAT";
|
2013-10-30 22:35:49 +08:00
|
|
|
subtype = evt->u.erat_error.erat_error_type <
|
|
|
|
ARRAY_SIZE(mc_erat_types) ?
|
|
|
|
mc_erat_types[evt->u.erat_error.erat_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.erat_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.erat_error.effective_address;
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_TLB:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "TLB";
|
2013-10-30 22:35:49 +08:00
|
|
|
subtype = evt->u.tlb_error.tlb_error_type <
|
|
|
|
ARRAY_SIZE(mc_tlb_types) ?
|
|
|
|
mc_tlb_types[evt->u.tlb_error.tlb_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.tlb_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.tlb_error.effective_address;
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
2017-02-28 10:00:48 +08:00
|
|
|
case MCE_ERROR_TYPE_USER:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "User";
|
2017-02-28 10:00:48 +08:00
|
|
|
subtype = evt->u.user_error.user_error_type <
|
|
|
|
ARRAY_SIZE(mc_user_types) ?
|
|
|
|
mc_user_types[evt->u.user_error.user_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.user_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.user_error.effective_address;
|
2017-02-28 10:00:48 +08:00
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_RA:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "Real address";
|
2017-02-28 10:00:48 +08:00
|
|
|
subtype = evt->u.ra_error.ra_error_type <
|
|
|
|
ARRAY_SIZE(mc_ra_types) ?
|
|
|
|
mc_ra_types[evt->u.ra_error.ra_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.ra_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.ra_error.effective_address;
|
2017-02-28 10:00:48 +08:00
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_LINK:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "Link";
|
2017-02-28 10:00:48 +08:00
|
|
|
subtype = evt->u.link_error.link_error_type <
|
|
|
|
ARRAY_SIZE(mc_link_types) ?
|
|
|
|
mc_link_types[evt->u.link_error.link_error_type]
|
|
|
|
: "Unknown";
|
|
|
|
if (evt->u.link_error.effective_address_provided)
|
2019-04-30 02:15:48 +08:00
|
|
|
ea = evt->u.link_error.effective_address;
|
2017-02-28 10:00:48 +08:00
|
|
|
break;
|
2019-08-02 18:56:34 +08:00
|
|
|
case MCE_ERROR_TYPE_DCACHE:
|
|
|
|
err_type = "D-Cache";
|
|
|
|
subtype = "Unknown";
|
|
|
|
break;
|
|
|
|
case MCE_ERROR_TYPE_ICACHE:
|
|
|
|
err_type = "I-Cache";
|
|
|
|
subtype = "Unknown";
|
|
|
|
break;
|
2013-10-30 22:35:49 +08:00
|
|
|
default:
|
|
|
|
case MCE_ERROR_TYPE_UNKNOWN:
|
2019-04-30 02:15:48 +08:00
|
|
|
err_type = "Unknown";
|
|
|
|
subtype = "";
|
2013-10-30 22:35:49 +08:00
|
|
|
break;
|
|
|
|
}
|
2019-04-30 02:15:48 +08:00
|
|
|
|
|
|
|
dar_str[0] = pa_str[0] = '\0';
|
|
|
|
if (ea && evt->srr0 != ea) {
|
|
|
|
/* Load/Store address */
|
|
|
|
n = sprintf(dar_str, "DAR: %016llx ", ea);
|
|
|
|
if (pa)
|
|
|
|
sprintf(dar_str + n, "paddr: %016llx ", pa);
|
|
|
|
} else if (pa) {
|
|
|
|
sprintf(pa_str, " paddr: %016llx", pa);
|
|
|
|
}
|
|
|
|
|
|
|
|
printk("%sMCE: CPU%d: machine check (%s) %s %s %s %s[%s]\n",
|
|
|
|
level, evt->cpu, sevstr, in_guest ? "Guest" : "Host",
|
|
|
|
err_type, subtype, dar_str,
|
|
|
|
evt->disposition == MCE_DISPOSITION_RECOVERED ?
|
|
|
|
"Recovered" : "Not recovered");
|
|
|
|
|
|
|
|
if (in_guest || user_mode) {
|
|
|
|
printk("%sMCE: CPU%d: PID: %d Comm: %s %sNIP: [%016llx]%s\n",
|
|
|
|
level, evt->cpu, current->pid, current->comm,
|
|
|
|
in_guest ? "Guest " : "", evt->srr0, pa_str);
|
|
|
|
} else {
|
|
|
|
printk("%sMCE: CPU%d: NIP: [%016llx] %pS%s\n",
|
|
|
|
level, evt->cpu, evt->srr0, (void *)evt->srr0, pa_str);
|
|
|
|
}
|
2019-04-30 02:16:02 +08:00
|
|
|
|
2019-08-02 18:56:34 +08:00
|
|
|
printk("%sMCE: CPU%d: Initiator %s\n", level, evt->cpu, initiator);
|
|
|
|
|
2019-04-30 02:16:02 +08:00
|
|
|
subtype = evt->error_class < ARRAY_SIZE(mc_error_class) ?
|
|
|
|
mc_error_class[evt->error_class] : "Unknown";
|
|
|
|
printk("%sMCE: CPU%d: %s\n", level, evt->cpu, subtype);
|
2019-08-02 18:56:33 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
|
|
|
/* Display faulty slb contents for SLB errors. */
|
|
|
|
if (evt->error_type == MCE_ERROR_TYPE_SLB)
|
|
|
|
slb_dump_contents(local_paca->mce_faulty_slbs);
|
|
|
|
#endif
|
2013-10-30 22:35:49 +08:00
|
|
|
}
|
2017-05-11 19:03:12 +08:00
|
|
|
EXPORT_SYMBOL_GPL(machine_check_print_event_info);
|
2013-10-30 22:36:13 +08:00
|
|
|
|
2017-08-08 14:39:24 +08:00
|
|
|
/*
|
|
|
|
* This function is called in real mode. Strictly no printk's please.
|
|
|
|
*
|
|
|
|
* regs->nip and regs->msr contains srr0 and ssr1.
|
|
|
|
*/
|
2020-05-08 12:34:05 +08:00
|
|
|
long notrace machine_check_early(struct pt_regs *regs)
|
2017-08-08 14:39:24 +08:00
|
|
|
{
|
|
|
|
long handled = 0;
|
2020-05-08 12:34:05 +08:00
|
|
|
u8 ftrace_enabled = this_cpu_get_ftrace_enabled();
|
|
|
|
|
|
|
|
this_cpu_set_ftrace_enabled(0);
|
2020-10-09 14:40:04 +08:00
|
|
|
/* Do not use nmi_enter/exit for pseries hpte guest */
|
|
|
|
if (radix_enabled() || !firmware_has_feature(FW_FEATURE_LPAR))
|
2020-05-08 12:34:03 +08:00
|
|
|
nmi_enter();
|
2017-08-08 14:39:24 +08:00
|
|
|
|
2019-02-26 16:51:07 +08:00
|
|
|
hv_nmi_check_nonrecoverable(regs);
|
|
|
|
|
2018-09-11 22:27:00 +08:00
|
|
|
/*
|
|
|
|
* See if platform is capable of handling machine check.
|
|
|
|
*/
|
|
|
|
if (ppc_md.machine_check_early)
|
|
|
|
handled = ppc_md.machine_check_early(regs);
|
2020-05-08 12:34:03 +08:00
|
|
|
|
2020-10-09 14:40:04 +08:00
|
|
|
if (radix_enabled() || !firmware_has_feature(FW_FEATURE_LPAR))
|
2020-05-08 12:34:03 +08:00
|
|
|
nmi_exit();
|
|
|
|
|
2020-05-08 12:34:05 +08:00
|
|
|
this_cpu_set_ftrace_enabled(ftrace_enabled);
|
|
|
|
|
2017-08-08 14:39:24 +08:00
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER). In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause. The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory. In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.
The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest. If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest. Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.
This adds code to determine explicitly what the cause of a debug
trigger HMI will be. This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code. If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.
The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.
This also removes a BUG_ON in the KVM code. BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-17 17:51:13 +08:00
|
|
|
/* Possible meanings for HMER_DEBUG_TRIG bit being set on POWER9 */
|
|
|
|
static enum {
|
|
|
|
DTRIG_UNKNOWN,
|
|
|
|
DTRIG_VECTOR_CI, /* need to emulate vector CI load instr */
|
|
|
|
DTRIG_SUSPEND_ESCAPE, /* need to escape from TM suspend mode */
|
|
|
|
} hmer_debug_trig_function;
|
|
|
|
|
|
|
|
static int init_debug_trig_function(void)
|
2017-08-08 14:39:24 +08:00
|
|
|
{
|
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER). In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause. The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory. In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.
The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest. If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest. Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.
This adds code to determine explicitly what the cause of a debug
trigger HMI will be. This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code. If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.
The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.
This also removes a BUG_ON in the KVM code. BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-17 17:51:13 +08:00
|
|
|
int pvr;
|
|
|
|
struct device_node *cpun;
|
|
|
|
struct property *prop = NULL;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
/* First look in the device tree */
|
|
|
|
preempt_disable();
|
|
|
|
cpun = of_get_cpu_node(smp_processor_id(), NULL);
|
|
|
|
if (cpun) {
|
|
|
|
of_property_for_each_string(cpun, "ibm,hmi-special-triggers",
|
|
|
|
prop, str) {
|
|
|
|
if (strcmp(str, "bit17-vector-ci-load") == 0)
|
|
|
|
hmer_debug_trig_function = DTRIG_VECTOR_CI;
|
|
|
|
else if (strcmp(str, "bit17-tm-suspend-escape") == 0)
|
|
|
|
hmer_debug_trig_function = DTRIG_SUSPEND_ESCAPE;
|
2017-09-15 13:25:48 +08:00
|
|
|
}
|
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER). In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause. The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory. In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.
The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest. If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest. Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.
This adds code to determine explicitly what the cause of a debug
trigger HMI will be. This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code. If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.
The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.
This also removes a BUG_ON in the KVM code. BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-17 17:51:13 +08:00
|
|
|
of_node_put(cpun);
|
|
|
|
}
|
|
|
|
preempt_enable();
|
|
|
|
|
|
|
|
/* If we found the property, don't look at PVR */
|
|
|
|
if (prop)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
pvr = mfspr(SPRN_PVR);
|
|
|
|
/* Check for POWER9 Nimbus (scale-out) */
|
|
|
|
if ((PVR_VER(pvr) == PVR_POWER9) && (pvr & 0xe000) == 0) {
|
|
|
|
/* DD2.2 and later */
|
|
|
|
if ((pvr & 0xfff) >= 0x202)
|
|
|
|
hmer_debug_trig_function = DTRIG_SUSPEND_ESCAPE;
|
|
|
|
/* DD2.0 and DD2.1 - used for vector CI load emulation */
|
|
|
|
else if ((pvr & 0xfff) >= 0x200)
|
|
|
|
hmer_debug_trig_function = DTRIG_VECTOR_CI;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
switch (hmer_debug_trig_function) {
|
|
|
|
case DTRIG_VECTOR_CI:
|
|
|
|
pr_debug("HMI debug trigger used for vector CI load\n");
|
|
|
|
break;
|
|
|
|
case DTRIG_SUSPEND_ESCAPE:
|
|
|
|
pr_debug("HMI debug trigger used for TM suspend escape\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-09-15 13:25:48 +08:00
|
|
|
}
|
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER). In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause. The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory. In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.
The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest. If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest. Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.
This adds code to determine explicitly what the cause of a debug
trigger HMI will be. This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code. If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.
The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.
This also removes a BUG_ON in the KVM code. BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-17 17:51:13 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
__initcall(init_debug_trig_function);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle HMIs that occur as a result of a debug trigger.
|
|
|
|
* Return values:
|
|
|
|
* -1 means this is not a HMI cause that we know about
|
|
|
|
* 0 means no further handling is required
|
|
|
|
* 1 means further handling is required
|
|
|
|
*/
|
|
|
|
long hmi_handle_debugtrig(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
unsigned long hmer = mfspr(SPRN_HMER);
|
|
|
|
long ret = 0;
|
|
|
|
|
|
|
|
/* HMER_DEBUG_TRIG bit is used for various workarounds on P9 */
|
|
|
|
if (!((hmer & HMER_DEBUG_TRIG)
|
|
|
|
&& hmer_debug_trig_function != DTRIG_UNKNOWN))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
hmer &= ~HMER_DEBUG_TRIG;
|
|
|
|
/* HMER is a write-AND register */
|
|
|
|
mtspr(SPRN_HMER, ~HMER_DEBUG_TRIG);
|
|
|
|
|
|
|
|
switch (hmer_debug_trig_function) {
|
|
|
|
case DTRIG_VECTOR_CI:
|
|
|
|
/*
|
|
|
|
* Now to avoid problems with soft-disable we
|
|
|
|
* only do the emulation if we are coming from
|
|
|
|
* host user space
|
|
|
|
*/
|
|
|
|
if (regs && user_mode(regs))
|
|
|
|
ret = local_paca->hmi_p9_special_emu = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if any other HMI causes remain to be handled
|
|
|
|
*/
|
|
|
|
if (hmer & mfspr(SPRN_HMEER))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return values:
|
|
|
|
*/
|
|
|
|
long hmi_exception_realmode(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2020-06-23 18:27:50 +08:00
|
|
|
local_paca->hmi_irqs++;
|
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER). In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause. The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory. In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.
The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest. If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest. Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.
This adds code to determine explicitly what the cause of a debug
trigger HMI will be. This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code. If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.
The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.
This also removes a BUG_ON in the KVM code. BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-17 17:51:13 +08:00
|
|
|
|
|
|
|
ret = hmi_handle_debugtrig(regs);
|
|
|
|
if (ret >= 0)
|
|
|
|
return ret;
|
2017-09-15 13:25:48 +08:00
|
|
|
|
2017-08-08 14:39:24 +08:00
|
|
|
wait_for_subcore_guest_exit();
|
|
|
|
|
|
|
|
if (ppc_md.hmi_exception_early)
|
|
|
|
ppc_md.hmi_exception_early(regs);
|
|
|
|
|
|
|
|
wait_for_tb_resync();
|
|
|
|
|
2017-09-15 13:25:48 +08:00
|
|
|
return 1;
|
2017-08-08 14:39:24 +08:00
|
|
|
}
|