abortfixup.c revision 1.3
11.3Sbjh21/* $NetBSD: abortfixup.c,v 1.3 2002/03/17 12:25:11 bjh21 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.3Sbjh21__RCSID("$NetBSD: abortfixup.c,v 1.3 2002/03/17 12:25:11 bjh21 Exp $");
431.1Sreinoud
441.1Sreinoud#include <signal.h>
451.1Sreinoud#include <stdio.h>
461.1Sreinoud#include <stdlib.h>
471.1Sreinoud#include <stdio.h>
481.1Sreinoud
491.3Sbjh21void
501.3Sbjh21sighandler(int sig)
511.3Sbjh21{
521.3Sbjh21
531.3Sbjh21	/* Catching SIGSEGV means the test passed. */
541.3Sbjh21	exit(0);
551.3Sbjh21}
561.3Sbjh21
571.3Sbjh21int
581.3Sbjh21main(void)
591.3Sbjh21{
601.3Sbjh21
611.3Sbjh21	if (signal(SIGSEGV, sighandler) == SIG_ERR)
621.3Sbjh21		err(1, "signal");
631.1Sreinoud
641.1Sreinoud	printf("ARM 6/7 abort fixup panic regression test\n");
651.3Sbjh21	printf("    It should not panic!\n");
661.1Sreinoud
671.1Sreinoud	/*
681.1Sreinoud 	 * issue an instruction that for certain generates a page
691.1Sreinoud	 * fault but _can't_ be fixed up by late abort fixup
701.1Sreinoud	 * routines due to its structure.
711.1Sreinoud	 */
721.3Sbjh21
731.1Sreinoud	__asm __volatile ("
741.1Sreinoud		mvn r0, #0
751.1Sreinoud		mov r1, r0
761.2Sbjh21		str r1, [r0], r1, ror #10
771.1Sreinoud	");
781.1Sreinoud
791.1Sreinoud	/* Should not be reached if OK */
801.1Sreinoud	printf("!!! Regression test FAILED - no SEGV recieved\n");
811.1Sreinoud	return 1;
821.1Sreinoud};
831.1Sreinoud
84