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 5660060d70SSathvika Vasireddy #define TEST_SETB(t, bfa) ppc_inst(PPC_INST_SETB | ___PPC_RT(t) | ___PPC_RA((bfa & 0x7) << 2)) 5760060d70SSathvika Vasireddy 584f825900SJordan Niethe 594ceae137SRavi Bangoria static void __init init_pt_regs(struct pt_regs *regs) 604ceae137SRavi Bangoria { 614ceae137SRavi Bangoria static unsigned long msr; 624ceae137SRavi Bangoria static bool msr_cached; 634ceae137SRavi Bangoria 644ceae137SRavi Bangoria memset(regs, 0, sizeof(struct pt_regs)); 654ceae137SRavi Bangoria 664ceae137SRavi Bangoria if (likely(msr_cached)) { 674ceae137SRavi Bangoria regs->msr = msr; 684ceae137SRavi Bangoria return; 694ceae137SRavi Bangoria } 704ceae137SRavi Bangoria 714ceae137SRavi Bangoria asm volatile("mfmsr %0" : "=r"(regs->msr)); 724ceae137SRavi Bangoria 734ceae137SRavi Bangoria regs->msr |= MSR_FP; 744ceae137SRavi Bangoria regs->msr |= MSR_VEC; 754ceae137SRavi Bangoria regs->msr |= MSR_VSX; 764ceae137SRavi Bangoria 774ceae137SRavi Bangoria msr = regs->msr; 784ceae137SRavi Bangoria msr_cached = true; 794ceae137SRavi Bangoria } 804ceae137SRavi Bangoria 8184022ac1SSandipan Das static void __init show_result(char *mnemonic, char *result) 824ceae137SRavi Bangoria { 8384022ac1SSandipan Das pr_info("%-14s : %s\n", mnemonic, result); 8484022ac1SSandipan Das } 8584022ac1SSandipan Das 8684022ac1SSandipan Das static void __init show_result_with_descr(char *mnemonic, char *descr, 8784022ac1SSandipan Das char *result) 8884022ac1SSandipan Das { 8984022ac1SSandipan Das pr_info("%-14s : %-50s %s\n", mnemonic, descr, result); 904ceae137SRavi Bangoria } 914ceae137SRavi Bangoria 924ceae137SRavi Bangoria static void __init test_ld(void) 934ceae137SRavi Bangoria { 944ceae137SRavi Bangoria struct pt_regs regs; 954ceae137SRavi Bangoria unsigned long a = 0x23; 964ceae137SRavi Bangoria int stepped = -1; 974ceae137SRavi Bangoria 984ceae137SRavi Bangoria init_pt_regs(®s); 994ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 1004ceae137SRavi Bangoria 1014ceae137SRavi Bangoria /* ld r5, 0(r3) */ 1021d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LD(5, 3, 0))); 1034ceae137SRavi Bangoria 1044ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a) 1054ceae137SRavi Bangoria show_result("ld", "PASS"); 1064ceae137SRavi Bangoria else 1074ceae137SRavi Bangoria show_result("ld", "FAIL"); 1084ceae137SRavi Bangoria } 1094ceae137SRavi Bangoria 110b6b54b42SJordan Niethe static void __init test_pld(void) 111b6b54b42SJordan Niethe { 112b6b54b42SJordan Niethe struct pt_regs regs; 113b6b54b42SJordan Niethe unsigned long a = 0x23; 114b6b54b42SJordan Niethe int stepped = -1; 115b6b54b42SJordan Niethe 116b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 117b6b54b42SJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 118b6b54b42SJordan Niethe return; 119b6b54b42SJordan Niethe } 120b6b54b42SJordan Niethe 121b6b54b42SJordan Niethe init_pt_regs(®s); 122b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 123b6b54b42SJordan Niethe 124b6b54b42SJordan Niethe /* pld r5, 0(r3), 0 */ 125b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLD(5, 3, 0, 0)); 126b6b54b42SJordan Niethe 127b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a) 128b6b54b42SJordan Niethe show_result("pld", "PASS"); 129b6b54b42SJordan Niethe else 130b6b54b42SJordan Niethe show_result("pld", "FAIL"); 131b6b54b42SJordan Niethe } 132b6b54b42SJordan Niethe 1334ceae137SRavi Bangoria static void __init test_lwz(void) 1344ceae137SRavi Bangoria { 1354ceae137SRavi Bangoria struct pt_regs regs; 1364ceae137SRavi Bangoria unsigned int a = 0x4545; 1374ceae137SRavi Bangoria int stepped = -1; 1384ceae137SRavi Bangoria 1394ceae137SRavi Bangoria init_pt_regs(®s); 1404ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 1414ceae137SRavi Bangoria 1424ceae137SRavi Bangoria /* lwz r5, 0(r3) */ 1431d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZ(5, 3, 0))); 1444ceae137SRavi Bangoria 1454ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a) 1464ceae137SRavi Bangoria show_result("lwz", "PASS"); 1474ceae137SRavi Bangoria else 1484ceae137SRavi Bangoria show_result("lwz", "FAIL"); 1494ceae137SRavi Bangoria } 1504ceae137SRavi Bangoria 151b6b54b42SJordan Niethe static void __init test_plwz(void) 152b6b54b42SJordan Niethe { 153b6b54b42SJordan Niethe struct pt_regs regs; 154b6b54b42SJordan Niethe unsigned int a = 0x4545; 155b6b54b42SJordan Niethe int stepped = -1; 156b6b54b42SJordan Niethe 157b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 158b6b54b42SJordan Niethe show_result("plwz", "SKIP (!CPU_FTR_ARCH_31)"); 159b6b54b42SJordan Niethe return; 160b6b54b42SJordan Niethe } 161b6b54b42SJordan Niethe 162b6b54b42SJordan Niethe init_pt_regs(®s); 163b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 164b6b54b42SJordan Niethe 165b6b54b42SJordan Niethe /* plwz r5, 0(r3), 0 */ 166b6b54b42SJordan Niethe 167b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PLWZ(5, 3, 0, 0)); 168b6b54b42SJordan Niethe 169b6b54b42SJordan Niethe if (stepped == 1 && regs.gpr[5] == a) 170b6b54b42SJordan Niethe show_result("plwz", "PASS"); 171b6b54b42SJordan Niethe else 172b6b54b42SJordan Niethe show_result("plwz", "FAIL"); 173b6b54b42SJordan Niethe } 174b6b54b42SJordan Niethe 1754ceae137SRavi Bangoria static void __init test_lwzx(void) 1764ceae137SRavi Bangoria { 1774ceae137SRavi Bangoria struct pt_regs regs; 1784ceae137SRavi Bangoria unsigned int a[3] = {0x0, 0x0, 0x1234}; 1794ceae137SRavi Bangoria int stepped = -1; 1804ceae137SRavi Bangoria 1814ceae137SRavi Bangoria init_pt_regs(®s); 1824ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) a; 1834ceae137SRavi Bangoria regs.gpr[4] = 8; 1844ceae137SRavi Bangoria regs.gpr[5] = 0x8765; 1854ceae137SRavi Bangoria 1864ceae137SRavi Bangoria /* lwzx r5, r3, r4 */ 1871d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LWZX(5, 3, 4))); 1884ceae137SRavi Bangoria if (stepped == 1 && regs.gpr[5] == a[2]) 1894ceae137SRavi Bangoria show_result("lwzx", "PASS"); 1904ceae137SRavi Bangoria else 1914ceae137SRavi Bangoria show_result("lwzx", "FAIL"); 1924ceae137SRavi Bangoria } 1934ceae137SRavi Bangoria 1944ceae137SRavi Bangoria static void __init test_std(void) 1954ceae137SRavi Bangoria { 1964ceae137SRavi Bangoria struct pt_regs regs; 1974ceae137SRavi Bangoria unsigned long a = 0x1234; 1984ceae137SRavi Bangoria int stepped = -1; 1994ceae137SRavi Bangoria 2004ceae137SRavi Bangoria init_pt_regs(®s); 2014ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 2024ceae137SRavi Bangoria regs.gpr[5] = 0x5678; 2034ceae137SRavi Bangoria 2044ceae137SRavi Bangoria /* std r5, 0(r3) */ 2051d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STD(5, 3, 0))); 20659ed2adfSNicholas Piggin if (stepped == 1 && regs.gpr[5] == a) 2074ceae137SRavi Bangoria show_result("std", "PASS"); 2084ceae137SRavi Bangoria else 2094ceae137SRavi Bangoria show_result("std", "FAIL"); 2104ceae137SRavi Bangoria } 2114ceae137SRavi Bangoria 212b6b54b42SJordan Niethe static void __init test_pstd(void) 213b6b54b42SJordan Niethe { 214b6b54b42SJordan Niethe struct pt_regs regs; 215b6b54b42SJordan Niethe unsigned long a = 0x1234; 216b6b54b42SJordan Niethe int stepped = -1; 217b6b54b42SJordan Niethe 218b6b54b42SJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 219b6b54b42SJordan Niethe show_result("pstd", "SKIP (!CPU_FTR_ARCH_31)"); 220b6b54b42SJordan Niethe return; 221b6b54b42SJordan Niethe } 222b6b54b42SJordan Niethe 223b6b54b42SJordan Niethe init_pt_regs(®s); 224b6b54b42SJordan Niethe regs.gpr[3] = (unsigned long)&a; 225b6b54b42SJordan Niethe regs.gpr[5] = 0x5678; 226b6b54b42SJordan Niethe 227b6b54b42SJordan Niethe /* pstd r5, 0(r3), 0 */ 228b6b54b42SJordan Niethe stepped = emulate_step(®s, TEST_PSTD(5, 3, 0, 0)); 229b6b54b42SJordan Niethe if (stepped == 1 || regs.gpr[5] == a) 230b6b54b42SJordan Niethe show_result("pstd", "PASS"); 231b6b54b42SJordan Niethe else 232b6b54b42SJordan Niethe show_result("pstd", "FAIL"); 233b6b54b42SJordan Niethe } 234b6b54b42SJordan Niethe 2354ceae137SRavi Bangoria static void __init test_ldarx_stdcx(void) 2364ceae137SRavi Bangoria { 2374ceae137SRavi Bangoria struct pt_regs regs; 2384ceae137SRavi Bangoria unsigned long a = 0x1234; 2394ceae137SRavi Bangoria int stepped = -1; 2404ceae137SRavi Bangoria unsigned long cr0_eq = 0x1 << 29; /* eq bit of CR0 */ 2414ceae137SRavi Bangoria 2424ceae137SRavi Bangoria init_pt_regs(®s); 2434ceae137SRavi Bangoria asm volatile("mfcr %0" : "=r"(regs.ccr)); 2444ceae137SRavi Bangoria 2454ceae137SRavi Bangoria 2464ceae137SRavi Bangoria /*** ldarx ***/ 2474ceae137SRavi Bangoria 2484ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &a; 2494ceae137SRavi Bangoria regs.gpr[4] = 0; 2504ceae137SRavi Bangoria regs.gpr[5] = 0x5678; 2514ceae137SRavi Bangoria 2524ceae137SRavi Bangoria /* ldarx r5, r3, r4, 0 */ 2531d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LDARX(5, 3, 4, 0))); 2544ceae137SRavi Bangoria 2554ceae137SRavi Bangoria /* 2564ceae137SRavi Bangoria * Don't touch 'a' here. Touching 'a' can do Load/store 2574ceae137SRavi Bangoria * of 'a' which result in failure of subsequent stdcx. 2584ceae137SRavi Bangoria * Instead, use hardcoded value for comparison. 2594ceae137SRavi Bangoria */ 2604ceae137SRavi Bangoria if (stepped <= 0 || regs.gpr[5] != 0x1234) { 2614ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (ldarx)"); 2624ceae137SRavi Bangoria return; 2634ceae137SRavi Bangoria } 2644ceae137SRavi Bangoria 2654ceae137SRavi Bangoria 2664ceae137SRavi Bangoria /*** stdcx. ***/ 2674ceae137SRavi Bangoria 2684ceae137SRavi Bangoria regs.gpr[5] = 0x9ABC; 2694ceae137SRavi Bangoria 2704ceae137SRavi Bangoria /* stdcx. r5, r3, r4 */ 2711d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STDCX(5, 3, 4))); 2724ceae137SRavi Bangoria 2734ceae137SRavi Bangoria /* 2744ceae137SRavi Bangoria * Two possible scenarios that indicates successful emulation 2754ceae137SRavi Bangoria * of stdcx. : 2764ceae137SRavi Bangoria * 1. Reservation is active and store is performed. In this 2774ceae137SRavi Bangoria * case cr0.eq bit will be set to 1. 2784ceae137SRavi Bangoria * 2. Reservation is not active and store is not performed. 2794ceae137SRavi Bangoria * In this case cr0.eq bit will be set to 0. 2804ceae137SRavi Bangoria */ 2814ceae137SRavi Bangoria if (stepped == 1 && ((regs.gpr[5] == a && (regs.ccr & cr0_eq)) 2824ceae137SRavi Bangoria || (regs.gpr[5] != a && !(regs.ccr & cr0_eq)))) 2834ceae137SRavi Bangoria show_result("ldarx / stdcx.", "PASS"); 2844ceae137SRavi Bangoria else 2854ceae137SRavi Bangoria show_result("ldarx / stdcx.", "FAIL (stdcx.)"); 2864ceae137SRavi Bangoria } 2874ceae137SRavi Bangoria 2884ceae137SRavi Bangoria #ifdef CONFIG_PPC_FPU 2894ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void) 2904ceae137SRavi Bangoria { 2914ceae137SRavi Bangoria struct pt_regs regs; 2924ceae137SRavi Bangoria union { 2934ceae137SRavi Bangoria float a; 2944ceae137SRavi Bangoria int b; 2954ceae137SRavi Bangoria } c; 2964ceae137SRavi Bangoria int cached_b; 2974ceae137SRavi Bangoria int stepped = -1; 2984ceae137SRavi Bangoria 2994ceae137SRavi Bangoria init_pt_regs(®s); 3004ceae137SRavi Bangoria 3014ceae137SRavi Bangoria 3024ceae137SRavi Bangoria /*** lfsx ***/ 3034ceae137SRavi Bangoria 3044ceae137SRavi Bangoria c.a = 123.45; 3054ceae137SRavi Bangoria cached_b = c.b; 3064ceae137SRavi Bangoria 3074ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 3084ceae137SRavi Bangoria regs.gpr[4] = 0; 3094ceae137SRavi Bangoria 3104ceae137SRavi Bangoria /* lfsx frt10, r3, r4 */ 3111d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFSX(10, 3, 4))); 3124ceae137SRavi Bangoria 3134ceae137SRavi Bangoria if (stepped == 1) 3144ceae137SRavi Bangoria show_result("lfsx", "PASS"); 3154ceae137SRavi Bangoria else 3164ceae137SRavi Bangoria show_result("lfsx", "FAIL"); 3174ceae137SRavi Bangoria 3184ceae137SRavi Bangoria 3194ceae137SRavi Bangoria /*** stfsx ***/ 3204ceae137SRavi Bangoria 3214ceae137SRavi Bangoria c.a = 678.91; 3224ceae137SRavi Bangoria 3234ceae137SRavi Bangoria /* stfsx frs10, r3, r4 */ 3241d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFSX(10, 3, 4))); 3254ceae137SRavi Bangoria 3264ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b) 3274ceae137SRavi Bangoria show_result("stfsx", "PASS"); 3284ceae137SRavi Bangoria else 3294ceae137SRavi Bangoria show_result("stfsx", "FAIL"); 3304ceae137SRavi Bangoria } 3314ceae137SRavi Bangoria 3320396de6dSJordan Niethe static void __init test_plfs_pstfs(void) 3330396de6dSJordan Niethe { 3340396de6dSJordan Niethe struct pt_regs regs; 3350396de6dSJordan Niethe union { 3360396de6dSJordan Niethe float a; 3370396de6dSJordan Niethe int b; 3380396de6dSJordan Niethe } c; 3390396de6dSJordan Niethe int cached_b; 3400396de6dSJordan Niethe int stepped = -1; 3410396de6dSJordan Niethe 3420396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 3430396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 3440396de6dSJordan Niethe return; 3450396de6dSJordan Niethe } 3460396de6dSJordan Niethe 3470396de6dSJordan Niethe init_pt_regs(®s); 3480396de6dSJordan Niethe 3490396de6dSJordan Niethe 3500396de6dSJordan Niethe /*** plfs ***/ 3510396de6dSJordan Niethe 3520396de6dSJordan Niethe c.a = 123.45; 3530396de6dSJordan Niethe cached_b = c.b; 3540396de6dSJordan Niethe 3550396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a; 3560396de6dSJordan Niethe 3570396de6dSJordan Niethe /* plfs frt10, 0(r3), 0 */ 3580396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFS(10, 3, 0, 0)); 3590396de6dSJordan Niethe 3600396de6dSJordan Niethe if (stepped == 1) 3610396de6dSJordan Niethe show_result("plfs", "PASS"); 3620396de6dSJordan Niethe else 3630396de6dSJordan Niethe show_result("plfs", "FAIL"); 3640396de6dSJordan Niethe 3650396de6dSJordan Niethe 3660396de6dSJordan Niethe /*** pstfs ***/ 3670396de6dSJordan Niethe 3680396de6dSJordan Niethe c.a = 678.91; 3690396de6dSJordan Niethe 3700396de6dSJordan Niethe /* pstfs frs10, 0(r3), 0 */ 3710396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFS(10, 3, 0, 0)); 3720396de6dSJordan Niethe 3730396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b) 3740396de6dSJordan Niethe show_result("pstfs", "PASS"); 3750396de6dSJordan Niethe else 3760396de6dSJordan Niethe show_result("pstfs", "FAIL"); 3770396de6dSJordan Niethe } 3780396de6dSJordan Niethe 3794ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void) 3804ceae137SRavi Bangoria { 3814ceae137SRavi Bangoria struct pt_regs regs; 3824ceae137SRavi Bangoria union { 3834ceae137SRavi Bangoria double a; 3844ceae137SRavi Bangoria long b; 3854ceae137SRavi Bangoria } c; 3864ceae137SRavi Bangoria long cached_b; 3874ceae137SRavi Bangoria int stepped = -1; 3884ceae137SRavi Bangoria 3894ceae137SRavi Bangoria init_pt_regs(®s); 3904ceae137SRavi Bangoria 3914ceae137SRavi Bangoria 3924ceae137SRavi Bangoria /*** lfdx ***/ 3934ceae137SRavi Bangoria 3944ceae137SRavi Bangoria c.a = 123456.78; 3954ceae137SRavi Bangoria cached_b = c.b; 3964ceae137SRavi Bangoria 3974ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 3984ceae137SRavi Bangoria regs.gpr[4] = 0; 3994ceae137SRavi Bangoria 4004ceae137SRavi Bangoria /* lfdx frt10, r3, r4 */ 4011d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LFDX(10, 3, 4))); 4024ceae137SRavi Bangoria 4034ceae137SRavi Bangoria if (stepped == 1) 4044ceae137SRavi Bangoria show_result("lfdx", "PASS"); 4054ceae137SRavi Bangoria else 4064ceae137SRavi Bangoria show_result("lfdx", "FAIL"); 4074ceae137SRavi Bangoria 4084ceae137SRavi Bangoria 4094ceae137SRavi Bangoria /*** stfdx ***/ 4104ceae137SRavi Bangoria 4114ceae137SRavi Bangoria c.a = 987654.32; 4124ceae137SRavi Bangoria 4134ceae137SRavi Bangoria /* stfdx frs10, r3, r4 */ 4141d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STFDX(10, 3, 4))); 4154ceae137SRavi Bangoria 4164ceae137SRavi Bangoria if (stepped == 1 && c.b == cached_b) 4174ceae137SRavi Bangoria show_result("stfdx", "PASS"); 4184ceae137SRavi Bangoria else 4194ceae137SRavi Bangoria show_result("stfdx", "FAIL"); 4204ceae137SRavi Bangoria } 4210396de6dSJordan Niethe 4220396de6dSJordan Niethe static void __init test_plfd_pstfd(void) 4230396de6dSJordan Niethe { 4240396de6dSJordan Niethe struct pt_regs regs; 4250396de6dSJordan Niethe union { 4260396de6dSJordan Niethe double a; 4270396de6dSJordan Niethe long b; 4280396de6dSJordan Niethe } c; 4290396de6dSJordan Niethe long cached_b; 4300396de6dSJordan Niethe int stepped = -1; 4310396de6dSJordan Niethe 4320396de6dSJordan Niethe if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 4330396de6dSJordan Niethe show_result("pld", "SKIP (!CPU_FTR_ARCH_31)"); 4340396de6dSJordan Niethe return; 4350396de6dSJordan Niethe } 4360396de6dSJordan Niethe 4370396de6dSJordan Niethe init_pt_regs(®s); 4380396de6dSJordan Niethe 4390396de6dSJordan Niethe 4400396de6dSJordan Niethe /*** plfd ***/ 4410396de6dSJordan Niethe 4420396de6dSJordan Niethe c.a = 123456.78; 4430396de6dSJordan Niethe cached_b = c.b; 4440396de6dSJordan Niethe 4450396de6dSJordan Niethe regs.gpr[3] = (unsigned long)&c.a; 4460396de6dSJordan Niethe 4470396de6dSJordan Niethe /* plfd frt10, 0(r3), 0 */ 4480396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PLFD(10, 3, 0, 0)); 4490396de6dSJordan Niethe 4500396de6dSJordan Niethe if (stepped == 1) 4510396de6dSJordan Niethe show_result("plfd", "PASS"); 4520396de6dSJordan Niethe else 4530396de6dSJordan Niethe show_result("plfd", "FAIL"); 4540396de6dSJordan Niethe 4550396de6dSJordan Niethe 4560396de6dSJordan Niethe /*** pstfd ***/ 4570396de6dSJordan Niethe 4580396de6dSJordan Niethe c.a = 987654.32; 4590396de6dSJordan Niethe 4600396de6dSJordan Niethe /* pstfd frs10, 0(r3), 0 */ 4610396de6dSJordan Niethe stepped = emulate_step(®s, TEST_PSTFD(10, 3, 0, 0)); 4620396de6dSJordan Niethe 4630396de6dSJordan Niethe if (stepped == 1 && c.b == cached_b) 4640396de6dSJordan Niethe show_result("pstfd", "PASS"); 4650396de6dSJordan Niethe else 4660396de6dSJordan Niethe show_result("pstfd", "FAIL"); 4670396de6dSJordan Niethe } 4684ceae137SRavi Bangoria #else 4694ceae137SRavi Bangoria static void __init test_lfsx_stfsx(void) 4704ceae137SRavi Bangoria { 4714ceae137SRavi Bangoria show_result("lfsx", "SKIP (CONFIG_PPC_FPU is not set)"); 4724ceae137SRavi Bangoria show_result("stfsx", "SKIP (CONFIG_PPC_FPU is not set)"); 4734ceae137SRavi Bangoria } 4744ceae137SRavi Bangoria 4750396de6dSJordan Niethe static void __init test_plfs_pstfs(void) 4760396de6dSJordan Niethe { 4770396de6dSJordan Niethe show_result("plfs", "SKIP (CONFIG_PPC_FPU is not set)"); 4780396de6dSJordan Niethe show_result("pstfs", "SKIP (CONFIG_PPC_FPU is not set)"); 4790396de6dSJordan Niethe } 4800396de6dSJordan Niethe 4814ceae137SRavi Bangoria static void __init test_lfdx_stfdx(void) 4824ceae137SRavi Bangoria { 4834ceae137SRavi Bangoria show_result("lfdx", "SKIP (CONFIG_PPC_FPU is not set)"); 4844ceae137SRavi Bangoria show_result("stfdx", "SKIP (CONFIG_PPC_FPU is not set)"); 4854ceae137SRavi Bangoria } 4860396de6dSJordan Niethe 4870396de6dSJordan Niethe static void __init test_plfd_pstfd(void) 4880396de6dSJordan Niethe { 4890396de6dSJordan Niethe show_result("plfd", "SKIP (CONFIG_PPC_FPU is not set)"); 4900396de6dSJordan Niethe show_result("pstfd", "SKIP (CONFIG_PPC_FPU is not set)"); 4910396de6dSJordan Niethe } 4924ceae137SRavi Bangoria #endif /* CONFIG_PPC_FPU */ 4934ceae137SRavi Bangoria 4944ceae137SRavi Bangoria #ifdef CONFIG_ALTIVEC 4954ceae137SRavi Bangoria static void __init test_lvx_stvx(void) 4964ceae137SRavi Bangoria { 4974ceae137SRavi Bangoria struct pt_regs regs; 4984ceae137SRavi Bangoria union { 4994ceae137SRavi Bangoria vector128 a; 5004ceae137SRavi Bangoria u32 b[4]; 5014ceae137SRavi Bangoria } c; 5024ceae137SRavi Bangoria u32 cached_b[4]; 5034ceae137SRavi Bangoria int stepped = -1; 5044ceae137SRavi Bangoria 5054ceae137SRavi Bangoria init_pt_regs(®s); 5064ceae137SRavi Bangoria 5074ceae137SRavi Bangoria 5084ceae137SRavi Bangoria /*** lvx ***/ 5094ceae137SRavi Bangoria 5104ceae137SRavi Bangoria cached_b[0] = c.b[0] = 923745; 5114ceae137SRavi Bangoria cached_b[1] = c.b[1] = 2139478; 5124ceae137SRavi Bangoria cached_b[2] = c.b[2] = 9012; 5134ceae137SRavi Bangoria cached_b[3] = c.b[3] = 982134; 5144ceae137SRavi Bangoria 5154ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 5164ceae137SRavi Bangoria regs.gpr[4] = 0; 5174ceae137SRavi Bangoria 5184ceae137SRavi Bangoria /* lvx vrt10, r3, r4 */ 5191d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LVX(10, 3, 4))); 5204ceae137SRavi Bangoria 5214ceae137SRavi Bangoria if (stepped == 1) 5224ceae137SRavi Bangoria show_result("lvx", "PASS"); 5234ceae137SRavi Bangoria else 5244ceae137SRavi Bangoria show_result("lvx", "FAIL"); 5254ceae137SRavi Bangoria 5264ceae137SRavi Bangoria 5274ceae137SRavi Bangoria /*** stvx ***/ 5284ceae137SRavi Bangoria 5294ceae137SRavi Bangoria c.b[0] = 4987513; 5304ceae137SRavi Bangoria c.b[1] = 84313948; 5314ceae137SRavi Bangoria c.b[2] = 71; 5324ceae137SRavi Bangoria c.b[3] = 498532; 5334ceae137SRavi Bangoria 5344ceae137SRavi Bangoria /* stvx vrs10, r3, r4 */ 5351d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STVX(10, 3, 4))); 5364ceae137SRavi Bangoria 5374ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] && 5384ceae137SRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3]) 5394ceae137SRavi Bangoria show_result("stvx", "PASS"); 5404ceae137SRavi Bangoria else 5414ceae137SRavi Bangoria show_result("stvx", "FAIL"); 5424ceae137SRavi Bangoria } 5434ceae137SRavi Bangoria #else 5444ceae137SRavi Bangoria static void __init test_lvx_stvx(void) 5454ceae137SRavi Bangoria { 5464ceae137SRavi Bangoria show_result("lvx", "SKIP (CONFIG_ALTIVEC is not set)"); 5474ceae137SRavi Bangoria show_result("stvx", "SKIP (CONFIG_ALTIVEC is not set)"); 5484ceae137SRavi Bangoria } 5494ceae137SRavi Bangoria #endif /* CONFIG_ALTIVEC */ 5504ceae137SRavi Bangoria 5514ceae137SRavi Bangoria #ifdef CONFIG_VSX 5524ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void) 5534ceae137SRavi Bangoria { 5544ceae137SRavi Bangoria struct pt_regs regs; 5554ceae137SRavi Bangoria union { 5564ceae137SRavi Bangoria vector128 a; 5574ceae137SRavi Bangoria u32 b[4]; 5584ceae137SRavi Bangoria } c; 5594ceae137SRavi Bangoria u32 cached_b[4]; 5604ceae137SRavi Bangoria int stepped = -1; 5614ceae137SRavi Bangoria 5624ceae137SRavi Bangoria init_pt_regs(®s); 5634ceae137SRavi Bangoria 5644ceae137SRavi Bangoria 5654ceae137SRavi Bangoria /*** lxvd2x ***/ 5664ceae137SRavi Bangoria 5674ceae137SRavi Bangoria cached_b[0] = c.b[0] = 18233; 5684ceae137SRavi Bangoria cached_b[1] = c.b[1] = 34863571; 5694ceae137SRavi Bangoria cached_b[2] = c.b[2] = 834; 5704ceae137SRavi Bangoria cached_b[3] = c.b[3] = 6138911; 5714ceae137SRavi Bangoria 5724ceae137SRavi Bangoria regs.gpr[3] = (unsigned long) &c.a; 5734ceae137SRavi Bangoria regs.gpr[4] = 0; 5744ceae137SRavi Bangoria 5754ceae137SRavi Bangoria /* lxvd2x vsr39, r3, r4 */ 5761d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVD2X(39, R3, R4))); 5774ceae137SRavi Bangoria 5785a61640eSRavi Bangoria if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 5794ceae137SRavi Bangoria show_result("lxvd2x", "PASS"); 5805a61640eSRavi Bangoria } else { 5815a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX)) 5825a61640eSRavi Bangoria show_result("lxvd2x", "PASS (!CPU_FTR_VSX)"); 5834ceae137SRavi Bangoria else 5844ceae137SRavi Bangoria show_result("lxvd2x", "FAIL"); 5855a61640eSRavi Bangoria } 5864ceae137SRavi Bangoria 5874ceae137SRavi Bangoria 5884ceae137SRavi Bangoria /*** stxvd2x ***/ 5894ceae137SRavi Bangoria 5904ceae137SRavi Bangoria c.b[0] = 21379463; 5914ceae137SRavi Bangoria c.b[1] = 87; 5924ceae137SRavi Bangoria c.b[2] = 374234; 5934ceae137SRavi Bangoria c.b[3] = 4; 5944ceae137SRavi Bangoria 5954ceae137SRavi Bangoria /* stxvd2x vsr39, r3, r4 */ 5961d33dd84SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVD2X(39, R3, R4))); 5974ceae137SRavi Bangoria 5984ceae137SRavi Bangoria if (stepped == 1 && cached_b[0] == c.b[0] && cached_b[1] == c.b[1] && 5995a61640eSRavi Bangoria cached_b[2] == c.b[2] && cached_b[3] == c.b[3] && 6005a61640eSRavi Bangoria cpu_has_feature(CPU_FTR_VSX)) { 6014ceae137SRavi Bangoria show_result("stxvd2x", "PASS"); 6025a61640eSRavi Bangoria } else { 6035a61640eSRavi Bangoria if (!cpu_has_feature(CPU_FTR_VSX)) 6045a61640eSRavi Bangoria show_result("stxvd2x", "PASS (!CPU_FTR_VSX)"); 6054ceae137SRavi Bangoria else 6064ceae137SRavi Bangoria show_result("stxvd2x", "FAIL"); 6074ceae137SRavi Bangoria } 6085a61640eSRavi Bangoria } 6094ceae137SRavi Bangoria #else 6104ceae137SRavi Bangoria static void __init test_lxvd2x_stxvd2x(void) 6114ceae137SRavi Bangoria { 6124ceae137SRavi Bangoria show_result("lxvd2x", "SKIP (CONFIG_VSX is not set)"); 6134ceae137SRavi Bangoria show_result("stxvd2x", "SKIP (CONFIG_VSX is not set)"); 6144ceae137SRavi Bangoria } 6154ceae137SRavi Bangoria #endif /* CONFIG_VSX */ 6164ceae137SRavi Bangoria 61735785b29SBalamuruhan S #ifdef CONFIG_VSX 61835785b29SBalamuruhan S static void __init test_lxvp_stxvp(void) 61935785b29SBalamuruhan S { 62035785b29SBalamuruhan S struct pt_regs regs; 62135785b29SBalamuruhan S union { 62235785b29SBalamuruhan S vector128 a; 62335785b29SBalamuruhan S u32 b[4]; 62435785b29SBalamuruhan S } c[2]; 62535785b29SBalamuruhan S u32 cached_b[8]; 62635785b29SBalamuruhan S int stepped = -1; 62735785b29SBalamuruhan S 62835785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 62935785b29SBalamuruhan S show_result("lxvp", "SKIP (!CPU_FTR_ARCH_31)"); 63035785b29SBalamuruhan S show_result("stxvp", "SKIP (!CPU_FTR_ARCH_31)"); 63135785b29SBalamuruhan S return; 63235785b29SBalamuruhan S } 63335785b29SBalamuruhan S 63435785b29SBalamuruhan S init_pt_regs(®s); 63535785b29SBalamuruhan S 63635785b29SBalamuruhan S /*** lxvp ***/ 63735785b29SBalamuruhan S 63835785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 63935785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 64035785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 64135785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 64235785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 64335785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 64435785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 64535785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 64635785b29SBalamuruhan S 64735785b29SBalamuruhan S regs.gpr[4] = (unsigned long)&c[0].a; 64835785b29SBalamuruhan S 64935785b29SBalamuruhan S /* 65035785b29SBalamuruhan S * lxvp XTp,DQ(RA) 65135785b29SBalamuruhan S * XTp = 32xTX + 2xTp 65235785b29SBalamuruhan S * let TX=1 Tp=1 RA=4 DQ=0 65335785b29SBalamuruhan S */ 65435785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVP(34, 4, 0))); 65535785b29SBalamuruhan S 65635785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 65735785b29SBalamuruhan S show_result("lxvp", "PASS"); 65835785b29SBalamuruhan S } else { 65935785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 66035785b29SBalamuruhan S show_result("lxvp", "PASS (!CPU_FTR_VSX)"); 66135785b29SBalamuruhan S else 66235785b29SBalamuruhan S show_result("lxvp", "FAIL"); 66335785b29SBalamuruhan S } 66435785b29SBalamuruhan S 66535785b29SBalamuruhan S /*** stxvp ***/ 66635785b29SBalamuruhan S 66735785b29SBalamuruhan S c[0].b[0] = 21379463; 66835785b29SBalamuruhan S c[0].b[1] = 87; 66935785b29SBalamuruhan S c[0].b[2] = 374234; 67035785b29SBalamuruhan S c[0].b[3] = 4; 67135785b29SBalamuruhan S c[1].b[0] = 90; 67235785b29SBalamuruhan S c[1].b[1] = 122; 67335785b29SBalamuruhan S c[1].b[2] = 555; 67435785b29SBalamuruhan S c[1].b[3] = 32144; 67535785b29SBalamuruhan S 67635785b29SBalamuruhan S /* 67735785b29SBalamuruhan S * stxvp XSp,DQ(RA) 67835785b29SBalamuruhan S * XSp = 32xSX + 2xSp 67935785b29SBalamuruhan S * let SX=1 Sp=1 RA=4 DQ=0 68035785b29SBalamuruhan S */ 68135785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVP(34, 4, 0))); 68235785b29SBalamuruhan S 68335785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 68435785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 68535785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 68635785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 68735785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 68835785b29SBalamuruhan S show_result("stxvp", "PASS"); 68935785b29SBalamuruhan S } else { 69035785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 69135785b29SBalamuruhan S show_result("stxvp", "PASS (!CPU_FTR_VSX)"); 69235785b29SBalamuruhan S else 69335785b29SBalamuruhan S show_result("stxvp", "FAIL"); 69435785b29SBalamuruhan S } 69535785b29SBalamuruhan S } 69635785b29SBalamuruhan S #else 69735785b29SBalamuruhan S static void __init test_lxvp_stxvp(void) 69835785b29SBalamuruhan S { 69935785b29SBalamuruhan S show_result("lxvp", "SKIP (CONFIG_VSX is not set)"); 70035785b29SBalamuruhan S show_result("stxvp", "SKIP (CONFIG_VSX is not set)"); 70135785b29SBalamuruhan S } 70235785b29SBalamuruhan S #endif /* CONFIG_VSX */ 70335785b29SBalamuruhan S 70435785b29SBalamuruhan S #ifdef CONFIG_VSX 70535785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void) 70635785b29SBalamuruhan S { 70735785b29SBalamuruhan S struct pt_regs regs; 70835785b29SBalamuruhan S union { 70935785b29SBalamuruhan S vector128 a; 71035785b29SBalamuruhan S u32 b[4]; 71135785b29SBalamuruhan S } c[2]; 71235785b29SBalamuruhan S u32 cached_b[8]; 71335785b29SBalamuruhan S int stepped = -1; 71435785b29SBalamuruhan S 71535785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 71635785b29SBalamuruhan S show_result("lxvpx", "SKIP (!CPU_FTR_ARCH_31)"); 71735785b29SBalamuruhan S show_result("stxvpx", "SKIP (!CPU_FTR_ARCH_31)"); 71835785b29SBalamuruhan S return; 71935785b29SBalamuruhan S } 72035785b29SBalamuruhan S 72135785b29SBalamuruhan S init_pt_regs(®s); 72235785b29SBalamuruhan S 72335785b29SBalamuruhan S /*** lxvpx ***/ 72435785b29SBalamuruhan S 72535785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 72635785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 72735785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 72835785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 72935785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 73035785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 73135785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 73235785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 73335785b29SBalamuruhan S 73435785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a; 73535785b29SBalamuruhan S regs.gpr[4] = 0; 73635785b29SBalamuruhan S 73735785b29SBalamuruhan S /* 73835785b29SBalamuruhan S * lxvpx XTp,RA,RB 73935785b29SBalamuruhan S * XTp = 32xTX + 2xTp 74035785b29SBalamuruhan S * let TX=1 Tp=1 RA=3 RB=4 74135785b29SBalamuruhan S */ 74235785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_LXVPX(34, 3, 4))); 74335785b29SBalamuruhan S 74435785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 74535785b29SBalamuruhan S show_result("lxvpx", "PASS"); 74635785b29SBalamuruhan S } else { 74735785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 74835785b29SBalamuruhan S show_result("lxvpx", "PASS (!CPU_FTR_VSX)"); 74935785b29SBalamuruhan S else 75035785b29SBalamuruhan S show_result("lxvpx", "FAIL"); 75135785b29SBalamuruhan S } 75235785b29SBalamuruhan S 75335785b29SBalamuruhan S /*** stxvpx ***/ 75435785b29SBalamuruhan S 75535785b29SBalamuruhan S c[0].b[0] = 21379463; 75635785b29SBalamuruhan S c[0].b[1] = 87; 75735785b29SBalamuruhan S c[0].b[2] = 374234; 75835785b29SBalamuruhan S c[0].b[3] = 4; 75935785b29SBalamuruhan S c[1].b[0] = 90; 76035785b29SBalamuruhan S c[1].b[1] = 122; 76135785b29SBalamuruhan S c[1].b[2] = 555; 76235785b29SBalamuruhan S c[1].b[3] = 32144; 76335785b29SBalamuruhan S 76435785b29SBalamuruhan S /* 76535785b29SBalamuruhan S * stxvpx XSp,RA,RB 76635785b29SBalamuruhan S * XSp = 32xSX + 2xSp 76735785b29SBalamuruhan S * let SX=1 Sp=1 RA=3 RB=4 76835785b29SBalamuruhan S */ 76935785b29SBalamuruhan S stepped = emulate_step(®s, ppc_inst(PPC_RAW_STXVPX(34, 3, 4))); 77035785b29SBalamuruhan S 77135785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 77235785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 77335785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 77435785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 77535785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 77635785b29SBalamuruhan S show_result("stxvpx", "PASS"); 77735785b29SBalamuruhan S } else { 77835785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 77935785b29SBalamuruhan S show_result("stxvpx", "PASS (!CPU_FTR_VSX)"); 78035785b29SBalamuruhan S else 78135785b29SBalamuruhan S show_result("stxvpx", "FAIL"); 78235785b29SBalamuruhan S } 78335785b29SBalamuruhan S } 78435785b29SBalamuruhan S #else 78535785b29SBalamuruhan S static void __init test_lxvpx_stxvpx(void) 78635785b29SBalamuruhan S { 78735785b29SBalamuruhan S show_result("lxvpx", "SKIP (CONFIG_VSX is not set)"); 78835785b29SBalamuruhan S show_result("stxvpx", "SKIP (CONFIG_VSX is not set)"); 78935785b29SBalamuruhan S } 79035785b29SBalamuruhan S #endif /* CONFIG_VSX */ 79135785b29SBalamuruhan S 79235785b29SBalamuruhan S #ifdef CONFIG_VSX 79335785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void) 79435785b29SBalamuruhan S { 79535785b29SBalamuruhan S struct ppc_inst instr; 79635785b29SBalamuruhan S struct pt_regs regs; 79735785b29SBalamuruhan S union { 79835785b29SBalamuruhan S vector128 a; 79935785b29SBalamuruhan S u32 b[4]; 80035785b29SBalamuruhan S } c[2]; 80135785b29SBalamuruhan S u32 cached_b[8]; 80235785b29SBalamuruhan S int stepped = -1; 80335785b29SBalamuruhan S 80435785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_ARCH_31)) { 80535785b29SBalamuruhan S show_result("plxvp", "SKIP (!CPU_FTR_ARCH_31)"); 80635785b29SBalamuruhan S show_result("pstxvp", "SKIP (!CPU_FTR_ARCH_31)"); 80735785b29SBalamuruhan S return; 80835785b29SBalamuruhan S } 80935785b29SBalamuruhan S 81035785b29SBalamuruhan S /*** plxvp ***/ 81135785b29SBalamuruhan S 81235785b29SBalamuruhan S cached_b[0] = c[0].b[0] = 18233; 81335785b29SBalamuruhan S cached_b[1] = c[0].b[1] = 34863571; 81435785b29SBalamuruhan S cached_b[2] = c[0].b[2] = 834; 81535785b29SBalamuruhan S cached_b[3] = c[0].b[3] = 6138911; 81635785b29SBalamuruhan S cached_b[4] = c[1].b[0] = 1234; 81735785b29SBalamuruhan S cached_b[5] = c[1].b[1] = 5678; 81835785b29SBalamuruhan S cached_b[6] = c[1].b[2] = 91011; 81935785b29SBalamuruhan S cached_b[7] = c[1].b[3] = 121314; 82035785b29SBalamuruhan S 82135785b29SBalamuruhan S init_pt_regs(®s); 82235785b29SBalamuruhan S regs.gpr[3] = (unsigned long)&c[0].a; 82335785b29SBalamuruhan S 82435785b29SBalamuruhan S /* 82535785b29SBalamuruhan S * plxvp XTp,D(RA),R 82635785b29SBalamuruhan S * XTp = 32xTX + 2xTp 82735785b29SBalamuruhan S * let RA=3 R=0 D=d0||d1=0 R=0 Tp=1 TX=1 82835785b29SBalamuruhan S */ 829148a0476SChristophe Leroy instr = ppc_inst_prefix(PPC_RAW_PLXVP_P(34, 0, 3, 0), PPC_RAW_PLXVP_S(34, 0, 3, 0)); 83035785b29SBalamuruhan S 83135785b29SBalamuruhan S stepped = emulate_step(®s, instr); 83235785b29SBalamuruhan S if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) { 83335785b29SBalamuruhan S show_result("plxvp", "PASS"); 83435785b29SBalamuruhan S } else { 83535785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 83635785b29SBalamuruhan S show_result("plxvp", "PASS (!CPU_FTR_VSX)"); 83735785b29SBalamuruhan S else 83835785b29SBalamuruhan S show_result("plxvp", "FAIL"); 83935785b29SBalamuruhan S } 84035785b29SBalamuruhan S 84135785b29SBalamuruhan S /*** pstxvp ***/ 84235785b29SBalamuruhan S 84335785b29SBalamuruhan S c[0].b[0] = 21379463; 84435785b29SBalamuruhan S c[0].b[1] = 87; 84535785b29SBalamuruhan S c[0].b[2] = 374234; 84635785b29SBalamuruhan S c[0].b[3] = 4; 84735785b29SBalamuruhan S c[1].b[0] = 90; 84835785b29SBalamuruhan S c[1].b[1] = 122; 84935785b29SBalamuruhan S c[1].b[2] = 555; 85035785b29SBalamuruhan S c[1].b[3] = 32144; 85135785b29SBalamuruhan S 85235785b29SBalamuruhan S /* 85335785b29SBalamuruhan S * pstxvp XSp,D(RA),R 85435785b29SBalamuruhan S * XSp = 32xSX + 2xSp 85535785b29SBalamuruhan S * let RA=3 D=d0||d1=0 R=0 Sp=1 SX=1 85635785b29SBalamuruhan S */ 857148a0476SChristophe Leroy instr = ppc_inst_prefix(PPC_RAW_PSTXVP_P(34, 0, 3, 0), PPC_RAW_PSTXVP_S(34, 0, 3, 0)); 85835785b29SBalamuruhan S 85935785b29SBalamuruhan S stepped = emulate_step(®s, instr); 86035785b29SBalamuruhan S 86135785b29SBalamuruhan S if (stepped == 1 && cached_b[0] == c[0].b[0] && cached_b[1] == c[0].b[1] && 86235785b29SBalamuruhan S cached_b[2] == c[0].b[2] && cached_b[3] == c[0].b[3] && 86335785b29SBalamuruhan S cached_b[4] == c[1].b[0] && cached_b[5] == c[1].b[1] && 86435785b29SBalamuruhan S cached_b[6] == c[1].b[2] && cached_b[7] == c[1].b[3] && 86535785b29SBalamuruhan S cpu_has_feature(CPU_FTR_VSX)) { 86635785b29SBalamuruhan S show_result("pstxvp", "PASS"); 86735785b29SBalamuruhan S } else { 86835785b29SBalamuruhan S if (!cpu_has_feature(CPU_FTR_VSX)) 86935785b29SBalamuruhan S show_result("pstxvp", "PASS (!CPU_FTR_VSX)"); 87035785b29SBalamuruhan S else 87135785b29SBalamuruhan S show_result("pstxvp", "FAIL"); 87235785b29SBalamuruhan S } 87335785b29SBalamuruhan S } 87435785b29SBalamuruhan S #else 87535785b29SBalamuruhan S static void __init test_plxvp_pstxvp(void) 87635785b29SBalamuruhan S { 87735785b29SBalamuruhan S show_result("plxvp", "SKIP (CONFIG_VSX is not set)"); 87835785b29SBalamuruhan S show_result("pstxvp", "SKIP (CONFIG_VSX is not set)"); 87935785b29SBalamuruhan S } 88035785b29SBalamuruhan S #endif /* CONFIG_VSX */ 88135785b29SBalamuruhan 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(); 89835785b29SBalamuruhan S test_lxvp_stxvp(); 89935785b29SBalamuruhan S test_lxvpx_stxvpx(); 90035785b29SBalamuruhan 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", 925f30becb5SChristophe Leroy .instr = ppc_inst(PPC_RAW_NOP()), 92684022ac1SSandipan Das .regs = { 92784022ac1SSandipan Das .gpr[0] = LONG_MAX, 92884022ac1SSandipan Das } 92984022ac1SSandipan Das } 93084022ac1SSandipan Das } 93144dea178SSandipan Das }, 93244dea178SSandipan Das { 93360060d70SSathvika Vasireddy .mnemonic = "setb", 93460060d70SSathvika Vasireddy .cpu_feature = CPU_FTR_ARCH_300, 93560060d70SSathvika Vasireddy .subtests = { 93660060d70SSathvika Vasireddy { 93760060d70SSathvika Vasireddy .descr = "BFA = 1, CR = GT", 93860060d70SSathvika Vasireddy .instr = TEST_SETB(20, 1), 93960060d70SSathvika Vasireddy .regs = { 94060060d70SSathvika Vasireddy .ccr = 0x4000000, 94160060d70SSathvika Vasireddy } 94260060d70SSathvika Vasireddy }, 94360060d70SSathvika Vasireddy { 94460060d70SSathvika Vasireddy .descr = "BFA = 4, CR = LT", 94560060d70SSathvika Vasireddy .instr = TEST_SETB(20, 4), 94660060d70SSathvika Vasireddy .regs = { 94760060d70SSathvika Vasireddy .ccr = 0x8000, 94860060d70SSathvika Vasireddy } 94960060d70SSathvika Vasireddy }, 95060060d70SSathvika Vasireddy { 95160060d70SSathvika Vasireddy .descr = "BFA = 5, CR = EQ", 95260060d70SSathvika Vasireddy .instr = TEST_SETB(20, 5), 95360060d70SSathvika Vasireddy .regs = { 95460060d70SSathvika Vasireddy .ccr = 0x200, 95560060d70SSathvika Vasireddy } 95660060d70SSathvika Vasireddy } 95760060d70SSathvika Vasireddy } 95860060d70SSathvika Vasireddy }, 95960060d70SSathvika Vasireddy { 96044dea178SSandipan Das .mnemonic = "add", 96144dea178SSandipan Das .subtests = { 96244dea178SSandipan Das { 96344dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 9641d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 96544dea178SSandipan Das .regs = { 96644dea178SSandipan Das .gpr[21] = LONG_MIN, 96744dea178SSandipan Das .gpr[22] = LONG_MIN, 96844dea178SSandipan Das } 96944dea178SSandipan Das }, 97044dea178SSandipan Das { 97144dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 9721d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 97344dea178SSandipan Das .regs = { 97444dea178SSandipan Das .gpr[21] = LONG_MIN, 97544dea178SSandipan Das .gpr[22] = LONG_MAX, 97644dea178SSandipan Das } 97744dea178SSandipan Das }, 97844dea178SSandipan Das { 97944dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 9801d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 98144dea178SSandipan Das .regs = { 98244dea178SSandipan Das .gpr[21] = LONG_MAX, 98344dea178SSandipan Das .gpr[22] = LONG_MAX, 98444dea178SSandipan Das } 98544dea178SSandipan Das }, 98644dea178SSandipan Das { 98744dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 9881d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 98944dea178SSandipan Das .regs = { 99044dea178SSandipan Das .gpr[21] = ULONG_MAX, 99144dea178SSandipan Das .gpr[22] = ULONG_MAX, 99244dea178SSandipan Das } 99344dea178SSandipan Das }, 99444dea178SSandipan Das { 99544dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 9961d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 99744dea178SSandipan Das .regs = { 99844dea178SSandipan Das .gpr[21] = ULONG_MAX, 99944dea178SSandipan Das .gpr[22] = 0x1, 100044dea178SSandipan Das } 100144dea178SSandipan Das }, 100244dea178SSandipan Das { 100344dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 10041d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 100544dea178SSandipan Das .regs = { 100644dea178SSandipan Das .gpr[21] = INT_MIN, 100744dea178SSandipan Das .gpr[22] = INT_MIN, 100844dea178SSandipan Das } 100944dea178SSandipan Das }, 101044dea178SSandipan Das { 101144dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 10121d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 101344dea178SSandipan Das .regs = { 101444dea178SSandipan Das .gpr[21] = INT_MIN, 101544dea178SSandipan Das .gpr[22] = INT_MAX, 101644dea178SSandipan Das } 101744dea178SSandipan Das }, 101844dea178SSandipan Das { 101944dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 10201d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 102144dea178SSandipan Das .regs = { 102244dea178SSandipan Das .gpr[21] = INT_MAX, 102344dea178SSandipan Das .gpr[22] = INT_MAX, 102444dea178SSandipan Das } 102544dea178SSandipan Das }, 102644dea178SSandipan Das { 102744dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 10281d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 102944dea178SSandipan Das .regs = { 103044dea178SSandipan Das .gpr[21] = UINT_MAX, 103144dea178SSandipan Das .gpr[22] = UINT_MAX, 103244dea178SSandipan Das } 103344dea178SSandipan Das }, 103444dea178SSandipan Das { 103544dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 10361d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)), 103744dea178SSandipan Das .regs = { 103844dea178SSandipan Das .gpr[21] = UINT_MAX, 103944dea178SSandipan Das .gpr[22] = 0x1, 104044dea178SSandipan Das } 104144dea178SSandipan Das } 104244dea178SSandipan Das } 104344dea178SSandipan Das }, 104444dea178SSandipan Das { 104544dea178SSandipan Das .mnemonic = "add.", 104644dea178SSandipan Das .subtests = { 104744dea178SSandipan Das { 104844dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 104944dea178SSandipan Das .flags = IGNORE_CCR, 10501d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 105144dea178SSandipan Das .regs = { 105244dea178SSandipan Das .gpr[21] = LONG_MIN, 105344dea178SSandipan Das .gpr[22] = LONG_MIN, 105444dea178SSandipan Das } 105544dea178SSandipan Das }, 105644dea178SSandipan Das { 105744dea178SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 10581d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 105944dea178SSandipan Das .regs = { 106044dea178SSandipan Das .gpr[21] = LONG_MIN, 106144dea178SSandipan Das .gpr[22] = LONG_MAX, 106244dea178SSandipan Das } 106344dea178SSandipan Das }, 106444dea178SSandipan Das { 106544dea178SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 106644dea178SSandipan Das .flags = IGNORE_CCR, 10671d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 106844dea178SSandipan Das .regs = { 106944dea178SSandipan Das .gpr[21] = LONG_MAX, 107044dea178SSandipan Das .gpr[22] = LONG_MAX, 107144dea178SSandipan Das } 107244dea178SSandipan Das }, 107344dea178SSandipan Das { 107444dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 10751d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 107644dea178SSandipan Das .regs = { 107744dea178SSandipan Das .gpr[21] = ULONG_MAX, 107844dea178SSandipan Das .gpr[22] = ULONG_MAX, 107944dea178SSandipan Das } 108044dea178SSandipan Das }, 108144dea178SSandipan Das { 108244dea178SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 10831d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 108444dea178SSandipan Das .regs = { 108544dea178SSandipan Das .gpr[21] = ULONG_MAX, 108644dea178SSandipan Das .gpr[22] = 0x1, 108744dea178SSandipan Das } 108844dea178SSandipan Das }, 108944dea178SSandipan Das { 109044dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 10911d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 109244dea178SSandipan Das .regs = { 109344dea178SSandipan Das .gpr[21] = INT_MIN, 109444dea178SSandipan Das .gpr[22] = INT_MIN, 109544dea178SSandipan Das } 109644dea178SSandipan Das }, 109744dea178SSandipan Das { 109844dea178SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 10991d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 110044dea178SSandipan Das .regs = { 110144dea178SSandipan Das .gpr[21] = INT_MIN, 110244dea178SSandipan Das .gpr[22] = INT_MAX, 110344dea178SSandipan Das } 110444dea178SSandipan Das }, 110544dea178SSandipan Das { 110644dea178SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 11071d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 110844dea178SSandipan Das .regs = { 110944dea178SSandipan Das .gpr[21] = INT_MAX, 111044dea178SSandipan Das .gpr[22] = INT_MAX, 111144dea178SSandipan Das } 111244dea178SSandipan Das }, 111344dea178SSandipan Das { 111444dea178SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 11151d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 111644dea178SSandipan Das .regs = { 111744dea178SSandipan Das .gpr[21] = UINT_MAX, 111844dea178SSandipan Das .gpr[22] = UINT_MAX, 111944dea178SSandipan Das } 112044dea178SSandipan Das }, 112144dea178SSandipan Das { 112244dea178SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 11231d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADD_DOT(20, 21, 22)), 112444dea178SSandipan Das .regs = { 112544dea178SSandipan Das .gpr[21] = UINT_MAX, 112644dea178SSandipan Das .gpr[22] = 0x1, 112744dea178SSandipan Das } 112844dea178SSandipan Das } 112944dea178SSandipan Das } 113078a8da06SSandipan Das }, 113178a8da06SSandipan Das { 113278a8da06SSandipan Das .mnemonic = "addc", 113378a8da06SSandipan Das .subtests = { 113478a8da06SSandipan Das { 113578a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 11361d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 113778a8da06SSandipan Das .regs = { 113878a8da06SSandipan Das .gpr[21] = LONG_MIN, 113978a8da06SSandipan Das .gpr[22] = LONG_MIN, 114078a8da06SSandipan Das } 114178a8da06SSandipan Das }, 114278a8da06SSandipan Das { 114378a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 11441d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 114578a8da06SSandipan Das .regs = { 114678a8da06SSandipan Das .gpr[21] = LONG_MIN, 114778a8da06SSandipan Das .gpr[22] = LONG_MAX, 114878a8da06SSandipan Das } 114978a8da06SSandipan Das }, 115078a8da06SSandipan Das { 115178a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 11521d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 115378a8da06SSandipan Das .regs = { 115478a8da06SSandipan Das .gpr[21] = LONG_MAX, 115578a8da06SSandipan Das .gpr[22] = LONG_MAX, 115678a8da06SSandipan Das } 115778a8da06SSandipan Das }, 115878a8da06SSandipan Das { 115978a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 11601d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 116178a8da06SSandipan Das .regs = { 116278a8da06SSandipan Das .gpr[21] = ULONG_MAX, 116378a8da06SSandipan Das .gpr[22] = ULONG_MAX, 116478a8da06SSandipan Das } 116578a8da06SSandipan Das }, 116678a8da06SSandipan Das { 116778a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 11681d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 116978a8da06SSandipan Das .regs = { 117078a8da06SSandipan Das .gpr[21] = ULONG_MAX, 117178a8da06SSandipan Das .gpr[22] = 0x1, 117278a8da06SSandipan Das } 117378a8da06SSandipan Das }, 117478a8da06SSandipan Das { 117578a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 11761d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 117778a8da06SSandipan Das .regs = { 117878a8da06SSandipan Das .gpr[21] = INT_MIN, 117978a8da06SSandipan Das .gpr[22] = INT_MIN, 118078a8da06SSandipan Das } 118178a8da06SSandipan Das }, 118278a8da06SSandipan Das { 118378a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 11841d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 118578a8da06SSandipan Das .regs = { 118678a8da06SSandipan Das .gpr[21] = INT_MIN, 118778a8da06SSandipan Das .gpr[22] = INT_MAX, 118878a8da06SSandipan Das } 118978a8da06SSandipan Das }, 119078a8da06SSandipan Das { 119178a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 11921d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 119378a8da06SSandipan Das .regs = { 119478a8da06SSandipan Das .gpr[21] = INT_MAX, 119578a8da06SSandipan Das .gpr[22] = INT_MAX, 119678a8da06SSandipan Das } 119778a8da06SSandipan Das }, 119878a8da06SSandipan Das { 119978a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 12001d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 120178a8da06SSandipan Das .regs = { 120278a8da06SSandipan Das .gpr[21] = UINT_MAX, 120378a8da06SSandipan Das .gpr[22] = UINT_MAX, 120478a8da06SSandipan Das } 120578a8da06SSandipan Das }, 120678a8da06SSandipan Das { 120778a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 12081d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 120978a8da06SSandipan Das .regs = { 121078a8da06SSandipan Das .gpr[21] = UINT_MAX, 121178a8da06SSandipan Das .gpr[22] = 0x1, 121278a8da06SSandipan Das } 121378a8da06SSandipan Das }, 121478a8da06SSandipan Das { 121578a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN", 12161d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC(20, 21, 22)), 121778a8da06SSandipan Das .regs = { 121878a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN, 121978a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN, 122078a8da06SSandipan Das } 122178a8da06SSandipan Das } 122278a8da06SSandipan Das } 122378a8da06SSandipan Das }, 122478a8da06SSandipan Das { 122578a8da06SSandipan Das .mnemonic = "addc.", 122678a8da06SSandipan Das .subtests = { 122778a8da06SSandipan Das { 122878a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MIN", 122978a8da06SSandipan Das .flags = IGNORE_CCR, 12301d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 123178a8da06SSandipan Das .regs = { 123278a8da06SSandipan Das .gpr[21] = LONG_MIN, 123378a8da06SSandipan Das .gpr[22] = LONG_MIN, 123478a8da06SSandipan Das } 123578a8da06SSandipan Das }, 123678a8da06SSandipan Das { 123778a8da06SSandipan Das .descr = "RA = LONG_MIN, RB = LONG_MAX", 12381d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 123978a8da06SSandipan Das .regs = { 124078a8da06SSandipan Das .gpr[21] = LONG_MIN, 124178a8da06SSandipan Das .gpr[22] = LONG_MAX, 124278a8da06SSandipan Das } 124378a8da06SSandipan Das }, 124478a8da06SSandipan Das { 124578a8da06SSandipan Das .descr = "RA = LONG_MAX, RB = LONG_MAX", 124678a8da06SSandipan Das .flags = IGNORE_CCR, 12471d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 124878a8da06SSandipan Das .regs = { 124978a8da06SSandipan Das .gpr[21] = LONG_MAX, 125078a8da06SSandipan Das .gpr[22] = LONG_MAX, 125178a8da06SSandipan Das } 125278a8da06SSandipan Das }, 125378a8da06SSandipan Das { 125478a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = ULONG_MAX", 12551d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 125678a8da06SSandipan Das .regs = { 125778a8da06SSandipan Das .gpr[21] = ULONG_MAX, 125878a8da06SSandipan Das .gpr[22] = ULONG_MAX, 125978a8da06SSandipan Das } 126078a8da06SSandipan Das }, 126178a8da06SSandipan Das { 126278a8da06SSandipan Das .descr = "RA = ULONG_MAX, RB = 0x1", 12631d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 126478a8da06SSandipan Das .regs = { 126578a8da06SSandipan Das .gpr[21] = ULONG_MAX, 126678a8da06SSandipan Das .gpr[22] = 0x1, 126778a8da06SSandipan Das } 126878a8da06SSandipan Das }, 126978a8da06SSandipan Das { 127078a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MIN", 12711d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 127278a8da06SSandipan Das .regs = { 127378a8da06SSandipan Das .gpr[21] = INT_MIN, 127478a8da06SSandipan Das .gpr[22] = INT_MIN, 127578a8da06SSandipan Das } 127678a8da06SSandipan Das }, 127778a8da06SSandipan Das { 127878a8da06SSandipan Das .descr = "RA = INT_MIN, RB = INT_MAX", 12791d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 128078a8da06SSandipan Das .regs = { 128178a8da06SSandipan Das .gpr[21] = INT_MIN, 128278a8da06SSandipan Das .gpr[22] = INT_MAX, 128378a8da06SSandipan Das } 128478a8da06SSandipan Das }, 128578a8da06SSandipan Das { 128678a8da06SSandipan Das .descr = "RA = INT_MAX, RB = INT_MAX", 12871d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 128878a8da06SSandipan Das .regs = { 128978a8da06SSandipan Das .gpr[21] = INT_MAX, 129078a8da06SSandipan Das .gpr[22] = INT_MAX, 129178a8da06SSandipan Das } 129278a8da06SSandipan Das }, 129378a8da06SSandipan Das { 129478a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = UINT_MAX", 12951d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 129678a8da06SSandipan Das .regs = { 129778a8da06SSandipan Das .gpr[21] = UINT_MAX, 129878a8da06SSandipan Das .gpr[22] = UINT_MAX, 129978a8da06SSandipan Das } 130078a8da06SSandipan Das }, 130178a8da06SSandipan Das { 130278a8da06SSandipan Das .descr = "RA = UINT_MAX, RB = 0x1", 13031d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 130478a8da06SSandipan Das .regs = { 130578a8da06SSandipan Das .gpr[21] = UINT_MAX, 130678a8da06SSandipan Das .gpr[22] = 0x1, 130778a8da06SSandipan Das } 130878a8da06SSandipan Das }, 130978a8da06SSandipan Das { 131078a8da06SSandipan Das .descr = "RA = LONG_MIN | INT_MIN, RB = LONG_MIN | INT_MIN", 13111d33dd84SBalamuruhan S .instr = ppc_inst(PPC_RAW_ADDC_DOT(20, 21, 22)), 131278a8da06SSandipan Das .regs = { 131378a8da06SSandipan Das .gpr[21] = LONG_MIN | (uint)INT_MIN, 131478a8da06SSandipan Das .gpr[22] = LONG_MIN | (uint)INT_MIN, 131578a8da06SSandipan Das } 131678a8da06SSandipan Das } 131778a8da06SSandipan Das } 13184f825900SJordan Niethe }, 13194f825900SJordan Niethe { 1320b859c95cSBalamuruhan S .mnemonic = "divde", 1321b859c95cSBalamuruhan S .subtests = { 1322b859c95cSBalamuruhan S { 1323b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1324b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1325b859c95cSBalamuruhan S .regs = { 1326b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1327b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1328b859c95cSBalamuruhan S } 1329b859c95cSBalamuruhan S }, 1330b859c95cSBalamuruhan S { 1331b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1332b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1333b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1334b859c95cSBalamuruhan S .regs = { 1335b859c95cSBalamuruhan S .gpr[21] = 1L, 1336b859c95cSBalamuruhan S .gpr[22] = 0, 1337b859c95cSBalamuruhan S } 1338b859c95cSBalamuruhan S }, 1339b859c95cSBalamuruhan S { 1340b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1341b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1342b859c95cSBalamuruhan S .regs = { 1343b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1344b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1345b859c95cSBalamuruhan S } 1346b859c95cSBalamuruhan S } 1347b859c95cSBalamuruhan S } 1348b859c95cSBalamuruhan S }, 1349b859c95cSBalamuruhan S { 1350b859c95cSBalamuruhan S .mnemonic = "divde.", 1351b859c95cSBalamuruhan S .subtests = { 1352b859c95cSBalamuruhan S { 1353b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1354b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1355b859c95cSBalamuruhan S .regs = { 1356b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1357b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1358b859c95cSBalamuruhan S } 1359b859c95cSBalamuruhan S }, 1360b859c95cSBalamuruhan S { 1361b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1362b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1363b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1364b859c95cSBalamuruhan S .regs = { 1365b859c95cSBalamuruhan S .gpr[21] = 1L, 1366b859c95cSBalamuruhan S .gpr[22] = 0, 1367b859c95cSBalamuruhan S } 1368b859c95cSBalamuruhan S }, 1369b859c95cSBalamuruhan S { 1370b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1371b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1372b859c95cSBalamuruhan S .regs = { 1373b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1374b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1375b859c95cSBalamuruhan S } 1376b859c95cSBalamuruhan S } 1377b859c95cSBalamuruhan S } 1378b859c95cSBalamuruhan S }, 1379b859c95cSBalamuruhan S { 1380b859c95cSBalamuruhan S .mnemonic = "divdeu", 1381b859c95cSBalamuruhan S .subtests = { 1382b859c95cSBalamuruhan S { 1383b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1384b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1385b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1386b859c95cSBalamuruhan S .regs = { 1387b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1388b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1389b859c95cSBalamuruhan S } 1390b859c95cSBalamuruhan S }, 1391b859c95cSBalamuruhan S { 1392b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1393b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1394b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1395b859c95cSBalamuruhan S .regs = { 1396b859c95cSBalamuruhan S .gpr[21] = 1L, 1397b859c95cSBalamuruhan S .gpr[22] = 0, 1398b859c95cSBalamuruhan S } 1399b859c95cSBalamuruhan S }, 1400b859c95cSBalamuruhan S { 1401b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1402b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1403b859c95cSBalamuruhan S .regs = { 1404b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1405b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1406b859c95cSBalamuruhan S } 1407b859c95cSBalamuruhan S }, 1408b859c95cSBalamuruhan S { 1409b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1410b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1411b859c95cSBalamuruhan S .regs = { 1412b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1, 1413b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1414b859c95cSBalamuruhan S } 1415b859c95cSBalamuruhan S }, 1416b859c95cSBalamuruhan S { 1417b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1418b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1419b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1420b859c95cSBalamuruhan S .regs = { 1421b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1, 1422b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1423b859c95cSBalamuruhan S } 1424b859c95cSBalamuruhan S } 1425b859c95cSBalamuruhan S } 1426b859c95cSBalamuruhan S }, 1427b859c95cSBalamuruhan S { 1428b859c95cSBalamuruhan S .mnemonic = "divdeu.", 1429b859c95cSBalamuruhan S .subtests = { 1430b859c95cSBalamuruhan S { 1431b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MIN", 1432b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1433b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1434b859c95cSBalamuruhan S .regs = { 1435b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1436b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1437b859c95cSBalamuruhan S } 1438b859c95cSBalamuruhan S }, 1439b859c95cSBalamuruhan S { 1440b859c95cSBalamuruhan S .descr = "RA = 1L, RB = 0", 1441b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1442b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1443b859c95cSBalamuruhan S .regs = { 1444b859c95cSBalamuruhan S .gpr[21] = 1L, 1445b859c95cSBalamuruhan S .gpr[22] = 0, 1446b859c95cSBalamuruhan S } 1447b859c95cSBalamuruhan S }, 1448b859c95cSBalamuruhan S { 1449b859c95cSBalamuruhan S .descr = "RA = LONG_MIN, RB = LONG_MAX", 1450b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1451b859c95cSBalamuruhan S .regs = { 1452b859c95cSBalamuruhan S .gpr[21] = LONG_MIN, 1453b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1454b859c95cSBalamuruhan S } 1455b859c95cSBalamuruhan S }, 1456b859c95cSBalamuruhan S { 1457b859c95cSBalamuruhan S .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1458b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1459b859c95cSBalamuruhan S .regs = { 1460b859c95cSBalamuruhan S .gpr[21] = LONG_MAX - 1, 1461b859c95cSBalamuruhan S .gpr[22] = LONG_MAX, 1462b859c95cSBalamuruhan S } 1463b859c95cSBalamuruhan S }, 1464b859c95cSBalamuruhan S { 1465b859c95cSBalamuruhan S .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1466b859c95cSBalamuruhan S .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1467b859c95cSBalamuruhan S .flags = IGNORE_GPR(20), 1468b859c95cSBalamuruhan S .regs = { 1469b859c95cSBalamuruhan S .gpr[21] = LONG_MIN + 1, 1470b859c95cSBalamuruhan S .gpr[22] = LONG_MIN, 1471b859c95cSBalamuruhan S } 1472b859c95cSBalamuruhan S } 1473b859c95cSBalamuruhan S } 1474b859c95cSBalamuruhan S }, 1475b859c95cSBalamuruhan S { 14764f825900SJordan Niethe .mnemonic = "paddi", 14774f825900SJordan Niethe .cpu_feature = CPU_FTR_ARCH_31, 14784f825900SJordan Niethe .subtests = { 14794f825900SJordan Niethe { 14804f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MIN, R = 0", 14814f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 14824f825900SJordan Niethe .regs = { 14834f825900SJordan Niethe .gpr[21] = 0, 14844f825900SJordan Niethe .gpr[22] = LONG_MIN, 14854f825900SJordan Niethe } 14864f825900SJordan Niethe }, 14874f825900SJordan Niethe { 14884f825900SJordan Niethe .descr = "RA = LONG_MIN, SI = SI_MAX, R = 0", 14894f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 14904f825900SJordan Niethe .regs = { 14914f825900SJordan Niethe .gpr[21] = 0, 14924f825900SJordan Niethe .gpr[22] = LONG_MIN, 14934f825900SJordan Niethe } 14944f825900SJordan Niethe }, 14954f825900SJordan Niethe { 14964f825900SJordan Niethe .descr = "RA = LONG_MAX, SI = SI_MAX, R = 0", 14974f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 14984f825900SJordan Niethe .regs = { 14994f825900SJordan Niethe .gpr[21] = 0, 15004f825900SJordan Niethe .gpr[22] = LONG_MAX, 15014f825900SJordan Niethe } 15024f825900SJordan Niethe }, 15034f825900SJordan Niethe { 15044f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = SI_UMAX, R = 0", 15054f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_UMAX, 0), 15064f825900SJordan Niethe .regs = { 15074f825900SJordan Niethe .gpr[21] = 0, 15084f825900SJordan Niethe .gpr[22] = ULONG_MAX, 15094f825900SJordan Niethe } 15104f825900SJordan Niethe }, 15114f825900SJordan Niethe { 15124f825900SJordan Niethe .descr = "RA = ULONG_MAX, SI = 0x1, R = 0", 15134f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0), 15144f825900SJordan Niethe .regs = { 15154f825900SJordan Niethe .gpr[21] = 0, 15164f825900SJordan Niethe .gpr[22] = ULONG_MAX, 15174f825900SJordan Niethe } 15184f825900SJordan Niethe }, 15194f825900SJordan Niethe { 15204f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MIN, R = 0", 15214f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 15224f825900SJordan Niethe .regs = { 15234f825900SJordan Niethe .gpr[21] = 0, 15244f825900SJordan Niethe .gpr[22] = INT_MIN, 15254f825900SJordan Niethe } 15264f825900SJordan Niethe }, 15274f825900SJordan Niethe { 15284f825900SJordan Niethe .descr = "RA = INT_MIN, SI = SI_MAX, R = 0", 15294f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 15304f825900SJordan Niethe .regs = { 15314f825900SJordan Niethe .gpr[21] = 0, 15324f825900SJordan Niethe .gpr[22] = INT_MIN, 15334f825900SJordan Niethe } 15344f825900SJordan Niethe }, 15354f825900SJordan Niethe { 15364f825900SJordan Niethe .descr = "RA = INT_MAX, SI = SI_MAX, R = 0", 15374f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 15384f825900SJordan Niethe .regs = { 15394f825900SJordan Niethe .gpr[21] = 0, 15404f825900SJordan Niethe .gpr[22] = INT_MAX, 15414f825900SJordan Niethe } 15424f825900SJordan Niethe }, 15434f825900SJordan Niethe { 15444f825900SJordan Niethe .descr = "RA = UINT_MAX, SI = 0x1, R = 0", 15454f825900SJordan Niethe .instr = TEST_PADDI(21, 22, 0x1, 0), 15464f825900SJordan Niethe .regs = { 15474f825900SJordan Niethe .gpr[21] = 0, 15484f825900SJordan Niethe .gpr[22] = UINT_MAX, 15494f825900SJordan Niethe } 15504f825900SJordan Niethe }, 15514f825900SJordan Niethe { 15524f825900SJordan Niethe .descr = "RA = UINT_MAX, SI = SI_MAX, R = 0", 15534f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MAX, 0), 15544f825900SJordan Niethe .regs = { 15554f825900SJordan Niethe .gpr[21] = 0, 15564f825900SJordan Niethe .gpr[22] = UINT_MAX, 15574f825900SJordan Niethe } 15584f825900SJordan Niethe }, 15594f825900SJordan Niethe { 15604f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 0", 15614f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 0), 15624f825900SJordan Niethe .regs = { 15634f825900SJordan Niethe .gpr[21] = 0x0, 15644f825900SJordan Niethe } 15654f825900SJordan Niethe }, 15664f825900SJordan Niethe { 15674f825900SJordan Niethe .descr = "RA = 0, SI = SI_MIN, R = 0", 15684f825900SJordan Niethe .instr = TEST_PADDI(21, 22, SI_MIN, 0), 15694f825900SJordan Niethe .regs = { 15704f825900SJordan Niethe .gpr[21] = 0x0, 15714f825900SJordan Niethe .gpr[22] = 0x0, 15724f825900SJordan Niethe } 15734f825900SJordan Niethe }, 15744f825900SJordan Niethe { 15754f825900SJordan Niethe .descr = "RA is r0, SI = 0, R = 1", 15764f825900SJordan Niethe .instr = TEST_PADDI(21, 0, 0, 1), 15774f825900SJordan Niethe .regs = { 15784f825900SJordan Niethe .gpr[21] = 0, 15794f825900SJordan Niethe } 15804f825900SJordan Niethe }, 15814f825900SJordan Niethe { 15824f825900SJordan Niethe .descr = "RA is r0, SI = SI_MIN, R = 1", 15834f825900SJordan Niethe .instr = TEST_PADDI(21, 0, SI_MIN, 1), 15844f825900SJordan Niethe .regs = { 15854f825900SJordan Niethe .gpr[21] = 0, 15864f825900SJordan Niethe } 15877e67c73bSBalamuruhan S }, 15887e67c73bSBalamuruhan S /* Invalid instruction form with R = 1 and RA != 0 */ 15897e67c73bSBalamuruhan S { 15907e67c73bSBalamuruhan S .descr = "RA = R22(0), SI = 0, R = 1", 15917e67c73bSBalamuruhan S .instr = TEST_PADDI(21, 22, 0, 1), 15927e67c73bSBalamuruhan S .flags = NEGATIVE_TEST, 15937e67c73bSBalamuruhan S .regs = { 15947e67c73bSBalamuruhan S .gpr[21] = 0, 15957e67c73bSBalamuruhan S .gpr[22] = 0, 15967e67c73bSBalamuruhan S } 15974f825900SJordan Niethe } 15984f825900SJordan Niethe } 159984022ac1SSandipan Das } 160084022ac1SSandipan Das }; 160184022ac1SSandipan Das 160284022ac1SSandipan Das static int __init emulate_compute_instr(struct pt_regs *regs, 160393c3a0baSBalamuruhan S struct ppc_inst instr, 160493c3a0baSBalamuruhan S bool negative) 160584022ac1SSandipan Das { 160693c3a0baSBalamuruhan S int analysed; 160784022ac1SSandipan Das struct instruction_op op; 160884022ac1SSandipan Das 1609777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr)) 161084022ac1SSandipan Das return -EINVAL; 161184022ac1SSandipan Das 1612*59dc5bfcSNicholas Piggin /* This is not a return frame regs */ 16131c89cf7fSJordan Niethe regs->nip = patch_site_addr(&patch__exec_instr); 16141c89cf7fSJordan Niethe 161593c3a0baSBalamuruhan S analysed = analyse_instr(&op, regs, instr); 161693c3a0baSBalamuruhan S if (analysed != 1 || GETTYPE(op.type) != COMPUTE) { 161793c3a0baSBalamuruhan S if (negative) 161893c3a0baSBalamuruhan S return -EFAULT; 161993c3a0baSBalamuruhan S pr_info("emulation failed, instruction = %s\n", ppc_inst_as_str(instr)); 162084022ac1SSandipan Das return -EFAULT; 162184022ac1SSandipan Das } 162293c3a0baSBalamuruhan S if (analysed == 1 && negative) 162393c3a0baSBalamuruhan S pr_info("negative test failed, instruction = %s\n", ppc_inst_as_str(instr)); 162493c3a0baSBalamuruhan S if (!negative) 162584022ac1SSandipan Das emulate_update_regs(regs, &op); 162684022ac1SSandipan Das return 0; 162784022ac1SSandipan Das } 162884022ac1SSandipan Das 162984022ac1SSandipan Das static int __init execute_compute_instr(struct pt_regs *regs, 163094afd069SJordan Niethe struct ppc_inst instr) 163184022ac1SSandipan Das { 163284022ac1SSandipan Das extern int exec_instr(struct pt_regs *regs); 163384022ac1SSandipan Das 1634777e26f0SJordan Niethe if (!regs || !ppc_inst_val(instr)) 163584022ac1SSandipan Das return -EINVAL; 163684022ac1SSandipan Das 163784022ac1SSandipan Das /* Patch the NOP with the actual instruction */ 163884022ac1SSandipan Das patch_instruction_site(&patch__exec_instr, instr); 163984022ac1SSandipan Das if (exec_instr(regs)) { 164050428fdcSJordan Niethe pr_info("execution failed, instruction = %s\n", ppc_inst_as_str(instr)); 164184022ac1SSandipan Das return -EFAULT; 164284022ac1SSandipan Das } 164384022ac1SSandipan Das 164484022ac1SSandipan Das return 0; 164584022ac1SSandipan Das } 164684022ac1SSandipan Das 164784022ac1SSandipan Das #define gpr_mismatch(gprn, exp, got) \ 164884022ac1SSandipan Das pr_info("GPR%u mismatch, exp = 0x%016lx, got = 0x%016lx\n", \ 164984022ac1SSandipan Das gprn, exp, got) 165084022ac1SSandipan Das 165184022ac1SSandipan Das #define reg_mismatch(name, exp, got) \ 165284022ac1SSandipan Das pr_info("%s mismatch, exp = 0x%016lx, got = 0x%016lx\n", \ 165384022ac1SSandipan Das name, exp, got) 165484022ac1SSandipan Das 165584022ac1SSandipan Das static void __init run_tests_compute(void) 165684022ac1SSandipan Das { 165784022ac1SSandipan Das unsigned long flags; 165884022ac1SSandipan Das struct compute_test *test; 165984022ac1SSandipan Das struct pt_regs *regs, exp, got; 166094afd069SJordan Niethe unsigned int i, j, k; 166194afd069SJordan Niethe struct ppc_inst instr; 166293c3a0baSBalamuruhan S bool ignore_gpr, ignore_xer, ignore_ccr, passed, rc, negative; 166384022ac1SSandipan Das 166484022ac1SSandipan Das for (i = 0; i < ARRAY_SIZE(compute_tests); i++) { 166584022ac1SSandipan Das test = &compute_tests[i]; 166684022ac1SSandipan Das 1667301ebf7dSJordan Niethe if (test->cpu_feature && !early_cpu_has_feature(test->cpu_feature)) { 1668301ebf7dSJordan Niethe show_result(test->mnemonic, "SKIP (!CPU_FTR)"); 1669301ebf7dSJordan Niethe continue; 1670301ebf7dSJordan Niethe } 1671301ebf7dSJordan Niethe 167284022ac1SSandipan Das for (j = 0; j < MAX_SUBTESTS && test->subtests[j].descr; j++) { 167384022ac1SSandipan Das instr = test->subtests[j].instr; 167484022ac1SSandipan Das flags = test->subtests[j].flags; 167584022ac1SSandipan Das regs = &test->subtests[j].regs; 167693c3a0baSBalamuruhan S negative = flags & NEGATIVE_TEST; 167784022ac1SSandipan Das ignore_xer = flags & IGNORE_XER; 167884022ac1SSandipan Das ignore_ccr = flags & IGNORE_CCR; 167984022ac1SSandipan Das passed = true; 168084022ac1SSandipan Das 168184022ac1SSandipan Das memcpy(&exp, regs, sizeof(struct pt_regs)); 168284022ac1SSandipan Das memcpy(&got, regs, sizeof(struct pt_regs)); 168384022ac1SSandipan Das 168484022ac1SSandipan Das /* 168584022ac1SSandipan Das * Set a compatible MSR value explicitly to ensure 168684022ac1SSandipan Das * that XER and CR bits are updated appropriately 168784022ac1SSandipan Das */ 168884022ac1SSandipan Das exp.msr = MSR_KERNEL; 168984022ac1SSandipan Das got.msr = MSR_KERNEL; 169084022ac1SSandipan Das 169193c3a0baSBalamuruhan S rc = emulate_compute_instr(&got, instr, negative) != 0; 169293c3a0baSBalamuruhan S if (negative) { 169393c3a0baSBalamuruhan S /* skip executing instruction */ 169493c3a0baSBalamuruhan S passed = rc; 169593c3a0baSBalamuruhan S goto print; 169693c3a0baSBalamuruhan S } else if (rc || execute_compute_instr(&exp, instr)) { 169784022ac1SSandipan Das passed = false; 169884022ac1SSandipan Das goto print; 169984022ac1SSandipan Das } 170084022ac1SSandipan Das 170184022ac1SSandipan Das /* Verify GPR values */ 170284022ac1SSandipan Das for (k = 0; k < 32; k++) { 170384022ac1SSandipan Das ignore_gpr = flags & IGNORE_GPR(k); 170484022ac1SSandipan Das if (!ignore_gpr && exp.gpr[k] != got.gpr[k]) { 170584022ac1SSandipan Das passed = false; 170684022ac1SSandipan Das gpr_mismatch(k, exp.gpr[k], got.gpr[k]); 170784022ac1SSandipan Das } 170884022ac1SSandipan Das } 170984022ac1SSandipan Das 171084022ac1SSandipan Das /* Verify LR value */ 171184022ac1SSandipan Das if (exp.link != got.link) { 171284022ac1SSandipan Das passed = false; 171384022ac1SSandipan Das reg_mismatch("LR", exp.link, got.link); 171484022ac1SSandipan Das } 171584022ac1SSandipan Das 171684022ac1SSandipan Das /* Verify XER value */ 171784022ac1SSandipan Das if (!ignore_xer && exp.xer != got.xer) { 171884022ac1SSandipan Das passed = false; 171984022ac1SSandipan Das reg_mismatch("XER", exp.xer, got.xer); 172084022ac1SSandipan Das } 172184022ac1SSandipan Das 172284022ac1SSandipan Das /* Verify CR value */ 172384022ac1SSandipan Das if (!ignore_ccr && exp.ccr != got.ccr) { 172484022ac1SSandipan Das passed = false; 172584022ac1SSandipan Das reg_mismatch("CR", exp.ccr, got.ccr); 172684022ac1SSandipan Das } 172784022ac1SSandipan Das 172884022ac1SSandipan Das print: 172984022ac1SSandipan Das show_result_with_descr(test->mnemonic, 173084022ac1SSandipan Das test->subtests[j].descr, 173184022ac1SSandipan Das passed ? "PASS" : "FAIL"); 173284022ac1SSandipan Das } 173384022ac1SSandipan Das } 173484022ac1SSandipan Das } 173584022ac1SSandipan Das 173684022ac1SSandipan Das static int __init test_emulate_step(void) 173784022ac1SSandipan Das { 173884022ac1SSandipan Das printk(KERN_INFO "Running instruction emulation self-tests ...\n"); 173984022ac1SSandipan Das run_tests_load_store(); 174084022ac1SSandipan Das run_tests_compute(); 17414ceae137SRavi Bangoria 17424ceae137SRavi Bangoria return 0; 17434ceae137SRavi Bangoria } 17444ceae137SRavi Bangoria late_initcall(test_emulate_step); 1745