summaryrefslogtreecommitdiff
path: root/src/pal/src/arch
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityam@microsoft.com>2015-07-19 17:24:17 -0700
committerAditya Mandaleeka <adityam@microsoft.com>2015-07-20 17:01:53 -0700
commitcf0fd3269a6bb4846f5f92e7a21e933d7c731f3a (patch)
tree39621850273346af78014c579675d3708eedf7af /src/pal/src/arch
parentbff51f77734b6eca0cf31d823687c167fcfc7d57 (diff)
downloadcoreclr-cf0fd3269a6bb4846f5f92e7a21e933d7c731f3a.tar.gz
coreclr-cf0fd3269a6bb4846f5f92e7a21e933d7c731f3a.tar.bz2
coreclr-cf0fd3269a6bb4846f5f92e7a21e933d7c731f3a.zip
Fix alignment issue when converting to/from native context.
When building in release mode, the code in CONTEXTFromNativeContext and CONTEXTToNativeContext was using the movaps instruction to move the float and XMM register values to/from the native context. This is because the macros FPREG_St and FPREG_Xmm were casting unaligned pointers to an aligned struct type (M128A). This change adds a type M128U which is the same as M128A but without the alignment guarantee. Using this type in those macros prevents the compiler from trying to use movaps on potentially unaligned memory. This bug manifested when trying to call these functions with native contexts that were passed into a real-time signal handler.
Diffstat (limited to 'src/pal/src/arch')
-rw-r--r--src/pal/src/arch/i386/context.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pal/src/arch/i386/context.cpp b/src/pal/src/arch/i386/context.cpp
index d749f874bb..14a96bb9b0 100644
--- a/src/pal/src/arch/i386/context.cpp
+++ b/src/pal/src/arch/i386/context.cpp
@@ -402,13 +402,13 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native)
for (int i = 0; i < 8; i++)
{
- FPREG_St(native, i) = lpContext->FltSave.FloatRegisters[i];
+ FPREG_St(native, i) = ((M128U*)lpContext->FltSave.FloatRegisters)[i];
}
for (int i = 0; i < 16; i++)
{
- FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i];
- }
+ FPREG_Xmm(native, i) = ((M128U*)lpContext->FltSave.XmmRegisters)[i];
+ }
}
}
@@ -459,13 +459,13 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex
for (int i = 0; i < 8; i++)
{
- lpContext->FltSave.FloatRegisters[i] = FPREG_St(native, i);
+ ((M128U*)lpContext->FltSave.FloatRegisters)[i] = FPREG_St(native, i);
}
for (int i = 0; i < 16; i++)
{
- lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i);
- }
+ ((M128U*)lpContext->FltSave.XmmRegisters)[i] = FPREG_Xmm(native, i);
+ }
}
}