xref: /freebsd/sys/vm/memguard.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1c0587701SJoel Dahl /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni  *
4e4eb384bSBosko Milekic  * Copyright (c) 2005,
58076cb52SBosko Milekic  *     Bosko Milekic <bmilekic@FreeBSD.org>.  All rights reserved.
6e4eb384bSBosko Milekic  *
7e4eb384bSBosko Milekic  * Redistribution and use in source and binary forms, with or without
8e4eb384bSBosko Milekic  * modification, are permitted provided that the following conditions
9e4eb384bSBosko Milekic  * are met:
10e4eb384bSBosko Milekic  * 1. Redistributions of source code must retain the above copyright
11e4eb384bSBosko Milekic  *    notice unmodified, this list of conditions, and the following
12e4eb384bSBosko Milekic  *    disclaimer.
13e4eb384bSBosko Milekic  * 2. Redistributions in binary form must reproduce the above copyright
14e4eb384bSBosko Milekic  *    notice, this list of conditions and the following disclaimer in the
15e4eb384bSBosko Milekic  *    documentation and/or other materials provided with the distribution.
16e4eb384bSBosko Milekic  *
17e4eb384bSBosko Milekic  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18e4eb384bSBosko Milekic  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19e4eb384bSBosko Milekic  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20e4eb384bSBosko Milekic  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21e4eb384bSBosko Milekic  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22e4eb384bSBosko Milekic  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23e4eb384bSBosko Milekic  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24e4eb384bSBosko Milekic  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25e4eb384bSBosko Milekic  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26e4eb384bSBosko Milekic  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27e4eb384bSBosko Milekic  */
28e4eb384bSBosko Milekic 
29f02d86e2SMatthew D Fleming #ifndef _VM_MEMGUARD_H_
30f02d86e2SMatthew D Fleming #define	_VM_MEMGUARD_H_
31f02d86e2SMatthew D Fleming 
32e3813573SMatthew D Fleming #include "opt_vm.h"
33d362c40dSPawel Jakub Dawidek 
34f02d86e2SMatthew D Fleming struct malloc_type;
35f02d86e2SMatthew D Fleming struct vm_map;
365df87b21SJeff Roberson struct vmem;
37f02d86e2SMatthew D Fleming 
38e3813573SMatthew D Fleming #ifdef DEBUG_MEMGUARD
39f806cdcfSMatthew D Fleming unsigned long	memguard_fudge(unsigned long, const struct vm_map *);
405df87b21SJeff Roberson void	memguard_init(struct vmem *);
41e3813573SMatthew D Fleming void 	*memguard_alloc(unsigned long, int);
426d3ed393SMatthew D Fleming void	*memguard_realloc(void *, unsigned long, struct malloc_type *, int);
43e3813573SMatthew D Fleming void	memguard_free(void *);
445d4bf057SVladimir Kondratyev unsigned long	memguard_get_req_size(const void *);
458d689e04SGleb Smirnoff int	memguard_cmp_mtp(struct malloc_type *, unsigned long);
468d689e04SGleb Smirnoff int	memguard_cmp_zone(uma_zone_t);
47e3813573SMatthew D Fleming int	is_memguard_addr(void *);
48e3813573SMatthew D Fleming #else
49e3813573SMatthew D Fleming #define	memguard_fudge(size, xxx)	(size)
50e3813573SMatthew D Fleming #define	memguard_init(map)		do { } while (0)
51e3813573SMatthew D Fleming #define	memguard_alloc(size, flags)	NULL
526d3ed393SMatthew D Fleming #define	memguard_realloc(a, s, mtp, f)	NULL
53e3813573SMatthew D Fleming #define	memguard_free(addr)		do { } while (0)
545d4bf057SVladimir Kondratyev #define	memguard_get_req_size(addr)	0
558d689e04SGleb Smirnoff #define	memguard_cmp_mtp(mtp, size)	0
568d689e04SGleb Smirnoff #define	memguard_cmp_zone(zone)		0
57e3813573SMatthew D Fleming #define	is_memguard_addr(addr)		0
58e3813573SMatthew D Fleming #endif
59f02d86e2SMatthew D Fleming 
60f02d86e2SMatthew D Fleming #endif /* _VM_MEMGUARD_H_ */
61