From: Pat Gavlin Date: Mon, 31 Jul 2017 22:38:54 +0000 (-0700) Subject: Lock all ABI arg registers when generating a GS check on ARM/Legacy. X-Git-Tag: accepted/tizen/base/20180629.140029~1083^2~26^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a36a86f476d75d6fb0468a1b2b463b884e372aea;p=platform%2Fupstream%2Fcoreclr.git Lock all ABI arg registers when generating a GS check on ARM/Legacy. These registers may otherwise be overwritten by code that is generated between the JMP/tail call and the epilog (e.g. GS cookie checks). Fixes #12919. --- diff --git a/src/jit/codegenlegacy.cpp b/src/jit/codegenlegacy.cpp index 69a7447..3a2498f 100644 --- a/src/jit/codegenlegacy.cpp +++ b/src/jit/codegenlegacy.cpp @@ -2840,8 +2840,6 @@ GenTreePtr CodeGen::genMakeAddrOrFPstk(GenTreePtr tree, regMaskTP* regMaskPtr, b * Generate code to check that the GS cookie wasn't thrashed by a buffer * overrun. If pushReg is true, preserve all registers around code sequence. * Otherwise, ECX maybe modified. - * - * TODO-ARM-Bug?: pushReg is not implemented (is it needed for ARM?) */ void CodeGen::genEmitGSCookieCheck(bool pushReg) { @@ -2857,13 +2855,20 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg) noway_assert(compiler->gsGlobalSecurityCookieAddr || compiler->gsGlobalSecurityCookieVal); +#if CPU_LOAD_STORE_ARCH + // Lock all ABI argument registers before generating the check. All other registers should be dead, so this + // shouldn't over-constrain us. + const regMaskTP unlockedArgRegs = RBM_ARG_REGS & ~regSet.rsMaskLock; + regMaskTP usedArgRegs; + regSet.rsLockReg(unlockedArgRegs, &usedArgRegs); +#endif + if (compiler->gsGlobalSecurityCookieAddr == NULL) { // JIT case CLANG_FORMAT_COMMENT_ANCHOR; #if CPU_LOAD_STORE_ARCH - regNumber reg = regSet.rsGrabReg(RBM_ALLINT); getEmitter()->emitIns_R_S(ins_Load(TYP_INT), EA_4BYTE, reg, compiler->lvaGSSecurityCookie, 0); regTracker.rsTrackRegTrash(reg); @@ -2941,6 +2946,11 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg) genDefineTempLabel(gsCheckBlk); genPopRegs(pushedRegs, byrefPushedRegs, norefPushedRegs); + +#if CPU_LOAD_STORE_ARCH + // Unlock all ABI argument registers. + regSet.rsUnlockReg(unlockedArgRegs, usedArgRegs); +#endif } /*****************************************************************************