brintos

brintos / linux-shallow public Read only

0
0
Text · 878 B · 5f96682 Raw
39 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/*3 * Copyright IBM Corp. 20204 *5 * This test attempts to cause a FP denormal exception on POWER8 CPUs. Unfortunately6 * if the denormal handler is not configured or working properly, this can cause a bad7 * crash in kernel mode when the kernel tries to save FP registers when the process8 * exits.9 */10 11#include <stdio.h>12#include <string.h>13 14#include "utils.h"15 16static int test_denormal_fpu(void)17{18	unsigned int m32;19	unsigned long m64;20	volatile float f;21	volatile double d;22 23	/* try to induce lfs <denormal> ; stfd */24 25	m32 = 0x00715fcf; /* random denormal */26	memcpy((float *)&f, &m32, sizeof(f));27	d = f;28	memcpy(&m64, (double *)&d, sizeof(d));29 30	FAIL_IF((long)(m64 != 0x380c57f3c0000000)); /* renormalised value */31 32	return 0;33}34 35int main(int argc, char *argv[])36{37	return test_harness(test_denormal_fpu, "fpu_denormal");38}39