diff options
-rw-r--r-- | readme.md | 4 | ||||
-rw-r--r-- | src/fp.cpp | 4 | ||||
-rw-r--r-- | src/fp_generator.hpp | 5 |
3 files changed, 9 insertions, 4 deletions
@@ -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)
@@ -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<const uint64_t*>(getCurr()); for (size_t i = 0; i < op.N; i++) { |