12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
24ceae137SRavi Bangoria /*
384022ac1SSandipan Das * Simple sanity tests for instruction emulation infrastructure.
44ceae137SRavi Bangoria *
54ceae137SRavi Bangoria * Copyright IBM Corp. 2016
64ceae137SRavi Bangoria */
74ceae137SRavi Bangoria
84ceae137SRavi Bangoria #define pr_fmt(fmt) "emulate_step_test: " fmt
94ceae137SRavi Bangoria
104ceae137SRavi Bangoria #include <linux/ptrace.h>
1170cc062cSMichael Ellerman #include <asm/cpu_has_feature.h>
124ceae137SRavi Bangoria #include <asm/sstep.h>
134ceae137SRavi Bangoria #include <asm/ppc-opcode.h>
1484022ac1SSandipan Das #include <asm/code-patching.h>
1575346251SJordan Niethe #include <asm/inst.h>
164ceae137SRavi Bangoria
1784022ac1SSandipan Das #define MAX_SUBTESTS 16
1884022ac1SSandipan Das
1984022ac1SSandipan Das #define IGNORE_GPR(n) (0x1UL << (n))
2084022ac1SSandipan Das #define IGNORE_XER (0x1UL << 32)
2184022ac1SSandipan Das #define IGNORE_CCR (0x1UL << 33)
2293c3a0baSBalamuruhan S #define NEGATIVE_TEST (0x1UL << 63)
234ceae137SRavi Bangoria
24b6b54b42SJordan Niethe #define TEST_PLD(r, base, i, pr) \
25b6b54b42SJordan Niethe ppc_inst_prefix(PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_H(i), \
26b6b54b42SJordan Niethe PPC_INST_PLD | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
27b6b54b42SJordan Niethe
28b6b54b42SJordan Niethe #define TEST_PLWZ(r, base, i, pr) \
29b6b54b42SJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
30b6b54b42SJordan Niethe PPC_RAW_LWZ(r, base, i))
31b6b54b42SJordan Niethe
32b6b54b42SJordan Niethe #define TEST_PSTD(r, base, i, pr) \
33b6b54b42SJordan Niethe ppc_inst_prefix(PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_H(i), \
34b6b54b42SJordan Niethe PPC_INST_PSTD | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
35b6b54b42SJordan Niethe
360396de6dSJordan Niethe #define TEST_PLFS(r, base, i, pr) \
370396de6dSJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
380396de6dSJordan Niethe PPC_INST_LFS | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
390396de6dSJordan Niethe
400396de6dSJordan Niethe #define TEST_PSTFS(r, base, i, pr) \
410396de6dSJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
420396de6dSJordan Niethe PPC_INST_STFS | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
430396de6dSJordan Niethe
440396de6dSJordan Niethe #define TEST_PLFD(r, base, i, pr) \
450396de6dSJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
460396de6dSJordan Niethe PPC_INST_LFD | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
470396de6dSJordan Niethe
480396de6dSJordan Niethe #define TEST_PSTFD(r, base, i, pr) \
490396de6dSJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
500396de6dSJordan Niethe PPC_INST_STFD | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))
510396de6dSJordan Niethe
524f825900SJordan Niethe #define TEST_PADDI(t, a, i, pr) \
534f825900SJordan Niethe ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
544f825900SJordan Niethe PPC_RAW_ADDI(t, a, i))
554f825900SJordan Niethe
init_pt_regs(struct pt_regs * regs)564ceae137SRavi Bangoria static void __init init_pt_regs(struct pt_regs *regs)
574ceae137SRavi Bangoria {
584ceae137SRavi Bangoria static unsigned long msr;
594ceae137SRavi Bangoria static bool msr_cached;
604ceae137SRavi Bangoria
614ceae137SRavi Bangoria memset(regs, 0, sizeof(struct pt_regs));
624ceae137SRavi Bangoria
634ceae137SRavi Bangoria if (likely(msr_cached)) {
644ceae137SRavi Bangoria regs->msr = msr;
654ceae137SRavi Bangoria return;
664ceae137SRavi Bangoria }
674ceae137SRavi Bangoria
684ceae137SRavi Bangoria asm volatile("mfmsr %0" : "=r"(regs->msr));
694ceae137SRavi Bangoria
704ceae137SRavi Bangoria regs->msr |= MSR_FP;
714ceae137SRavi Bangoria regs->msr |= MSR_VEC;
724ceae137SRavi Bangoria regs->msr |= MSR_VSX;
734ceae137SRavi Bangoria
744ceae137SRavi Bangoria msr = regs->msr;
754ceae137SRavi Bangoria msr_cached = true;
764ceae137SRavi Bangoria }
774ceae137SRavi Bangoria
show_result(char * mnemonic,char * result)7884022ac1SSandipan Das static void __init show_result(char *mnemonic, char *result)
794ceae137SRavi Bangoria {
8084022ac1SSandipan Das pr_info("%-14s : %s\n", mnemonic, result);
8184022ac1SSandipan Das }
8284022ac1SSandipan Das
show_result_with_descr(char * mnemonic,char * descr,char * result)8384022ac1SSandipan Das static void __init show_result_with_descr(char *mnemonic, char *descr,
8484022ac1SSandipan Das char *result)
8584022ac1SSandipan Das {
8684022ac1SSandipan Das pr_info("%-14s : %-50s %s\n", mnemonic, descr, result);
874ceae137SRavi Bangoria }
884ceae137SRavi Bangoria
test_ld(void)894ceae137SRavi Bangoria static void __init test_ld(void)
904ceae137SRavi Bangoria {
914ceae137SRavi Bangoria struct pt_regs regs;
924ceae137SRavi Bangoria unsigned long a = 0x23;
934ceae137SRavi Bangoria int stepped = -1;
944ceae137SRavi Bangoria
954ceae137SRavi Bangoria init_pt_regs(®s);
964ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a;
974ceae137SRavi Bangoria
984ceae137SRavi Bangoria /* ld r5, 0(r3) */
991d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LD(5, 3, 0)));
1004ceae137SRavi Bangoria
1014ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a)
1024ceae137SRavi Bangoria show_result("ld", "PASS");
1034ceae137SRavi Bangoria else
1044ceae137SRavi Bangoria show_result("ld", "FAIL");
1054ceae137SRavi Bangoria }
1064ceae137SRavi Bangoria
test_pld(void)107b6b54b42SJordan Niethe static void __init test_pld(void)
108b6b54b42SJordan Niethe {
109b6b54b42SJordan Niethe struct pt_regs regs;
110b6b54b42SJordan Niethe unsigned long a = 0x23;
111b6b54b42SJordan Niethe int stepped = -1;
112b6b54b42SJordan Niethe
113b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
114b6b54b42SJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)");
115b6b54b42SJordan Niethe return;
116b6b54b42SJordan Niethe }
117b6b54b42SJordan Niethe
118b6b54b42SJordan Niethe init_pt_regs(®s);
119b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a;
120b6b54b42SJordan Niethe
121b6b54b42SJordan Niethe /* pld r5, 0(r3), 0 */
122b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLD(5, 3, 0, 0));
123b6b54b42SJordan Niethe
124b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a)
125b6b54b42SJordan Niethe show_result("pld", "PASS");
126b6b54b42SJordan Niethe else
127b6b54b42SJordan Niethe show_result("pld", "FAIL");
128b6b54b42SJordan Niethe }
129b6b54b42SJordan Niethe
test_lwz(void)1304ceae137SRavi Bangoria static void __init test_lwz(void)
1314ceae137SRavi Bangoria {
1324ceae137SRavi Bangoria struct pt_regs regs;
1334ceae137SRavi Bangoria unsigned int a = 0x4545;
1344ceae137SRavi Bangoria int stepped = -1;
1354ceae137SRavi Bangoria
1364ceae137SRavi Bangoria init_pt_regs(®s);
1374ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a;
1384ceae137SRavi Bangoria
1394ceae137SRavi Bangoria /* lwz r5, 0(r3) */
1401d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZ(5, 3, 0)));
1414ceae137SRavi Bangoria
1424ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a)
1434ceae137SRavi Bangoria show_result("lwz", "PASS");
1444ceae137SRavi Bangoria else
1454ceae137SRavi Bangoria show_result("lwz", "FAIL");
1464ceae137SRavi Bangoria }
1474ceae137SRavi Bangoria
test_plwz(void)148b6b54b42SJordan Niethe static void __init test_plwz(void)
149b6b54b42SJordan Niethe {
150b6b54b42SJordan Niethe struct pt_regs regs;
151b6b54b42SJordan Niethe unsigned int a = 0x4545;
152b6b54b42SJordan Niethe int stepped = -1;
153b6b54b42SJordan Niethe
154b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
155b6b54b42SJordan Niethe show_result("plwz", "SKIP (!CPU_FTR_ARCH_31)");
156b6b54b42SJordan Niethe return;
157b6b54b42SJordan Niethe }
158b6b54b42SJordan Niethe
159b6b54b42SJordan Niethe init_pt_regs(®s);
160b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a;
161b6b54b42SJordan Niethe
162b6b54b42SJordan Niethe /* plwz r5, 0(r3), 0 */
163b6b54b42SJordan Niethe
164b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLWZ(5, 3, 0, 0));
165b6b54b42SJordan Niethe
166b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a)
167b6b54b42SJordan Niethe show_result("plwz", "PASS");
168b6b54b42SJordan Niethe else
169b6b54b42SJordan Niethe show_result("plwz", "FAIL");
170b6b54b42SJordan Niethe }
171b6b54b42SJordan Niethe
test_lwzx(void)1724ceae137SRavi Bangoria static void __init test_lwzx(void)
1734ceae137SRavi Bangoria {
1744ceae137SRavi Bangoria struct pt_regs regs;
1754ceae137SRavi Bangoria unsigned int a[3] = {0x0, 0x0, 0x1234};
1764ceae137SRavi Bangoria int stepped = -1;
1774ceae137SRavi Bangoria
1784ceae137SRavi Bangoria init_pt_regs(®s);
1794ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) a;
1804ceae137SRavi Bangoria regs.gpr[4] = 8;
1814ceae137SRavi Bangoria regs.gpr[5] = 0x8765;
1824ceae137SRavi Bangoria
1834ceae137SRavi Bangoria /* lwzx r5, r3, r4 */
1841d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZX(5, 3, 4)));
1854ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a[2])
1864ceae137SRavi Bangoria show_result("lwzx", "PASS");
1874ceae137SRavi Bangoria else
1884ceae137SRavi Bangoria show_result("lwzx", "FAIL");
1894ceae137SRavi Bangoria }
1904ceae137SRavi Bangoria
test_std(void)1914ceae137SRavi Bangoria static void __init test_std(void)
1924ceae137SRavi Bangoria {
1934ceae137SRavi Bangoria struct pt_regs regs;
1944ceae137SRavi Bangoria unsigned long a = 0x1234;
1954ceae137SRavi Bangoria int stepped = -1;
1964ceae137SRavi Bangoria
1974ceae137SRavi Bangoria init_pt_regs(®s);
1984ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a;
1994ceae137SRavi Bangoria regs.gpr[5] = 0x5678;
2004ceae137SRavi Bangoria
2014ceae137SRavi Bangoria /* std r5, 0(r3) */
2021d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STD(5, 3, 0)));
20359ed2adfSNicholas Piggin if (stepped == 1 && regs.gpr[5] == a)
2044ceae137SRavi Bangoria show_result("std", "PASS");
2054ceae137SRavi Bangoria else
2064ceae137SRavi Bangoria show_result("std", "FAIL");
2074ceae137SRavi Bangoria }
2084ceae137SRavi Bangoria
test_pstd(void)209b6b54b42SJordan Niethe static void __init test_pstd(void)
210b6b54b42SJordan Niethe {
211b6b54b42SJordan Niethe struct pt_regs regs;
212b6b54b42SJordan Niethe unsigned long a = 0x1234;
213b6b54b42SJordan Niethe int stepped = -1;
214b6b54b42SJordan Niethe
215b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
216b6b54b42SJordan Niethe show_result("pstd", "SKIP (!CPU_FTR_ARCH_31)");
217b6b54b42SJordan Niethe return;
218b6b54b42SJordan Niethe }
219b6b54b42SJordan Niethe
220b6b54b42SJordan Niethe init_pt_regs(®s);
221b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a;
222b6b54b42SJordan Niethe regs.gpr[5] = 0x5678;
223b6b54b42SJordan Niethe
224b6b54b42SJordan Niethe /* pstd r5, 0(r3), 0 */
225b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PSTD(5, 3, 0, 0));
226b6b54b42SJordan Niethe if (stepped == 1 || regs.gpr[5] == a)
227b6b54b42SJordan Niethe show_result("pstd", "PASS");
228b6b54b42SJordan Niethe else
229b6b54b42SJordan Niethe show_result("pstd", "FAIL");
230b6b54b42SJordan Niethe }
231b6b54b42SJordan Niethe
test_ldarx_stdcx(void)2324ceae137SRavi Bangoria static void __init test_ldarx_stdcx(void)
2334ceae137SRavi Bangoria {
2344ceae137SRavi Bangoria struct pt_regs regs;
2354ceae137SRavi Bangoria unsigned long a = 0x1234;
2364ceae137SRavi Bangoria int stepped = -1;
2374ceae137SRavi Bangoria unsigned long cr0_eq = 0x1 << 29; /* eq bit of CR0 */
2384ceae137SRavi Bangoria
2394ceae137SRavi Bangoria init_pt_regs(®s);
2404ceae137SRavi Bangoria asm volatile("mfcr %0" : "=r"(regs.ccr));
2414ceae137SRavi Bangoria
2424ceae137SRavi Bangoria
2434ceae137SRavi Bangoria /*** ldarx ***/
2444ceae137SRavi Bangoria
2454ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a;
2464ceae137SRavi Bangoria regs.gpr[4] = 0;
2474ceae137SRavi Bangoria regs.gpr[5] = 0x5678;
2484ceae137SRavi Bangoria
2494ceae137SRavi Bangoria /* ldarx r5, r3, r4, 0 */
2501d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LDARX(5, 3, 4, 0)));
2514ceae137SRavi Bangoria
2524ceae137SRavi Bangoria /*
2534ceae137SRavi Bangoria * Don't touch 'a' here. Touching 'a' can do Load/store
2544ceae137SRavi Bangoria * of 'a' which result in failure of subsequent stdcx.
2554ceae137SRavi Bangoria * Instead, use hardcoded value for comparison.
2564ceae137SRavi Bangoria */
2574ceae137SRavi Bangoria if (stepped <= 0 || regs.gpr[5] != 0x1234) {
2584ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (ldarx)");
2594ceae137SRavi Bangoria return;
2604ceae137SRavi Bangoria }
2614ceae137SRavi Bangoria
2624ceae137SRavi Bangoria
2634ceae137SRavi Bangoria /*** stdcx. ***/
2644ceae137SRavi Bangoria
2654ceae137SRavi Bangoria regs.gpr[5] = 0x9ABC;
2664ceae137SRavi Bangoria
2674ceae137SRavi Bangoria /* stdcx. r5, r3, r4 */
2681d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STDCX(5, 3, 4)));
2694ceae137SRavi Bangoria
2704ceae137SRavi Bangoria /*
2714ceae137SRavi Bangoria * Two possible scenarios that indicates successful emulation
2724ceae137SRavi Bangoria * of stdcx. :
2734ceae137SRavi Bangoria * 1. Reservation is active and store is performed. In this
2744ceae137SRavi Bangoria * case cr0.eq bit will be set to 1.
2754ceae137SRavi Bangoria * 2. Reservation is not active and store is not performed.
2764ceae137SRavi Bangoria * In this case cr0.eq bit will be set to 0.
2774ceae137SRavi Bangoria */
2784ceae137SRavi Bangoria if (stepped == 1 && ((regs.gpr[5] == a && (regs.ccr & cr0_eq))
2794ceae137SRavi Bangoria || (regs.gpr[5] != a && !(regs.ccr & cr0_eq))))
2804ceae137SRavi Bangoria show_result("ldarx / stdcx.", "PASS");
2814ceae137SRavi Bangoria else
2824ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (stdcx.)");
2834ceae137SRavi Bangoria }
2844ceae137SRavi Bangoria
2854ceae137SRavi Bangoria #ifdef CONFIG_PPC_FPU
test_lfsx_stfsx(void)2864ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void)
2874ceae137SRavi Bangoria {
2884ceae137SRavi Bangoria struct pt_regs regs;
2894ceae137SRavi Bangoria union {
2904ceae137SRavi Bangoria float a;
2914ceae137SRavi Bangoria int b;
2924ceae137SRavi Bangoria } c;
2934ceae137SRavi Bangoria int cached_b;
2944ceae137SRavi Bangoria int stepped = -1;
2954ceae137SRavi Bangoria
2964ceae137SRavi Bangoria init_pt_regs(®s);
2974ceae137SRavi Bangoria
2984ceae137SRavi Bangoria
2994ceae137SRavi Bangoria /*** lfsx ***/
3004ceae137SRavi Bangoria
3014ceae137SRavi Bangoria c.a = 123.45;
3024ceae137SRavi Bangoria cached_b = c.b;
3034ceae137SRavi Bangoria
3044ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a;
3054ceae137SRavi Bangoria regs.gpr[4] = 0;
3064ceae137SRavi Bangoria
3074ceae137SRavi Bangoria /* lfsx frt10, r3, r4 */
3081d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFSX(10, 3, 4)));
3094ceae137SRavi Bangoria
3104ceae137SRavi Bangoria if (stepped == 1)
3114ceae137SRavi Bangoria show_result("lfsx", "PASS");
3124ceae137SRavi Bangoria else
3134ceae137SRavi Bangoria show_result("lfsx", "FAIL");
3144ceae137SRavi Bangoria
3154ceae137SRavi Bangoria
3164ceae137SRavi Bangoria /*** stfsx ***/
3174ceae137SRavi Bangoria
3184ceae137SRavi Bangoria c.a = 678.91;
3194ceae137SRavi Bangoria
3204ceae137SRavi Bangoria /* stfsx frs10, r3, r4 */
3211d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFSX(10, 3, 4)));
3224ceae137SRavi Bangoria
3234ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b)
3244ceae137SRavi Bangoria show_result("stfsx", "PASS");
3254ceae137SRavi Bangoria else
3264ceae137SRavi Bangoria show_result("stfsx", "FAIL");
3274ceae137SRavi Bangoria }
3284ceae137SRavi Bangoria
test_plfs_pstfs(void)3290396de6dSJordan Niethe static void __init test_plfs_pstfs(void)
3300396de6dSJordan Niethe {
3310396de6dSJordan Niethe struct pt_regs regs;
3320396de6dSJordan Niethe union {
3330396de6dSJordan Niethe float a;
3340396de6dSJordan Niethe int b;
3350396de6dSJordan Niethe } c;
3360396de6dSJordan Niethe int cached_b;
3370396de6dSJordan Niethe int stepped = -1;
3380396de6dSJordan Niethe
3390396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
3400396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)");
3410396de6dSJordan Niethe return;
3420396de6dSJordan Niethe }
3430396de6dSJordan Niethe
3440396de6dSJordan Niethe init_pt_regs(®s);
3450396de6dSJordan Niethe
3460396de6dSJordan Niethe
3470396de6dSJordan Niethe /*** plfs ***/
3480396de6dSJordan Niethe
3490396de6dSJordan Niethe c.a = 123.45;
3500396de6dSJordan Niethe cached_b = c.b;
3510396de6dSJordan Niethe
3520396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a;
3530396de6dSJordan Niethe
3540396de6dSJordan Niethe /* plfs frt10, 0(r3), 0 */
3550396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFS(10, 3, 0, 0));
3560396de6dSJordan Niethe
3570396de6dSJordan Niethe if (stepped == 1)
3580396de6dSJordan Niethe show_result("plfs", "PASS");
3590396de6dSJordan Niethe else
3600396de6dSJordan Niethe show_result("plfs", "FAIL");
3610396de6dSJordan Niethe
3620396de6dSJordan Niethe
3630396de6dSJordan Niethe /*** pstfs ***/
3640396de6dSJordan Niethe
3650396de6dSJordan Niethe c.a = 678.91;
3660396de6dSJordan Niethe
3670396de6dSJordan Niethe /* pstfs frs10, 0(r3), 0 */
3680396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFS(10, 3, 0, 0));
3690396de6dSJordan Niethe
3700396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b)
3710396de6dSJordan Niethe show_result("pstfs", "PASS");
3720396de6dSJordan Niethe else
3730396de6dSJordan Niethe show_result("pstfs", "FAIL");
3740396de6dSJordan Niethe }
3750396de6dSJordan Niethe
test_lfdx_stfdx(void)3764ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void)
3774ceae137SRavi Bangoria {
3784ceae137SRavi Bangoria struct pt_regs regs;
3794ceae137SRavi Bangoria union {
3804ceae137SRavi Bangoria double a;
3814ceae137SRavi Bangoria long b;
3824ceae137SRavi Bangoria } c;
3834ceae137SRavi Bangoria long cached_b;
3844ceae137SRavi Bangoria int stepped = -1;
3854ceae137SRavi Bangoria
3864ceae137SRavi Bangoria init_pt_regs(®s);
3874ceae137SRavi Bangoria
3884ceae137SRavi Bangoria
3894ceae137SRavi Bangoria /*** lfdx ***/
3904ceae137SRavi Bangoria
3914ceae137SRavi Bangoria c.a = 123456.78;
3924ceae137SRavi Bangoria cached_b = c.b;
3934ceae137SRavi Bangoria
3944ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a;
3954ceae137SRavi Bangoria regs.gpr[4] = 0;
3964ceae137SRavi Bangoria
3974ceae137SRavi Bangoria /* lfdx frt10, r3, r4 */
3981d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFDX(10, 3, 4)));
3994ceae137SRavi Bangoria
4004ceae137SRavi Bangoria if (stepped == 1)
4014ceae137SRavi Bangoria show_result("lfdx", "PASS");
4024ceae137SRavi Bangoria else
4034ceae137SRavi Bangoria show_result("lfdx", "FAIL");
4044ceae137SRavi Bangoria
4054ceae137SRavi Bangoria
4064ceae137SRavi Bangoria /*** stfdx ***/
4074ceae137SRavi Bangoria
4084ceae137SRavi Bangoria c.a = 987654.32;
4094ceae137SRavi Bangoria
4104ceae137SRavi Bangoria /* stfdx frs10, r3, r4 */
4111d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFDX(10, 3, 4)));
4124ceae137SRavi Bangoria
4134ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b)
4144ceae137SRavi Bangoria show_result("stfdx", "PASS");
4154ceae137SRavi Bangoria else
4164ceae137SRavi Bangoria show_result("stfdx", "FAIL");
4174ceae137SRavi Bangoria }
4180396de6dSJordan Niethe
test_plfd_pstfd(void)4190396de6dSJordan Niethe static void __init test_plfd_pstfd(void)
4200396de6dSJordan Niethe {
4210396de6dSJordan Niethe struct pt_regs regs;
4220396de6dSJordan Niethe union {
4230396de6dSJordan Niethe double a;
4240396de6dSJordan Niethe long b;
4250396de6dSJordan Niethe } c;
4260396de6dSJordan Niethe long cached_b;
4270396de6dSJordan Niethe int stepped = -1;
4280396de6dSJordan Niethe
4290396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
4300396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)");
4310396de6dSJordan Niethe return;
4320396de6dSJordan Niethe }
4330396de6dSJordan Niethe
4340396de6dSJordan Niethe init_pt_regs(®s);
4350396de6dSJordan Niethe
4360396de6dSJordan Niethe
4370396de6dSJordan Niethe /*** plfd ***/
4380396de6dSJordan Niethe
4390396de6dSJordan Niethe c.a = 123456.78;
4400396de6dSJordan Niethe cached_b = c.b;
4410396de6dSJordan Niethe
4420396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a;
4430396de6dSJordan Niethe
4440396de6dSJordan Niethe /* plfd frt10, 0(r3), 0 */
4450396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFD(10, 3, 0, 0));
4460396de6dSJordan Niethe
4470396de6dSJordan Niethe if (stepped == 1)
4480396de6dSJordan Niethe show_result("plfd", "PASS");
4490396de6dSJordan Niethe else
4500396de6dSJordan Niethe show_result("plfd", "FAIL");
4510396de6dSJordan Niethe
4520396de6dSJordan Niethe
4530396de6dSJordan Niethe /*** pstfd ***/
4540396de6dSJordan Niethe
4550396de6dSJordan Niethe c.a = 987654.32;
4560396de6dSJordan Niethe
4570396de6dSJordan Niethe /* pstfd frs10, 0(r3), 0 */
4580396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFD(10, 3, 0, 0));
4590396de6dSJordan Niethe
4600396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b)
4610396de6dSJordan Niethe show_result("pstfd", "PASS");
4620396de6dSJordan Niethe else
4630396de6dSJordan Niethe show_result("pstfd", "FAIL");
4640396de6dSJordan Niethe }
4654ceae137SRavi Bangoria #else
test_lfsx_stfsx(void)4664ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void)
4674ceae137SRavi Bangoria {
4684ceae137SRavi Bangoria show_result("lfsx", "SKIP (CONFIG_PPC_FPU is not set)");
4694ceae137SRavi Bangoria show_result("stfsx", "SKIP (CONFIG_PPC_FPU is not set)");
4704ceae137SRavi Bangoria }
4714ceae137SRavi Bangoria
test_plfs_pstfs(void)4720396de6dSJordan Niethe static void __init test_plfs_pstfs(void)
4730396de6dSJordan Niethe {
4740396de6dSJordan Niethe show_result("plfs", "SKIP (CONFIG_PPC_FPU is not set)");
4750396de6dSJordan Niethe show_result("pstfs", "SKIP (CONFIG_PPC_FPU is not set)");
4760396de6dSJordan Niethe }
4770396de6dSJordan Niethe
test_lfdx_stfdx(void)4784ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void)
4794ceae137SRavi Bangoria {
4804ceae137SRavi Bangoria show_result("lfdx", "SKIP (CONFIG_PPC_FPU is not set)");
4814ceae137SRavi Bangoria show_result("stfdx", "SKIP (CONFIG_PPC_FPU is not set)");
4824ceae137SRavi Bangoria }
4830396de6dSJordan Niethe
test_plfd_pstfd(void)4840396de6dSJordan Niethe static void __init test_plfd_pstfd(void)
4850396de6dSJordan Niethe {
4860396de6dSJordan Niethe show_result("plfd", "SKIP (CONFIG_PPC_FPU is not set)");
4870396de6dSJordan Niethe show_result("pstfd", "SKIP (CONFIG_PPC_FPU is not set)");
4880396de6dSJordan Niethe }
4894ceae137SRavi Bangoria #endif /* CONFIG_PPC_FPU */
4904ceae137SRavi Bangoria
4914ceae137SRavi Bangoria #ifdef CONFIG_ALTIVEC
test_lvx_stvx(void)4924ceae137SRavi Bangoria static void __init test_lvx_stvx(void)
4934ceae137SRavi Bangoria {
4944ceae137SRavi Bangoria struct pt_regs regs;
4954ceae137SRavi Bangoria union {
4964ceae137SRavi Bangoria vector128 a;
4974ceae137SRavi Bangoria u32 b[4];
4984ceae137SRavi Bangoria } c;
4994ceae137SRavi Bangoria u32 cached_b[4];
5004ceae137SRavi Bangoria int stepped = -1;
5014ceae137SRavi Bangoria
5024ceae137SRavi Bangoria init_pt_regs(®s);
5034ceae137SRavi Bangoria
5044ceae137SRavi Bangoria
5054ceae137SRavi Bangoria /*** lvx ***/
5064ceae137SRavi Bangoria
5074ceae137SRavi Bangoria cached_b[0] = c.b[0] = 923745;
5084ceae137SRavi Bangoria cached_b[1] = c.b[1] = 2139478;
5094ceae137SRavi Bangoria cached_b[2] = c.b[2] = 9012;
5104ceae137SRavi Bangoria cached_b[3] = c.b[3] = 982134;
5114ceae137SRavi Bangoria
5124ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a;
5134ceae137SRavi Bangoria regs.gpr[4] = 0;
5144ceae137SRavi Bangoria
5154ceae137SRavi Bangoria /* lvx vrt10, r3, r4 */
5161d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LVX(10, 3, 4)));
5174ceae137SRavi Bangoria
5184ceae137SRavi Bangoria if (stepped == 1)
5194ceae137SRavi Bangoria show_result("lvx", "PASS");
5204ceae137SRavi Bangoria else
5214ceae137SRavi Bangoria show_result("lvx", "FAIL");
5224ceae137SRavi Bangoria
5234ceae137SRavi Bangoria
5244ceae137SRavi Bangoria /*** stvx ***/
5254ceae137SRavi Bangoria
5264ceae137SRavi Bangoria c.b[0] = 4987513;
5274ceae137SRavi Bangoria c.b[1] = 84313948;
5284ceae137SRavi Bangoria c.b[2] = 71;
5294ceae137SRavi Bangoria c.b[3] = 498532;
5304ceae137SRavi Bangoria
5314ceae137SRavi Bangoria /* stvx vrs10, r3, r4 */
5321d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STVX(10, 3, 4)));
5334ceae137SRavi Bangoria
5344ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] &&
5354ceae137SRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3])
5364ceae137SRavi Bangoria show_result("stvx", "PASS");
5374ceae137SRavi Bangoria else
5384ceae137SRavi Bangoria show_result("stvx", "FAIL");
5394ceae137SRavi Bangoria }
5404ceae137SRavi Bangoria #else
test_lvx_stvx(void)5414ceae137SRavi Bangoria static void __init test_lvx_stvx(void)
5424ceae137SRavi Bangoria {
5434ceae137SRavi Bangoria show_result("lvx", "SKIP (CONFIG_ALTIVEC is not set)");
5444ceae137SRavi Bangoria show_result("stvx", "SKIP (CONFIG_ALTIVEC is not set)");
5454ceae137SRavi Bangoria }
5464ceae137SRavi Bangoria #endif /* CONFIG_ALTIVEC */
5474ceae137SRavi Bangoria
5484ceae137SRavi Bangoria #ifdef CONFIG_VSX
test_lxvd2x_stxvd2x(void)5494ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void)
5504ceae137SRavi Bangoria {
5514ceae137SRavi Bangoria struct pt_regs regs;
5524ceae137SRavi Bangoria union {
5534ceae137SRavi Bangoria vector128 a;
5544ceae137SRavi Bangoria u32 b[4];
5554ceae137SRavi Bangoria } c;
5564ceae137SRavi Bangoria u32 cached_b[4];
5574ceae137SRavi Bangoria int stepped = -1;
5584ceae137SRavi Bangoria
5594ceae137SRavi Bangoria init_pt_regs(®s);
5604ceae137SRavi Bangoria
5614ceae137SRavi Bangoria
5624ceae137SRavi Bangoria /*** lxvd2x ***/
5634ceae137SRavi Bangoria
5644ceae137SRavi Bangoria cached_b[0] = c.b[0] = 18233;
5654ceae137SRavi Bangoria cached_b[1] = c.b[1] = 34863571;
5664ceae137SRavi Bangoria cached_b[2] = c.b[2] = 834;
5674ceae137SRavi Bangoria cached_b[3] = c.b[3] = 6138911;
5684ceae137SRavi Bangoria
5694ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a;
5704ceae137SRavi Bangoria regs.gpr[4] = 0;
5714ceae137SRavi Bangoria
5724ceae137SRavi Bangoria /* lxvd2x vsr39, r3, r4 */
5731d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVD2X(39, R3, R4)));
5744ceae137SRavi Bangoria
5755a61640eSRavi Bangoria if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) {
5764ceae137SRavi Bangoria show_result("lxvd2x", "PASS");
5775a61640eSRavi Bangoria } else {
5785a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX))
5795a61640eSRavi Bangoria show_result("lxvd2x", "PASS (!CPU_FTR_VSX)");
5804ceae137SRavi Bangoria else
5814ceae137SRavi Bangoria show_result("lxvd2x", "FAIL");
5825a61640eSRavi Bangoria }
5834ceae137SRavi Bangoria
5844ceae137SRavi Bangoria
5854ceae137SRavi Bangoria /*** stxvd2x ***/
5864ceae137SRavi Bangoria
5874ceae137SRavi Bangoria c.b[0] = 21379463;
5884ceae137SRavi Bangoria c.b[1] = 87;
5894ceae137SRavi Bangoria c.b[2] = 374234;
5904ceae137SRavi Bangoria c.b[3] = 4;
5914ceae137SRavi Bangoria
5924ceae137SRavi Bangoria /* stxvd2x vsr39, r3, r4 */
5931d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVD2X(39, R3, R4)));
5944ceae137SRavi Bangoria
5954ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] &&
5965a61640eSRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3] &&
5975a61640eSRavi Bangoria cpu_has_feature(CPU_FTR_VSX)) {
5984ceae137SRavi Bangoria show_result("stxvd2x", "PASS");
5995a61640eSRavi Bangoria } else {
6005a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX))
6015a61640eSRavi Bangoria show_result("stxvd2x", "PASS (!CPU_FTR_VSX)");
6024ceae137SRavi Bangoria else
6034ceae137SRavi Bangoria show_result("stxvd2x", "FAIL");
6044ceae137SRavi Bangoria }
6055a61640eSRavi Bangoria }
6064ceae137SRavi Bangoria #else
test_lxvd2x_stxvd2x(void)6074ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void)
6084ceae137SRavi Bangoria {
6094ceae137SRavi Bangoria show_result("lxvd2x", "SKIP (CONFIG_VSX is not set)");
6104ceae137SRavi Bangoria show_result("stxvd2x", "SKIP (CONFIG_VSX is not set)");
6114ceae137SRavi Bangoria }
6124ceae137SRavi Bangoria #endif /* CONFIG_VSX */
6134ceae137SRavi Bangoria
61435785b29SBalamuruhan S #ifdef CONFIG_VSX
test_lxvp_stxvp(void)61535785b29SBalamuruhan S static void __init test_lxvp_stxvp(void)
61635785b29SBalamuruhan S {
61735785b29SBalamuruhan S struct pt_regs regs;
61835785b29SBalamuruhan S union {
61935785b29SBalamuruhan S vector128 a;
62035785b29SBalamuruhan S u32 b[4];
62135785b29SBalamuruhan S } c[2];
62235785b29SBalamuruhan S u32 cached_b[8];
62335785b29SBalamuruhan S int stepped = -1;
62435785b29SBalamuruhan S
62535785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
62635785b29SBalamuruhan S show_result("lxvp", "SKIP (!CPU_FTR_ARCH_31)");
62735785b29SBalamuruhan S show_result("stxvp", "SKIP (!CPU_FTR_ARCH_31)");
62835785b29SBalamuruhan S return;
62935785b29SBalamuruhan S }
63035785b29SBalamuruhan S
63135785b29SBalamuruhan S init_pt_regs(®s);
63235785b29SBalamuruhan S
63335785b29SBalamuruhan S /*** lxvp ***/
63435785b29SBalamuruhan S
63535785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233;
63635785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571;
63735785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834;
63835785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911;
63935785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234;
64035785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678;
64135785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011;
64235785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314;
64335785b29SBalamuruhan S
64435785b29SBalamuruhan S regs.gpr[4] = (unsigned long)&c[0].a;
64535785b29SBalamuruhan S
64635785b29SBalamuruhan S /*
64735785b29SBalamuruhan S * lxvp XTp,DQ(RA)
64835785b29SBalamuruhan S * XTp = 32xTX + 2xTp
64935785b29SBalamuruhan S * let TX=1 Tp=1 RA=4 DQ=0
65035785b29SBalamuruhan S */
65135785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVP(34, 4, 0)));
65235785b29SBalamuruhan S
65335785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) {
65435785b29SBalamuruhan S show_result("lxvp", "PASS");
65535785b29SBalamuruhan S } else {
65635785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
65735785b29SBalamuruhan S show_result("lxvp", "PASS (!CPU_FTR_VSX)");
65835785b29SBalamuruhan S else
65935785b29SBalamuruhan S show_result("lxvp", "FAIL");
66035785b29SBalamuruhan S }
66135785b29SBalamuruhan S
66235785b29SBalamuruhan S /*** stxvp ***/
66335785b29SBalamuruhan S
66435785b29SBalamuruhan S c[0].b[0] = 21379463;
66535785b29SBalamuruhan S c[0].b[1] = 87;
66635785b29SBalamuruhan S c[0].b[2] = 374234;
66735785b29SBalamuruhan S c[0].b[3] = 4;
66835785b29SBalamuruhan S c[1].b[0] = 90;
66935785b29SBalamuruhan S c[1].b[1] = 122;
67035785b29SBalamuruhan S c[1].b[2] = 555;
67135785b29SBalamuruhan S c[1].b[3] = 32144;
67235785b29SBalamuruhan S
67335785b29SBalamuruhan S /*
67435785b29SBalamuruhan S * stxvp XSp,DQ(RA)
67535785b29SBalamuruhan S * XSp = 32xSX + 2xSp
67635785b29SBalamuruhan S * let SX=1 Sp=1 RA=4 DQ=0
67735785b29SBalamuruhan S */
67835785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVP(34, 4, 0)));
67935785b29SBalamuruhan S
68035785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] &&
68135785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] &&
68235785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] &&
68335785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] &&
68435785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) {
68535785b29SBalamuruhan S show_result("stxvp", "PASS");
68635785b29SBalamuruhan S } else {
68735785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
68835785b29SBalamuruhan S show_result("stxvp", "PASS (!CPU_FTR_VSX)");
68935785b29SBalamuruhan S else
69035785b29SBalamuruhan S show_result("stxvp", "FAIL");
69135785b29SBalamuruhan S }
69235785b29SBalamuruhan S }
69335785b29SBalamuruhan S #else
test_lxvp_stxvp(void)69435785b29SBalamuruhan S static void __init test_lxvp_stxvp(void)
69535785b29SBalamuruhan S {
69635785b29SBalamuruhan S show_result("lxvp", "SKIP (CONFIG_VSX is not set)");
69735785b29SBalamuruhan S show_result("stxvp", "SKIP (CONFIG_VSX is not set)");
69835785b29SBalamuruhan S }
69935785b29SBalamuruhan S #endif /* CONFIG_VSX */
70035785b29SBalamuruhan S
70135785b29SBalamuruhan S #ifdef CONFIG_VSX
test_lxvpx_stxvpx(void)70235785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void)
70335785b29SBalamuruhan S {
70435785b29SBalamuruhan S struct pt_regs regs;
70535785b29SBalamuruhan S union {
70635785b29SBalamuruhan S vector128 a;
70735785b29SBalamuruhan S u32 b[4];
70835785b29SBalamuruhan S } c[2];
70935785b29SBalamuruhan S u32 cached_b[8];
71035785b29SBalamuruhan S int stepped = -1;
71135785b29SBalamuruhan S
71235785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
71335785b29SBalamuruhan S show_result("lxvpx", "SKIP (!CPU_FTR_ARCH_31)");
71435785b29SBalamuruhan S show_result("stxvpx", "SKIP (!CPU_FTR_ARCH_31)");
71535785b29SBalamuruhan S return;
71635785b29SBalamuruhan S }
71735785b29SBalamuruhan S
71835785b29SBalamuruhan S init_pt_regs(®s);
71935785b29SBalamuruhan S
72035785b29SBalamuruhan S /*** lxvpx ***/
72135785b29SBalamuruhan S
72235785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233;
72335785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571;
72435785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834;
72535785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911;
72635785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234;
72735785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678;
72835785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011;
72935785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314;
73035785b29SBalamuruhan S
73135785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a;
73235785b29SBalamuruhan S regs.gpr[4] = 0;
73335785b29SBalamuruhan S
73435785b29SBalamuruhan S /*
73535785b29SBalamuruhan S * lxvpx XTp,RA,RB
73635785b29SBalamuruhan S * XTp = 32xTX + 2xTp
73735785b29SBalamuruhan S * let TX=1 Tp=1 RA=3 RB=4
73835785b29SBalamuruhan S */
73935785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVPX(34, 3, 4)));
74035785b29SBalamuruhan S
74135785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) {
74235785b29SBalamuruhan S show_result("lxvpx", "PASS");
74335785b29SBalamuruhan S } else {
74435785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
74535785b29SBalamuruhan S show_result("lxvpx", "PASS (!CPU_FTR_VSX)");
74635785b29SBalamuruhan S else
74735785b29SBalamuruhan S show_result("lxvpx", "FAIL");
74835785b29SBalamuruhan S }
74935785b29SBalamuruhan S
75035785b29SBalamuruhan S /*** stxvpx ***/
75135785b29SBalamuruhan S
75235785b29SBalamuruhan S c[0].b[0] = 21379463;
75335785b29SBalamuruhan S c[0].b[1] = 87;
75435785b29SBalamuruhan S c[0].b[2] = 374234;
75535785b29SBalamuruhan S c[0].b[3] = 4;
75635785b29SBalamuruhan S c[1].b[0] = 90;
75735785b29SBalamuruhan S c[1].b[1] = 122;
75835785b29SBalamuruhan S c[1].b[2] = 555;
75935785b29SBalamuruhan S c[1].b[3] = 32144;
76035785b29SBalamuruhan S
76135785b29SBalamuruhan S /*
76235785b29SBalamuruhan S * stxvpx XSp,RA,RB
76335785b29SBalamuruhan S * XSp = 32xSX + 2xSp
76435785b29SBalamuruhan S * let SX=1 Sp=1 RA=3 RB=4
76535785b29SBalamuruhan S */
76635785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVPX(34, 3, 4)));
76735785b29SBalamuruhan S
76835785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] &&
76935785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] &&
77035785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] &&
77135785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] &&
77235785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) {
77335785b29SBalamuruhan S show_result("stxvpx", "PASS");
77435785b29SBalamuruhan S } else {
77535785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
77635785b29SBalamuruhan S show_result("stxvpx", "PASS (!CPU_FTR_VSX)");
77735785b29SBalamuruhan S else
77835785b29SBalamuruhan S show_result("stxvpx", "FAIL");
77935785b29SBalamuruhan S }
78035785b29SBalamuruhan S }
78135785b29SBalamuruhan S #else
test_lxvpx_stxvpx(void)78235785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void)
78335785b29SBalamuruhan S {
78435785b29SBalamuruhan S show_result("lxvpx", "SKIP (CONFIG_VSX is not set)");
78535785b29SBalamuruhan S show_result("stxvpx", "SKIP (CONFIG_VSX is not set)");
78635785b29SBalamuruhan S }
78735785b29SBalamuruhan S #endif /* CONFIG_VSX */
78835785b29SBalamuruhan S
78935785b29SBalamuruhan S #ifdef CONFIG_VSX
test_plxvp_pstxvp(void)79035785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void)
79135785b29SBalamuruhan S {
792c545b9f0SChristophe Leroy ppc_inst_t instr;
79335785b29SBalamuruhan S struct pt_regs regs;
79435785b29SBalamuruhan S union {
79535785b29SBalamuruhan S vector128 a;
79635785b29SBalamuruhan S u32 b[4];
79735785b29SBalamuruhan S } c[2];
79835785b29SBalamuruhan S u32 cached_b[8];
79935785b29SBalamuruhan S int stepped = -1;
80035785b29SBalamuruhan S
80135785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) {
80235785b29SBalamuruhan S show_result("plxvp", "SKIP (!CPU_FTR_ARCH_31)");
80335785b29SBalamuruhan S show_result("pstxvp", "SKIP (!CPU_FTR_ARCH_31)");
80435785b29SBalamuruhan S return;
80535785b29SBalamuruhan S }
80635785b29SBalamuruhan S
80735785b29SBalamuruhan S /*** plxvp ***/
80835785b29SBalamuruhan S
80935785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233;
81035785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571;
81135785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834;
81235785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911;
81335785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234;
81435785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678;
81535785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011;
81635785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314;
81735785b29SBalamuruhan S
81835785b29SBalamuruhan S init_pt_regs(®s);
81935785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a;
82035785b29SBalamuruhan S
82135785b29SBalamuruhan S /*
82235785b29SBalamuruhan S * plxvp XTp,D(RA),R
82335785b29SBalamuruhan S * XTp = 32xTX + 2xTp
82435785b29SBalamuruhan S * let RA=3 R=0 D=d0||d1=0 R=0 Tp=1 TX=1
82535785b29SBalamuruhan S */
826148a0476SChristophe Leroy instr = ppc_inst_prefix(PPC_RAW_PLXVP_P(34, 0, 3, 0), PPC_RAW_PLXVP_S(34, 0, 3, 0));
82735785b29SBalamuruhan S
82835785b29SBalamuruhan S stepped = emulate_step(®s, instr);
82935785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) {
83035785b29SBalamuruhan S show_result("plxvp", "PASS");
83135785b29SBalamuruhan S } else {
83235785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
83335785b29SBalamuruhan S show_result("plxvp", "PASS (!CPU_FTR_VSX)");
83435785b29SBalamuruhan S else
83535785b29SBalamuruhan S show_result("plxvp", "FAIL");
83635785b29SBalamuruhan S }
83735785b29SBalamuruhan S
83835785b29SBalamuruhan S /*** pstxvp ***/
83935785b29SBalamuruhan S
84035785b29SBalamuruhan S c[0].b[0] = 21379463;
84135785b29SBalamuruhan S c[0].b[1] = 87;
84235785b29SBalamuruhan S c[0].b[2] = 374234;
84335785b29SBalamuruhan S c[0].b[3] = 4;
84435785b29SBalamuruhan S c[1].b[0] = 90;
84535785b29SBalamuruhan S c[1].b[1] = 122;
84635785b29SBalamuruhan S c[1].b[2] = 555;
84735785b29SBalamuruhan S c[1].b[3] = 32144;
84835785b29SBalamuruhan S
84935785b29SBalamuruhan S /*
85035785b29SBalamuruhan S * pstxvp XSp,D(RA),R
85135785b29SBalamuruhan S * XSp = 32xSX + 2xSp
85235785b29SBalamuruhan S * let RA=3 D=d0||d1=0 R=0 Sp=1 SX=1
85335785b29SBalamuruhan S */
854148a0476SChristophe Leroy instr = ppc_inst_prefix(PPC_RAW_PSTXVP_P(34, 0, 3, 0), PPC_RAW_PSTXVP_S(34, 0, 3, 0));
85535785b29SBalamuruhan S
85635785b29SBalamuruhan S stepped = emulate_step(®s, instr);
85735785b29SBalamuruhan S
85835785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] &&
85935785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] &&
86035785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] &&
86135785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] &&
86235785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) {
86335785b29SBalamuruhan S show_result("pstxvp", "PASS");
86435785b29SBalamuruhan S } else {
86535785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX))
86635785b29SBalamuruhan S show_result("pstxvp", "PASS (!CPU_FTR_VSX)");
86735785b29SBalamuruhan S else
86835785b29SBalamuruhan S show_result("pstxvp", "FAIL");
86935785b29SBalamuruhan S }
87035785b29SBalamuruhan S }
87135785b29SBalamuruhan S #else
test_plxvp_pstxvp(void)87235785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void)
87335785b29SBalamuruhan S {
87435785b29SBalamuruhan S show_result("plxvp", "SKIP (CONFIG_VSX is not set)");
87535785b29SBalamuruhan S show_result("pstxvp", "SKIP (CONFIG_VSX is not set)");
87635785b29SBalamuruhan S }
87735785b29SBalamuruhan S #endif /* CONFIG_VSX */
87835785b29SBalamuruhan S
run_tests_load_store(void)87984022ac1SSandipan Das static void __init run_tests_load_store(void)
8804ceae137SRavi Bangoria {
8814ceae137SRavi Bangoria test_ld();
882b6b54b42SJordan Niethe test_pld();
8834ceae137SRavi Bangoria test_lwz();
884b6b54b42SJordan Niethe test_plwz();
8854ceae137SRavi Bangoria test_lwzx();
8864ceae137SRavi Bangoria test_std();
887b6b54b42SJordan Niethe test_pstd();
8884ceae137SRavi Bangoria test_ldarx_stdcx();
8894ceae137SRavi Bangoria test_lfsx_stfsx();
8900396de6dSJordan Niethe test_plfs_pstfs();
8914ceae137SRavi Bangoria test_lfdx_stfdx();
8920396de6dSJordan Niethe test_plfd_pstfd();
8934ceae137SRavi Bangoria test_lvx_stvx();
8944ceae137SRavi Bangoria test_lxvd2x_stxvd2x();
89535785b29SBalamuruhan S test_lxvp_stxvp();
89635785b29SBalamuruhan S test_lxvpx_stxvpx();
89735785b29SBalamuruhan S test_plxvp_pstxvp();
89884022ac1SSandipan Das }
89984022ac1SSandipan Das
90084022ac1SSandipan Das struct compute_test {
90184022ac1SSandipan Das char *mnemonic;
902301ebf7dSJordan Niethe unsigned long cpu_feature;
90384022ac1SSandipan Das struct {
90484022ac1SSandipan Das char *descr;
90584022ac1SSandipan Das unsigned long flags;
906c545b9f0SChristophe Leroy ppc_inst_t instr;
90784022ac1SSandipan Das struct pt_regs regs;
90884022ac1SSandipan Das } subtests[MAX_SUBTESTS + 1];
90984022ac1SSandipan Das };
91084022ac1SSandipan Das
9114f825900SJordan Niethe /* Extreme values for si0||si1 (the MLS:D-form 34 bit immediate field) */
9124f825900SJordan Niethe #define SI_MIN BIT(33)
9134f825900SJordan Niethe #define SI_MAX (BIT(33) - 1)
9144f825900SJordan Niethe #define SI_UMAX (BIT(34) - 1)
9154f825900SJordan Niethe
91684022ac1SSandipan Das static struct compute_test compute_tests[] = {
91784022ac1SSandipan Das {
91884022ac1SSandipan Das .mnemonic = "nop",
91984022ac1SSandipan Das .subtests = {
92084022ac1SSandipan Das {
92184022ac1SSandipan Das .descr = "R0 = LONG_MAX",
922f30becb5SChristophe Leroy .instr = ppc_inst(PPC_RAW_NOP()),
92384022ac1SSandipan Das .regs = {
92484022ac1SSandipan Das .gpr[0] = LONG_MAX,
92584022ac1SSandipan Das }
92684022ac1SSandipan Das }
92784022ac1SSandipan Das }
92844dea178SSandipan Das },
92944dea178SSandipan Das {
93060060d70SSathvika Vasireddy .mnemonic = "setb",
93160060d70SSathvika Vasireddy .cpu_feature = CPU_FTR_ARCH_300,
93260060d70SSathvika Vasireddy .subtests = {
93360060d70SSathvika Vasireddy {
93460060d70SSathvika Vasireddy .descr = "BFA = 1, CR = GT",
935*de40303bSChristophe Leroy .instr = ppc_inst(PPC_RAW_SETB(20, 1)),
93660060d70SSathvika Vasireddy .regs = {
93760060d70SSathvika Vasireddy .ccr = 0x4000000,
93860060d70SSathvika Vasireddy }
93960060d70SSathvika Vasireddy },
94060060d70SSathvika Vasireddy {
94160060d70SSathvika Vasireddy .descr = "BFA = 4, CR = LT",
942*de40303bSChristophe Leroy .instr = ppc_inst(PPC_RAW_SETB(20, 4)),
94360060d70SSathvika Vasireddy .regs = {
94460060d70SSathvika Vasireddy .ccr = 0x8000,
94560060d70SSathvika Vasireddy }
94660060d70SSathvika Vasireddy },
94760060d70SSathvika Vasireddy {
94860060d70SSathvika Vasireddy .descr = "BFA = 5, CR = EQ",
949*de40303bSChristophe Leroy .instr = ppc_inst(PPC_RAW_SETB(20, 5)),
95060060d70SSathvika Vasireddy .regs = {
95160060d70SSathvika Vasireddy .ccr = 0x200,
95260060d70SSathvika Vasireddy }
95360060d70SSathvika Vasireddy }
95460060d70SSathvika Vasireddy }
95560060d70SSathvika Vasireddy },
95660060d70SSathvika Vasireddy {
95744dea178SSandipan Das .mnemonic = "add",
95844dea178SSandipan Das .subtests = {
95944dea178SSandipan Das {
96044dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN",
9611d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
96244dea178SSandipan Das .regs = {
96344dea178SSandipan Das .gpr[21] = LONG_MIN,
96444dea178SSandipan Das .gpr[22] = LONG_MIN,
96544dea178SSandipan Das }
96644dea178SSandipan Das },
96744dea178SSandipan Das {
96844dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX",
9691d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
97044dea178SSandipan Das .regs = {
97144dea178SSandipan Das .gpr[21] = LONG_MIN,
97244dea178SSandipan Das .gpr[22] = LONG_MAX,
97344dea178SSandipan Das }
97444dea178SSandipan Das },
97544dea178SSandipan Das {
97644dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX",
9771d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
97844dea178SSandipan Das .regs = {
97944dea178SSandipan Das .gpr[21] = LONG_MAX,
98044dea178SSandipan Das .gpr[22] = LONG_MAX,
98144dea178SSandipan Das }
98244dea178SSandipan Das },
98344dea178SSandipan Das {
98444dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
9851d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
98644dea178SSandipan Das .regs = {
98744dea178SSandipan Das .gpr[21] = ULONG_MAX,
98844dea178SSandipan Das .gpr[22] = ULONG_MAX,
98944dea178SSandipan Das }
99044dea178SSandipan Das },
99144dea178SSandipan Das {
99244dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1",
9931d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
99444dea178SSandipan Das .regs = {
99544dea178SSandipan Das .gpr[21] = ULONG_MAX,
99644dea178SSandipan Das .gpr[22] = 0x1,
99744dea178SSandipan Das }
99844dea178SSandipan Das },
99944dea178SSandipan Das {
100044dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN",
10011d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
100244dea178SSandipan Das .regs = {
100344dea178SSandipan Das .gpr[21] = INT_MIN,
100444dea178SSandipan Das .gpr[22] = INT_MIN,
100544dea178SSandipan Das }
100644dea178SSandipan Das },
100744dea178SSandipan Das {
100844dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX",
10091d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
101044dea178SSandipan Das .regs = {
101144dea178SSandipan Das .gpr[21] = INT_MIN,
101244dea178SSandipan Das .gpr[22] = INT_MAX,
101344dea178SSandipan Das }
101444dea178SSandipan Das },
101544dea178SSandipan Das {
101644dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX",
10171d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
101844dea178SSandipan Das .regs = {
101944dea178SSandipan Das .gpr[21] = INT_MAX,
102044dea178SSandipan Das .gpr[22] = INT_MAX,
102144dea178SSandipan Das }
102244dea178SSandipan Das },
102344dea178SSandipan Das {
102444dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX",
10251d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
102644dea178SSandipan Das .regs = {
102744dea178SSandipan Das .gpr[21] = UINT_MAX,
102844dea178SSandipan Das .gpr[22] = UINT_MAX,
102944dea178SSandipan Das }
103044dea178SSandipan Das },
103144dea178SSandipan Das {
103244dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1",
10331d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
103444dea178SSandipan Das .regs = {
103544dea178SSandipan Das .gpr[21] = UINT_MAX,
103644dea178SSandipan Das .gpr[22] = 0x1,
103744dea178SSandipan Das }
103844dea178SSandipan Das }
103944dea178SSandipan Das }
104044dea178SSandipan Das },
104144dea178SSandipan Das {
104244dea178SSandipan Das .mnemonic = "add.",
104344dea178SSandipan Das .subtests = {
104444dea178SSandipan Das {
104544dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN",
104644dea178SSandipan Das .flags = IGNORE_CCR,
10471d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
104844dea178SSandipan Das .regs = {
104944dea178SSandipan Das .gpr[21] = LONG_MIN,
105044dea178SSandipan Das .gpr[22] = LONG_MIN,
105144dea178SSandipan Das }
105244dea178SSandipan Das },
105344dea178SSandipan Das {
105444dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX",
10551d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
105644dea178SSandipan Das .regs = {
105744dea178SSandipan Das .gpr[21] = LONG_MIN,
105844dea178SSandipan Das .gpr[22] = LONG_MAX,
105944dea178SSandipan Das }
106044dea178SSandipan Das },
106144dea178SSandipan Das {
106244dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX",
106344dea178SSandipan Das .flags = IGNORE_CCR,
10641d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
106544dea178SSandipan Das .regs = {
106644dea178SSandipan Das .gpr[21] = LONG_MAX,
106744dea178SSandipan Das .gpr[22] = LONG_MAX,
106844dea178SSandipan Das }
106944dea178SSandipan Das },
107044dea178SSandipan Das {
107144dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
10721d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
107344dea178SSandipan Das .regs = {
107444dea178SSandipan Das .gpr[21] = ULONG_MAX,
107544dea178SSandipan Das .gpr[22] = ULONG_MAX,
107644dea178SSandipan Das }
107744dea178SSandipan Das },
107844dea178SSandipan Das {
107944dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1",
10801d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
108144dea178SSandipan Das .regs = {
108244dea178SSandipan Das .gpr[21] = ULONG_MAX,
108344dea178SSandipan Das .gpr[22] = 0x1,
108444dea178SSandipan Das }
108544dea178SSandipan Das },
108644dea178SSandipan Das {
108744dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN",
10881d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
108944dea178SSandipan Das .regs = {
109044dea178SSandipan Das .gpr[21] = INT_MIN,
109144dea178SSandipan Das .gpr[22] = INT_MIN,
109244dea178SSandipan Das }
109344dea178SSandipan Das },
109444dea178SSandipan Das {
109544dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX",
10961d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
109744dea178SSandipan Das .regs = {
109844dea178SSandipan Das .gpr[21] = INT_MIN,
109944dea178SSandipan Das .gpr[22] = INT_MAX,
110044dea178SSandipan Das }
110144dea178SSandipan Das },
110244dea178SSandipan Das {
110344dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX",
11041d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
110544dea178SSandipan Das .regs = {
110644dea178SSandipan Das .gpr[21] = INT_MAX,
110744dea178SSandipan Das .gpr[22] = INT_MAX,
110844dea178SSandipan Das }
110944dea178SSandipan Das },
111044dea178SSandipan Das {
111144dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX",
11121d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
111344dea178SSandipan Das .regs = {
111444dea178SSandipan Das .gpr[21] = UINT_MAX,
111544dea178SSandipan Das .gpr[22] = UINT_MAX,
111644dea178SSandipan Das }
111744dea178SSandipan Das },
111844dea178SSandipan Das {
111944dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1",
11201d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)),
112144dea178SSandipan Das .regs = {
112244dea178SSandipan Das .gpr[21] = UINT_MAX,
112344dea178SSandipan Das .gpr[22] = 0x1,
112444dea178SSandipan Das }
112544dea178SSandipan Das }
112644dea178SSandipan Das }
112778a8da06SSandipan Das },
112878a8da06SSandipan Das {
112978a8da06SSandipan Das .mnemonic = "addc",
113078a8da06SSandipan Das .subtests = {
113178a8da06SSandipan Das {
113278a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN",
11331d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
113478a8da06SSandipan Das .regs = {
113578a8da06SSandipan Das .gpr[21] = LONG_MIN,
113678a8da06SSandipan Das .gpr[22] = LONG_MIN,
113778a8da06SSandipan Das }
113878a8da06SSandipan Das },
113978a8da06SSandipan Das {
114078a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX",
11411d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
114278a8da06SSandipan Das .regs = {
114378a8da06SSandipan Das .gpr[21] = LONG_MIN,
114478a8da06SSandipan Das .gpr[22] = LONG_MAX,
114578a8da06SSandipan Das }
114678a8da06SSandipan Das },
114778a8da06SSandipan Das {
114878a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX",
11491d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
115078a8da06SSandipan Das .regs = {
115178a8da06SSandipan Das .gpr[21] = LONG_MAX,
115278a8da06SSandipan Das .gpr[22] = LONG_MAX,
115378a8da06SSandipan Das }
115478a8da06SSandipan Das },
115578a8da06SSandipan Das {
115678a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
11571d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
115878a8da06SSandipan Das .regs = {
115978a8da06SSandipan Das .gpr[21] = ULONG_MAX,
116078a8da06SSandipan Das .gpr[22] = ULONG_MAX,
116178a8da06SSandipan Das }
116278a8da06SSandipan Das },
116378a8da06SSandipan Das {
116478a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1",
11651d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
116678a8da06SSandipan Das .regs = {
116778a8da06SSandipan Das .gpr[21] = ULONG_MAX,
116878a8da06SSandipan Das .gpr[22] = 0x1,
116978a8da06SSandipan Das }
117078a8da06SSandipan Das },
117178a8da06SSandipan Das {
117278a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN",
11731d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
117478a8da06SSandipan Das .regs = {
117578a8da06SSandipan Das .gpr[21] = INT_MIN,
117678a8da06SSandipan Das .gpr[22] = INT_MIN,
117778a8da06SSandipan Das }
117878a8da06SSandipan Das },
117978a8da06SSandipan Das {
118078a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX",
11811d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
118278a8da06SSandipan Das .regs = {
118378a8da06SSandipan Das .gpr[21] = INT_MIN,
118478a8da06SSandipan Das .gpr[22] = INT_MAX,
118578a8da06SSandipan Das }
118678a8da06SSandipan Das },
118778a8da06SSandipan Das {
118878a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX",
11891d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
119078a8da06SSandipan Das .regs = {
119178a8da06SSandipan Das .gpr[21] = INT_MAX,
119278a8da06SSandipan Das .gpr[22] = INT_MAX,
119378a8da06SSandipan Das }
119478a8da06SSandipan Das },
119578a8da06SSandipan Das {
119678a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX",
11971d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
119878a8da06SSandipan Das .regs = {
119978a8da06SSandipan Das .gpr[21] = UINT_MAX,
120078a8da06SSandipan Das .gpr[22] = UINT_MAX,
120178a8da06SSandipan Das }
120278a8da06SSandipan Das },
120378a8da06SSandipan Das {
120478a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1",
12051d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
120678a8da06SSandipan Das .regs = {
120778a8da06SSandipan Das .gpr[21] = UINT_MAX,
120878a8da06SSandipan Das .gpr[22] = 0x1,
120978a8da06SSandipan Das }
121078a8da06SSandipan Das },
121178a8da06SSandipan Das {
121278a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN",
12131d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)),
121478a8da06SSandipan Das .regs = {
121578a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN,
121678a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN,
121778a8da06SSandipan Das }
121878a8da06SSandipan Das }
121978a8da06SSandipan Das }
122078a8da06SSandipan Das },
122178a8da06SSandipan Das {
122278a8da06SSandipan Das .mnemonic = "addc.",
122378a8da06SSandipan Das .subtests = {
122478a8da06SSandipan Das {
122578a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN",
122678a8da06SSandipan Das .flags = IGNORE_CCR,
12271d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
122878a8da06SSandipan Das .regs = {
122978a8da06SSandipan Das .gpr[21] = LONG_MIN,
123078a8da06SSandipan Das .gpr[22] = LONG_MIN,
123178a8da06SSandipan Das }
123278a8da06SSandipan Das },
123378a8da06SSandipan Das {
123478a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX",
12351d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
123678a8da06SSandipan Das .regs = {
123778a8da06SSandipan Das .gpr[21] = LONG_MIN,
123878a8da06SSandipan Das .gpr[22] = LONG_MAX,
123978a8da06SSandipan Das }
124078a8da06SSandipan Das },
124178a8da06SSandipan Das {
124278a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX",
124378a8da06SSandipan Das .flags = IGNORE_CCR,
12441d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
124578a8da06SSandipan Das .regs = {
124678a8da06SSandipan Das .gpr[21] = LONG_MAX,
124778a8da06SSandipan Das .gpr[22] = LONG_MAX,
124878a8da06SSandipan Das }
124978a8da06SSandipan Das },
125078a8da06SSandipan Das {
125178a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
12521d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
125378a8da06SSandipan Das .regs = {
125478a8da06SSandipan Das .gpr[21] = ULONG_MAX,
125578a8da06SSandipan Das .gpr[22] = ULONG_MAX,
125678a8da06SSandipan Das }
125778a8da06SSandipan Das },
125878a8da06SSandipan Das {
125978a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1",
12601d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
126178a8da06SSandipan Das .regs = {
126278a8da06SSandipan Das .gpr[21] = ULONG_MAX,
126378a8da06SSandipan Das .gpr[22] = 0x1,
126478a8da06SSandipan Das }
126578a8da06SSandipan Das },
126678a8da06SSandipan Das {
126778a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN",
12681d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
126978a8da06SSandipan Das .regs = {
127078a8da06SSandipan Das .gpr[21] = INT_MIN,
127178a8da06SSandipan Das .gpr[22] = INT_MIN,
127278a8da06SSandipan Das }
127378a8da06SSandipan Das },
127478a8da06SSandipan Das {
127578a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX",
12761d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
127778a8da06SSandipan Das .regs = {
127878a8da06SSandipan Das .gpr[21] = INT_MIN,
127978a8da06SSandipan Das .gpr[22] = INT_MAX,
128078a8da06SSandipan Das }
128178a8da06SSandipan Das },
128278a8da06SSandipan Das {
128378a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX",
12841d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
128578a8da06SSandipan Das .regs = {
128678a8da06SSandipan Das .gpr[21] = INT_MAX,
128778a8da06SSandipan Das .gpr[22] = INT_MAX,
128878a8da06SSandipan Das }
128978a8da06SSandipan Das },
129078a8da06SSandipan Das {
129178a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX",
12921d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
129378a8da06SSandipan Das .regs = {
129478a8da06SSandipan Das .gpr[21] = UINT_MAX,
129578a8da06SSandipan Das .gpr[22] = UINT_MAX,
129678a8da06SSandipan Das }
129778a8da06SSandipan Das },
129878a8da06SSandipan Das {
129978a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1",
13001d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
130178a8da06SSandipan Das .regs = {
130278a8da06SSandipan Das .gpr[21] = UINT_MAX,
130378a8da06SSandipan Das .gpr[22] = 0x1,
130478a8da06SSandipan Das }
130578a8da06SSandipan Das },
130678a8da06SSandipan Das {
130778a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN",
13081d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)),
130978a8da06SSandipan Das .regs = {
131078a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN,
131178a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN,
131278a8da06SSandipan Das }
131378a8da06SSandipan Das }
131478a8da06SSandipan Das }
13154f825900SJordan Niethe },
13164f825900SJordan Niethe {
1317b859c95cSBalamuruhan S .mnemonic = "divde",
1318b859c95cSBalamuruhan S .subtests = {
1319b859c95cSBalamuruhan S {
1320b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN",
1321b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)),
1322b859c95cSBalamuruhan S .regs = {
1323b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1324b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1325b859c95cSBalamuruhan S }
1326b859c95cSBalamuruhan S },
1327b859c95cSBalamuruhan S {
1328b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0",
1329b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)),
1330b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1331b859c95cSBalamuruhan S .regs = {
1332b859c95cSBalamuruhan S .gpr[21] = 1L,
1333b859c95cSBalamuruhan S .gpr[22] = 0,
1334b859c95cSBalamuruhan S }
1335b859c95cSBalamuruhan S },
1336b859c95cSBalamuruhan S {
1337b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX",
1338b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)),
1339b859c95cSBalamuruhan S .regs = {
1340b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1341b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1342b859c95cSBalamuruhan S }
1343b859c95cSBalamuruhan S }
1344b859c95cSBalamuruhan S }
1345b859c95cSBalamuruhan S },
1346b859c95cSBalamuruhan S {
1347b859c95cSBalamuruhan S .mnemonic = "divde.",
1348b859c95cSBalamuruhan S .subtests = {
1349b859c95cSBalamuruhan S {
1350b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN",
1351b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)),
1352b859c95cSBalamuruhan S .regs = {
1353b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1354b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1355b859c95cSBalamuruhan S }
1356b859c95cSBalamuruhan S },
1357b859c95cSBalamuruhan S {
1358b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0",
1359b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)),
1360b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1361b859c95cSBalamuruhan S .regs = {
1362b859c95cSBalamuruhan S .gpr[21] = 1L,
1363b859c95cSBalamuruhan S .gpr[22] = 0,
1364b859c95cSBalamuruhan S }
1365b859c95cSBalamuruhan S },
1366b859c95cSBalamuruhan S {
1367b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX",
1368b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)),
1369b859c95cSBalamuruhan S .regs = {
1370b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1371b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1372b859c95cSBalamuruhan S }
1373b859c95cSBalamuruhan S }
1374b859c95cSBalamuruhan S }
1375b859c95cSBalamuruhan S },
1376b859c95cSBalamuruhan S {
1377b859c95cSBalamuruhan S .mnemonic = "divdeu",
1378b859c95cSBalamuruhan S .subtests = {
1379b859c95cSBalamuruhan S {
1380b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN",
1381b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)),
1382b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1383b859c95cSBalamuruhan S .regs = {
1384b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1385b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1386b859c95cSBalamuruhan S }
1387b859c95cSBalamuruhan S },
1388b859c95cSBalamuruhan S {
1389b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0",
1390b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)),
1391b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1392b859c95cSBalamuruhan S .regs = {
1393b859c95cSBalamuruhan S .gpr[21] = 1L,
1394b859c95cSBalamuruhan S .gpr[22] = 0,
1395b859c95cSBalamuruhan S }
1396b859c95cSBalamuruhan S },
1397b859c95cSBalamuruhan S {
1398b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX",
1399b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)),
1400b859c95cSBalamuruhan S .regs = {
1401b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1402b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1403b859c95cSBalamuruhan S }
1404b859c95cSBalamuruhan S },
1405b859c95cSBalamuruhan S {
1406b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX",
1407b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)),
1408b859c95cSBalamuruhan S .regs = {
1409b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1,
1410b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1411b859c95cSBalamuruhan S }
1412b859c95cSBalamuruhan S },
1413b859c95cSBalamuruhan S {
1414b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN",
1415b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)),
1416b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1417b859c95cSBalamuruhan S .regs = {
1418b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1,
1419b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1420b859c95cSBalamuruhan S }
1421b859c95cSBalamuruhan S }
1422b859c95cSBalamuruhan S }
1423b859c95cSBalamuruhan S },
1424b859c95cSBalamuruhan S {
1425b859c95cSBalamuruhan S .mnemonic = "divdeu.",
1426b859c95cSBalamuruhan S .subtests = {
1427b859c95cSBalamuruhan S {
1428b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN",
1429b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)),
1430b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1431b859c95cSBalamuruhan S .regs = {
1432b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1433b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1434b859c95cSBalamuruhan S }
1435b859c95cSBalamuruhan S },
1436b859c95cSBalamuruhan S {
1437b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0",
1438b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)),
1439b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1440b859c95cSBalamuruhan S .regs = {
1441b859c95cSBalamuruhan S .gpr[21] = 1L,
1442b859c95cSBalamuruhan S .gpr[22] = 0,
1443b859c95cSBalamuruhan S }
1444b859c95cSBalamuruhan S },
1445b859c95cSBalamuruhan S {
1446b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX",
1447b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)),
1448b859c95cSBalamuruhan S .regs = {
1449b859c95cSBalamuruhan S .gpr[21] = LONG_MIN,
1450b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1451b859c95cSBalamuruhan S }
1452b859c95cSBalamuruhan S },
1453b859c95cSBalamuruhan S {
1454b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX",
1455b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)),
1456b859c95cSBalamuruhan S .regs = {
1457b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1,
1458b859c95cSBalamuruhan S .gpr[22] = LONG_MAX,
1459b859c95cSBalamuruhan S }
1460b859c95cSBalamuruhan S },
1461b859c95cSBalamuruhan S {
1462b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN",
1463b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)),
1464b859c95cSBalamuruhan S .flags = IGNORE_GPR(20),
1465b859c95cSBalamuruhan S .regs = {
1466b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1,
1467b859c95cSBalamuruhan S .gpr[22] = LONG_MIN,
1468b859c95cSBalamuruhan S }
1469b859c95cSBalamuruhan S }
1470b859c95cSBalamuruhan S }
1471b859c95cSBalamuruhan S },
1472b859c95cSBalamuruhan S {
14734f825900SJordan Niethe .mnemonic = "paddi",
14744f825900SJordan Niethe .cpu_feature = CPU_FTR_ARCH_31,
14754f825900SJordan Niethe .subtests = {
14764f825900SJordan Niethe {
14774f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MIN, R = 0",
14784f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0),
14794f825900SJordan Niethe .regs = {
14804f825900SJordan Niethe .gpr[21] = 0,
14814f825900SJordan Niethe .gpr[22] = LONG_MIN,
14824f825900SJordan Niethe }
14834f825900SJordan Niethe },
14844f825900SJordan Niethe {
14854f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MAX, R = 0",
14864f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0),
14874f825900SJordan Niethe .regs = {
14884f825900SJordan Niethe .gpr[21] = 0,
14894f825900SJordan Niethe .gpr[22] = LONG_MIN,
14904f825900SJordan Niethe }
14914f825900SJordan Niethe },
14924f825900SJordan Niethe {
14934f825900SJordan Niethe .descr = "RA = LONG_MAX, SI = SI_MAX, R = 0",
14944f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0),
14954f825900SJordan Niethe .regs = {
14964f825900SJordan Niethe .gpr[21] = 0,
14974f825900SJordan Niethe .gpr[22] = LONG_MAX,
14984f825900SJordan Niethe }
14994f825900SJordan Niethe },
15004f825900SJordan Niethe {
15014f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = SI_UMAX, R = 0",
15024f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_UMAX, 0),
15034f825900SJordan Niethe .regs = {
15044f825900SJordan Niethe .gpr[21] = 0,
15054f825900SJordan Niethe .gpr[22] = ULONG_MAX,
15064f825900SJordan Niethe }
15074f825900SJordan Niethe },
15084f825900SJordan Niethe {
15094f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = 0x1, R = 0",
15104f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0),
15114f825900SJordan Niethe .regs = {
15124f825900SJordan Niethe .gpr[21] = 0,
15134f825900SJordan Niethe .gpr[22] = ULONG_MAX,
15144f825900SJordan Niethe }
15154f825900SJordan Niethe },
15164f825900SJordan Niethe {
15174f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MIN, R = 0",
15184f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0),
15194f825900SJordan Niethe .regs = {
15204f825900SJordan Niethe .gpr[21] = 0,
15214f825900SJordan Niethe .gpr[22] = INT_MIN,
15224f825900SJordan Niethe }
15234f825900SJordan Niethe },
15244f825900SJordan Niethe {
15254f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MAX, R = 0",
15264f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0),
15274f825900SJordan Niethe .regs = {
15284f825900SJordan Niethe .gpr[21] = 0,
15294f825900SJordan Niethe .gpr[22] = INT_MIN,
15304f825900SJordan Niethe }
15314f825900SJordan Niethe },
15324f825900SJordan Niethe {
15334f825900SJordan Niethe .descr = "RA = INT_MAX, SI = SI_MAX, R = 0",
15344f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0),
15354f825900SJordan Niethe .regs = {
15364f825900SJordan Niethe .gpr[21] = 0,
15374f825900SJordan Niethe .gpr[22] = INT_MAX,
15384f825900SJordan Niethe }
15394f825900SJordan Niethe },
15404f825900SJordan Niethe {
15414f825900SJordan Niethe .descr = "RA = UINT_MAX, SI = 0x1, R = 0",
15424f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0),
15434f825900SJordan Niethe .regs = {
15444f825900SJordan Niethe .gpr[21] = 0,
15454f825900SJordan Niethe .gpr[22] = UINT_MAX,
15464f825900SJordan Niethe }
15474f825900SJordan Niethe },
15484f825900SJordan Niethe {
15494f825900SJordan Niethe .descr = "RA = UINT_MAX, SI = SI_MAX, R = 0",
15504f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0),
15514f825900SJordan Niethe .regs = {
15524f825900SJordan Niethe .gpr[21] = 0,
15534f825900SJordan Niethe .gpr[22] = UINT_MAX,
15544f825900SJordan Niethe }
15554f825900SJordan Niethe },
15564f825900SJordan Niethe {
15574f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 0",
15584f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 0),
15594f825900SJordan Niethe .regs = {
15604f825900SJordan Niethe .gpr[21] = 0x0,
15614f825900SJordan Niethe }
15624f825900SJordan Niethe },
15634f825900SJordan Niethe {
15644f825900SJordan Niethe .descr = "RA = 0, SI = SI_MIN, R = 0",
15654f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0),
15664f825900SJordan Niethe .regs = {
15674f825900SJordan Niethe .gpr[21] = 0x0,
15684f825900SJordan Niethe .gpr[22] = 0x0,
15694f825900SJordan Niethe }
15704f825900SJordan Niethe },
15714f825900SJordan Niethe {
15724f825900SJordan Niethe .descr = "RA is r0, SI = 0, R = 1",
15734f825900SJordan Niethe .instr = TEST_PADDI(21, 0, 0, 1),
15744f825900SJordan Niethe .regs = {
15754f825900SJordan Niethe .gpr[21] = 0,
15764f825900SJordan Niethe }
15774f825900SJordan Niethe },
15784f825900SJordan Niethe {
15794f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 1",
15804f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 1),
15814f825900SJordan Niethe .regs = {
15824f825900SJordan Niethe .gpr[21] = 0,
15834f825900SJordan Niethe }
15847e67c73bSBalamuruhan S },
15857e67c73bSBalamuruhan S /* Invalid instruction form with R = 1 and RA != 0 */
15867e67c73bSBalamuruhan S {
15877e67c73bSBalamuruhan S .descr = "RA = R22(0), SI = 0, R = 1",
15887e67c73bSBalamuruhan S .instr = TEST_PADDI(21, 22, 0, 1),
15897e67c73bSBalamuruhan S .flags = NEGATIVE_TEST,
15907e67c73bSBalamuruhan S .regs = {
15917e67c73bSBalamuruhan S .gpr[21] = 0,
15927e67c73bSBalamuruhan S .gpr[22] = 0,
15937e67c73bSBalamuruhan S }
15944f825900SJordan Niethe }
15954f825900SJordan Niethe }
159684022ac1SSandipan Das }
159784022ac1SSandipan Das };
159884022ac1SSandipan Das
emulate_compute_instr(struct pt_regs * regs,ppc_inst_t instr,bool negative)159984022ac1SSandipan Das static int __init emulate_compute_instr(struct pt_regs *regs,
1600c545b9f0SChristophe Leroy ppc_inst_t instr,
160193c3a0baSBalamuruhan S bool negative)
160284022ac1SSandipan Das {
160393c3a0baSBalamuruhan S int analysed;
160484022ac1SSandipan Das struct instruction_op op;
160584022ac1SSandipan Das
1606777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr))
160784022ac1SSandipan Das return -EINVAL;
160884022ac1SSandipan Das
160959dc5bfcSNicholas Piggin /* This is not a return frame regs */
16101c89cf7fSJordan Niethe regs->nip = patch_site_addr(&patch__exec_instr);
16111c89cf7fSJordan Niethe
161293c3a0baSBalamuruhan S analysed = analyse_instr(&op, regs, instr);
161393c3a0baSBalamuruhan S if (analysed != 1 || GETTYPE(op.type) != COMPUTE) {
161493c3a0baSBalamuruhan S if (negative)
161593c3a0baSBalamuruhan S return -EFAULT;
16162a83afe7SMichael Ellerman pr_info("emulation failed, instruction = %08lx\n", ppc_inst_as_ulong(instr));
161784022ac1SSandipan Das return -EFAULT;
161884022ac1SSandipan Das }
161993c3a0baSBalamuruhan S if (analysed == 1 && negative)
16202a83afe7SMichael Ellerman pr_info("negative test failed, instruction = %08lx\n", ppc_inst_as_ulong(instr));
162193c3a0baSBalamuruhan S if (!negative)
162284022ac1SSandipan Das emulate_update_regs(regs, &op);
162384022ac1SSandipan Das return 0;
162484022ac1SSandipan Das }
162584022ac1SSandipan Das
execute_compute_instr(struct pt_regs * regs,ppc_inst_t instr)162684022ac1SSandipan Das static int __init execute_compute_instr(struct pt_regs *regs,
1627c545b9f0SChristophe Leroy ppc_inst_t instr)
162884022ac1SSandipan Das {
162984022ac1SSandipan Das extern int exec_instr(struct pt_regs *regs);
163084022ac1SSandipan Das
1631777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr))
163284022ac1SSandipan Das return -EINVAL;
163384022ac1SSandipan Das
163484022ac1SSandipan Das /* Patch the NOP with the actual instruction */
163584022ac1SSandipan Das patch_instruction_site(&patch__exec_instr, instr);
163684022ac1SSandipan Das if (exec_instr(regs)) {
16372a83afe7SMichael Ellerman pr_info("execution failed, instruction = %08lx\n", ppc_inst_as_ulong(instr));
163884022ac1SSandipan Das return -EFAULT;
163984022ac1SSandipan Das }
164084022ac1SSandipan Das
164184022ac1SSandipan Das return 0;
164284022ac1SSandipan Das }
164384022ac1SSandipan Das
164484022ac1SSandipan Das #define gpr_mismatch(gprn, exp, got) \
164584022ac1SSandipan Das pr_info("GPR%u mismatch, exp = 0x%016lx, got = 0x%016lx\n", \
164684022ac1SSandipan Das gprn, exp, got)
164784022ac1SSandipan Das
164884022ac1SSandipan Das #define reg_mismatch(name, exp, got) \
164984022ac1SSandipan Das pr_info("%s mismatch, exp = 0x%016lx, got = 0x%016lx\n", \
165084022ac1SSandipan Das name, exp, got)
165184022ac1SSandipan Das
run_tests_compute(void)165284022ac1SSandipan Das static void __init run_tests_compute(void)
165384022ac1SSandipan Das {
165484022ac1SSandipan Das unsigned long flags;
165584022ac1SSandipan Das struct compute_test *test;
165684022ac1SSandipan Das struct pt_regs *regs, exp, got;
165794afd069SJordan Niethe unsigned int i, j, k;
1658c545b9f0SChristophe Leroy ppc_inst_t instr;
165993c3a0baSBalamuruhan S bool ignore_gpr, ignore_xer, ignore_ccr, passed, rc, negative;
166084022ac1SSandipan Das
166184022ac1SSandipan Das for (i = 0; i < ARRAY_SIZE(compute_tests); i++) {
166284022ac1SSandipan Das test = &compute_tests[i];
166384022ac1SSandipan Das
1664301ebf7dSJordan Niethe if (test->cpu_feature && !early_cpu_has_feature(test->cpu_feature)) {
1665301ebf7dSJordan Niethe show_result(test->mnemonic, "SKIP (!CPU_FTR)");
1666301ebf7dSJordan Niethe continue;
1667301ebf7dSJordan Niethe }
1668301ebf7dSJordan Niethe
166984022ac1SSandipan Das for (j = 0; j < MAX_SUBTESTS && test->subtests[j].descr; j++) {
167084022ac1SSandipan Das instr = test->subtests[j].instr;
167184022ac1SSandipan Das flags = test->subtests[j].flags;
167284022ac1SSandipan Das regs = &test->subtests[j].regs;
167393c3a0baSBalamuruhan S negative = flags & NEGATIVE_TEST;
167484022ac1SSandipan Das ignore_xer = flags & IGNORE_XER;
167584022ac1SSandipan Das ignore_ccr = flags & IGNORE_CCR;
167684022ac1SSandipan Das passed = true;
167784022ac1SSandipan Das
167884022ac1SSandipan Das memcpy(&exp, regs, sizeof(struct pt_regs));
167984022ac1SSandipan Das memcpy(&got, regs, sizeof(struct pt_regs));
168084022ac1SSandipan Das
168184022ac1SSandipan Das /*
168284022ac1SSandipan Das * Set a compatible MSR value explicitly to ensure
168384022ac1SSandipan Das * that XER and CR bits are updated appropriately
168484022ac1SSandipan Das */
168584022ac1SSandipan Das exp.msr = MSR_KERNEL;
168684022ac1SSandipan Das got.msr = MSR_KERNEL;
168784022ac1SSandipan Das
168893c3a0baSBalamuruhan S rc = emulate_compute_instr(&got, instr, negative) != 0;
168993c3a0baSBalamuruhan S if (negative) {
169093c3a0baSBalamuruhan S /* skip executing instruction */
169193c3a0baSBalamuruhan S passed = rc;
169293c3a0baSBalamuruhan S goto print;
169393c3a0baSBalamuruhan S } else if (rc || execute_compute_instr(&exp, instr)) {
169484022ac1SSandipan Das passed = false;
169584022ac1SSandipan Das goto print;
169684022ac1SSandipan Das }
169784022ac1SSandipan Das
169884022ac1SSandipan Das /* Verify GPR values */
169984022ac1SSandipan Das for (k = 0; k < 32; k++) {
170084022ac1SSandipan Das ignore_gpr = flags & IGNORE_GPR(k);
170184022ac1SSandipan Das if (!ignore_gpr && exp.gpr[k] != got.gpr[k]) {
170284022ac1SSandipan Das passed = false;
170384022ac1SSandipan Das gpr_mismatch(k, exp.gpr[k], got.gpr[k]);
170484022ac1SSandipan Das }
170584022ac1SSandipan Das }
170684022ac1SSandipan Das
170784022ac1SSandipan Das /* Verify LR value */
170884022ac1SSandipan Das if (exp.link != got.link) {
170984022ac1SSandipan Das passed = false;
171084022ac1SSandipan Das reg_mismatch("LR", exp.link, got.link);
171184022ac1SSandipan Das }
171284022ac1SSandipan Das
171384022ac1SSandipan Das /* Verify XER value */
171484022ac1SSandipan Das if (!ignore_xer && exp.xer != got.xer) {
171584022ac1SSandipan Das passed = false;
171684022ac1SSandipan Das reg_mismatch("XER", exp.xer, got.xer);
171784022ac1SSandipan Das }
171884022ac1SSandipan Das
171984022ac1SSandipan Das /* Verify CR value */
172084022ac1SSandipan Das if (!ignore_ccr && exp.ccr != got.ccr) {
172184022ac1SSandipan Das passed = false;
172284022ac1SSandipan Das reg_mismatch("CR", exp.ccr, got.ccr);
172384022ac1SSandipan Das }
172484022ac1SSandipan Das
172584022ac1SSandipan Das print:
172684022ac1SSandipan Das show_result_with_descr(test->mnemonic,
172784022ac1SSandipan Das test->subtests[j].descr,
172884022ac1SSandipan Das passed ? "PASS" : "FAIL");
172984022ac1SSandipan Das }
173084022ac1SSandipan Das }
173184022ac1SSandipan Das }
173284022ac1SSandipan Das
test_emulate_step(void)173384022ac1SSandipan Das static int __init test_emulate_step(void)
173484022ac1SSandipan Das {
173584022ac1SSandipan Das printk(KERN_INFO "Running instruction emulation self-tests ...\n");
173684022ac1SSandipan Das run_tests_load_store();
173784022ac1SSandipan Das run_tests_compute();
17384ceae137SRavi Bangoria
17394ceae137SRavi Bangoria return 0;
17404ceae137SRavi Bangoria }
17414ceae137SRavi Bangoria late_initcall(test_emulate_step);
1742