File Index
Files and directories
Sign in
FILE

fpu_denormal.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/powerpc/math/fpu_denormal.c C
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * Copyright IBM Corp. 2020
 4 *
 5 * This test attempts to cause a FP denormal exception on POWER8 CPUs. Unfortunately
 6 * if the denormal handler is not configured or working properly, this can cause a bad
 7 * crash in kernel mode when the kernel tries to save FP registers when the process
 8 * 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}
~/ Read-only file preview.