abortfixup.c revision 1.6
11.6Sthorpej/* $NetBSD: abortfixup.c,v 1.6 2002/04/09 03:13:18 thorpej Exp $ */ 21.1Sreinoud 31.1Sreinoud/*- 41.1Sreinoud * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Sreinoud * All rights reserved. 61.1Sreinoud * 71.1Sreinoud * Redistribution and use in source and binary forms, with or without 81.1Sreinoud * modification, are permitted provided that the following conditions 91.1Sreinoud * are met: 101.1Sreinoud * 1. Redistributions of source code must retain the above copyright 111.1Sreinoud * notice, this list of conditions and the following disclaimer. 121.1Sreinoud * 2. Redistributions in binary form must reproduce the above copyright 131.1Sreinoud * notice, this list of conditions and the following disclaimer in the 141.1Sreinoud * documentation and/or other materials provided with the distribution. 151.1Sreinoud * 3. All advertising materials mentioning features or use of this software 161.1Sreinoud * must display the following acknowledgement: 171.1Sreinoud * This product includes software developed by the NetBSD 181.1Sreinoud * Foundation, Inc. and its contributors. 191.1Sreinoud * 4. Neither the name of The NetBSD Foundation nor the names of its 201.1Sreinoud * contributors may be used to endorse or promote products derived 211.1Sreinoud * from this software without specific prior written permission. 221.1Sreinoud * 231.1Sreinoud * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 241.1Sreinoud * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 251.1Sreinoud * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 261.1Sreinoud * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 271.1Sreinoud * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Sreinoud * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Sreinoud * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 301.1Sreinoud * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 311.1Sreinoud * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 321.1Sreinoud * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 331.1Sreinoud * POSSIBILITY OF SUCH DAMAGE. 341.1Sreinoud * 351.1Sreinoud * 361.1Sreinoud * Trying out if an unhandled instruction pattern in the late abort fixup 371.1Sreinoud * generates a panic or sysfaults like it ought to do. 381.1Sreinoud */ 391.1Sreinoud 401.1Sreinoud#include <sys/types.h> 411.1Sreinoud 421.6Sthorpej__RCSID("$NetBSD: abortfixup.c,v 1.6 2002/04/09 03:13:18 thorpej Exp $"); 431.1Sreinoud 441.5Sbjh21#include <setjmp.h> 451.1Sreinoud#include <signal.h> 461.1Sreinoud#include <stdio.h> 471.1Sreinoud#include <stdlib.h> 481.1Sreinoud#include <stdio.h> 491.1Sreinoud 501.5Sbjh21jmp_buf buf; 511.5Sbjh21 521.3Sbjh21void 531.3Sbjh21sighandler(int sig) 541.3Sbjh21{ 551.3Sbjh21 561.3Sbjh21 /* Catching SIGSEGV means the test passed. */ 571.5Sbjh21 longjmp(buf, 1); 581.3Sbjh21} 591.3Sbjh21 601.3Sbjh21int 611.3Sbjh21main(void) 621.3Sbjh21{ 631.3Sbjh21 641.3Sbjh21 if (signal(SIGSEGV, sighandler) == SIG_ERR) 651.3Sbjh21 err(1, "signal"); 661.1Sreinoud 671.5Sbjh21 printf("ARM6/7 abort fixup panic\n"); 681.1Sreinoud 691.1Sreinoud /* 701.1Sreinoud * issue an instruction that for certain generates a page 711.1Sreinoud * fault but _can't_ be fixed up by late abort fixup 721.1Sreinoud * routines due to its structure. 731.1Sreinoud */ 741.3Sbjh21 751.5Sbjh21 if (setjmp(buf) == 0) { 761.6Sthorpej __asm __volatile ( 771.6Sthorpej " mov r0, #0 \n" 781.6Sthorpej " mov r1, r0 \n" 791.6Sthorpej " str r1, [r0], r1, ror #10"); 801.5Sbjh21 811.5Sbjh21 /* Should not be reached if OK */ 821.5Sbjh21 printf("!!! Regression test FAILED - no SEGV recieved\n"); 831.5Sbjh21 exit(1); 841.5Sbjh21 } 851.5Sbjh21 861.5Sbjh21 printf("ARM2/3 abort address panic\n"); 871.5Sbjh21 881.5Sbjh21 /* Similar but pre-indexed, to check ARM2/3 abort address function. */ 891.5Sbjh21 901.5Sbjh21 if (setjmp(buf) == 0) { 911.6Sthorpej __asm __volatile ( 921.6Sthorpej " mov r0, #0 \n" 931.6Sthorpej " mov r1, r0 \n" 941.6Sthorpej " str r1, [r0, r1, ror #10]"); 951.5Sbjh21 961.5Sbjh21 /* Should not be reached if OK */ 971.5Sbjh21 printf("!!! Regression test FAILED - no SEGV recieved\n"); 981.5Sbjh21 exit(1); 991.5Sbjh21 } 1001.5Sbjh21 1011.5Sbjh21 printf("All OK\n"); 1021.5Sbjh21 1031.5Sbjh21 exit(0); 1041.1Sreinoud}; 105