1*8279d5c6Sskrll /* $NetBSD: exec_prot.h,v 1.2 2022/05/31 07:12:15 skrll Exp $ */ 2ca453df6Sjym 3ca453df6Sjym /*- 4ca453df6Sjym * Copyright (c) 2011 The NetBSD Foundation, Inc. 5ca453df6Sjym * All rights reserved. 6ca453df6Sjym * 7ca453df6Sjym * This code is derived from software contributed to The NetBSD Foundation 8ca453df6Sjym * by Jean-Yves Migeon. 9ca453df6Sjym * 10ca453df6Sjym * Redistribution and use in source and binary forms, with or without 11ca453df6Sjym * modification, are permitted provided that the following conditions 12ca453df6Sjym * are met: 13ca453df6Sjym * 1. Redistributions of source code must retain the above copyright 14ca453df6Sjym * notice, this list of conditions and the following disclaimer. 15ca453df6Sjym * 2. Redistributions in binary form must reproduce the above copyright 16ca453df6Sjym * notice, this list of conditions and the following disclaimer in the 17ca453df6Sjym * documentation and/or other materials provided with the distribution. 18ca453df6Sjym * 19ca453df6Sjym * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20ca453df6Sjym * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21ca453df6Sjym * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22ca453df6Sjym * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23ca453df6Sjym * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24ca453df6Sjym * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25ca453df6Sjym * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26ca453df6Sjym * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27ca453df6Sjym * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28ca453df6Sjym * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29ca453df6Sjym * POSSIBILITY OF SUCH DAMAGE. 30ca453df6Sjym */ 31ca453df6Sjym 32ca453df6Sjym #ifndef _TESTS_EXEC_PROT_H_ 33ca453df6Sjym #define _TESTS_EXEC_PROT_H_ 34ca453df6Sjym 35ca453df6Sjym /* 36ca453df6Sjym * Prototype definitions of external helper functions for executable 37ca453df6Sjym * mapping tests. 38ca453df6Sjym */ 39ca453df6Sjym 40ca453df6Sjym /* 41ca453df6Sjym * Trivial MD shellcode that justs returns 1. 42ca453df6Sjym */ 43*8279d5c6Sskrll #ifdef __hppa__ 44*8279d5c6Sskrll extern char return_one[]; 45*8279d5c6Sskrll extern char return_one_end[]; 46*8279d5c6Sskrll #else 47ca453df6Sjym int return_one(void); /* begin marker -- shellcode entry */ 48ca453df6Sjym int return_one_end(void); /* end marker */ 49*8279d5c6Sskrll #endif 50ca453df6Sjym 51ca453df6Sjym /* 52ca453df6Sjym * MD callback to verify whether host offers executable space protection. 53ca453df6Sjym * Returns execute protection level. 54ca453df6Sjym */ 55ca453df6Sjym int exec_prot_support(void); 56ca453df6Sjym 57ca453df6Sjym /* execute protection level */ 58ca453df6Sjym enum { 59ca453df6Sjym NOTIMPL = -1, /* callback not implemented */ 60ca453df6Sjym NO_XP, /* no execute protection */ 61ca453df6Sjym PERPAGE_XP, /* per-page execute protection */ 62ca453df6Sjym PARTIAL_XP /* partial execute protection. Depending on where the 63ca453df6Sjym page is located in virtual memory, executable space 64ca453df6Sjym protection may be enforced or not. */ 65ca453df6Sjym }; 66ca453df6Sjym #endif 67