···17#include <asm/uaccess.h>18#include <linux/smp.h>19#include <linux/smp_lock.h>20+#include <linux/perf_event.h>02122enum direction {23 load, /* ld, ldd, ldh, ldsh */···28 fpstore,29 invalid,30};0000003132static inline enum direction decode_direction(unsigned int insn)33{···255 unsigned long addr = compute_effective_address(regs, insn);256 int err;257258+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);000259 switch (dir) {260 case load:261 err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),···350 }351352 addr = compute_effective_address(regs, insn);353+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);354 switch(dir) {355 case load:356 err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
+9-14
arch/sparc/kernel/unaligned_64.c
···20#include <asm/uaccess.h>21#include <linux/smp.h>22#include <linux/bitops.h>023#include <asm/fpumacro.h>24-25-/* #define DEBUG_MNA */2627enum direction {28 load, /* ld, ldd, ldh, ldsh */···31 fpst,32 invalid,33};34-35-#ifdef DEBUG_MNA36-static char *dirstrings[] = {37- "load", "store", "both", "fpload", "fpstore", "invalid"38-};39-#endif4041static inline enum direction decode_direction(unsigned int insn)42{···320321 addr = compute_effective_address(regs, insn,322 ((insn >> 25) & 0x1f));323-#ifdef DEBUG_MNA324- printk("KMNA: pc=%016lx [dir=%s addr=%016lx size=%d] "325- "retpc[%016lx]\n",326- regs->tpc, dirstrings[dir], addr, size,327- regs->u_regs[UREG_RETPC]);328-#endif329 switch (asi) {330 case ASI_NL:331 case ASI_AIUPL:···387 int ret, i, rd = ((insn >> 25) & 0x1f);388 int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;3890390 if (insn & 0x2000) {391 maybe_flush_windows(0, 0, rd, from_kernel);392 value = sign_extend_imm13(insn);···433 struct fpustate *f = FPUSTATE;434 int asi = decode_asi(insn, regs);435 int flag = (freg < 32) ? FPRS_DL : FPRS_DU;00436437 save_and_clear_fpu();438 current_thread_info()->xfsr[0] &= ~0x1c000;···557 int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;558 unsigned long *reg;55900560 maybe_flush_windows(0, 0, rd, from_kernel);561 reg = fetch_reg_addr(rd, regs);562 if (from_kernel || rd < 16) {···589590 if (tstate & TSTATE_PRIV)591 die_if_kernel("lddfmna from kernel", regs);0592 if (test_thread_flag(TIF_32BIT))593 pc = (u32)pc;594 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {···651652 if (tstate & TSTATE_PRIV)653 die_if_kernel("stdfmna from kernel", regs);0654 if (test_thread_flag(TIF_32BIT))655 pc = (u32)pc;656 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
···20#include <asm/uaccess.h>21#include <linux/smp.h>22#include <linux/bitops.h>23+#include <linux/perf_event.h>24#include <asm/fpumacro.h>002526enum direction {27 load, /* ld, ldd, ldh, ldsh */···32 fpst,33 invalid,34};0000003536static inline enum direction decode_direction(unsigned int insn)37{···327328 addr = compute_effective_address(regs, insn,329 ((insn >> 25) & 0x1f));330+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);00000331 switch (asi) {332 case ASI_NL:333 case ASI_AIUPL:···399 int ret, i, rd = ((insn >> 25) & 0x1f);400 int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;401402+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);403 if (insn & 0x2000) {404 maybe_flush_windows(0, 0, rd, from_kernel);405 value = sign_extend_imm13(insn);···444 struct fpustate *f = FPUSTATE;445 int asi = decode_asi(insn, regs);446 int flag = (freg < 32) ? FPRS_DL : FPRS_DU;447+448+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);449450 save_and_clear_fpu();451 current_thread_info()->xfsr[0] &= ~0x1c000;···566 int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;567 unsigned long *reg;568569+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);570+571 maybe_flush_windows(0, 0, rd, from_kernel);572 reg = fetch_reg_addr(rd, regs);573 if (from_kernel || rd < 16) {···596597 if (tstate & TSTATE_PRIV)598 die_if_kernel("lddfmna from kernel", regs);599+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);600 if (test_thread_flag(TIF_32BIT))601 pc = (u32)pc;602 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {···657658 if (tstate & TSTATE_PRIV)659 die_if_kernel("stdfmna from kernel", regs);660+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);661 if (test_thread_flag(TIF_32BIT))662 pc = (u32)pc;663 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
+3
arch/sparc/kernel/visemul.c
···5#include <linux/kernel.h>6#include <linux/errno.h>7#include <linux/thread_info.h>089#include <asm/ptrace.h>10#include <asm/pstate.h>···801 unsigned int opf;802803 BUG_ON(regs->tstate & TSTATE_PRIV);00804805 if (test_thread_flag(TIF_32BIT))806 pc = (u32)pc;
···5#include <linux/kernel.h>6#include <linux/errno.h>7#include <linux/thread_info.h>8+#include <linux/perf_event.h>910#include <asm/ptrace.h>11#include <asm/pstate.h>···800 unsigned int opf;801802 BUG_ON(regs->tstate & TSTATE_PRIV);803+804+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);805806 if (test_thread_flag(TIF_32BIT))807 pc = (u32)pc;
+3
arch/sparc/math-emu/math_32.c
···67#include <linux/types.h>68#include <linux/sched.h>69#include <linux/mm.h>070#include <asm/uaccess.h>7172#include "sfp-util_32.h"···163 int i;164 int retcode = 0; /* assume all succeed */165 unsigned long insn;00166167#ifdef DEBUG_MATHEMU168 printk("In do_mathemu()... pc is %08lx\n", regs->pc);
···67#include <linux/types.h>68#include <linux/sched.h>69#include <linux/mm.h>70+#include <linux/perf_event.h>71#include <asm/uaccess.h>7273#include "sfp-util_32.h"···162 int i;163 int retcode = 0; /* assume all succeed */164 unsigned long insn;165+166+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);167168#ifdef DEBUG_MATHEMU169 printk("In do_mathemu()... pc is %08lx\n", regs->pc);
+2
arch/sparc/math-emu/math_64.c
···11#include <linux/types.h>12#include <linux/sched.h>13#include <linux/errno.h>01415#include <asm/fpumacro.h>16#include <asm/ptrace.h>···184185 if (tstate & TSTATE_PRIV)186 die_if_kernel("unfinished/unimplemented FPop from kernel", regs);0187 if (test_thread_flag(TIF_32BIT))188 pc = (u32)pc;189 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
···11#include <linux/types.h>12#include <linux/sched.h>13#include <linux/errno.h>14+#include <linux/perf_event.h>1516#include <asm/fpumacro.h>17#include <asm/ptrace.h>···183184 if (tstate & TSTATE_PRIV)185 die_if_kernel("unfinished/unimplemented FPop from kernel", regs);186+ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);187 if (test_thread_flag(TIF_32BIT))188 pc = (u32)pc;189 if (get_user(insn, (u32 __user *) pc) != -EFAULT) {