1*0fca6ea1SDimitry Andric//===-- allocator_config.def ------------------------------------*- C++ -*-===// 2*0fca6ea1SDimitry Andric// 3*0fca6ea1SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0fca6ea1SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*0fca6ea1SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0fca6ea1SDimitry Andric// 7*0fca6ea1SDimitry Andric//===----------------------------------------------------------------------===// 8*0fca6ea1SDimitry Andric// 9*0fca6ea1SDimitry Andric// This file defines all the flags and types supported in Scudo. For optional 10*0fca6ea1SDimitry Andric// flags and types, only explicitly define them when interested (i.e., unused 11*0fca6ea1SDimitry Andric// optional flags or types can be skipped). 12*0fca6ea1SDimitry Andric 13*0fca6ea1SDimitry Andric#ifndef BASE_REQUIRED_TEMPLATE_TYPE 14*0fca6ea1SDimitry Andric#define BASE_REQUIRED_TEMPLATE_TYPE(...) 15*0fca6ea1SDimitry Andric#endif 16*0fca6ea1SDimitry Andric#ifndef BASE_OPTIONAL 17*0fca6ea1SDimitry Andric#define BASE_OPTIONAL(...) 18*0fca6ea1SDimitry Andric#endif 19*0fca6ea1SDimitry Andric#ifndef PRIMARY_REQUIRED_TYPE 20*0fca6ea1SDimitry Andric#define PRIMARY_REQUIRED_TYPE(...) 21*0fca6ea1SDimitry Andric#endif 22*0fca6ea1SDimitry Andric#ifndef PRIMARY_REQUIRED 23*0fca6ea1SDimitry Andric#define PRIMARY_REQUIRED(...) 24*0fca6ea1SDimitry Andric#endif 25*0fca6ea1SDimitry Andric#ifndef PRIMARY_OPTIONAL 26*0fca6ea1SDimitry Andric#define PRIMARY_OPTIONAL(...) 27*0fca6ea1SDimitry Andric#endif 28*0fca6ea1SDimitry Andric#ifndef PRIMARY_OPTIONAL_TYPE 29*0fca6ea1SDimitry Andric#define PRIMARY_OPTIONAL_TYPE(...) 30*0fca6ea1SDimitry Andric#endif 31*0fca6ea1SDimitry Andric#ifndef SECONDARY_REQUIRED_TEMPLATE_TYPE 32*0fca6ea1SDimitry Andric#define SECONDARY_REQUIRED_TEMPLATE_TYPE(...) 33*0fca6ea1SDimitry Andric#endif 34*0fca6ea1SDimitry Andric#ifndef SECONDARY_CACHE_OPTIONAL 35*0fca6ea1SDimitry Andric#define SECONDARY_CACHE_OPTIONAL(...) 36*0fca6ea1SDimitry Andric#endif 37*0fca6ea1SDimitry Andric 38*0fca6ea1SDimitry Andric// BASE_REQUIRED_TEMPLATE_TYPE(NAME) 39*0fca6ea1SDimitry Andric// 40*0fca6ea1SDimitry Andric// Thread-Specific Data Registry used, shared or exclusive. 41*0fca6ea1SDimitry AndricBASE_REQUIRED_TEMPLATE_TYPE(TSDRegistryT) 42*0fca6ea1SDimitry Andric 43*0fca6ea1SDimitry Andric// Defines the type of Primary allocator to use. 44*0fca6ea1SDimitry AndricBASE_REQUIRED_TEMPLATE_TYPE(PrimaryT) 45*0fca6ea1SDimitry Andric 46*0fca6ea1SDimitry Andric// Defines the type of Secondary allocator to use. 47*0fca6ea1SDimitry AndricBASE_REQUIRED_TEMPLATE_TYPE(SecondaryT) 48*0fca6ea1SDimitry Andric 49*0fca6ea1SDimitry Andric// BASE_OPTIONAL(TYPE, NAME, DEFAULT) 50*0fca6ea1SDimitry Andric// 51*0fca6ea1SDimitry Andric// Indicates possible support for Memory Tagging. 52*0fca6ea1SDimitry AndricBASE_OPTIONAL(const bool, MaySupportMemoryTagging, false) 53*0fca6ea1SDimitry Andric 54*0fca6ea1SDimitry Andric// PRIMARY_REQUIRED_TYPE(NAME) 55*0fca6ea1SDimitry Andric// 56*0fca6ea1SDimitry Andric// SizeClassMap to use with the Primary. 57*0fca6ea1SDimitry AndricPRIMARY_REQUIRED_TYPE(SizeClassMap) 58*0fca6ea1SDimitry Andric 59*0fca6ea1SDimitry Andric// PRIMARY_REQUIRED(TYPE, NAME) 60*0fca6ea1SDimitry Andric// 61*0fca6ea1SDimitry Andric// Log2 of the size of a size class region, as used by the Primary. 62*0fca6ea1SDimitry AndricPRIMARY_REQUIRED(const uptr, RegionSizeLog) 63*0fca6ea1SDimitry Andric 64*0fca6ea1SDimitry Andric// Conceptually, a region will be divided into groups based on the address 65*0fca6ea1SDimitry Andric// range. Each allocation consumes blocks in the same group until exhaustion 66*0fca6ea1SDimitry Andric// then it pops out blocks in a new group. Therefore, `GroupSizeLog` is always 67*0fca6ea1SDimitry Andric// smaller or equal to `RegionSizeLog`. Note that `GroupSizeLog` needs to be 68*0fca6ea1SDimitry Andric// equal to `RegionSizeLog` for SizeClassAllocator32 because of certain 69*0fca6ea1SDimitry Andric// constraints. 70*0fca6ea1SDimitry AndricPRIMARY_REQUIRED(const uptr, GroupSizeLog) 71*0fca6ea1SDimitry Andric 72*0fca6ea1SDimitry Andric// Call map for user memory with at least this size. Only used with primary64. 73*0fca6ea1SDimitry AndricPRIMARY_REQUIRED(const uptr, MapSizeIncrement) 74*0fca6ea1SDimitry Andric 75*0fca6ea1SDimitry Andric// Defines the minimal & maximal release interval that can be set. 76*0fca6ea1SDimitry AndricPRIMARY_REQUIRED(const s32, MinReleaseToOsIntervalMs) 77*0fca6ea1SDimitry AndricPRIMARY_REQUIRED(const s32, MaxReleaseToOsIntervalMs) 78*0fca6ea1SDimitry Andric 79*0fca6ea1SDimitry Andric// PRIMARY_OPTIONAL(TYPE, NAME, DEFAULT) 80*0fca6ea1SDimitry Andric// 81*0fca6ea1SDimitry Andric// The scale of a compact pointer. E.g., Ptr = Base + (CompactPtr << Scale). 82*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL(const uptr, CompactPtrScale, SCUDO_MIN_ALIGNMENT_LOG) 83*0fca6ea1SDimitry Andric 84*0fca6ea1SDimitry Andric// Indicates support for offsetting the start of a region by a random number of 85*0fca6ea1SDimitry Andric// pages. This is only used if `EnableContiguousRegions` is enabled. 86*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL(const bool, EnableRandomOffset, false) 87*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL(const s32, DefaultReleaseToOsIntervalMs, INT32_MIN) 88*0fca6ea1SDimitry Andric 89*0fca6ea1SDimitry Andric// When `EnableContiguousRegions` is true, all regions will be be arranged in 90*0fca6ea1SDimitry Andric// adjacency. This will reduce the fragmentation caused by region allocations 91*0fca6ea1SDimitry Andric// but may require a huge amount of contiguous pages at initialization. 92*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL(const bool, EnableContiguousRegions, true) 93*0fca6ea1SDimitry Andric 94*0fca6ea1SDimitry Andric// PRIMARY_OPTIONAL_TYPE(NAME, DEFAULT) 95*0fca6ea1SDimitry Andric// 96*0fca6ea1SDimitry Andric// Use condition variable to shorten the waiting time of refillment of 97*0fca6ea1SDimitry Andric// freelist. Note that this depends on the implementation of condition 98*0fca6ea1SDimitry Andric// variable on each platform and the performance may vary so that it does not 99*0fca6ea1SDimitry Andric// guarantee a performance benefit. 100*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL_TYPE(ConditionVariableT, ConditionVariableDummy) 101*0fca6ea1SDimitry Andric 102*0fca6ea1SDimitry Andric// Defines the type and scale of a compact pointer. A compact pointer can 103*0fca6ea1SDimitry Andric// be understood as the offset of a pointer within the region it belongs 104*0fca6ea1SDimitry Andric// to, in increments of a power-of-2 scale. See `CompactPtrScale` also. 105*0fca6ea1SDimitry AndricPRIMARY_OPTIONAL_TYPE(CompactPtrT, uptr) 106*0fca6ea1SDimitry Andric 107*0fca6ea1SDimitry Andric// SECONDARY_REQUIRED_TEMPLATE_TYPE(NAME) 108*0fca6ea1SDimitry Andric// 109*0fca6ea1SDimitry Andric// Defines the type of Secondary Cache to use. 110*0fca6ea1SDimitry AndricSECONDARY_REQUIRED_TEMPLATE_TYPE(CacheT) 111*0fca6ea1SDimitry Andric 112*0fca6ea1SDimitry Andric// SECONDARY_CACHE_OPTIONAL(TYPE, NAME, DEFAULT) 113*0fca6ea1SDimitry Andric// 114*0fca6ea1SDimitry Andric// Defines the type of cache used by the Secondary. Some additional 115*0fca6ea1SDimitry Andric// configuration entries can be necessary depending on the Cache. 116*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const u32, EntriesArraySize, 0) 117*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const u32, QuarantineSize, 0) 118*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntriesCount, 0) 119*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const uptr, DefaultMaxEntrySize, 0) 120*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const s32, MinReleaseToOsIntervalMs, INT32_MIN) 121*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const s32, MaxReleaseToOsIntervalMs, INT32_MAX) 122*0fca6ea1SDimitry AndricSECONDARY_CACHE_OPTIONAL(const s32, DefaultReleaseToOsIntervalMs, INT32_MIN) 123*0fca6ea1SDimitry Andric 124*0fca6ea1SDimitry Andric#undef SECONDARY_CACHE_OPTIONAL 125*0fca6ea1SDimitry Andric#undef SECONDARY_REQUIRED_TEMPLATE_TYPE 126*0fca6ea1SDimitry Andric#undef PRIMARY_OPTIONAL_TYPE 127*0fca6ea1SDimitry Andric#undef PRIMARY_OPTIONAL 128*0fca6ea1SDimitry Andric#undef PRIMARY_REQUIRED 129*0fca6ea1SDimitry Andric#undef PRIMARY_REQUIRED_TYPE 130*0fca6ea1SDimitry Andric#undef BASE_OPTIONAL 131*0fca6ea1SDimitry Andric#undef BASE_REQUIRED_TEMPLATE_TYPE 132