18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Ptrace interface test helper functions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#include <inttypes.h>
88c2ecf20Sopenharmony_ci#include <unistd.h>
98c2ecf20Sopenharmony_ci#include <stdlib.h>
108c2ecf20Sopenharmony_ci#include <string.h>
118c2ecf20Sopenharmony_ci#include <malloc.h>
128c2ecf20Sopenharmony_ci#include <errno.h>
138c2ecf20Sopenharmony_ci#include <time.h>
148c2ecf20Sopenharmony_ci#include <sys/ptrace.h>
158c2ecf20Sopenharmony_ci#include <sys/ioctl.h>
168c2ecf20Sopenharmony_ci#include <sys/uio.h>
178c2ecf20Sopenharmony_ci#include <sys/types.h>
188c2ecf20Sopenharmony_ci#include <sys/wait.h>
198c2ecf20Sopenharmony_ci#include <sys/signal.h>
208c2ecf20Sopenharmony_ci#include <sys/ipc.h>
218c2ecf20Sopenharmony_ci#include <sys/shm.h>
228c2ecf20Sopenharmony_ci#include <sys/user.h>
238c2ecf20Sopenharmony_ci#include <linux/elf.h>
248c2ecf20Sopenharmony_ci#include <linux/types.h>
258c2ecf20Sopenharmony_ci#include <linux/auxvec.h>
268c2ecf20Sopenharmony_ci#include "reg.h"
278c2ecf20Sopenharmony_ci#include "utils.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define TEST_PASS 0
308c2ecf20Sopenharmony_ci#define TEST_FAIL 1
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistruct fpr_regs {
338c2ecf20Sopenharmony_ci	unsigned long fpr[32];
348c2ecf20Sopenharmony_ci	unsigned long fpscr;
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistruct tm_spr_regs {
388c2ecf20Sopenharmony_ci	unsigned long tm_tfhar;
398c2ecf20Sopenharmony_ci	unsigned long tm_texasr;
408c2ecf20Sopenharmony_ci	unsigned long tm_tfiar;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#ifndef NT_PPC_TAR
448c2ecf20Sopenharmony_ci#define NT_PPC_TAR	0x103
458c2ecf20Sopenharmony_ci#define NT_PPC_PPR	0x104
468c2ecf20Sopenharmony_ci#define NT_PPC_DSCR	0x105
478c2ecf20Sopenharmony_ci#define NT_PPC_EBB	0x106
488c2ecf20Sopenharmony_ci#define NT_PPC_PMU	0x107
498c2ecf20Sopenharmony_ci#define NT_PPC_TM_CGPR	0x108
508c2ecf20Sopenharmony_ci#define NT_PPC_TM_CFPR	0x109
518c2ecf20Sopenharmony_ci#define NT_PPC_TM_CVMX	0x10a
528c2ecf20Sopenharmony_ci#define NT_PPC_TM_CVSX	0x10b
538c2ecf20Sopenharmony_ci#define NT_PPC_TM_SPR	0x10c
548c2ecf20Sopenharmony_ci#define NT_PPC_TM_CTAR	0x10d
558c2ecf20Sopenharmony_ci#define NT_PPC_TM_CPPR	0x10e
568c2ecf20Sopenharmony_ci#define NT_PPC_TM_CDSCR	0x10f
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Basic ptrace operations */
608c2ecf20Sopenharmony_ciint start_trace(pid_t child)
618c2ecf20Sopenharmony_ci{
628c2ecf20Sopenharmony_ci	int ret;
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_ATTACH, child, NULL, NULL);
658c2ecf20Sopenharmony_ci	if (ret) {
668c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_ATTACH) failed");
678c2ecf20Sopenharmony_ci		return TEST_FAIL;
688c2ecf20Sopenharmony_ci	}
698c2ecf20Sopenharmony_ci	ret = waitpid(child, NULL, 0);
708c2ecf20Sopenharmony_ci	if (ret != child) {
718c2ecf20Sopenharmony_ci		perror("waitpid() failed");
728c2ecf20Sopenharmony_ci		return TEST_FAIL;
738c2ecf20Sopenharmony_ci	}
748c2ecf20Sopenharmony_ci	return TEST_PASS;
758c2ecf20Sopenharmony_ci}
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciint stop_trace(pid_t child)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	int ret;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_DETACH, child, NULL, NULL);
828c2ecf20Sopenharmony_ci	if (ret) {
838c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_DETACH) failed");
848c2ecf20Sopenharmony_ci		return TEST_FAIL;
858c2ecf20Sopenharmony_ci	}
868c2ecf20Sopenharmony_ci	return TEST_PASS;
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciint cont_trace(pid_t child)
908c2ecf20Sopenharmony_ci{
918c2ecf20Sopenharmony_ci	int ret;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_CONT, child, NULL, NULL);
948c2ecf20Sopenharmony_ci	if (ret) {
958c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_CONT) failed");
968c2ecf20Sopenharmony_ci		return TEST_FAIL;
978c2ecf20Sopenharmony_ci	}
988c2ecf20Sopenharmony_ci	return TEST_PASS;
998c2ecf20Sopenharmony_ci}
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ciint ptrace_read_regs(pid_t child, unsigned long type, unsigned long regs[],
1028c2ecf20Sopenharmony_ci		     int n)
1038c2ecf20Sopenharmony_ci{
1048c2ecf20Sopenharmony_ci	struct iovec iov;
1058c2ecf20Sopenharmony_ci	long ret;
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	FAIL_IF(start_trace(child));
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	iov.iov_base = regs;
1108c2ecf20Sopenharmony_ci	iov.iov_len = n * sizeof(unsigned long);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, type, &iov);
1138c2ecf20Sopenharmony_ci	if (ret)
1148c2ecf20Sopenharmony_ci		return ret;
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	FAIL_IF(stop_trace(child));
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	return TEST_PASS;
1198c2ecf20Sopenharmony_ci}
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cilong ptrace_write_regs(pid_t child, unsigned long type, unsigned long regs[],
1228c2ecf20Sopenharmony_ci		       int n)
1238c2ecf20Sopenharmony_ci{
1248c2ecf20Sopenharmony_ci	struct iovec iov;
1258c2ecf20Sopenharmony_ci	long ret;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	FAIL_IF(start_trace(child));
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	iov.iov_base = regs;
1308c2ecf20Sopenharmony_ci	iov.iov_len = n * sizeof(unsigned long);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, type, &iov);
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	FAIL_IF(stop_trace(child));
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	return ret;
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* TAR, PPR, DSCR */
1408c2ecf20Sopenharmony_ciint show_tar_registers(pid_t child, unsigned long *out)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	struct iovec iov;
1438c2ecf20Sopenharmony_ci	unsigned long *reg;
1448c2ecf20Sopenharmony_ci	int ret;
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	reg = malloc(sizeof(unsigned long));
1478c2ecf20Sopenharmony_ci	if (!reg) {
1488c2ecf20Sopenharmony_ci		perror("malloc() failed");
1498c2ecf20Sopenharmony_ci		return TEST_FAIL;
1508c2ecf20Sopenharmony_ci	}
1518c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) reg;
1528c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(unsigned long);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TAR, &iov);
1558c2ecf20Sopenharmony_ci	if (ret) {
1568c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
1578c2ecf20Sopenharmony_ci		goto fail;
1588c2ecf20Sopenharmony_ci	}
1598c2ecf20Sopenharmony_ci	if (out)
1608c2ecf20Sopenharmony_ci		out[0] = *reg;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_PPR, &iov);
1638c2ecf20Sopenharmony_ci	if (ret) {
1648c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
1658c2ecf20Sopenharmony_ci		goto fail;
1668c2ecf20Sopenharmony_ci	}
1678c2ecf20Sopenharmony_ci	if (out)
1688c2ecf20Sopenharmony_ci		out[1] = *reg;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_DSCR, &iov);
1718c2ecf20Sopenharmony_ci	if (ret) {
1728c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
1738c2ecf20Sopenharmony_ci		goto fail;
1748c2ecf20Sopenharmony_ci	}
1758c2ecf20Sopenharmony_ci	if (out)
1768c2ecf20Sopenharmony_ci		out[2] = *reg;
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	free(reg);
1798c2ecf20Sopenharmony_ci	return TEST_PASS;
1808c2ecf20Sopenharmony_cifail:
1818c2ecf20Sopenharmony_ci	free(reg);
1828c2ecf20Sopenharmony_ci	return TEST_FAIL;
1838c2ecf20Sopenharmony_ci}
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ciint write_tar_registers(pid_t child, unsigned long tar,
1868c2ecf20Sopenharmony_ci		unsigned long ppr, unsigned long dscr)
1878c2ecf20Sopenharmony_ci{
1888c2ecf20Sopenharmony_ci	struct iovec iov;
1898c2ecf20Sopenharmony_ci	unsigned long *reg;
1908c2ecf20Sopenharmony_ci	int ret;
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	reg = malloc(sizeof(unsigned long));
1938c2ecf20Sopenharmony_ci	if (!reg) {
1948c2ecf20Sopenharmony_ci		perror("malloc() failed");
1958c2ecf20Sopenharmony_ci		return TEST_FAIL;
1968c2ecf20Sopenharmony_ci	}
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) reg;
1998c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(unsigned long);
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	*reg = tar;
2028c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TAR, &iov);
2038c2ecf20Sopenharmony_ci	if (ret) {
2048c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETREGSET) failed");
2058c2ecf20Sopenharmony_ci		goto fail;
2068c2ecf20Sopenharmony_ci	}
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	*reg = ppr;
2098c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_PPR, &iov);
2108c2ecf20Sopenharmony_ci	if (ret) {
2118c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETREGSET) failed");
2128c2ecf20Sopenharmony_ci		goto fail;
2138c2ecf20Sopenharmony_ci	}
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	*reg = dscr;
2168c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_DSCR, &iov);
2178c2ecf20Sopenharmony_ci	if (ret) {
2188c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETREGSET) failed");
2198c2ecf20Sopenharmony_ci		goto fail;
2208c2ecf20Sopenharmony_ci	}
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	free(reg);
2238c2ecf20Sopenharmony_ci	return TEST_PASS;
2248c2ecf20Sopenharmony_cifail:
2258c2ecf20Sopenharmony_ci	free(reg);
2268c2ecf20Sopenharmony_ci	return TEST_FAIL;
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ciint show_tm_checkpointed_state(pid_t child, unsigned long *out)
2308c2ecf20Sopenharmony_ci{
2318c2ecf20Sopenharmony_ci	struct iovec iov;
2328c2ecf20Sopenharmony_ci	unsigned long *reg;
2338c2ecf20Sopenharmony_ci	int ret;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	reg = malloc(sizeof(unsigned long));
2368c2ecf20Sopenharmony_ci	if (!reg) {
2378c2ecf20Sopenharmony_ci		perror("malloc() failed");
2388c2ecf20Sopenharmony_ci		return TEST_FAIL;
2398c2ecf20Sopenharmony_ci	}
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) reg;
2428c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(unsigned long);
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CTAR, &iov);
2458c2ecf20Sopenharmony_ci	if (ret) {
2468c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
2478c2ecf20Sopenharmony_ci		goto fail;
2488c2ecf20Sopenharmony_ci	}
2498c2ecf20Sopenharmony_ci	if (out)
2508c2ecf20Sopenharmony_ci		out[0] = *reg;
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CPPR, &iov);
2538c2ecf20Sopenharmony_ci	if (ret) {
2548c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
2558c2ecf20Sopenharmony_ci		goto fail;
2568c2ecf20Sopenharmony_ci	}
2578c2ecf20Sopenharmony_ci	if (out)
2588c2ecf20Sopenharmony_ci		out[1] = *reg;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CDSCR, &iov);
2618c2ecf20Sopenharmony_ci	if (ret) {
2628c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
2638c2ecf20Sopenharmony_ci		goto fail;
2648c2ecf20Sopenharmony_ci	}
2658c2ecf20Sopenharmony_ci	if (out)
2668c2ecf20Sopenharmony_ci		out[2] = *reg;
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	free(reg);
2698c2ecf20Sopenharmony_ci	return TEST_PASS;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_cifail:
2728c2ecf20Sopenharmony_ci	free(reg);
2738c2ecf20Sopenharmony_ci	return TEST_FAIL;
2748c2ecf20Sopenharmony_ci}
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ciint write_ckpt_tar_registers(pid_t child, unsigned long tar,
2778c2ecf20Sopenharmony_ci		unsigned long ppr, unsigned long dscr)
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci	struct iovec iov;
2808c2ecf20Sopenharmony_ci	unsigned long *reg;
2818c2ecf20Sopenharmony_ci	int ret;
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	reg = malloc(sizeof(unsigned long));
2848c2ecf20Sopenharmony_ci	if (!reg) {
2858c2ecf20Sopenharmony_ci		perror("malloc() failed");
2868c2ecf20Sopenharmony_ci		return TEST_FAIL;
2878c2ecf20Sopenharmony_ci	}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) reg;
2908c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(unsigned long);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	*reg = tar;
2938c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CTAR, &iov);
2948c2ecf20Sopenharmony_ci	if (ret) {
2958c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
2968c2ecf20Sopenharmony_ci		goto fail;
2978c2ecf20Sopenharmony_ci	}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	*reg = ppr;
3008c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CPPR, &iov);
3018c2ecf20Sopenharmony_ci	if (ret) {
3028c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3038c2ecf20Sopenharmony_ci		goto fail;
3048c2ecf20Sopenharmony_ci	}
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	*reg = dscr;
3078c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CDSCR, &iov);
3088c2ecf20Sopenharmony_ci	if (ret) {
3098c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3108c2ecf20Sopenharmony_ci		goto fail;
3118c2ecf20Sopenharmony_ci	}
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	free(reg);
3148c2ecf20Sopenharmony_ci	return TEST_PASS;
3158c2ecf20Sopenharmony_cifail:
3168c2ecf20Sopenharmony_ci	free(reg);
3178c2ecf20Sopenharmony_ci	return TEST_FAIL;
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci/* FPR */
3218c2ecf20Sopenharmony_ciint show_fpr(pid_t child, unsigned long *fpr)
3228c2ecf20Sopenharmony_ci{
3238c2ecf20Sopenharmony_ci	struct fpr_regs *regs;
3248c2ecf20Sopenharmony_ci	int ret, i;
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	regs = (struct fpr_regs *) malloc(sizeof(struct fpr_regs));
3278c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETFPREGS, child, NULL, regs);
3288c2ecf20Sopenharmony_ci	if (ret) {
3298c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3308c2ecf20Sopenharmony_ci		return TEST_FAIL;
3318c2ecf20Sopenharmony_ci	}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	if (fpr) {
3348c2ecf20Sopenharmony_ci		for (i = 0; i < 32; i++)
3358c2ecf20Sopenharmony_ci			fpr[i] = regs->fpr[i];
3368c2ecf20Sopenharmony_ci	}
3378c2ecf20Sopenharmony_ci	return TEST_PASS;
3388c2ecf20Sopenharmony_ci}
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ciint write_fpr(pid_t child, unsigned long val)
3418c2ecf20Sopenharmony_ci{
3428c2ecf20Sopenharmony_ci	struct fpr_regs *regs;
3438c2ecf20Sopenharmony_ci	int ret, i;
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	regs = (struct fpr_regs *) malloc(sizeof(struct fpr_regs));
3468c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETFPREGS, child, NULL, regs);
3478c2ecf20Sopenharmony_ci	if (ret) {
3488c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3498c2ecf20Sopenharmony_ci		return TEST_FAIL;
3508c2ecf20Sopenharmony_ci	}
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci	for (i = 0; i < 32; i++)
3538c2ecf20Sopenharmony_ci		regs->fpr[i] = val;
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETFPREGS, child, NULL, regs);
3568c2ecf20Sopenharmony_ci	if (ret) {
3578c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3588c2ecf20Sopenharmony_ci		return TEST_FAIL;
3598c2ecf20Sopenharmony_ci	}
3608c2ecf20Sopenharmony_ci	return TEST_PASS;
3618c2ecf20Sopenharmony_ci}
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ciint show_ckpt_fpr(pid_t child, unsigned long *fpr)
3648c2ecf20Sopenharmony_ci{
3658c2ecf20Sopenharmony_ci	struct fpr_regs *regs;
3668c2ecf20Sopenharmony_ci	struct iovec iov;
3678c2ecf20Sopenharmony_ci	int ret, i;
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci	regs = (struct fpr_regs *) malloc(sizeof(struct fpr_regs));
3708c2ecf20Sopenharmony_ci	iov.iov_base = regs;
3718c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(struct fpr_regs);
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CFPR, &iov);
3748c2ecf20Sopenharmony_ci	if (ret) {
3758c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
3768c2ecf20Sopenharmony_ci		return TEST_FAIL;
3778c2ecf20Sopenharmony_ci	}
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	if (fpr) {
3808c2ecf20Sopenharmony_ci		for (i = 0; i < 32; i++)
3818c2ecf20Sopenharmony_ci			fpr[i] = regs->fpr[i];
3828c2ecf20Sopenharmony_ci	}
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	return TEST_PASS;
3858c2ecf20Sopenharmony_ci}
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ciint write_ckpt_fpr(pid_t child, unsigned long val)
3888c2ecf20Sopenharmony_ci{
3898c2ecf20Sopenharmony_ci	struct fpr_regs *regs;
3908c2ecf20Sopenharmony_ci	struct iovec iov;
3918c2ecf20Sopenharmony_ci	int ret, i;
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci	regs = (struct fpr_regs *) malloc(sizeof(struct fpr_regs));
3948c2ecf20Sopenharmony_ci	iov.iov_base = regs;
3958c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(struct fpr_regs);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CFPR, &iov);
3988c2ecf20Sopenharmony_ci	if (ret) {
3998c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4008c2ecf20Sopenharmony_ci		return TEST_FAIL;
4018c2ecf20Sopenharmony_ci	}
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	for (i = 0; i < 32; i++)
4048c2ecf20Sopenharmony_ci		regs->fpr[i] = val;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CFPR, &iov);
4078c2ecf20Sopenharmony_ci	if (ret) {
4088c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4098c2ecf20Sopenharmony_ci		return TEST_FAIL;
4108c2ecf20Sopenharmony_ci	}
4118c2ecf20Sopenharmony_ci	return TEST_PASS;
4128c2ecf20Sopenharmony_ci}
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci/* GPR */
4158c2ecf20Sopenharmony_ciint show_gpr(pid_t child, unsigned long *gpr)
4168c2ecf20Sopenharmony_ci{
4178c2ecf20Sopenharmony_ci	struct pt_regs *regs;
4188c2ecf20Sopenharmony_ci	int ret, i;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	regs = (struct pt_regs *) malloc(sizeof(struct pt_regs));
4218c2ecf20Sopenharmony_ci	if (!regs) {
4228c2ecf20Sopenharmony_ci		perror("malloc() failed");
4238c2ecf20Sopenharmony_ci		return TEST_FAIL;
4248c2ecf20Sopenharmony_ci	}
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGS, child, NULL, regs);
4278c2ecf20Sopenharmony_ci	if (ret) {
4288c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4298c2ecf20Sopenharmony_ci		return TEST_FAIL;
4308c2ecf20Sopenharmony_ci	}
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	if (gpr) {
4338c2ecf20Sopenharmony_ci		for (i = 14; i < 32; i++)
4348c2ecf20Sopenharmony_ci			gpr[i-14] = regs->gpr[i];
4358c2ecf20Sopenharmony_ci	}
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	return TEST_PASS;
4388c2ecf20Sopenharmony_ci}
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ciint write_gpr(pid_t child, unsigned long val)
4418c2ecf20Sopenharmony_ci{
4428c2ecf20Sopenharmony_ci	struct pt_regs *regs;
4438c2ecf20Sopenharmony_ci	int i, ret;
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci	regs = (struct pt_regs *) malloc(sizeof(struct pt_regs));
4468c2ecf20Sopenharmony_ci	if (!regs) {
4478c2ecf20Sopenharmony_ci		perror("malloc() failed");
4488c2ecf20Sopenharmony_ci		return TEST_FAIL;
4498c2ecf20Sopenharmony_ci	}
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGS, child, NULL, regs);
4528c2ecf20Sopenharmony_ci	if (ret) {
4538c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4548c2ecf20Sopenharmony_ci		return TEST_FAIL;
4558c2ecf20Sopenharmony_ci	}
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci	for (i = 14; i < 32; i++)
4588c2ecf20Sopenharmony_ci		regs->gpr[i] = val;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGS, child, NULL, regs);
4618c2ecf20Sopenharmony_ci	if (ret) {
4628c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4638c2ecf20Sopenharmony_ci		return TEST_FAIL;
4648c2ecf20Sopenharmony_ci	}
4658c2ecf20Sopenharmony_ci	return TEST_PASS;
4668c2ecf20Sopenharmony_ci}
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ciint show_ckpt_gpr(pid_t child, unsigned long *gpr)
4698c2ecf20Sopenharmony_ci{
4708c2ecf20Sopenharmony_ci	struct pt_regs *regs;
4718c2ecf20Sopenharmony_ci	struct iovec iov;
4728c2ecf20Sopenharmony_ci	int ret, i;
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci	regs = (struct pt_regs *) malloc(sizeof(struct pt_regs));
4758c2ecf20Sopenharmony_ci	if (!regs) {
4768c2ecf20Sopenharmony_ci		perror("malloc() failed");
4778c2ecf20Sopenharmony_ci		return TEST_FAIL;
4788c2ecf20Sopenharmony_ci	}
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
4818c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(struct pt_regs);
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CGPR, &iov);
4848c2ecf20Sopenharmony_ci	if (ret) {
4858c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
4868c2ecf20Sopenharmony_ci		return TEST_FAIL;
4878c2ecf20Sopenharmony_ci	}
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	if (gpr) {
4908c2ecf20Sopenharmony_ci		for (i = 14; i < 32; i++)
4918c2ecf20Sopenharmony_ci			gpr[i-14] = regs->gpr[i];
4928c2ecf20Sopenharmony_ci	}
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	return TEST_PASS;
4958c2ecf20Sopenharmony_ci}
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ciint write_ckpt_gpr(pid_t child, unsigned long val)
4988c2ecf20Sopenharmony_ci{
4998c2ecf20Sopenharmony_ci	struct pt_regs *regs;
5008c2ecf20Sopenharmony_ci	struct iovec iov;
5018c2ecf20Sopenharmony_ci	int ret, i;
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	regs = (struct pt_regs *) malloc(sizeof(struct pt_regs));
5048c2ecf20Sopenharmony_ci	if (!regs) {
5058c2ecf20Sopenharmony_ci		perror("malloc() failed\n");
5068c2ecf20Sopenharmony_ci		return TEST_FAIL;
5078c2ecf20Sopenharmony_ci	}
5088c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
5098c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(struct pt_regs);
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CGPR, &iov);
5128c2ecf20Sopenharmony_ci	if (ret) {
5138c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
5148c2ecf20Sopenharmony_ci		return TEST_FAIL;
5158c2ecf20Sopenharmony_ci	}
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	for (i = 14; i < 32; i++)
5188c2ecf20Sopenharmony_ci		regs->gpr[i] = val;
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CGPR, &iov);
5218c2ecf20Sopenharmony_ci	if (ret) {
5228c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
5238c2ecf20Sopenharmony_ci		return TEST_FAIL;
5248c2ecf20Sopenharmony_ci	}
5258c2ecf20Sopenharmony_ci	return TEST_PASS;
5268c2ecf20Sopenharmony_ci}
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci/* VMX */
5298c2ecf20Sopenharmony_ciint show_vmx(pid_t child, unsigned long vmx[][2])
5308c2ecf20Sopenharmony_ci{
5318c2ecf20Sopenharmony_ci	int ret;
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETVRREGS, child, 0, vmx);
5348c2ecf20Sopenharmony_ci	if (ret) {
5358c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETVRREGS) failed");
5368c2ecf20Sopenharmony_ci		return TEST_FAIL;
5378c2ecf20Sopenharmony_ci	}
5388c2ecf20Sopenharmony_ci	return TEST_PASS;
5398c2ecf20Sopenharmony_ci}
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ciint show_vmx_ckpt(pid_t child, unsigned long vmx[][2])
5428c2ecf20Sopenharmony_ci{
5438c2ecf20Sopenharmony_ci	unsigned long regs[34][2];
5448c2ecf20Sopenharmony_ci	struct iovec iov;
5458c2ecf20Sopenharmony_ci	int ret;
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
5488c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(regs);
5498c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CVMX, &iov);
5508c2ecf20Sopenharmony_ci	if (ret) {
5518c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET, NT_PPC_TM_CVMX) failed");
5528c2ecf20Sopenharmony_ci		return TEST_FAIL;
5538c2ecf20Sopenharmony_ci	}
5548c2ecf20Sopenharmony_ci	memcpy(vmx, regs, sizeof(regs));
5558c2ecf20Sopenharmony_ci	return TEST_PASS;
5568c2ecf20Sopenharmony_ci}
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_ciint write_vmx(pid_t child, unsigned long vmx[][2])
5608c2ecf20Sopenharmony_ci{
5618c2ecf20Sopenharmony_ci	int ret;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETVRREGS, child, 0, vmx);
5648c2ecf20Sopenharmony_ci	if (ret) {
5658c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETVRREGS) failed");
5668c2ecf20Sopenharmony_ci		return TEST_FAIL;
5678c2ecf20Sopenharmony_ci	}
5688c2ecf20Sopenharmony_ci	return TEST_PASS;
5698c2ecf20Sopenharmony_ci}
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ciint write_vmx_ckpt(pid_t child, unsigned long vmx[][2])
5728c2ecf20Sopenharmony_ci{
5738c2ecf20Sopenharmony_ci	unsigned long regs[34][2];
5748c2ecf20Sopenharmony_ci	struct iovec iov;
5758c2ecf20Sopenharmony_ci	int ret;
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	memcpy(regs, vmx, sizeof(regs));
5788c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
5798c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(regs);
5808c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CVMX, &iov);
5818c2ecf20Sopenharmony_ci	if (ret) {
5828c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETREGSET, NT_PPC_TM_CVMX) failed");
5838c2ecf20Sopenharmony_ci		return TEST_FAIL;
5848c2ecf20Sopenharmony_ci	}
5858c2ecf20Sopenharmony_ci	return TEST_PASS;
5868c2ecf20Sopenharmony_ci}
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci/* VSX */
5898c2ecf20Sopenharmony_ciint show_vsx(pid_t child, unsigned long *vsx)
5908c2ecf20Sopenharmony_ci{
5918c2ecf20Sopenharmony_ci	int ret;
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETVSRREGS, child, 0, vsx);
5948c2ecf20Sopenharmony_ci	if (ret) {
5958c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETVSRREGS) failed");
5968c2ecf20Sopenharmony_ci		return TEST_FAIL;
5978c2ecf20Sopenharmony_ci	}
5988c2ecf20Sopenharmony_ci	return TEST_PASS;
5998c2ecf20Sopenharmony_ci}
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ciint show_vsx_ckpt(pid_t child, unsigned long *vsx)
6028c2ecf20Sopenharmony_ci{
6038c2ecf20Sopenharmony_ci	unsigned long regs[32];
6048c2ecf20Sopenharmony_ci	struct iovec iov;
6058c2ecf20Sopenharmony_ci	int ret;
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
6088c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(regs);
6098c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_CVSX, &iov);
6108c2ecf20Sopenharmony_ci	if (ret) {
6118c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET, NT_PPC_TM_CVSX) failed");
6128c2ecf20Sopenharmony_ci		return TEST_FAIL;
6138c2ecf20Sopenharmony_ci	}
6148c2ecf20Sopenharmony_ci	memcpy(vsx, regs, sizeof(regs));
6158c2ecf20Sopenharmony_ci	return TEST_PASS;
6168c2ecf20Sopenharmony_ci}
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ciint write_vsx(pid_t child, unsigned long *vsx)
6198c2ecf20Sopenharmony_ci{
6208c2ecf20Sopenharmony_ci	int ret;
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETVSRREGS, child, 0, vsx);
6238c2ecf20Sopenharmony_ci	if (ret) {
6248c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETVSRREGS) failed");
6258c2ecf20Sopenharmony_ci		return TEST_FAIL;
6268c2ecf20Sopenharmony_ci	}
6278c2ecf20Sopenharmony_ci	return TEST_PASS;
6288c2ecf20Sopenharmony_ci}
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ciint write_vsx_ckpt(pid_t child, unsigned long *vsx)
6318c2ecf20Sopenharmony_ci{
6328c2ecf20Sopenharmony_ci	unsigned long regs[32];
6338c2ecf20Sopenharmony_ci	struct iovec iov;
6348c2ecf20Sopenharmony_ci	int ret;
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_ci	memcpy(regs, vsx, sizeof(regs));
6378c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
6388c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(regs);
6398c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_SETREGSET, child, NT_PPC_TM_CVSX, &iov);
6408c2ecf20Sopenharmony_ci	if (ret) {
6418c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_SETREGSET, NT_PPC_TM_CVSX) failed");
6428c2ecf20Sopenharmony_ci		return TEST_FAIL;
6438c2ecf20Sopenharmony_ci	}
6448c2ecf20Sopenharmony_ci	return TEST_PASS;
6458c2ecf20Sopenharmony_ci}
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci/* TM SPR */
6488c2ecf20Sopenharmony_ciint show_tm_spr(pid_t child, struct tm_spr_regs *out)
6498c2ecf20Sopenharmony_ci{
6508c2ecf20Sopenharmony_ci	struct tm_spr_regs *regs;
6518c2ecf20Sopenharmony_ci	struct iovec iov;
6528c2ecf20Sopenharmony_ci	int ret;
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci	regs = (struct tm_spr_regs *) malloc(sizeof(struct tm_spr_regs));
6558c2ecf20Sopenharmony_ci	if (!regs) {
6568c2ecf20Sopenharmony_ci		perror("malloc() failed");
6578c2ecf20Sopenharmony_ci		return TEST_FAIL;
6588c2ecf20Sopenharmony_ci	}
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci	iov.iov_base = (u64 *) regs;
6618c2ecf20Sopenharmony_ci	iov.iov_len = sizeof(struct tm_spr_regs);
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci	ret = ptrace(PTRACE_GETREGSET, child, NT_PPC_TM_SPR, &iov);
6648c2ecf20Sopenharmony_ci	if (ret) {
6658c2ecf20Sopenharmony_ci		perror("ptrace(PTRACE_GETREGSET) failed");
6668c2ecf20Sopenharmony_ci		return TEST_FAIL;
6678c2ecf20Sopenharmony_ci	}
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	if (out)
6708c2ecf20Sopenharmony_ci		memcpy(out, regs, sizeof(struct tm_spr_regs));
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	return TEST_PASS;
6738c2ecf20Sopenharmony_ci}
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci/* Analyse TEXASR after TM failure */
6788c2ecf20Sopenharmony_ciinline unsigned long get_tfiar(void)
6798c2ecf20Sopenharmony_ci{
6808c2ecf20Sopenharmony_ci	unsigned long ret;
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci	asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_TFIAR));
6838c2ecf20Sopenharmony_ci	return ret;
6848c2ecf20Sopenharmony_ci}
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_civoid analyse_texasr(unsigned long texasr)
6878c2ecf20Sopenharmony_ci{
6888c2ecf20Sopenharmony_ci	printf("TEXASR: %16lx\t", texasr);
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci	if (texasr & TEXASR_FP)
6918c2ecf20Sopenharmony_ci		printf("TEXASR_FP  ");
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	if (texasr & TEXASR_DA)
6948c2ecf20Sopenharmony_ci		printf("TEXASR_DA  ");
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci	if (texasr & TEXASR_NO)
6978c2ecf20Sopenharmony_ci		printf("TEXASR_NO  ");
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_ci	if (texasr & TEXASR_FO)
7008c2ecf20Sopenharmony_ci		printf("TEXASR_FO  ");
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci	if (texasr & TEXASR_SIC)
7038c2ecf20Sopenharmony_ci		printf("TEXASR_SIC  ");
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci	if (texasr & TEXASR_NTC)
7068c2ecf20Sopenharmony_ci		printf("TEXASR_NTC  ");
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_ci	if (texasr & TEXASR_TC)
7098c2ecf20Sopenharmony_ci		printf("TEXASR_TC  ");
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci	if (texasr & TEXASR_TIC)
7128c2ecf20Sopenharmony_ci		printf("TEXASR_TIC  ");
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci	if (texasr & TEXASR_IC)
7158c2ecf20Sopenharmony_ci		printf("TEXASR_IC  ");
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci	if (texasr & TEXASR_IFC)
7188c2ecf20Sopenharmony_ci		printf("TEXASR_IFC  ");
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci	if (texasr & TEXASR_ABT)
7218c2ecf20Sopenharmony_ci		printf("TEXASR_ABT  ");
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci	if (texasr & TEXASR_SPD)
7248c2ecf20Sopenharmony_ci		printf("TEXASR_SPD  ");
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_ci	if (texasr & TEXASR_HV)
7278c2ecf20Sopenharmony_ci		printf("TEXASR_HV  ");
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_ci	if (texasr & TEXASR_PR)
7308c2ecf20Sopenharmony_ci		printf("TEXASR_PR  ");
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_ci	if (texasr & TEXASR_FS)
7338c2ecf20Sopenharmony_ci		printf("TEXASR_FS  ");
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci	if (texasr & TEXASR_TE)
7368c2ecf20Sopenharmony_ci		printf("TEXASR_TE  ");
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci	if (texasr & TEXASR_ROT)
7398c2ecf20Sopenharmony_ci		printf("TEXASR_ROT  ");
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci	printf("TFIAR :%lx\n", get_tfiar());
7428c2ecf20Sopenharmony_ci}
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_civoid store_gpr(unsigned long *addr);
7458c2ecf20Sopenharmony_civoid store_fpr(float *addr);
746