mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Safonov <dsafonov@virtuozzo.com>
To: <linux-kernel@vger.kernel.org>
Cc: <luto@amacapital.net>, <tglx@linutronix.de>, <mingo@redhat.com>,
	<hpa@zytor.com>, <x86@kernel.org>, <shuahkh@osg.samsung.com>,
	<bp@alien8.de>, <akpm@linux-foundation.org>,
	<linux-kselftest@vger.kernel.org>, <gorcunov@openvz.org>,
	<xemul@virtuozzo.com>, <khorenko@virtuozzo.com>,
	<0x7f454c46@gmail.com>, Dmitry Safonov <dsafonov@virtuozzo.com>
Subject: [PATCH 0/2] x86: add arch_prctl to switch between native/compat modes
Date: Wed, 6 Apr 2016 19:29:28 +0300	[thread overview]
Message-ID: <1459960170-4454-1-git-send-email-dsafonov@virtuozzo.com> (raw)

With those patches it becomes possible to tell the kernel in which mode
current task is.
I need it for compatibility process C/R:
restorer is native x86_64 process, that maps vmas, restore task parameters,
does clone to add threads and so on. To restore 32-bit application, that
runs on x86_64 (in compatibility mode), I need to set proper CS selector
for USER32_CS and tell the kernel, that the process is now in compat mode.
Switching selector isn't a hard task (and it's done in other selftests
with long jump/lret).
This patch makes possible to tell Linux kernel in which mode you are.

I also did vdso/vvar blob remapping on compat <-> native switch.
This part isn't really needed by CRIU, as on restore stage we already
have dumped vdso/vvar vma images.
So, this part is for other processes that may need to switch their mode.
(I will drop this part if no one else needs this possibility).

I add a selftest and I did CRIU branch that uses this to C/R 32-bit processes:
https://github.com/0x7f454c46/criu/tree/compat-2
There are dozens of patches there and I will prepare them for CRIU master
branch after mainstreaming this switching patch.

Dmitry Safonov (2):
  x86/arch_prctl: add ARCH_SET_{COMPAT,NATIVE} to change compatible mode
  x86/tools/testing: add test for ARCH_SET_COMPAT

 arch/x86/entry/vdso/vma.c                          |  76 ++++--
 arch/x86/include/asm/vdso.h                        |   5 +
 arch/x86/include/uapi/asm/prctl.h                  |   6 +
 arch/x86/kernel/process_64.c                       |  87 ++++++
 tools/testing/selftests/x86/Makefile               |   1 +
 .../testing/selftests/x86/arch_prctl_set_compat.c  | 295 +++++++++++++++++++++
 6 files changed, 453 insertions(+), 17 deletions(-)
 create mode 100644 tools/testing/selftests/x86/arch_prctl_set_compat.c

-- 
2.7.4

             reply	other threads:[~2016-04-06 16:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-06 16:29 Dmitry Safonov [this message]
2016-04-06 16:29 ` [PATCH 1/2] x86/arch_prctl: add ARCH_SET_{COMPAT,NATIVE} to change compatible mode Dmitry Safonov
2016-04-06 18:04   ` Andy Lutomirski
2016-04-06 18:49     ` Andy Lutomirski
2016-04-07 12:11     ` Dmitry Safonov
2016-04-07 12:21       ` Cyrill Gorcunov
2016-04-07 12:35         ` Dmitry Safonov
2016-04-07 14:39       ` Andy Lutomirski
2016-04-07 15:18         ` Dmitry Safonov
2016-04-08 13:50         ` Dmitry Safonov
2016-04-08 15:56           ` Andy Lutomirski
2016-04-08 16:18             ` Dmitry Safonov
2016-04-08 20:44               ` Andy Lutomirski
2016-04-09  8:06                 ` Dmitry Safonov
2016-04-13 16:55                 ` Dmitry Safonov
2016-04-14 18:27                   ` Andy Lutomirski
2016-04-20 11:04                     ` Peter Zijlstra
2016-04-20 15:40                       ` Andy Lutomirski
2016-04-20 19:05                         ` Peter Zijlstra
2016-04-21 19:39                           ` Andy Lutomirski
2016-04-21 20:12                             ` Peter Zijlstra
2016-04-21 23:27                               ` Andy Lutomirski
2016-04-21 23:46                                 ` Andy Lutomirski
2016-04-25 15:16                                 ` Peter Zijlstra
2016-04-25 16:50                                   ` Andy Lutomirski
2016-04-06 16:29 ` [PATCH 2/2] x86/tools/testing: add test for ARCH_SET_COMPAT Dmitry Safonov

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=1459960170-4454-1-git-send-email-dsafonov@virtuozzo.com \
    --to=dsafonov@virtuozzo.com \
    --cc=0x7f454c46@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=gorcunov@openvz.org \
    --cc=hpa@zytor.com \
    --cc=khorenko@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=shuahkh@osg.samsung.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xemul@virtuozzo.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

Powered by JetHome