linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Eli Cooper <elicooper@gmx.com>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Richard Weinberger <richard@nod.at>, Jeff Dike <jdike@addtoit.com>
Subject: [uml-devel] [PATCH v2 0/3] um: Add support for extended processor state
Date: Wed, 16 Mar 2016 16:48:26 +0800	[thread overview]
Message-ID: <1458118109-3178-1-git-send-email-elicooper@gmx.com> (raw)

This series adds support for the extended processor state (XSTATE) for
x86_64 UML, especially the YMM registers used by AVX/AVX2 instructions.

Modern userspace programs built with AVX can now run inside x86_64 UML
without YMM registers getting corrupted.

Tested with a tiny selftest program below, which of course requires the
following patch I sent earlier today to run correctly.
  um: fix FPU register double-restore after sigreturn

Also tested with a latest Arch Linux image on a CPU with AVX2 support.
Without YMM support in UML, a lot of programs crash unexpectedly,
or result in bad results (e.g., calculating SHA256 in OpenSSL).


Changes since v1:
 - Refactor functions with oversized stack frame
 - Add a tiny selftest program to the cover letter

Eli Cooper (3):
  um: extend _fpstate to _xstate
  um: add extended processor state save/restore support
  um: fix ptrace PTRACE_GETFPREGS and PTRACE_SETFPREG support

 arch/um/include/shared/registers.h    |  2 ++
 arch/um/kernel/process.c              |  2 +-
 arch/um/os-Linux/signal.c             | 28 ++++++++++++-----
 arch/x86/um/os-Linux/registers.c      | 49 ++++++++++++++++++++++++++++--
 arch/x86/um/ptrace_32.c               |  5 +--
 arch/x86/um/ptrace_64.c               | 16 +++++-----
 arch/x86/um/shared/sysdep/ptrace_64.h |  4 +--
 arch/x86/um/signal.c                  | 57 +++++++++++++++++++++++------------
 arch/x86/um/user-offsets.c            |  2 +-
 9 files changed, 121 insertions(+), 44 deletions(-)

---
/* test if context switches preserve YMM registers, should exit with code 0 */
#include <stdint.h>
#include <unistd.h>
#include <signal.h>
#include <immintrin.h>

int flag;
void sighandler(int signum)
{
	if (flag)
		exit(0);
	alarm(1);
	flag = 1;
	__m256i m0 = _mm256_set_epi64x(0, 0, 0, 0);
}

int main()
{
	register uint32_t a asm("eax") = 0;
	signal(SIGALRM, sighandler);
	alarm(1);

	__m256i m0 = _mm256_set_epi64x(1L << 32, 0, 0, 0);
	do {
		asm("vextracti128 $1,%ymm0,%xmm1");
		asm("vpextrd $3,%xmm1,%eax");
	} while (a == 1);

	return 1;
}


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


             reply	other threads:[~2016-03-16  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16  8:48 Eli Cooper [this message]
2016-03-16  8:48 ` [uml-devel] [PATCH v2 1/3] um: extend _fpstate to _xstate Eli Cooper
2016-03-16  8:48 ` [uml-devel] [PATCH v2 2/3] um: add extended processor state save/restore support Eli Cooper
2016-03-16  8:48 ` [uml-devel] [PATCH v2 3/3] um: fix ptrace PTRACE_GETFPREGS and PTRACE_SETFPREG support Eli Cooper

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=1458118109-3178-1-git-send-email-elicooper@gmx.com \
    --to=elicooper@gmx.com \
    --cc=jdike@addtoit.com \
    --cc=richard@nod.at \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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 NNTP newsgroup(s).