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 564f825900SJordan Niethe 574ceae137SRavi Bangoria static void __init init_pt_regs(struct pt_regs *regs) 584ceae137SRavi Bangoria { 594ceae137SRavi Bangoria static unsigned long msr; 604ceae137SRavi Bangoria static bool msr_cached; 614ceae137SRavi Bangoria 624ceae137SRavi Bangoria memset(regs, 0, sizeof(struct pt_regs)); 634ceae137SRavi Bangoria 644ceae137SRavi Bangoria if (likely(msr_cached)) { 654ceae137SRavi Bangoria regs->msr = msr; 664ceae137SRavi Bangoria return; 674ceae137SRavi Bangoria } 684ceae137SRavi Bangoria 694ceae137SRavi Bangoria asm volatile("mfmsr %0" : "=r"(regs->msr)); 704ceae137SRavi Bangoria 714ceae137SRavi Bangoria regs->msr |= MSR_FP; 724ceae137SRavi Bangoria regs->msr |= MSR_VEC; 734ceae137SRavi Bangoria regs->msr |= MSR_VSX; 744ceae137SRavi Bangoria 754ceae137SRavi Bangoria msr = regs->msr; 764ceae137SRavi Bangoria msr_cached = true; 774ceae137SRavi Bangoria } 784ceae137SRavi Bangoria 7984022ac1SSandipan Das static void __init show_result(char *mnemonic, char *result) 804ceae137SRavi Bangoria { 8184022ac1SSandipan Das pr_info("%-14s : %s\n", mnemonic, result); 8284022ac1SSandipan Das } 8384022ac1SSandipan Das 8484022ac1SSandipan Das static void __init show_result_with_descr(char *mnemonic, char *descr, 8584022ac1SSandipan Das char *result) 8684022ac1SSandipan Das { 8784022ac1SSandipan Das pr_info("%-14s : %-50s %s\n", mnemonic, descr, result); 884ceae137SRavi Bangoria } 894ceae137SRavi Bangoria 904ceae137SRavi Bangoria static void __init test_ld(void) 914ceae137SRavi Bangoria { 924ceae137SRavi Bangoria struct pt_regs regs; 934ceae137SRavi Bangoria unsigned long a = 0x23; 944ceae137SRavi Bangoria int stepped = -1; 954ceae137SRavi Bangoria 964ceae137SRavi Bangoria init_pt_regs(®s); 974ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 984ceae137SRavi Bangoria 994ceae137SRavi Bangoria /* ld r5, 0(r3) */ 1001d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LD(5, 3, 0))); 1014ceae137SRavi Bangoria 1024ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a) 1034ceae137SRavi Bangoria show_result("ld", "PASS"); 1044ceae137SRavi Bangoria else 1054ceae137SRavi Bangoria show_result("ld", "FAIL"); 1064ceae137SRavi Bangoria } 1074ceae137SRavi Bangoria 108b6b54b42SJordan Niethe static void __init test_pld(void) 109b6b54b42SJordan Niethe { 110b6b54b42SJordan Niethe struct pt_regs regs; 111b6b54b42SJordan Niethe unsigned long a = 0x23; 112b6b54b42SJordan Niethe int stepped = -1; 113b6b54b42SJordan Niethe 114b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 115b6b54b42SJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 116b6b54b42SJordan Niethe return; 117b6b54b42SJordan Niethe } 118b6b54b42SJordan Niethe 119b6b54b42SJordan Niethe init_pt_regs(®s); 120b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 121b6b54b42SJordan Niethe 122b6b54b42SJordan Niethe /* pld r5, 0(r3), 0 */ 123b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLD(5, 3, 0, 0)); 124b6b54b42SJordan Niethe 125b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a) 126b6b54b42SJordan Niethe show_result("pld", "PASS"); 127b6b54b42SJordan Niethe else 128b6b54b42SJordan Niethe show_result("pld", "FAIL"); 129b6b54b42SJordan Niethe } 130b6b54b42SJordan Niethe 1314ceae137SRavi Bangoria static void __init test_lwz(void) 1324ceae137SRavi Bangoria { 1334ceae137SRavi Bangoria struct pt_regs regs; 1344ceae137SRavi Bangoria unsigned int a = 0x4545; 1354ceae137SRavi Bangoria int stepped = -1; 1364ceae137SRavi Bangoria 1374ceae137SRavi Bangoria init_pt_regs(®s); 1384ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 1394ceae137SRavi Bangoria 1404ceae137SRavi Bangoria /* lwz r5, 0(r3) */ 1411d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZ(5, 3, 0))); 1424ceae137SRavi Bangoria 1434ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a) 1444ceae137SRavi Bangoria show_result("lwz", "PASS"); 1454ceae137SRavi Bangoria else 1464ceae137SRavi Bangoria show_result("lwz", "FAIL"); 1474ceae137SRavi Bangoria } 1484ceae137SRavi Bangoria 149b6b54b42SJordan Niethe static void __init test_plwz(void) 150b6b54b42SJordan Niethe { 151b6b54b42SJordan Niethe struct pt_regs regs; 152b6b54b42SJordan Niethe unsigned int a = 0x4545; 153b6b54b42SJordan Niethe int stepped = -1; 154b6b54b42SJordan Niethe 155b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 156b6b54b42SJordan Niethe show_result("plwz", "SKIP (!CPU_FTR_ARCH_31)"); 157b6b54b42SJordan Niethe return; 158b6b54b42SJordan Niethe } 159b6b54b42SJordan Niethe 160b6b54b42SJordan Niethe init_pt_regs(®s); 161b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 162b6b54b42SJordan Niethe 163b6b54b42SJordan Niethe /* plwz r5, 0(r3), 0 */ 164b6b54b42SJordan Niethe 165b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLWZ(5, 3, 0, 0)); 166b6b54b42SJordan Niethe 167b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a) 168b6b54b42SJordan Niethe show_result("plwz", "PASS"); 169b6b54b42SJordan Niethe else 170b6b54b42SJordan Niethe show_result("plwz", "FAIL"); 171b6b54b42SJordan Niethe } 172b6b54b42SJordan Niethe 1734ceae137SRavi Bangoria static void __init test_lwzx(void) 1744ceae137SRavi Bangoria { 1754ceae137SRavi Bangoria struct pt_regs regs; 1764ceae137SRavi Bangoria unsigned int a[3] = {0x0, 0x0, 0x1234}; 1774ceae137SRavi Bangoria int stepped = -1; 1784ceae137SRavi Bangoria 1794ceae137SRavi Bangoria init_pt_regs(®s); 1804ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) a; 1814ceae137SRavi Bangoria regs.gpr[4] = 8; 1824ceae137SRavi Bangoria regs.gpr[5] = 0x8765; 1834ceae137SRavi Bangoria 1844ceae137SRavi Bangoria /* lwzx r5, r3, r4 */ 1851d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZX(5, 3, 4))); 1864ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a[2]) 1874ceae137SRavi Bangoria show_result("lwzx", "PASS"); 1884ceae137SRavi Bangoria else 1894ceae137SRavi Bangoria show_result("lwzx", "FAIL"); 1904ceae137SRavi Bangoria } 1914ceae137SRavi Bangoria 1924ceae137SRavi Bangoria static void __init test_std(void) 1934ceae137SRavi Bangoria { 1944ceae137SRavi Bangoria struct pt_regs regs; 1954ceae137SRavi Bangoria unsigned long a = 0x1234; 1964ceae137SRavi Bangoria int stepped = -1; 1974ceae137SRavi Bangoria 1984ceae137SRavi Bangoria init_pt_regs(®s); 1994ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 2004ceae137SRavi Bangoria regs.gpr[5] = 0x5678; 2014ceae137SRavi Bangoria 2024ceae137SRavi Bangoria /* std r5, 0(r3) */ 2031d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STD(5, 3, 0))); 20459ed2adfSNicholas Piggin if (stepped == 1 && regs.gpr[5] == a) 2054ceae137SRavi Bangoria show_result("std", "PASS"); 2064ceae137SRavi Bangoria else 2074ceae137SRavi Bangoria show_result("std", "FAIL"); 2084ceae137SRavi Bangoria } 2094ceae137SRavi Bangoria 210b6b54b42SJordan Niethe static void __init test_pstd(void) 211b6b54b42SJordan Niethe { 212b6b54b42SJordan Niethe struct pt_regs regs; 213b6b54b42SJordan Niethe unsigned long a = 0x1234; 214b6b54b42SJordan Niethe int stepped = -1; 215b6b54b42SJordan Niethe 216b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 217b6b54b42SJordan Niethe show_result("pstd", "SKIP (!CPU_FTR_ARCH_31)"); 218b6b54b42SJordan Niethe return; 219b6b54b42SJordan Niethe } 220b6b54b42SJordan Niethe 221b6b54b42SJordan Niethe init_pt_regs(®s); 222b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 223b6b54b42SJordan Niethe regs.gpr[5] = 0x5678; 224b6b54b42SJordan Niethe 225b6b54b42SJordan Niethe /* pstd r5, 0(r3), 0 */ 226b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PSTD(5, 3, 0, 0)); 227b6b54b42SJordan Niethe if (stepped == 1 || regs.gpr[5] == a) 228b6b54b42SJordan Niethe show_result("pstd", "PASS"); 229b6b54b42SJordan Niethe else 230b6b54b42SJordan Niethe show_result("pstd", "FAIL"); 231b6b54b42SJordan Niethe } 232b6b54b42SJordan Niethe 2334ceae137SRavi Bangoria static void __init test_ldarx_stdcx(void) 2344ceae137SRavi Bangoria { 2354ceae137SRavi Bangoria struct pt_regs regs; 2364ceae137SRavi Bangoria unsigned long a = 0x1234; 2374ceae137SRavi Bangoria int stepped = -1; 2384ceae137SRavi Bangoria unsigned long cr0_eq = 0x1 << 29; /* eq bit of CR0 */ 2394ceae137SRavi Bangoria 2404ceae137SRavi Bangoria init_pt_regs(®s); 2414ceae137SRavi Bangoria asm volatile("mfcr %0" : "=r"(regs.ccr)); 2424ceae137SRavi Bangoria 2434ceae137SRavi Bangoria 2444ceae137SRavi Bangoria /*** ldarx ***/ 2454ceae137SRavi Bangoria 2464ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 2474ceae137SRavi Bangoria regs.gpr[4] = 0; 2484ceae137SRavi Bangoria regs.gpr[5] = 0x5678; 2494ceae137SRavi Bangoria 2504ceae137SRavi Bangoria /* ldarx r5, r3, r4, 0 */ 2511d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LDARX(5, 3, 4, 0))); 2524ceae137SRavi Bangoria 2534ceae137SRavi Bangoria /* 2544ceae137SRavi Bangoria * Don't touch 'a' here. Touching 'a' can do Load/store 2554ceae137SRavi Bangoria * of 'a' which result in failure of subsequent stdcx. 2564ceae137SRavi Bangoria * Instead, use hardcoded value for comparison. 2574ceae137SRavi Bangoria */ 2584ceae137SRavi Bangoria if (stepped <= 0 || regs.gpr[5] != 0x1234) { 2594ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (ldarx)"); 2604ceae137SRavi Bangoria return; 2614ceae137SRavi Bangoria } 2624ceae137SRavi Bangoria 2634ceae137SRavi Bangoria 2644ceae137SRavi Bangoria /*** stdcx. ***/ 2654ceae137SRavi Bangoria 2664ceae137SRavi Bangoria regs.gpr[5] = 0x9ABC; 2674ceae137SRavi Bangoria 2684ceae137SRavi Bangoria /* stdcx. r5, r3, r4 */ 2691d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STDCX(5, 3, 4))); 2704ceae137SRavi Bangoria 2714ceae137SRavi Bangoria /* 2724ceae137SRavi Bangoria * Two possible scenarios that indicates successful emulation 2734ceae137SRavi Bangoria * of stdcx. : 2744ceae137SRavi Bangoria * 1. Reservation is active and store is performed. In this 2754ceae137SRavi Bangoria * case cr0.eq bit will be set to 1. 2764ceae137SRavi Bangoria * 2. Reservation is not active and store is not performed. 2774ceae137SRavi Bangoria * In this case cr0.eq bit will be set to 0. 2784ceae137SRavi Bangoria */ 2794ceae137SRavi Bangoria if (stepped == 1 && ((regs.gpr[5] == a && (regs.ccr & cr0_eq)) 2804ceae137SRavi Bangoria || (regs.gpr[5] != a && !(regs.ccr & cr0_eq)))) 2814ceae137SRavi Bangoria show_result("ldarx / stdcx.", "PASS"); 2824ceae137SRavi Bangoria else 2834ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (stdcx.)"); 2844ceae137SRavi Bangoria } 2854ceae137SRavi Bangoria 2864ceae137SRavi Bangoria #ifdef CONFIG_PPC_FPU 2874ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void) 2884ceae137SRavi Bangoria { 2894ceae137SRavi Bangoria struct pt_regs regs; 2904ceae137SRavi Bangoria union { 2914ceae137SRavi Bangoria float a; 2924ceae137SRavi Bangoria int b; 2934ceae137SRavi Bangoria } c; 2944ceae137SRavi Bangoria int cached_b; 2954ceae137SRavi Bangoria int stepped = -1; 2964ceae137SRavi Bangoria 2974ceae137SRavi Bangoria init_pt_regs(®s); 2984ceae137SRavi Bangoria 2994ceae137SRavi Bangoria 3004ceae137SRavi Bangoria /*** lfsx ***/ 3014ceae137SRavi Bangoria 3024ceae137SRavi Bangoria c.a = 123.45; 3034ceae137SRavi Bangoria cached_b = c.b; 3044ceae137SRavi Bangoria 3054ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 3064ceae137SRavi Bangoria regs.gpr[4] = 0; 3074ceae137SRavi Bangoria 3084ceae137SRavi Bangoria /* lfsx frt10, r3, r4 */ 3091d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFSX(10, 3, 4))); 3104ceae137SRavi Bangoria 3114ceae137SRavi Bangoria if (stepped == 1) 3124ceae137SRavi Bangoria show_result("lfsx", "PASS"); 3134ceae137SRavi Bangoria else 3144ceae137SRavi Bangoria show_result("lfsx", "FAIL"); 3154ceae137SRavi Bangoria 3164ceae137SRavi Bangoria 3174ceae137SRavi Bangoria /*** stfsx ***/ 3184ceae137SRavi Bangoria 3194ceae137SRavi Bangoria c.a = 678.91; 3204ceae137SRavi Bangoria 3214ceae137SRavi Bangoria /* stfsx frs10, r3, r4 */ 3221d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFSX(10, 3, 4))); 3234ceae137SRavi Bangoria 3244ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b) 3254ceae137SRavi Bangoria show_result("stfsx", "PASS"); 3264ceae137SRavi Bangoria else 3274ceae137SRavi Bangoria show_result("stfsx", "FAIL"); 3284ceae137SRavi Bangoria } 3294ceae137SRavi Bangoria 3300396de6dSJordan Niethe static void __init test_plfs_pstfs(void) 3310396de6dSJordan Niethe { 3320396de6dSJordan Niethe struct pt_regs regs; 3330396de6dSJordan Niethe union { 3340396de6dSJordan Niethe float a; 3350396de6dSJordan Niethe int b; 3360396de6dSJordan Niethe } c; 3370396de6dSJordan Niethe int cached_b; 3380396de6dSJordan Niethe int stepped = -1; 3390396de6dSJordan Niethe 3400396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 3410396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 3420396de6dSJordan Niethe return; 3430396de6dSJordan Niethe } 3440396de6dSJordan Niethe 3450396de6dSJordan Niethe init_pt_regs(®s); 3460396de6dSJordan Niethe 3470396de6dSJordan Niethe 3480396de6dSJordan Niethe /*** plfs ***/ 3490396de6dSJordan Niethe 3500396de6dSJordan Niethe c.a = 123.45; 3510396de6dSJordan Niethe cached_b = c.b; 3520396de6dSJordan Niethe 3530396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a; 3540396de6dSJordan Niethe 3550396de6dSJordan Niethe /* plfs frt10, 0(r3), 0 */ 3560396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFS(10, 3, 0, 0)); 3570396de6dSJordan Niethe 3580396de6dSJordan Niethe if (stepped == 1) 3590396de6dSJordan Niethe show_result("plfs", "PASS"); 3600396de6dSJordan Niethe else 3610396de6dSJordan Niethe show_result("plfs", "FAIL"); 3620396de6dSJordan Niethe 3630396de6dSJordan Niethe 3640396de6dSJordan Niethe /*** pstfs ***/ 3650396de6dSJordan Niethe 3660396de6dSJordan Niethe c.a = 678.91; 3670396de6dSJordan Niethe 3680396de6dSJordan Niethe /* pstfs frs10, 0(r3), 0 */ 3690396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFS(10, 3, 0, 0)); 3700396de6dSJordan Niethe 3710396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b) 3720396de6dSJordan Niethe show_result("pstfs", "PASS"); 3730396de6dSJordan Niethe else 3740396de6dSJordan Niethe show_result("pstfs", "FAIL"); 3750396de6dSJordan Niethe } 3760396de6dSJordan Niethe 3774ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void) 3784ceae137SRavi Bangoria { 3794ceae137SRavi Bangoria struct pt_regs regs; 3804ceae137SRavi Bangoria union { 3814ceae137SRavi Bangoria double a; 3824ceae137SRavi Bangoria long b; 3834ceae137SRavi Bangoria } c; 3844ceae137SRavi Bangoria long cached_b; 3854ceae137SRavi Bangoria int stepped = -1; 3864ceae137SRavi Bangoria 3874ceae137SRavi Bangoria init_pt_regs(®s); 3884ceae137SRavi Bangoria 3894ceae137SRavi Bangoria 3904ceae137SRavi Bangoria /*** lfdx ***/ 3914ceae137SRavi Bangoria 3924ceae137SRavi Bangoria c.a = 123456.78; 3934ceae137SRavi Bangoria cached_b = c.b; 3944ceae137SRavi Bangoria 3954ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 3964ceae137SRavi Bangoria regs.gpr[4] = 0; 3974ceae137SRavi Bangoria 3984ceae137SRavi Bangoria /* lfdx frt10, r3, r4 */ 3991d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFDX(10, 3, 4))); 4004ceae137SRavi Bangoria 4014ceae137SRavi Bangoria if (stepped == 1) 4024ceae137SRavi Bangoria show_result("lfdx", "PASS"); 4034ceae137SRavi Bangoria else 4044ceae137SRavi Bangoria show_result("lfdx", "FAIL"); 4054ceae137SRavi Bangoria 4064ceae137SRavi Bangoria 4074ceae137SRavi Bangoria /*** stfdx ***/ 4084ceae137SRavi Bangoria 4094ceae137SRavi Bangoria c.a = 987654.32; 4104ceae137SRavi Bangoria 4114ceae137SRavi Bangoria /* stfdx frs10, r3, r4 */ 4121d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFDX(10, 3, 4))); 4134ceae137SRavi Bangoria 4144ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b) 4154ceae137SRavi Bangoria show_result("stfdx", "PASS"); 4164ceae137SRavi Bangoria else 4174ceae137SRavi Bangoria show_result("stfdx", "FAIL"); 4184ceae137SRavi Bangoria } 4190396de6dSJordan Niethe 4200396de6dSJordan Niethe static void __init test_plfd_pstfd(void) 4210396de6dSJordan Niethe { 4220396de6dSJordan Niethe struct pt_regs regs; 4230396de6dSJordan Niethe union { 4240396de6dSJordan Niethe double a; 4250396de6dSJordan Niethe long b; 4260396de6dSJordan Niethe } c; 4270396de6dSJordan Niethe long cached_b; 4280396de6dSJordan Niethe int stepped = -1; 4290396de6dSJordan Niethe 4300396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 4310396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 4320396de6dSJordan Niethe return; 4330396de6dSJordan Niethe } 4340396de6dSJordan Niethe 4350396de6dSJordan Niethe init_pt_regs(®s); 4360396de6dSJordan Niethe 4370396de6dSJordan Niethe 4380396de6dSJordan Niethe /*** plfd ***/ 4390396de6dSJordan Niethe 4400396de6dSJordan Niethe c.a = 123456.78; 4410396de6dSJordan Niethe cached_b = c.b; 4420396de6dSJordan Niethe 4430396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a; 4440396de6dSJordan Niethe 4450396de6dSJordan Niethe /* plfd frt10, 0(r3), 0 */ 4460396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFD(10, 3, 0, 0)); 4470396de6dSJordan Niethe 4480396de6dSJordan Niethe if (stepped == 1) 4490396de6dSJordan Niethe show_result("plfd", "PASS"); 4500396de6dSJordan Niethe else 4510396de6dSJordan Niethe show_result("plfd", "FAIL"); 4520396de6dSJordan Niethe 4530396de6dSJordan Niethe 4540396de6dSJordan Niethe /*** pstfd ***/ 4550396de6dSJordan Niethe 4560396de6dSJordan Niethe c.a = 987654.32; 4570396de6dSJordan Niethe 4580396de6dSJordan Niethe /* pstfd frs10, 0(r3), 0 */ 4590396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFD(10, 3, 0, 0)); 4600396de6dSJordan Niethe 4610396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b) 4620396de6dSJordan Niethe show_result("pstfd", "PASS"); 4630396de6dSJordan Niethe else 4640396de6dSJordan Niethe show_result("pstfd", "FAIL"); 4650396de6dSJordan Niethe } 4664ceae137SRavi Bangoria #else 4674ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void) 4684ceae137SRavi Bangoria { 4694ceae137SRavi Bangoria show_result("lfsx", "SKIP (CONFIG_PPC_FPU is not set)"); 4704ceae137SRavi Bangoria show_result("stfsx", "SKIP (CONFIG_PPC_FPU is not set)"); 4714ceae137SRavi Bangoria } 4724ceae137SRavi Bangoria 4730396de6dSJordan Niethe static void __init test_plfs_pstfs(void) 4740396de6dSJordan Niethe { 4750396de6dSJordan Niethe show_result("plfs", "SKIP (CONFIG_PPC_FPU is not set)"); 4760396de6dSJordan Niethe show_result("pstfs", "SKIP (CONFIG_PPC_FPU is not set)"); 4770396de6dSJordan Niethe } 4780396de6dSJordan Niethe 4794ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void) 4804ceae137SRavi Bangoria { 4814ceae137SRavi Bangoria show_result("lfdx", "SKIP (CONFIG_PPC_FPU is not set)"); 4824ceae137SRavi Bangoria show_result("stfdx", "SKIP (CONFIG_PPC_FPU is not set)"); 4834ceae137SRavi Bangoria } 4840396de6dSJordan Niethe 4850396de6dSJordan Niethe static void __init test_plfd_pstfd(void) 4860396de6dSJordan Niethe { 4870396de6dSJordan Niethe show_result("plfd", "SKIP (CONFIG_PPC_FPU is not set)"); 4880396de6dSJordan Niethe show_result("pstfd", "SKIP (CONFIG_PPC_FPU is not set)"); 4890396de6dSJordan Niethe } 4904ceae137SRavi Bangoria #endif /* CONFIG_PPC_FPU */ 4914ceae137SRavi Bangoria 4924ceae137SRavi Bangoria #ifdef CONFIG_ALTIVEC 4934ceae137SRavi Bangoria static void __init test_lvx_stvx(void) 4944ceae137SRavi Bangoria { 4954ceae137SRavi Bangoria struct pt_regs regs; 4964ceae137SRavi Bangoria union { 4974ceae137SRavi Bangoria vector128 a; 4984ceae137SRavi Bangoria u32 b[4]; 4994ceae137SRavi Bangoria } c; 5004ceae137SRavi Bangoria u32 cached_b[4]; 5014ceae137SRavi Bangoria int stepped = -1; 5024ceae137SRavi Bangoria 5034ceae137SRavi Bangoria init_pt_regs(®s); 5044ceae137SRavi Bangoria 5054ceae137SRavi Bangoria 5064ceae137SRavi Bangoria /*** lvx ***/ 5074ceae137SRavi Bangoria 5084ceae137SRavi Bangoria cached_b[0] = c.b[0] = 923745; 5094ceae137SRavi Bangoria cached_b[1] = c.b[1] = 2139478; 5104ceae137SRavi Bangoria cached_b[2] = c.b[2] = 9012; 5114ceae137SRavi Bangoria cached_b[3] = c.b[3] = 982134; 5124ceae137SRavi Bangoria 5134ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 5144ceae137SRavi Bangoria regs.gpr[4] = 0; 5154ceae137SRavi Bangoria 5164ceae137SRavi Bangoria /* lvx vrt10, r3, r4 */ 5171d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LVX(10, 3, 4))); 5184ceae137SRavi Bangoria 5194ceae137SRavi Bangoria if (stepped == 1) 5204ceae137SRavi Bangoria show_result("lvx", "PASS"); 5214ceae137SRavi Bangoria else 5224ceae137SRavi Bangoria show_result("lvx", "FAIL"); 5234ceae137SRavi Bangoria 5244ceae137SRavi Bangoria 5254ceae137SRavi Bangoria /*** stvx ***/ 5264ceae137SRavi Bangoria 5274ceae137SRavi Bangoria c.b[0] = 4987513; 5284ceae137SRavi Bangoria c.b[1] = 84313948; 5294ceae137SRavi Bangoria c.b[2] = 71; 5304ceae137SRavi Bangoria c.b[3] = 498532; 5314ceae137SRavi Bangoria 5324ceae137SRavi Bangoria /* stvx vrs10, r3, r4 */ 5331d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STVX(10, 3, 4))); 5344ceae137SRavi Bangoria 5354ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] && 5364ceae137SRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3]) 5374ceae137SRavi Bangoria show_result("stvx", "PASS"); 5384ceae137SRavi Bangoria else 5394ceae137SRavi Bangoria show_result("stvx", "FAIL"); 5404ceae137SRavi Bangoria } 5414ceae137SRavi Bangoria #else 5424ceae137SRavi Bangoria static void __init test_lvx_stvx(void) 5434ceae137SRavi Bangoria { 5444ceae137SRavi Bangoria show_result("lvx", "SKIP (CONFIG_ALTIVEC is not set)"); 5454ceae137SRavi Bangoria show_result("stvx", "SKIP (CONFIG_ALTIVEC is not set)"); 5464ceae137SRavi Bangoria } 5474ceae137SRavi Bangoria #endif /* CONFIG_ALTIVEC */ 5484ceae137SRavi Bangoria 5494ceae137SRavi Bangoria #ifdef CONFIG_VSX 5504ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void) 5514ceae137SRavi Bangoria { 5524ceae137SRavi Bangoria struct pt_regs regs; 5534ceae137SRavi Bangoria union { 5544ceae137SRavi Bangoria vector128 a; 5554ceae137SRavi Bangoria u32 b[4]; 5564ceae137SRavi Bangoria } c; 5574ceae137SRavi Bangoria u32 cached_b[4]; 5584ceae137SRavi Bangoria int stepped = -1; 5594ceae137SRavi Bangoria 5604ceae137SRavi Bangoria init_pt_regs(®s); 5614ceae137SRavi Bangoria 5624ceae137SRavi Bangoria 5634ceae137SRavi Bangoria /*** lxvd2x ***/ 5644ceae137SRavi Bangoria 5654ceae137SRavi Bangoria cached_b[0] = c.b[0] = 18233; 5664ceae137SRavi Bangoria cached_b[1] = c.b[1] = 34863571; 5674ceae137SRavi Bangoria cached_b[2] = c.b[2] = 834; 5684ceae137SRavi Bangoria cached_b[3] = c.b[3] = 6138911; 5694ceae137SRavi Bangoria 5704ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 5714ceae137SRavi Bangoria regs.gpr[4] = 0; 5724ceae137SRavi Bangoria 5734ceae137SRavi Bangoria /* lxvd2x vsr39, r3, r4 */ 5741d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVD2X(39, R3, R4))); 5754ceae137SRavi Bangoria 5765a61640eSRavi Bangoria if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 5774ceae137SRavi Bangoria show_result("lxvd2x", "PASS"); 5785a61640eSRavi Bangoria } else { 5795a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX)) 5805a61640eSRavi Bangoria show_result("lxvd2x", "PASS (!CPU_FTR_VSX)"); 5814ceae137SRavi Bangoria else 5824ceae137SRavi Bangoria show_result("lxvd2x", "FAIL"); 5835a61640eSRavi Bangoria } 5844ceae137SRavi Bangoria 5854ceae137SRavi Bangoria 5864ceae137SRavi Bangoria /*** stxvd2x ***/ 5874ceae137SRavi Bangoria 5884ceae137SRavi Bangoria c.b[0] = 21379463; 5894ceae137SRavi Bangoria c.b[1] = 87; 5904ceae137SRavi Bangoria c.b[2] = 374234; 5914ceae137SRavi Bangoria c.b[3] = 4; 5924ceae137SRavi Bangoria 5934ceae137SRavi Bangoria /* stxvd2x vsr39, r3, r4 */ 5941d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVD2X(39, R3, R4))); 5954ceae137SRavi Bangoria 5964ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] && 5975a61640eSRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3] && 5985a61640eSRavi Bangoria cpu_has_feature(CPU_FTR_VSX)) { 5994ceae137SRavi Bangoria show_result("stxvd2x", "PASS"); 6005a61640eSRavi Bangoria } else { 6015a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX)) 6025a61640eSRavi Bangoria show_result("stxvd2x", "PASS (!CPU_FTR_VSX)"); 6034ceae137SRavi Bangoria else 6044ceae137SRavi Bangoria show_result("stxvd2x", "FAIL"); 6054ceae137SRavi Bangoria } 6065a61640eSRavi Bangoria } 6074ceae137SRavi Bangoria #else 6084ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void) 6094ceae137SRavi Bangoria { 6104ceae137SRavi Bangoria show_result("lxvd2x", "SKIP (CONFIG_VSX is not set)"); 6114ceae137SRavi Bangoria show_result("stxvd2x", "SKIP (CONFIG_VSX is not set)"); 6124ceae137SRavi Bangoria } 6134ceae137SRavi Bangoria #endif /* CONFIG_VSX */ 6144ceae137SRavi Bangoria 615*35785b29SBalamuruhan S #ifdef CONFIG_VSX 616*35785b29SBalamuruhan S static void __init test_lxvp_stxvp(void) 617*35785b29SBalamuruhan S { 618*35785b29SBalamuruhan S struct pt_regs regs; 619*35785b29SBalamuruhan S union { 620*35785b29SBalamuruhan S vector128 a; 621*35785b29SBalamuruhan S u32 b[4]; 622*35785b29SBalamuruhan S } c[2]; 623*35785b29SBalamuruhan S u32 cached_b[8]; 624*35785b29SBalamuruhan S int stepped = -1; 625*35785b29SBalamuruhan S 626*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 627*35785b29SBalamuruhan S show_result("lxvp", "SKIP (!CPU_FTR_ARCH_31)"); 628*35785b29SBalamuruhan S show_result("stxvp", "SKIP (!CPU_FTR_ARCH_31)"); 629*35785b29SBalamuruhan S return; 630*35785b29SBalamuruhan S } 631*35785b29SBalamuruhan S 632*35785b29SBalamuruhan S init_pt_regs(®s); 633*35785b29SBalamuruhan S 634*35785b29SBalamuruhan S /*** lxvp ***/ 635*35785b29SBalamuruhan S 636*35785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 637*35785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 638*35785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 639*35785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 640*35785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 641*35785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 642*35785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 643*35785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 644*35785b29SBalamuruhan S 645*35785b29SBalamuruhan S regs.gpr[4] = (unsigned long)&c[0].a; 646*35785b29SBalamuruhan S 647*35785b29SBalamuruhan S /* 648*35785b29SBalamuruhan S * lxvp XTp,DQ(RA) 649*35785b29SBalamuruhan S * XTp = 32xTX + 2xTp 650*35785b29SBalamuruhan S * let TX=1 Tp=1 RA=4 DQ=0 651*35785b29SBalamuruhan S */ 652*35785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVP(34, 4, 0))); 653*35785b29SBalamuruhan S 654*35785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 655*35785b29SBalamuruhan S show_result("lxvp", "PASS"); 656*35785b29SBalamuruhan S } else { 657*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 658*35785b29SBalamuruhan S show_result("lxvp", "PASS (!CPU_FTR_VSX)"); 659*35785b29SBalamuruhan S else 660*35785b29SBalamuruhan S show_result("lxvp", "FAIL"); 661*35785b29SBalamuruhan S } 662*35785b29SBalamuruhan S 663*35785b29SBalamuruhan S /*** stxvp ***/ 664*35785b29SBalamuruhan S 665*35785b29SBalamuruhan S c[0].b[0] = 21379463; 666*35785b29SBalamuruhan S c[0].b[1] = 87; 667*35785b29SBalamuruhan S c[0].b[2] = 374234; 668*35785b29SBalamuruhan S c[0].b[3] = 4; 669*35785b29SBalamuruhan S c[1].b[0] = 90; 670*35785b29SBalamuruhan S c[1].b[1] = 122; 671*35785b29SBalamuruhan S c[1].b[2] = 555; 672*35785b29SBalamuruhan S c[1].b[3] = 32144; 673*35785b29SBalamuruhan S 674*35785b29SBalamuruhan S /* 675*35785b29SBalamuruhan S * stxvp XSp,DQ(RA) 676*35785b29SBalamuruhan S * XSp = 32xSX + 2xSp 677*35785b29SBalamuruhan S * let SX=1 Sp=1 RA=4 DQ=0 678*35785b29SBalamuruhan S */ 679*35785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVP(34, 4, 0))); 680*35785b29SBalamuruhan S 681*35785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 682*35785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 683*35785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 684*35785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 685*35785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 686*35785b29SBalamuruhan S show_result("stxvp", "PASS"); 687*35785b29SBalamuruhan S } else { 688*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 689*35785b29SBalamuruhan S show_result("stxvp", "PASS (!CPU_FTR_VSX)"); 690*35785b29SBalamuruhan S else 691*35785b29SBalamuruhan S show_result("stxvp", "FAIL"); 692*35785b29SBalamuruhan S } 693*35785b29SBalamuruhan S } 694*35785b29SBalamuruhan S #else 695*35785b29SBalamuruhan S static void __init test_lxvp_stxvp(void) 696*35785b29SBalamuruhan S { 697*35785b29SBalamuruhan S show_result("lxvp", "SKIP (CONFIG_VSX is not set)"); 698*35785b29SBalamuruhan S show_result("stxvp", "SKIP (CONFIG_VSX is not set)"); 699*35785b29SBalamuruhan S } 700*35785b29SBalamuruhan S #endif /* CONFIG_VSX */ 701*35785b29SBalamuruhan S 702*35785b29SBalamuruhan S #ifdef CONFIG_VSX 703*35785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void) 704*35785b29SBalamuruhan S { 705*35785b29SBalamuruhan S struct pt_regs regs; 706*35785b29SBalamuruhan S union { 707*35785b29SBalamuruhan S vector128 a; 708*35785b29SBalamuruhan S u32 b[4]; 709*35785b29SBalamuruhan S } c[2]; 710*35785b29SBalamuruhan S u32 cached_b[8]; 711*35785b29SBalamuruhan S int stepped = -1; 712*35785b29SBalamuruhan S 713*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 714*35785b29SBalamuruhan S show_result("lxvpx", "SKIP (!CPU_FTR_ARCH_31)"); 715*35785b29SBalamuruhan S show_result("stxvpx", "SKIP (!CPU_FTR_ARCH_31)"); 716*35785b29SBalamuruhan S return; 717*35785b29SBalamuruhan S } 718*35785b29SBalamuruhan S 719*35785b29SBalamuruhan S init_pt_regs(®s); 720*35785b29SBalamuruhan S 721*35785b29SBalamuruhan S /*** lxvpx ***/ 722*35785b29SBalamuruhan S 723*35785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 724*35785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 725*35785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 726*35785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 727*35785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 728*35785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 729*35785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 730*35785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 731*35785b29SBalamuruhan S 732*35785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a; 733*35785b29SBalamuruhan S regs.gpr[4] = 0; 734*35785b29SBalamuruhan S 735*35785b29SBalamuruhan S /* 736*35785b29SBalamuruhan S * lxvpx XTp,RA,RB 737*35785b29SBalamuruhan S * XTp = 32xTX + 2xTp 738*35785b29SBalamuruhan S * let TX=1 Tp=1 RA=3 RB=4 739*35785b29SBalamuruhan S */ 740*35785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVPX(34, 3, 4))); 741*35785b29SBalamuruhan S 742*35785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 743*35785b29SBalamuruhan S show_result("lxvpx", "PASS"); 744*35785b29SBalamuruhan S } else { 745*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 746*35785b29SBalamuruhan S show_result("lxvpx", "PASS (!CPU_FTR_VSX)"); 747*35785b29SBalamuruhan S else 748*35785b29SBalamuruhan S show_result("lxvpx", "FAIL"); 749*35785b29SBalamuruhan S } 750*35785b29SBalamuruhan S 751*35785b29SBalamuruhan S /*** stxvpx ***/ 752*35785b29SBalamuruhan S 753*35785b29SBalamuruhan S c[0].b[0] = 21379463; 754*35785b29SBalamuruhan S c[0].b[1] = 87; 755*35785b29SBalamuruhan S c[0].b[2] = 374234; 756*35785b29SBalamuruhan S c[0].b[3] = 4; 757*35785b29SBalamuruhan S c[1].b[0] = 90; 758*35785b29SBalamuruhan S c[1].b[1] = 122; 759*35785b29SBalamuruhan S c[1].b[2] = 555; 760*35785b29SBalamuruhan S c[1].b[3] = 32144; 761*35785b29SBalamuruhan S 762*35785b29SBalamuruhan S /* 763*35785b29SBalamuruhan S * stxvpx XSp,RA,RB 764*35785b29SBalamuruhan S * XSp = 32xSX + 2xSp 765*35785b29SBalamuruhan S * let SX=1 Sp=1 RA=3 RB=4 766*35785b29SBalamuruhan S */ 767*35785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVPX(34, 3, 4))); 768*35785b29SBalamuruhan S 769*35785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 770*35785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 771*35785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 772*35785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 773*35785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 774*35785b29SBalamuruhan S show_result("stxvpx", "PASS"); 775*35785b29SBalamuruhan S } else { 776*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 777*35785b29SBalamuruhan S show_result("stxvpx", "PASS (!CPU_FTR_VSX)"); 778*35785b29SBalamuruhan S else 779*35785b29SBalamuruhan S show_result("stxvpx", "FAIL"); 780*35785b29SBalamuruhan S } 781*35785b29SBalamuruhan S } 782*35785b29SBalamuruhan S #else 783*35785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void) 784*35785b29SBalamuruhan S { 785*35785b29SBalamuruhan S show_result("lxvpx", "SKIP (CONFIG_VSX is not set)"); 786*35785b29SBalamuruhan S show_result("stxvpx", "SKIP (CONFIG_VSX is not set)"); 787*35785b29SBalamuruhan S } 788*35785b29SBalamuruhan S #endif /* CONFIG_VSX */ 789*35785b29SBalamuruhan S 790*35785b29SBalamuruhan S #ifdef CONFIG_VSX 791*35785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void) 792*35785b29SBalamuruhan S { 793*35785b29SBalamuruhan S struct ppc_inst instr; 794*35785b29SBalamuruhan S struct pt_regs regs; 795*35785b29SBalamuruhan S union { 796*35785b29SBalamuruhan S vector128 a; 797*35785b29SBalamuruhan S u32 b[4]; 798*35785b29SBalamuruhan S } c[2]; 799*35785b29SBalamuruhan S u32 cached_b[8]; 800*35785b29SBalamuruhan S int stepped = -1; 801*35785b29SBalamuruhan S 802*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 803*35785b29SBalamuruhan S show_result("plxvp", "SKIP (!CPU_FTR_ARCH_31)"); 804*35785b29SBalamuruhan S show_result("pstxvp", "SKIP (!CPU_FTR_ARCH_31)"); 805*35785b29SBalamuruhan S return; 806*35785b29SBalamuruhan S } 807*35785b29SBalamuruhan S 808*35785b29SBalamuruhan S /*** plxvp ***/ 809*35785b29SBalamuruhan S 810*35785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 811*35785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 812*35785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 813*35785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 814*35785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 815*35785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 816*35785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 817*35785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 818*35785b29SBalamuruhan S 819*35785b29SBalamuruhan S init_pt_regs(®s); 820*35785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a; 821*35785b29SBalamuruhan S 822*35785b29SBalamuruhan S /* 823*35785b29SBalamuruhan S * plxvp XTp,D(RA),R 824*35785b29SBalamuruhan S * XTp = 32xTX + 2xTp 825*35785b29SBalamuruhan S * let RA=3 R=0 D=d0||d1=0 R=0 Tp=1 TX=1 826*35785b29SBalamuruhan S */ 827*35785b29SBalamuruhan S instr = ppc_inst_prefix(PPC_RAW_PLXVP(34, 0, 3, 0) >> 32, 828*35785b29SBalamuruhan S PPC_RAW_PLXVP(34, 0, 3, 0) & 0xffffffff); 829*35785b29SBalamuruhan S 830*35785b29SBalamuruhan S stepped = emulate_step(®s, instr); 831*35785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 832*35785b29SBalamuruhan S show_result("plxvp", "PASS"); 833*35785b29SBalamuruhan S } else { 834*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 835*35785b29SBalamuruhan S show_result("plxvp", "PASS (!CPU_FTR_VSX)"); 836*35785b29SBalamuruhan S else 837*35785b29SBalamuruhan S show_result("plxvp", "FAIL"); 838*35785b29SBalamuruhan S } 839*35785b29SBalamuruhan S 840*35785b29SBalamuruhan S /*** pstxvp ***/ 841*35785b29SBalamuruhan S 842*35785b29SBalamuruhan S c[0].b[0] = 21379463; 843*35785b29SBalamuruhan S c[0].b[1] = 87; 844*35785b29SBalamuruhan S c[0].b[2] = 374234; 845*35785b29SBalamuruhan S c[0].b[3] = 4; 846*35785b29SBalamuruhan S c[1].b[0] = 90; 847*35785b29SBalamuruhan S c[1].b[1] = 122; 848*35785b29SBalamuruhan S c[1].b[2] = 555; 849*35785b29SBalamuruhan S c[1].b[3] = 32144; 850*35785b29SBalamuruhan S 851*35785b29SBalamuruhan S /* 852*35785b29SBalamuruhan S * pstxvp XSp,D(RA),R 853*35785b29SBalamuruhan S * XSp = 32xSX + 2xSp 854*35785b29SBalamuruhan S * let RA=3 D=d0||d1=0 R=0 Sp=1 SX=1 855*35785b29SBalamuruhan S */ 856*35785b29SBalamuruhan S instr = ppc_inst_prefix(PPC_RAW_PSTXVP(34, 0, 3, 0) >> 32, 857*35785b29SBalamuruhan S PPC_RAW_PSTXVP(34, 0, 3, 0) & 0xffffffff); 858*35785b29SBalamuruhan S 859*35785b29SBalamuruhan S stepped = emulate_step(®s, instr); 860*35785b29SBalamuruhan S 861*35785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 862*35785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 863*35785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 864*35785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 865*35785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 866*35785b29SBalamuruhan S show_result("pstxvp", "PASS"); 867*35785b29SBalamuruhan S } else { 868*35785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 869*35785b29SBalamuruhan S show_result("pstxvp", "PASS (!CPU_FTR_VSX)"); 870*35785b29SBalamuruhan S else 871*35785b29SBalamuruhan S show_result("pstxvp", "FAIL"); 872*35785b29SBalamuruhan S } 873*35785b29SBalamuruhan S } 874*35785b29SBalamuruhan S #else 875*35785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void) 876*35785b29SBalamuruhan S { 877*35785b29SBalamuruhan S show_result("plxvp", "SKIP (CONFIG_VSX is not set)"); 878*35785b29SBalamuruhan S show_result("pstxvp", "SKIP (CONFIG_VSX is not set)"); 879*35785b29SBalamuruhan S } 880*35785b29SBalamuruhan S #endif /* CONFIG_VSX */ 881*35785b29SBalamuruhan S 88284022ac1SSandipan Das static void __init run_tests_load_store(void) 8834ceae137SRavi Bangoria { 8844ceae137SRavi Bangoria test_ld(); 885b6b54b42SJordan Niethe test_pld(); 8864ceae137SRavi Bangoria test_lwz(); 887b6b54b42SJordan Niethe test_plwz(); 8884ceae137SRavi Bangoria test_lwzx(); 8894ceae137SRavi Bangoria test_std(); 890b6b54b42SJordan Niethe test_pstd(); 8914ceae137SRavi Bangoria test_ldarx_stdcx(); 8924ceae137SRavi Bangoria test_lfsx_stfsx(); 8930396de6dSJordan Niethe test_plfs_pstfs(); 8944ceae137SRavi Bangoria test_lfdx_stfdx(); 8950396de6dSJordan Niethe test_plfd_pstfd(); 8964ceae137SRavi Bangoria test_lvx_stvx(); 8974ceae137SRavi Bangoria test_lxvd2x_stxvd2x(); 898*35785b29SBalamuruhan S test_lxvp_stxvp(); 899*35785b29SBalamuruhan S test_lxvpx_stxvpx(); 900*35785b29SBalamuruhan S test_plxvp_pstxvp(); 90184022ac1SSandipan Das } 90284022ac1SSandipan Das 90384022ac1SSandipan Das struct compute_test { 90484022ac1SSandipan Das char *mnemonic; 905301ebf7dSJordan Niethe unsigned long cpu_feature; 90684022ac1SSandipan Das struct { 90784022ac1SSandipan Das char *descr; 90884022ac1SSandipan Das unsigned long flags; 90994afd069SJordan Niethe struct ppc_inst instr; 91084022ac1SSandipan Das struct pt_regs regs; 91184022ac1SSandipan Das } subtests[MAX_SUBTESTS + 1]; 91284022ac1SSandipan Das }; 91384022ac1SSandipan Das 9144f825900SJordan Niethe /* Extreme values for si0||si1 (the MLS:D-form 34 bit immediate field) */ 9154f825900SJordan Niethe #define SI_MIN BIT(33) 9164f825900SJordan Niethe #define SI_MAX (BIT(33) - 1) 9174f825900SJordan Niethe #define SI_UMAX (BIT(34) - 1) 9184f825900SJordan Niethe 91984022ac1SSandipan Das static struct compute_test compute_tests[] = { 92084022ac1SSandipan Das { 92184022ac1SSandipan Das .mnemonic = "nop", 92284022ac1SSandipan Das .subtests = { 92384022ac1SSandipan Das { 92484022ac1SSandipan Das .descr = "R0 = LONG_MAX", 92575346251SJordan Niethe .instr = ppc_inst(PPC_INST_NOP), 92684022ac1SSandipan Das .regs = { 92784022ac1SSandipan Das .gpr[0] = LONG_MAX, 92884022ac1SSandipan Das } 92984022ac1SSandipan Das } 93084022ac1SSandipan Das } 93144dea178SSandipan Das }, 93244dea178SSandipan Das { 93344dea178SSandipan Das .mnemonic = "add", 93444dea178SSandipan Das .subtests = { 93544dea178SSandipan Das { 93644dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 9371d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 93844dea178SSandipan Das .regs = { 93944dea178SSandipan Das .gpr[21] = LONG_MIN, 94044dea178SSandipan Das .gpr[22] = LONG_MIN, 94144dea178SSandipan Das } 94244dea178SSandipan Das }, 94344dea178SSandipan Das { 94444dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 9451d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 94644dea178SSandipan Das .regs = { 94744dea178SSandipan Das .gpr[21] = LONG_MIN, 94844dea178SSandipan Das .gpr[22] = LONG_MAX, 94944dea178SSandipan Das } 95044dea178SSandipan Das }, 95144dea178SSandipan Das { 95244dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 9531d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 95444dea178SSandipan Das .regs = { 95544dea178SSandipan Das .gpr[21] = LONG_MAX, 95644dea178SSandipan Das .gpr[22] = LONG_MAX, 95744dea178SSandipan Das } 95844dea178SSandipan Das }, 95944dea178SSandipan Das { 96044dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 9611d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 96244dea178SSandipan Das .regs = { 96344dea178SSandipan Das .gpr[21] = ULONG_MAX, 96444dea178SSandipan Das .gpr[22] = ULONG_MAX, 96544dea178SSandipan Das } 96644dea178SSandipan Das }, 96744dea178SSandipan Das { 96844dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 9691d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 97044dea178SSandipan Das .regs = { 97144dea178SSandipan Das .gpr[21] = ULONG_MAX, 97244dea178SSandipan Das .gpr[22] = 0x1, 97344dea178SSandipan Das } 97444dea178SSandipan Das }, 97544dea178SSandipan Das { 97644dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 9771d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 97844dea178SSandipan Das .regs = { 97944dea178SSandipan Das .gpr[21] = INT_MIN, 98044dea178SSandipan Das .gpr[22] = INT_MIN, 98144dea178SSandipan Das } 98244dea178SSandipan Das }, 98344dea178SSandipan Das { 98444dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 9851d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 98644dea178SSandipan Das .regs = { 98744dea178SSandipan Das .gpr[21] = INT_MIN, 98844dea178SSandipan Das .gpr[22] = INT_MAX, 98944dea178SSandipan Das } 99044dea178SSandipan Das }, 99144dea178SSandipan Das { 99244dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 9931d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 99444dea178SSandipan Das .regs = { 99544dea178SSandipan Das .gpr[21] = INT_MAX, 99644dea178SSandipan Das .gpr[22] = INT_MAX, 99744dea178SSandipan Das } 99844dea178SSandipan Das }, 99944dea178SSandipan Das { 100044dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 10011d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 100244dea178SSandipan Das .regs = { 100344dea178SSandipan Das .gpr[21] = UINT_MAX, 100444dea178SSandipan Das .gpr[22] = UINT_MAX, 100544dea178SSandipan Das } 100644dea178SSandipan Das }, 100744dea178SSandipan Das { 100844dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 10091d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 101044dea178SSandipan Das .regs = { 101144dea178SSandipan Das .gpr[21] = UINT_MAX, 101244dea178SSandipan Das .gpr[22] = 0x1, 101344dea178SSandipan Das } 101444dea178SSandipan Das } 101544dea178SSandipan Das } 101644dea178SSandipan Das }, 101744dea178SSandipan Das { 101844dea178SSandipan Das .mnemonic = "add.", 101944dea178SSandipan Das .subtests = { 102044dea178SSandipan Das { 102144dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 102244dea178SSandipan Das .flags = IGNORE_CCR, 10231d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 102444dea178SSandipan Das .regs = { 102544dea178SSandipan Das .gpr[21] = LONG_MIN, 102644dea178SSandipan Das .gpr[22] = LONG_MIN, 102744dea178SSandipan Das } 102844dea178SSandipan Das }, 102944dea178SSandipan Das { 103044dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 10311d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 103244dea178SSandipan Das .regs = { 103344dea178SSandipan Das .gpr[21] = LONG_MIN, 103444dea178SSandipan Das .gpr[22] = LONG_MAX, 103544dea178SSandipan Das } 103644dea178SSandipan Das }, 103744dea178SSandipan Das { 103844dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 103944dea178SSandipan Das .flags = IGNORE_CCR, 10401d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 104144dea178SSandipan Das .regs = { 104244dea178SSandipan Das .gpr[21] = LONG_MAX, 104344dea178SSandipan Das .gpr[22] = LONG_MAX, 104444dea178SSandipan Das } 104544dea178SSandipan Das }, 104644dea178SSandipan Das { 104744dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 10481d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 104944dea178SSandipan Das .regs = { 105044dea178SSandipan Das .gpr[21] = ULONG_MAX, 105144dea178SSandipan Das .gpr[22] = ULONG_MAX, 105244dea178SSandipan Das } 105344dea178SSandipan Das }, 105444dea178SSandipan Das { 105544dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 10561d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 105744dea178SSandipan Das .regs = { 105844dea178SSandipan Das .gpr[21] = ULONG_MAX, 105944dea178SSandipan Das .gpr[22] = 0x1, 106044dea178SSandipan Das } 106144dea178SSandipan Das }, 106244dea178SSandipan Das { 106344dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 10641d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 106544dea178SSandipan Das .regs = { 106644dea178SSandipan Das .gpr[21] = INT_MIN, 106744dea178SSandipan Das .gpr[22] = INT_MIN, 106844dea178SSandipan Das } 106944dea178SSandipan Das }, 107044dea178SSandipan Das { 107144dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 10721d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 107344dea178SSandipan Das .regs = { 107444dea178SSandipan Das .gpr[21] = INT_MIN, 107544dea178SSandipan Das .gpr[22] = INT_MAX, 107644dea178SSandipan Das } 107744dea178SSandipan Das }, 107844dea178SSandipan Das { 107944dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 10801d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 108144dea178SSandipan Das .regs = { 108244dea178SSandipan Das .gpr[21] = INT_MAX, 108344dea178SSandipan Das .gpr[22] = INT_MAX, 108444dea178SSandipan Das } 108544dea178SSandipan Das }, 108644dea178SSandipan Das { 108744dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 10881d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 108944dea178SSandipan Das .regs = { 109044dea178SSandipan Das .gpr[21] = UINT_MAX, 109144dea178SSandipan Das .gpr[22] = UINT_MAX, 109244dea178SSandipan Das } 109344dea178SSandipan Das }, 109444dea178SSandipan Das { 109544dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 10961d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 109744dea178SSandipan Das .regs = { 109844dea178SSandipan Das .gpr[21] = UINT_MAX, 109944dea178SSandipan Das .gpr[22] = 0x1, 110044dea178SSandipan Das } 110144dea178SSandipan Das } 110244dea178SSandipan Das } 110378a8da06SSandipan Das }, 110478a8da06SSandipan Das { 110578a8da06SSandipan Das .mnemonic = "addc", 110678a8da06SSandipan Das .subtests = { 110778a8da06SSandipan Das { 110878a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 11091d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 111078a8da06SSandipan Das .regs = { 111178a8da06SSandipan Das .gpr[21] = LONG_MIN, 111278a8da06SSandipan Das .gpr[22] = LONG_MIN, 111378a8da06SSandipan Das } 111478a8da06SSandipan Das }, 111578a8da06SSandipan Das { 111678a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 11171d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 111878a8da06SSandipan Das .regs = { 111978a8da06SSandipan Das .gpr[21] = LONG_MIN, 112078a8da06SSandipan Das .gpr[22] = LONG_MAX, 112178a8da06SSandipan Das } 112278a8da06SSandipan Das }, 112378a8da06SSandipan Das { 112478a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 11251d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 112678a8da06SSandipan Das .regs = { 112778a8da06SSandipan Das .gpr[21] = LONG_MAX, 112878a8da06SSandipan Das .gpr[22] = LONG_MAX, 112978a8da06SSandipan Das } 113078a8da06SSandipan Das }, 113178a8da06SSandipan Das { 113278a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 11331d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 113478a8da06SSandipan Das .regs = { 113578a8da06SSandipan Das .gpr[21] = ULONG_MAX, 113678a8da06SSandipan Das .gpr[22] = ULONG_MAX, 113778a8da06SSandipan Das } 113878a8da06SSandipan Das }, 113978a8da06SSandipan Das { 114078a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 11411d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 114278a8da06SSandipan Das .regs = { 114378a8da06SSandipan Das .gpr[21] = ULONG_MAX, 114478a8da06SSandipan Das .gpr[22] = 0x1, 114578a8da06SSandipan Das } 114678a8da06SSandipan Das }, 114778a8da06SSandipan Das { 114878a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 11491d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 115078a8da06SSandipan Das .regs = { 115178a8da06SSandipan Das .gpr[21] = INT_MIN, 115278a8da06SSandipan Das .gpr[22] = INT_MIN, 115378a8da06SSandipan Das } 115478a8da06SSandipan Das }, 115578a8da06SSandipan Das { 115678a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 11571d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 115878a8da06SSandipan Das .regs = { 115978a8da06SSandipan Das .gpr[21] = INT_MIN, 116078a8da06SSandipan Das .gpr[22] = INT_MAX, 116178a8da06SSandipan Das } 116278a8da06SSandipan Das }, 116378a8da06SSandipan Das { 116478a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 11651d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 116678a8da06SSandipan Das .regs = { 116778a8da06SSandipan Das .gpr[21] = INT_MAX, 116878a8da06SSandipan Das .gpr[22] = INT_MAX, 116978a8da06SSandipan Das } 117078a8da06SSandipan Das }, 117178a8da06SSandipan Das { 117278a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 11731d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 117478a8da06SSandipan Das .regs = { 117578a8da06SSandipan Das .gpr[21] = UINT_MAX, 117678a8da06SSandipan Das .gpr[22] = UINT_MAX, 117778a8da06SSandipan Das } 117878a8da06SSandipan Das }, 117978a8da06SSandipan Das { 118078a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 11811d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 118278a8da06SSandipan Das .regs = { 118378a8da06SSandipan Das .gpr[21] = UINT_MAX, 118478a8da06SSandipan Das .gpr[22] = 0x1, 118578a8da06SSandipan Das } 118678a8da06SSandipan Das }, 118778a8da06SSandipan Das { 118878a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN", 11891d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 119078a8da06SSandipan Das .regs = { 119178a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN, 119278a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN, 119378a8da06SSandipan Das } 119478a8da06SSandipan Das } 119578a8da06SSandipan Das } 119678a8da06SSandipan Das }, 119778a8da06SSandipan Das { 119878a8da06SSandipan Das .mnemonic = "addc.", 119978a8da06SSandipan Das .subtests = { 120078a8da06SSandipan Das { 120178a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 120278a8da06SSandipan Das .flags = IGNORE_CCR, 12031d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 120478a8da06SSandipan Das .regs = { 120578a8da06SSandipan Das .gpr[21] = LONG_MIN, 120678a8da06SSandipan Das .gpr[22] = LONG_MIN, 120778a8da06SSandipan Das } 120878a8da06SSandipan Das }, 120978a8da06SSandipan Das { 121078a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 12111d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 121278a8da06SSandipan Das .regs = { 121378a8da06SSandipan Das .gpr[21] = LONG_MIN, 121478a8da06SSandipan Das .gpr[22] = LONG_MAX, 121578a8da06SSandipan Das } 121678a8da06SSandipan Das }, 121778a8da06SSandipan Das { 121878a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 121978a8da06SSandipan Das .flags = IGNORE_CCR, 12201d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 122178a8da06SSandipan Das .regs = { 122278a8da06SSandipan Das .gpr[21] = LONG_MAX, 122378a8da06SSandipan Das .gpr[22] = LONG_MAX, 122478a8da06SSandipan Das } 122578a8da06SSandipan Das }, 122678a8da06SSandipan Das { 122778a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 12281d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 122978a8da06SSandipan Das .regs = { 123078a8da06SSandipan Das .gpr[21] = ULONG_MAX, 123178a8da06SSandipan Das .gpr[22] = ULONG_MAX, 123278a8da06SSandipan Das } 123378a8da06SSandipan Das }, 123478a8da06SSandipan Das { 123578a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 12361d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 123778a8da06SSandipan Das .regs = { 123878a8da06SSandipan Das .gpr[21] = ULONG_MAX, 123978a8da06SSandipan Das .gpr[22] = 0x1, 124078a8da06SSandipan Das } 124178a8da06SSandipan Das }, 124278a8da06SSandipan Das { 124378a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 12441d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 124578a8da06SSandipan Das .regs = { 124678a8da06SSandipan Das .gpr[21] = INT_MIN, 124778a8da06SSandipan Das .gpr[22] = INT_MIN, 124878a8da06SSandipan Das } 124978a8da06SSandipan Das }, 125078a8da06SSandipan Das { 125178a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 12521d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 125378a8da06SSandipan Das .regs = { 125478a8da06SSandipan Das .gpr[21] = INT_MIN, 125578a8da06SSandipan Das .gpr[22] = INT_MAX, 125678a8da06SSandipan Das } 125778a8da06SSandipan Das }, 125878a8da06SSandipan Das { 125978a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 12601d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 126178a8da06SSandipan Das .regs = { 126278a8da06SSandipan Das .gpr[21] = INT_MAX, 126378a8da06SSandipan Das .gpr[22] = INT_MAX, 126478a8da06SSandipan Das } 126578a8da06SSandipan Das }, 126678a8da06SSandipan Das { 126778a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 12681d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 126978a8da06SSandipan Das .regs = { 127078a8da06SSandipan Das .gpr[21] = UINT_MAX, 127178a8da06SSandipan Das .gpr[22] = UINT_MAX, 127278a8da06SSandipan Das } 127378a8da06SSandipan Das }, 127478a8da06SSandipan Das { 127578a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 12761d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 127778a8da06SSandipan Das .regs = { 127878a8da06SSandipan Das .gpr[21] = UINT_MAX, 127978a8da06SSandipan Das .gpr[22] = 0x1, 128078a8da06SSandipan Das } 128178a8da06SSandipan Das }, 128278a8da06SSandipan Das { 128378a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN", 12841d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 128578a8da06SSandipan Das .regs = { 128678a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN, 128778a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN, 128878a8da06SSandipan Das } 128978a8da06SSandipan Das } 129078a8da06SSandipan Das } 12914f825900SJordan Niethe }, 12924f825900SJordan Niethe { 1293b859c95cSBalamuruhan S .mnemonic = "divde", 1294b859c95cSBalamuruhan S .subtests = { 1295b859c95cSBalamuruhan S { 1296b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1297b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1298b859c95cSBalamuruhan S .regs = { 1299b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1300b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1301b859c95cSBalamuruhan S } 1302b859c95cSBalamuruhan S }, 1303b859c95cSBalamuruhan S { 1304b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1305b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1306b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1307b859c95cSBalamuruhan S .regs = { 1308b859c95cSBalamuruhan S .gpr[21] = 1L, 1309b859c95cSBalamuruhan S .gpr[22] = 0, 1310b859c95cSBalamuruhan S } 1311b859c95cSBalamuruhan S }, 1312b859c95cSBalamuruhan S { 1313b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1314b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1315b859c95cSBalamuruhan S .regs = { 1316b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1317b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1318b859c95cSBalamuruhan S } 1319b859c95cSBalamuruhan S } 1320b859c95cSBalamuruhan S } 1321b859c95cSBalamuruhan S }, 1322b859c95cSBalamuruhan S { 1323b859c95cSBalamuruhan S .mnemonic = "divde.", 1324b859c95cSBalamuruhan S .subtests = { 1325b859c95cSBalamuruhan S { 1326b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1327b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1328b859c95cSBalamuruhan S .regs = { 1329b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1330b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1331b859c95cSBalamuruhan S } 1332b859c95cSBalamuruhan S }, 1333b859c95cSBalamuruhan S { 1334b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1335b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1336b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1337b859c95cSBalamuruhan S .regs = { 1338b859c95cSBalamuruhan S .gpr[21] = 1L, 1339b859c95cSBalamuruhan S .gpr[22] = 0, 1340b859c95cSBalamuruhan S } 1341b859c95cSBalamuruhan S }, 1342b859c95cSBalamuruhan S { 1343b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1344b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1345b859c95cSBalamuruhan S .regs = { 1346b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1347b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1348b859c95cSBalamuruhan S } 1349b859c95cSBalamuruhan S } 1350b859c95cSBalamuruhan S } 1351b859c95cSBalamuruhan S }, 1352b859c95cSBalamuruhan S { 1353b859c95cSBalamuruhan S .mnemonic = "divdeu", 1354b859c95cSBalamuruhan S .subtests = { 1355b859c95cSBalamuruhan S { 1356b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1357b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1358b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1359b859c95cSBalamuruhan S .regs = { 1360b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1361b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1362b859c95cSBalamuruhan S } 1363b859c95cSBalamuruhan S }, 1364b859c95cSBalamuruhan S { 1365b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1366b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1367b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1368b859c95cSBalamuruhan S .regs = { 1369b859c95cSBalamuruhan S .gpr[21] = 1L, 1370b859c95cSBalamuruhan S .gpr[22] = 0, 1371b859c95cSBalamuruhan S } 1372b859c95cSBalamuruhan S }, 1373b859c95cSBalamuruhan S { 1374b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1375b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1376b859c95cSBalamuruhan S .regs = { 1377b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1378b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1379b859c95cSBalamuruhan S } 1380b859c95cSBalamuruhan S }, 1381b859c95cSBalamuruhan S { 1382b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1383b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1384b859c95cSBalamuruhan S .regs = { 1385b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1, 1386b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1387b859c95cSBalamuruhan S } 1388b859c95cSBalamuruhan S }, 1389b859c95cSBalamuruhan S { 1390b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1391b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1392b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1393b859c95cSBalamuruhan S .regs = { 1394b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1, 1395b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1396b859c95cSBalamuruhan S } 1397b859c95cSBalamuruhan S } 1398b859c95cSBalamuruhan S } 1399b859c95cSBalamuruhan S }, 1400b859c95cSBalamuruhan S { 1401b859c95cSBalamuruhan S .mnemonic = "divdeu.", 1402b859c95cSBalamuruhan S .subtests = { 1403b859c95cSBalamuruhan S { 1404b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1405b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1406b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1407b859c95cSBalamuruhan S .regs = { 1408b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1409b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1410b859c95cSBalamuruhan S } 1411b859c95cSBalamuruhan S }, 1412b859c95cSBalamuruhan S { 1413b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1414b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1415b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1416b859c95cSBalamuruhan S .regs = { 1417b859c95cSBalamuruhan S .gpr[21] = 1L, 1418b859c95cSBalamuruhan S .gpr[22] = 0, 1419b859c95cSBalamuruhan S } 1420b859c95cSBalamuruhan S }, 1421b859c95cSBalamuruhan S { 1422b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1423b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1424b859c95cSBalamuruhan S .regs = { 1425b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1426b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1427b859c95cSBalamuruhan S } 1428b859c95cSBalamuruhan S }, 1429b859c95cSBalamuruhan S { 1430b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1431b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1432b859c95cSBalamuruhan S .regs = { 1433b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1, 1434b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1435b859c95cSBalamuruhan S } 1436b859c95cSBalamuruhan S }, 1437b859c95cSBalamuruhan S { 1438b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1439b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1440b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1441b859c95cSBalamuruhan S .regs = { 1442b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1, 1443b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1444b859c95cSBalamuruhan S } 1445b859c95cSBalamuruhan S } 1446b859c95cSBalamuruhan S } 1447b859c95cSBalamuruhan S }, 1448b859c95cSBalamuruhan S { 14494f825900SJordan Niethe .mnemonic = "paddi", 14504f825900SJordan Niethe .cpu_feature = CPU_FTR_ARCH_31, 14514f825900SJordan Niethe .subtests = { 14524f825900SJordan Niethe { 14534f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MIN, R = 0", 14544f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 14554f825900SJordan Niethe .regs = { 14564f825900SJordan Niethe .gpr[21] = 0, 14574f825900SJordan Niethe .gpr[22] = LONG_MIN, 14584f825900SJordan Niethe } 14594f825900SJordan Niethe }, 14604f825900SJordan Niethe { 14614f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MAX, R = 0", 14624f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 14634f825900SJordan Niethe .regs = { 14644f825900SJordan Niethe .gpr[21] = 0, 14654f825900SJordan Niethe .gpr[22] = LONG_MIN, 14664f825900SJordan Niethe } 14674f825900SJordan Niethe }, 14684f825900SJordan Niethe { 14694f825900SJordan Niethe .descr = "RA = LONG_MAX, SI = SI_MAX, R = 0", 14704f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 14714f825900SJordan Niethe .regs = { 14724f825900SJordan Niethe .gpr[21] = 0, 14734f825900SJordan Niethe .gpr[22] = LONG_MAX, 14744f825900SJordan Niethe } 14754f825900SJordan Niethe }, 14764f825900SJordan Niethe { 14774f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = SI_UMAX, R = 0", 14784f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_UMAX, 0), 14794f825900SJordan Niethe .regs = { 14804f825900SJordan Niethe .gpr[21] = 0, 14814f825900SJordan Niethe .gpr[22] = ULONG_MAX, 14824f825900SJordan Niethe } 14834f825900SJordan Niethe }, 14844f825900SJordan Niethe { 14854f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = 0x1, R = 0", 14864f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0), 14874f825900SJordan Niethe .regs = { 14884f825900SJordan Niethe .gpr[21] = 0, 14894f825900SJordan Niethe .gpr[22] = ULONG_MAX, 14904f825900SJordan Niethe } 14914f825900SJordan Niethe }, 14924f825900SJordan Niethe { 14934f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MIN, R = 0", 14944f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 14954f825900SJordan Niethe .regs = { 14964f825900SJordan Niethe .gpr[21] = 0, 14974f825900SJordan Niethe .gpr[22] = INT_MIN, 14984f825900SJordan Niethe } 14994f825900SJordan Niethe }, 15004f825900SJordan Niethe { 15014f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MAX, R = 0", 15024f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 15034f825900SJordan Niethe .regs = { 15044f825900SJordan Niethe .gpr[21] = 0, 15054f825900SJordan Niethe .gpr[22] = INT_MIN, 15064f825900SJordan Niethe } 15074f825900SJordan Niethe }, 15084f825900SJordan Niethe { 15094f825900SJordan Niethe .descr = "RA = INT_MAX, SI = SI_MAX, R = 0", 15104f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 15114f825900SJordan Niethe .regs = { 15124f825900SJordan Niethe .gpr[21] = 0, 15134f825900SJordan Niethe .gpr[22] = INT_MAX, 15144f825900SJordan Niethe } 15154f825900SJordan Niethe }, 15164f825900SJordan Niethe { 15174f825900SJordan Niethe .descr = "RA = UINT_MAX, SI = 0x1, R = 0", 15184f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0), 15194f825900SJordan Niethe .regs = { 15204f825900SJordan Niethe .gpr[21] = 0, 15214f825900SJordan Niethe .gpr[22] = UINT_MAX, 15224f825900SJordan Niethe } 15234f825900SJordan Niethe }, 15244f825900SJordan Niethe { 15254f825900SJordan Niethe .descr = "RA = UINT_MAX, 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] = UINT_MAX, 15304f825900SJordan Niethe } 15314f825900SJordan Niethe }, 15324f825900SJordan Niethe { 15334f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 0", 15344f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 0), 15354f825900SJordan Niethe .regs = { 15364f825900SJordan Niethe .gpr[21] = 0x0, 15374f825900SJordan Niethe } 15384f825900SJordan Niethe }, 15394f825900SJordan Niethe { 15404f825900SJordan Niethe .descr = "RA = 0, SI = SI_MIN, R = 0", 15414f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 15424f825900SJordan Niethe .regs = { 15434f825900SJordan Niethe .gpr[21] = 0x0, 15444f825900SJordan Niethe .gpr[22] = 0x0, 15454f825900SJordan Niethe } 15464f825900SJordan Niethe }, 15474f825900SJordan Niethe { 15484f825900SJordan Niethe .descr = "RA is r0, SI = 0, R = 1", 15494f825900SJordan Niethe .instr = TEST_PADDI(21, 0, 0, 1), 15504f825900SJordan Niethe .regs = { 15514f825900SJordan Niethe .gpr[21] = 0, 15524f825900SJordan Niethe } 15534f825900SJordan Niethe }, 15544f825900SJordan Niethe { 15554f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 1", 15564f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 1), 15574f825900SJordan Niethe .regs = { 15584f825900SJordan Niethe .gpr[21] = 0, 15594f825900SJordan Niethe } 15607e67c73bSBalamuruhan S }, 15617e67c73bSBalamuruhan S /* Invalid instruction form with R = 1 and RA != 0 */ 15627e67c73bSBalamuruhan S { 15637e67c73bSBalamuruhan S .descr = "RA = R22(0), SI = 0, R = 1", 15647e67c73bSBalamuruhan S .instr = TEST_PADDI(21, 22, 0, 1), 15657e67c73bSBalamuruhan S .flags = NEGATIVE_TEST, 15667e67c73bSBalamuruhan S .regs = { 15677e67c73bSBalamuruhan S .gpr[21] = 0, 15687e67c73bSBalamuruhan S .gpr[22] = 0, 15697e67c73bSBalamuruhan S } 15704f825900SJordan Niethe } 15714f825900SJordan Niethe } 157284022ac1SSandipan Das } 157384022ac1SSandipan Das }; 157484022ac1SSandipan Das 157584022ac1SSandipan Das static int __init emulate_compute_instr(struct pt_regs *regs, 157693c3a0baSBalamuruhan S struct ppc_inst instr, 157793c3a0baSBalamuruhan S bool negative) 157884022ac1SSandipan Das { 157993c3a0baSBalamuruhan S int analysed; 158084022ac1SSandipan Das struct instruction_op op; 158184022ac1SSandipan Das 1582777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr)) 158384022ac1SSandipan Das return -EINVAL; 158484022ac1SSandipan Das 15851c89cf7fSJordan Niethe regs->nip = patch_site_addr(&patch__exec_instr); 15861c89cf7fSJordan Niethe 158793c3a0baSBalamuruhan S analysed = analyse_instr(&op, regs, instr); 158893c3a0baSBalamuruhan S if (analysed != 1 || GETTYPE(op.type) != COMPUTE) { 158993c3a0baSBalamuruhan S if (negative) 159093c3a0baSBalamuruhan S return -EFAULT; 159193c3a0baSBalamuruhan S pr_info("emulation failed, instruction = %s\n", ppc_inst_as_str(instr)); 159284022ac1SSandipan Das return -EFAULT; 159384022ac1SSandipan Das } 159493c3a0baSBalamuruhan S if (analysed == 1 && negative) 159593c3a0baSBalamuruhan S pr_info("negative test failed, instruction = %s\n", ppc_inst_as_str(instr)); 159693c3a0baSBalamuruhan S if (!negative) 159784022ac1SSandipan Das emulate_update_regs(regs, &op); 159884022ac1SSandipan Das return 0; 159984022ac1SSandipan Das } 160084022ac1SSandipan Das 160184022ac1SSandipan Das static int __init execute_compute_instr(struct pt_regs *regs, 160294afd069SJordan Niethe struct ppc_inst instr) 160384022ac1SSandipan Das { 160484022ac1SSandipan Das extern int exec_instr(struct pt_regs *regs); 160584022ac1SSandipan Das 1606777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr)) 160784022ac1SSandipan Das return -EINVAL; 160884022ac1SSandipan Das 160984022ac1SSandipan Das /* Patch the NOP with the actual instruction */ 161084022ac1SSandipan Das patch_instruction_site(&patch__exec_instr, instr); 161184022ac1SSandipan Das if (exec_instr(regs)) { 161250428fdcSJordan Niethe pr_info("execution failed, instruction = %s\n", ppc_inst_as_str(instr)); 161384022ac1SSandipan Das return -EFAULT; 161484022ac1SSandipan Das } 161584022ac1SSandipan Das 161684022ac1SSandipan Das return 0; 161784022ac1SSandipan Das } 161884022ac1SSandipan Das 161984022ac1SSandipan Das #define gpr_mismatch(gprn, exp, got) \ 162084022ac1SSandipan Das pr_info("GPR%u mismatch, exp = 0x%016lx, got = 0x%016lx\n", \ 162184022ac1SSandipan Das gprn, exp, got) 162284022ac1SSandipan Das 162384022ac1SSandipan Das #define reg_mismatch(name, exp, got) \ 162484022ac1SSandipan Das pr_info("%s mismatch, exp = 0x%016lx, got = 0x%016lx\n", \ 162584022ac1SSandipan Das name, exp, got) 162684022ac1SSandipan Das 162784022ac1SSandipan Das static void __init run_tests_compute(void) 162884022ac1SSandipan Das { 162984022ac1SSandipan Das unsigned long flags; 163084022ac1SSandipan Das struct compute_test *test; 163184022ac1SSandipan Das struct pt_regs *regs, exp, got; 163294afd069SJordan Niethe unsigned int i, j, k; 163394afd069SJordan Niethe struct ppc_inst instr; 163493c3a0baSBalamuruhan S bool ignore_gpr, ignore_xer, ignore_ccr, passed, rc, negative; 163584022ac1SSandipan Das 163684022ac1SSandipan Das for (i = 0; i < ARRAY_SIZE(compute_tests); i++) { 163784022ac1SSandipan Das test = &compute_tests[i]; 163884022ac1SSandipan Das 1639301ebf7dSJordan Niethe if (test->cpu_feature && !early_cpu_has_feature(test->cpu_feature)) { 1640301ebf7dSJordan Niethe show_result(test->mnemonic, "SKIP (!CPU_FTR)"); 1641301ebf7dSJordan Niethe continue; 1642301ebf7dSJordan Niethe } 1643301ebf7dSJordan Niethe 164484022ac1SSandipan Das for (j = 0; j < MAX_SUBTESTS && test->subtests[j].descr; j++) { 164584022ac1SSandipan Das instr = test->subtests[j].instr; 164684022ac1SSandipan Das flags = test->subtests[j].flags; 164784022ac1SSandipan Das regs = &test->subtests[j].regs; 164893c3a0baSBalamuruhan S negative = flags & NEGATIVE_TEST; 164984022ac1SSandipan Das ignore_xer = flags & IGNORE_XER; 165084022ac1SSandipan Das ignore_ccr = flags & IGNORE_CCR; 165184022ac1SSandipan Das passed = true; 165284022ac1SSandipan Das 165384022ac1SSandipan Das memcpy(&exp, regs, sizeof(struct pt_regs)); 165484022ac1SSandipan Das memcpy(&got, regs, sizeof(struct pt_regs)); 165584022ac1SSandipan Das 165684022ac1SSandipan Das /* 165784022ac1SSandipan Das * Set a compatible MSR value explicitly to ensure 165884022ac1SSandipan Das * that XER and CR bits are updated appropriately 165984022ac1SSandipan Das */ 166084022ac1SSandipan Das exp.msr = MSR_KERNEL; 166184022ac1SSandipan Das got.msr = MSR_KERNEL; 166284022ac1SSandipan Das 166393c3a0baSBalamuruhan S rc = emulate_compute_instr(&got, instr, negative) != 0; 166493c3a0baSBalamuruhan S if (negative) { 166593c3a0baSBalamuruhan S /* skip executing instruction */ 166693c3a0baSBalamuruhan S passed = rc; 166793c3a0baSBalamuruhan S goto print; 166893c3a0baSBalamuruhan S } else if (rc || execute_compute_instr(&exp, instr)) { 166984022ac1SSandipan Das passed = false; 167084022ac1SSandipan Das goto print; 167184022ac1SSandipan Das } 167284022ac1SSandipan Das 167384022ac1SSandipan Das /* Verify GPR values */ 167484022ac1SSandipan Das for (k = 0; k < 32; k++) { 167584022ac1SSandipan Das ignore_gpr = flags & IGNORE_GPR(k); 167684022ac1SSandipan Das if (!ignore_gpr && exp.gpr[k] != got.gpr[k]) { 167784022ac1SSandipan Das passed = false; 167884022ac1SSandipan Das gpr_mismatch(k, exp.gpr[k], got.gpr[k]); 167984022ac1SSandipan Das } 168084022ac1SSandipan Das } 168184022ac1SSandipan Das 168284022ac1SSandipan Das /* Verify LR value */ 168384022ac1SSandipan Das if (exp.link != got.link) { 168484022ac1SSandipan Das passed = false; 168584022ac1SSandipan Das reg_mismatch("LR", exp.link, got.link); 168684022ac1SSandipan Das } 168784022ac1SSandipan Das 168884022ac1SSandipan Das /* Verify XER value */ 168984022ac1SSandipan Das if (!ignore_xer && exp.xer != got.xer) { 169084022ac1SSandipan Das passed = false; 169184022ac1SSandipan Das reg_mismatch("XER", exp.xer, got.xer); 169284022ac1SSandipan Das } 169384022ac1SSandipan Das 169484022ac1SSandipan Das /* Verify CR value */ 169584022ac1SSandipan Das if (!ignore_ccr && exp.ccr != got.ccr) { 169684022ac1SSandipan Das passed = false; 169784022ac1SSandipan Das reg_mismatch("CR", exp.ccr, got.ccr); 169884022ac1SSandipan Das } 169984022ac1SSandipan Das 170084022ac1SSandipan Das print: 170184022ac1SSandipan Das show_result_with_descr(test->mnemonic, 170284022ac1SSandipan Das test->subtests[j].descr, 170384022ac1SSandipan Das passed ? "PASS" : "FAIL"); 170484022ac1SSandipan Das } 170584022ac1SSandipan Das } 170684022ac1SSandipan Das } 170784022ac1SSandipan Das 170884022ac1SSandipan Das static int __init test_emulate_step(void) 170984022ac1SSandipan Das { 171084022ac1SSandipan Das printk(KERN_INFO "Running instruction emulation self-tests ...\n"); 171184022ac1SSandipan Das run_tests_load_store(); 171284022ac1SSandipan Das run_tests_compute(); 17134ceae137SRavi Bangoria 17144ceae137SRavi Bangoria return 0; 17154ceae137SRavi Bangoria } 17164ceae137SRavi Bangoria late_initcall(test_emulate_step); 1717