Optional W^X policy for JIT pages (#112)

This commit is contained in:
tevador
2019-08-25 13:47:40 +02:00
committed by GitHub
parent 971f10c9c2
commit 67010ab554
12 changed files with 195 additions and 55 deletions
+25 -9
View File
@@ -32,23 +32,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace randomx {
template<class Allocator, bool softAes>
void CompiledLightVm<Allocator, softAes>::setCache(randomx_cache* cache) {
template<class Allocator, bool softAes, bool secureJit>
void CompiledLightVm<Allocator, softAes, secureJit>::setCache(randomx_cache* cache) {
cachePtr = cache;
mem.memory = cache->memory;
if (secureJit) {
compiler.enableWriting();
}
compiler.generateSuperscalarHash(cache->programs, cache->reciprocalCache);
if (secureJit) {
compiler.enableExecution();
}
}
template<class Allocator, bool softAes>
void CompiledLightVm<Allocator, softAes>::run(void* seed) {
template<class Allocator, bool softAes, bool secureJit>
void CompiledLightVm<Allocator, softAes, secureJit>::run(void* seed) {
VmBase<Allocator, softAes>::generateProgram(seed);
randomx_vm::initialize();
if (secureJit) {
compiler.enableWriting();
}
compiler.generateProgramLight(program, config, datasetOffset);
CompiledVm<Allocator, softAes>::execute();
if (secureJit) {
compiler.enableExecution();
}
CompiledVm<Allocator, softAes, secureJit>::execute();
}
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, false>;
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, true>;
template class CompiledLightVm<LargePageAllocator, false>;
template class CompiledLightVm<LargePageAllocator, true>;
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, false, false>;
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, true, false>;
template class CompiledLightVm<LargePageAllocator, false, false>;
template class CompiledLightVm<LargePageAllocator, true, false>;
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, false, true>;
template class CompiledLightVm<AlignedAllocator<CacheLineSize>, true, true>;
template class CompiledLightVm<LargePageAllocator, false, true>;
template class CompiledLightVm<LargePageAllocator, true, true>;
}