diff --git a/readme.md b/readme.md index 15d8bef..44489d0 100644 --- a/readme.md +++ b/readme.md @@ -403,6 +403,10 @@ This library contains some part of the followings software licensed by BSD-3-Cla * [_Skew Frobenius Map and Efficient Scalar Multiplication for Pairing–Based Cryptography_](https://www.researchgate.net/publication/221282560_Skew_Frobenius_Map_and_Efficient_Scalar_Multiplication_for_Pairing-Based_Cryptography), Y. Sakemi, Y. Nogami, K. Okeya, Y. Morikawa, CANS 2008. +# History + +* 2019/Jan/31 fix crash on x64-CPU without AVX + # Author 光成滋生 MITSUNARI Shigeo(herumi@nifty.com) diff --git a/src/fp.cpp b/src/fp.cpp index 41e98e4..ebd9477 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -318,9 +318,9 @@ static bool initForMont(Op& op, const Unit *p, Mode mode) if (mode != FP_XBYAK) return true; #ifdef MCL_USE_XBYAK if (op.fg == 0) op.fg = Op::createFpGenerator(); - op.fg->init(op); + bool useXbyak = op.fg->init(op); - if (op.isMont && N <= 4) { + if (useXbyak && op.isMont && N <= 4) { op.fp_invOp = &invOpForMontC; initInvTbl(op); } diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp index a018c03..b496bc4 100644 --- a/src/fp_generator.hpp +++ b/src/fp_generator.hpp @@ -307,19 +307,20 @@ struct FpGenerator : Xbyak::CodeGenerator { useMulx_ = cpu_.has(Xbyak::util::Cpu::tBMI2); useAdx_ = cpu_.has(Xbyak::util::Cpu::tADX); } - void init(Op& op) + bool init(Op& op) { + if (!cpu_.has(Xbyak::util::Cpu::tAVX)) return false; reset(); // reset jit code for reuse setProtectModeRW(); // read/write memory init_inner(op); // printf("code size=%d\n", (int)getSize()); setProtectModeRE(); // set read/exec memory + return true; } private: void init_inner(Op& op) { op_ = &op; - if (!cpu_.has(Xbyak::util::Cpu::tAVX)) return; L(pL_); p_ = reinterpret_cast(getCurr()); for (size_t i = 0; i < op.N; i++) {