diff options
author | Pat Gavlin <pagavlin@microsoft.com> | 2017-07-31 15:38:54 -0700 |
---|---|---|
committer | Pat Gavlin <pagavlin@microsoft.com> | 2017-07-31 15:38:54 -0700 |
commit | a36a86f476d75d6fb0468a1b2b463b884e372aea (patch) | |
tree | 57a016db0c62d3852b3102d9a920b33c8cf6c8c1 /src/jit/codegenlegacy.cpp | |
parent | 8a163ca04ae8734f4a9ee51e470beda933c96333 (diff) | |
download | coreclr-a36a86f476d75d6fb0468a1b2b463b884e372aea.tar.gz coreclr-a36a86f476d75d6fb0468a1b2b463b884e372aea.tar.bz2 coreclr-a36a86f476d75d6fb0468a1b2b463b884e372aea.zip |
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.
Diffstat (limited to 'src/jit/codegenlegacy.cpp')
-rw-r--r-- | src/jit/codegenlegacy.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/jit/codegenlegacy.cpp b/src/jit/codegenlegacy.cpp index 69a74477b0..3a2498fcf9 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 } /***************************************************************************** |