1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3*49cdfc7eSAndroid Build Coastguard Worker *
4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify it
5*49cdfc7eSAndroid Build Coastguard Worker * under the terms of version 2 of the GNU General Public License as
6*49cdfc7eSAndroid Build Coastguard Worker * published by the Free Software Foundation.
7*49cdfc7eSAndroid Build Coastguard Worker *
8*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it would be useful, but
9*49cdfc7eSAndroid Build Coastguard Worker * WITHOUT ANY WARRANTY; without even the implied warranty of
10*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11*49cdfc7eSAndroid Build Coastguard Worker *
12*49cdfc7eSAndroid Build Coastguard Worker * Further, this software is distributed without any warranty that it is
13*49cdfc7eSAndroid Build Coastguard Worker * free of the rightful claim of any third person regarding infringement
14*49cdfc7eSAndroid Build Coastguard Worker * or the like. Any license provided herein, whether implied or
15*49cdfc7eSAndroid Build Coastguard Worker * otherwise, applies only to this software file. Patent licenses, if
16*49cdfc7eSAndroid Build Coastguard Worker * any, provided herein do not apply to combinations of this program with
17*49cdfc7eSAndroid Build Coastguard Worker * other software, or any other product whatsoever.
18*49cdfc7eSAndroid Build Coastguard Worker *
19*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License along
20*49cdfc7eSAndroid Build Coastguard Worker * with this program; if not, write the Free Software Foundation, Inc.,
21*49cdfc7eSAndroid Build Coastguard Worker * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22*49cdfc7eSAndroid Build Coastguard Worker *
23*49cdfc7eSAndroid Build Coastguard Worker * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24*49cdfc7eSAndroid Build Coastguard Worker * Mountain View, CA 94043, or:
25*49cdfc7eSAndroid Build Coastguard Worker *
26*49cdfc7eSAndroid Build Coastguard Worker * http://www.sgi.com
27*49cdfc7eSAndroid Build Coastguard Worker *
28*49cdfc7eSAndroid Build Coastguard Worker * For further information regarding this notice, see:
29*49cdfc7eSAndroid Build Coastguard Worker *
30*49cdfc7eSAndroid Build Coastguard Worker * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
31*49cdfc7eSAndroid Build Coastguard Worker *
32*49cdfc7eSAndroid Build Coastguard Worker */
33*49cdfc7eSAndroid Build Coastguard Worker /* $Id: f00f.c,v 1.5 2008/04/24 06:36:14 subrata_modak Exp $ */
34*49cdfc7eSAndroid Build Coastguard Worker /*
35*49cdfc7eSAndroid Build Coastguard Worker * This is a simple test for handling of the pentium f00f bug.
36*49cdfc7eSAndroid Build Coastguard Worker * It is an example of a catistrophic test case. If the system
37*49cdfc7eSAndroid Build Coastguard Worker * doesn't correctly handle this test, it will likely lockup.
38*49cdfc7eSAndroid Build Coastguard Worker */
39*49cdfc7eSAndroid Build Coastguard Worker #include <signal.h>
40*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
41*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
42*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "f00f";
45*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
46*49cdfc7eSAndroid Build Coastguard Worker
47*49cdfc7eSAndroid Build Coastguard Worker #ifdef __i386__
48*49cdfc7eSAndroid Build Coastguard Worker
sigill(int sig)49*49cdfc7eSAndroid Build Coastguard Worker void sigill(int sig)
50*49cdfc7eSAndroid Build Coastguard Worker {
51*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "SIGILL received from f00f instruction. Good.");
52*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
53*49cdfc7eSAndroid Build Coastguard Worker }
54*49cdfc7eSAndroid Build Coastguard Worker
main(void)55*49cdfc7eSAndroid Build Coastguard Worker int main(void)
56*49cdfc7eSAndroid Build Coastguard Worker {
57*49cdfc7eSAndroid Build Coastguard Worker signal(SIGILL, sigill);
58*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TINFO, "Testing for proper f00f instruction handling.");
59*49cdfc7eSAndroid Build Coastguard Worker
60*49cdfc7eSAndroid Build Coastguard Worker /*
61*49cdfc7eSAndroid Build Coastguard Worker * an f00f instruction
62*49cdfc7eSAndroid Build Coastguard Worker */
63*49cdfc7eSAndroid Build Coastguard Worker asm volatile (".byte 0xf0\n"
64*49cdfc7eSAndroid Build Coastguard Worker ".byte 0x0f\n" ".byte 0xc7\n" ".byte 0xc8\n");
65*49cdfc7eSAndroid Build Coastguard Worker
66*49cdfc7eSAndroid Build Coastguard Worker /*
67*49cdfc7eSAndroid Build Coastguard Worker * we shouldn't get here, the f00f instruction should trigger
68*49cdfc7eSAndroid Build Coastguard Worker * a SIGILL or lock the system.
69*49cdfc7eSAndroid Build Coastguard Worker */
70*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TFAIL, NULL,
71*49cdfc7eSAndroid Build Coastguard Worker "f00f instruction did not properly cause SIGILL");
72*49cdfc7eSAndroid Build Coastguard Worker }
73*49cdfc7eSAndroid Build Coastguard Worker
74*49cdfc7eSAndroid Build Coastguard Worker #else /* __i386__ */
75*49cdfc7eSAndroid Build Coastguard Worker
main(void)76*49cdfc7eSAndroid Build Coastguard Worker int main(void)
77*49cdfc7eSAndroid Build Coastguard Worker {
78*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, NULL, "f00f bug test only for i386");
79*49cdfc7eSAndroid Build Coastguard Worker }
80*49cdfc7eSAndroid Build Coastguard Worker
81*49cdfc7eSAndroid Build Coastguard Worker #endif /* __i386__ */
82