public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jon TURNEY <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon TURNEY <jon.turney@dronecode.org.uk>
Subject: [PATCH] Try to make sure struct _mcontext is 16-byte aligned
Date: Thu, 02 Apr 2015 16:25:00 -0000	[thread overview]
Message-ID: <1427991886-6156-1-git-send-email-jon.turney@dronecode.org.uk> (raw)

On x86_64, RtlCaptureContext() uses fxsave to save FPU/MMX/SSE state.

fxsave requires that the destination address is 16-byte aligned, or it will
fault.

CONTEXT is already annotated __attribute__ ((aligned (16))), do the same with
struct _mcontext.

Rearrange ucontext_t so that it's struct _mcontext element is also correctly
aligned.

	* include/cygwin/signal.h (struct __mcontext): 16-byte align.
	* include/sys/ucontext.h (ucontext_t): Ditto.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
 winsup/cygwin/ChangeLog               | 5 +++++
 winsup/cygwin/include/cygwin/signal.h | 2 +-
 winsup/cygwin/include/sys/ucontext.h  | 4 ++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9871b96..3b0e111 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-02  Jon TURNEY  <jon.turney@dronecode.org.uk>
+
+	* include/cygwin/signal.h (struct __mcontext): 16-byte align.
+	* include/sys/ucontext.h (ucontext_t): Ditto.
+
 2015-04-02  Corinna Vinschen  <corinna@vinschen.de>
 
 	* sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo.
diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h
index 04e65aa..f2a6fa3 100644
--- a/winsup/cygwin/include/cygwin/signal.h
+++ b/winsup/cygwin/include/cygwin/signal.h
@@ -49,7 +49,7 @@ struct _fpstate
   __uint32_t padding[24];
 };
 
-struct __mcontext
+ __attribute__ ((aligned (16))) struct __mcontext
 {
   __uint64_t p1home;
   __uint64_t p2home;
diff --git a/winsup/cygwin/include/sys/ucontext.h b/winsup/cygwin/include/sys/ucontext.h
index 9362d90..859eb29 100644
--- a/winsup/cygwin/include/sys/ucontext.h
+++ b/winsup/cygwin/include/sys/ucontext.h
@@ -15,11 +15,11 @@ details. */
 
 typedef struct __mcontext mcontext_t;
 
-typedef struct __ucontext {
+typedef  __attribute__ ((aligned (16))) struct __ucontext {
+	mcontext_t	uc_mcontext;
 	struct __ucontext *uc_link;
 	sigset_t	uc_sigmask;
 	stack_t	uc_stack;
-	mcontext_t	uc_mcontext;
 	unsigned long int	uc_flags;
 } ucontext_t;
 
-- 
2.1.4

             reply	other threads:[~2015-04-02 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 16:25 Jon TURNEY [this message]
2015-04-02 17:01 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427991886-6156-1-git-send-email-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).