mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 18:26:40 +07:00
5080332c2c
POWER9 DD2.1 and earlier has an issue where some cache inhibited vector load will return bad data. The workaround is two part, one firmware/microcode part triggers HMI interrupts when hitting such loads, the other part is this patch which then emulates the instructions in Linux. The affected instructions are limited to lxvd2x, lxvw4x, lxvb16x and lxvh8x. When an instruction triggers the HMI, all threads in the core will be sent to the HMI handler, not just the one running the vector load. In general, these spurious HMIs are detected by the emulation code and we just return back to the running process. Unfortunately, if a spurious interrupt occurs on a vector load that's to normal memory we have no way to detect that it's spurious (unless we walk the page tables, which is very expensive). In this case we emulate the load but we need do so using a vector load itself to ensure 128bit atomicity is preserved. Some additional debugfs emulated instruction counters are added also. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [mpe: Switch CONFIG_PPC_BOOK3S_64 to CONFIG_VSX to unbreak the build] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
97 lines
2.6 KiB
C
97 lines
2.6 KiB
C
/*
|
|
* Copyright 2007 Sony Corporation
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program.
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _ASM_POWERPC_EMULATED_OPS_H
|
|
#define _ASM_POWERPC_EMULATED_OPS_H
|
|
|
|
#include <linux/atomic.h>
|
|
#include <linux/perf_event.h>
|
|
|
|
|
|
#ifdef CONFIG_PPC_EMULATED_STATS
|
|
|
|
struct ppc_emulated_entry {
|
|
const char *name;
|
|
atomic_t val;
|
|
};
|
|
|
|
extern struct ppc_emulated {
|
|
#ifdef CONFIG_ALTIVEC
|
|
struct ppc_emulated_entry altivec;
|
|
#endif
|
|
struct ppc_emulated_entry dcba;
|
|
struct ppc_emulated_entry dcbz;
|
|
struct ppc_emulated_entry fp_pair;
|
|
struct ppc_emulated_entry isel;
|
|
struct ppc_emulated_entry mcrxr;
|
|
struct ppc_emulated_entry mfpvr;
|
|
struct ppc_emulated_entry multiple;
|
|
struct ppc_emulated_entry popcntb;
|
|
struct ppc_emulated_entry spe;
|
|
struct ppc_emulated_entry string;
|
|
struct ppc_emulated_entry sync;
|
|
struct ppc_emulated_entry unaligned;
|
|
#ifdef CONFIG_MATH_EMULATION
|
|
struct ppc_emulated_entry math;
|
|
#endif
|
|
#ifdef CONFIG_VSX
|
|
struct ppc_emulated_entry vsx;
|
|
#endif
|
|
#ifdef CONFIG_PPC64
|
|
struct ppc_emulated_entry mfdscr;
|
|
struct ppc_emulated_entry mtdscr;
|
|
struct ppc_emulated_entry lq_stq;
|
|
struct ppc_emulated_entry lxvw4x;
|
|
struct ppc_emulated_entry lxvh8x;
|
|
struct ppc_emulated_entry lxvd2x;
|
|
struct ppc_emulated_entry lxvb16x;
|
|
#endif
|
|
} ppc_emulated;
|
|
|
|
extern u32 ppc_warn_emulated;
|
|
|
|
extern void ppc_warn_emulated_print(const char *type);
|
|
|
|
#define __PPC_WARN_EMULATED(type) \
|
|
do { \
|
|
atomic_inc(&ppc_emulated.type.val); \
|
|
if (ppc_warn_emulated) \
|
|
ppc_warn_emulated_print(ppc_emulated.type.name); \
|
|
} while (0)
|
|
|
|
#else /* !CONFIG_PPC_EMULATED_STATS */
|
|
|
|
#define __PPC_WARN_EMULATED(type) do { } while (0)
|
|
|
|
#endif /* !CONFIG_PPC_EMULATED_STATS */
|
|
|
|
#define PPC_WARN_EMULATED(type, regs) \
|
|
do { \
|
|
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, \
|
|
1, regs, 0); \
|
|
__PPC_WARN_EMULATED(type); \
|
|
} while (0)
|
|
|
|
#define PPC_WARN_ALIGNMENT(type, regs) \
|
|
do { \
|
|
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, \
|
|
1, regs, regs->dar); \
|
|
__PPC_WARN_EMULATED(type); \
|
|
} while (0)
|
|
|
|
#endif /* _ASM_POWERPC_EMULATED_OPS_H */
|