Eli Cooper | 19 Mar 17:58 2016
Picon

[PATCH v3 0/3] um: fix and extend FPU support

This series first fixes a bug that results in corrupted FPU state after
invoking signal handlers. It also adds support for the extended processor
state (XSTATE) for x86_64 UML, especially the YMM registers used by AVX(2)
instructions.

Tested with a minimal multi-threaded FPU-intensive test program (see below).
This series supersedes the previous sigreturn fix as that one is incorrect
when the process is multi-threaded.

Changes since v2:
 - Add an improved sigreturn fix to this series
 - Merge the ptrace changes into the last commit
 - Make the selftest program multi-threaded

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

Eli Cooper (3):
  um: fix FPU state preservation around signal handlers
  um: extend fpstate to _xstate to support YMM registers
  um: add extended processor state save/restore 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 +--
(Continue reading)

Eli Cooper | 16 Mar 09:48 2016
Picon

[PATCH v2 0/3] um: Add support for extended processor state

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 +--
(Continue reading)

Eli Cooper | 16 Mar 02:25 2016
Picon

[PATCH] um: fix FPU register double-restore after sigreturn

This patch prevents userspace() from incorrectly restoring FPU registers
after a sigreturn or rt_sigreturn system call, which has already restored
FPU registers to the state prior to the signal handler was invoked.

Fixes FPU state corruption after invoking the signal handler.

Signed-off-by: Eli Cooper <elicooper <at> gmx.com>
---
 arch/um/os-Linux/skas/process.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 23025d6..664f184 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
 <at>  <at>  -310,6 +310,8  <at>  <at>  void userspace(struct uml_pt_regs *regs)
 	int err, status, op, pid = userspace_pid[0];
 	/* To prevent races if using_sysemu changes under us.*/
 	int local_using_sysemu;
+	/* To prevent FPU register restore after sigreturn syscalls. */
+	int skip_fp_restore = 0;
 	siginfo_t si;

 	/* Handle any immediate reschedules or signals */
 <at>  <at>  -328,8 +330,9  <at>  <at>  void userspace(struct uml_pt_regs *regs)
 		if (ptrace(PTRACE_SETREGS, pid, 0, regs->gp))
 			fatal_sigsegv();

-		if (put_fp_registers(pid, regs->fp))
-			fatal_sigsegv();
(Continue reading)

Eli Cooper | 6 Mar 15:36 2016
Picon

[PATCH 0/3] um: Add support for extended processor state

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.

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/x86/um/os-Linux/registers.c      | 49 +++++++++++++++++++++++++++++++++--
 arch/x86/um/ptrace_32.c               |  4 +--
 arch/x86/um/ptrace_64.c               | 14 +++++-----
 arch/x86/um/shared/sysdep/ptrace_64.h |  4 +--
 arch/x86/um/signal.c                  | 26 +++++++++----------
 arch/x86/um/user-offsets.c            |  2 +-
 8 files changed, 73 insertions(+), 30 deletions(-)

--

-- 
2.7.2

------------------------------------------------------------------------------
Richard Weinberger | 12 Jan 21:36 2016
Picon

[GIT PULL] UML updates for 4.5

Linus,

the following changes since commit 74bf8efb5fa6e958d2d7c7917b8bb672085ec0c6:

  Linux 4.4-rc7 (2015-12-27 18:17:37 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git for-linus-4.5-rc1

for you to fetch changes up to 3e46b25376321db119bc8507ce8c8841c580e736:

  um: Use race-free temporary file creation (2016-01-10 21:49:50 +0100)

----------------------------------------------------------------
Anton Ivanov (3):
      um: Prevent IRQ handler reentrancy
      um: Do not change hard IRQ flags in soft IRQ processing
      um: Update UBD to use pread/pwrite family of functions

Mickaël Salaün (7):
      um: Fix ptrace GETREGS/SETREGS bugs
      selftests/seccomp: Remove the need for HAVE_ARCH_TRACEHOOK
      um: Add full asm/syscall.h support
      um: Add seccomp support
      um: Fix build error and kconfig for i386
      um: Do not set unsecure permission for temporary file
      um: Use race-free temporary file creation

Vegard Nossum (3):
(Continue reading)

Richard Weinberger | 10 Jan 23:37 2016
Picon

Stuff for v4.5

Hi!

I've pushed everything I'd like to see in 4.5 merged.
Please speak up now if I forgot something!

https://git.kernel.org/cgit/linux/kernel/git/rw/uml.git/log/?h=linux-next

--

-- 
Thanks,
//richard

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
Anton Ivanov | 21 Dec 19:54 2015

[PATCH 1/2] Update UBD to use pread/pwrite family of functions

This decreases the number of syscalls per read/write by half.

Signed-off-by: Anton Ivanov <aivanov <at> brocade.com>
---
 arch/um/drivers/ubd_kern.c  | 27 +++++----------------------
 arch/um/include/shared/os.h |  2 ++
 arch/um/os-Linux/file.c     | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index e8ab93c..39ba207 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
 <at>  <at>  -535,11 +535,7  <at>  <at>  static int read_cow_bitmap(int fd, void *buf, int offset, int len)
 {
 	int err;

-	err = os_seek_file(fd, offset);
-	if (err < 0)
-		return err;
-
-	err = os_read_file(fd, buf, len);
+	err = os_pread_file(fd, buf, len, offset);
 	if (err < 0)
 		return err;

 <at>  <at>  -1377,14 +1373,8  <at>  <at>  static int update_bitmap(struct io_thread_req *req)
 	if(req->cow_offset == -1)
 		return 0;

(Continue reading)

Anton Ivanov | 21 Dec 12:28 2015

[PATCH 1/2] Prevent IRQ handler reentrancy

The existing IRQ handler design in UML does not prevent reentrancy

This is mitigated by fd-enable/fd-disable semantics for the IO
portion of the UML subsystem. The timer, however, can and is
re-entered resulting in very deep stack usage and occasional
stack exhaustion.

This patch prevents this by checking if there is a timer
interrupt in-flight before processing any pending timer interrupts.

Signed-off-by: Anton Ivanov <aivanov <at> brocade.com>
---
 arch/um/os-Linux/signal.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index c211153..7801666 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
 <at>  <at>  -62,6 +62,7  <at>  <at>  static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)

 static int signals_enabled;
 static unsigned int signals_pending;
+static unsigned int signals_active = 0;

 void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
 {
 <at>  <at>  -101,7 +102,12  <at>  <at>  void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)

 	block_signals();
(Continue reading)

Vegard Nossum | 6 Dec 16:34 2015
Picon

uml instance crashes when started from script

Hi,

I've been running into some odd crashes when starting my UML instance 
from Python. This is my script:

import subprocess
subprocess.check_call(['path/to/vmlinux', 'mem=2048M', 
'rootfstype=hostfs', 'rw', 'init=/bin/bash'])

This will crash 9 out of 10 times with various strange messages on the 
console:

[    1.890000] devtmpfs: mounted
[    1.960000] mount (947) used greatest stack depth: 5592 bytes left
[    1.990000] mount (948) used greatest stack depth: 5496 bytes left
#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#��+J <at> ��o��#7%����2Z����.�j
o
��h� -^(�l0�w8�\ <at> �}P�)o`o-�p)CS�-!���8��,��Ҋ8�>)DV9 � 
�9�����$��#�#�#�#[    6.870000]
[    6.870000] Pid: 1, comm: init Not tainted 4.4.0-rc3
[    6.870000] RIP: 0033:[<00000000018d4848>]
[    6.870000] RSP: 00000000dff3efa8  EFLAGS: 00010216
[    6.870000] RAX: 0000000000000001 RBX: 00000000600748c0 RCX: 
00007fb9d87dacd8
[    6.870000] RDX: ffffffffffffffff RSI: 0000000000000001 RDI: 
00000000dfeba3c8
[    6.870000] RBP: 00000000dff3efe8 R08: 00000000dff3ee38 R09: 
0000000000001382
[    6.870000] R10: 0000000000000000 R11: 0000000000000246 R12: 
00000000dff3e000
(Continue reading)

Richard Weinberger | 29 Nov 21:13 2015
Picon

[PATCH] um: Fix fpstate handling

The x86 FPU cleanup changed fpstate to a plain integer.
UML on x86 has to deal with that too.

Signed-off-by: Richard Weinberger <richard <at> nod.at>

diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index 06934a8..e5f854c 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
 <at>  <at>  -211,7 +211,7  <at>  <at>  static int copy_sc_from_user(struct pt_regs *regs,
 		if (err)
 			return 1;

-		err = convert_fxsr_from_user(&fpx, sc.fpstate);
+		err = convert_fxsr_from_user(&fpx, (void *)sc.fpstate);
 		if (err)
 			return 1;

 <at>  <at>  -227,7 +227,7  <at>  <at>  static int copy_sc_from_user(struct pt_regs *regs,
 	{
 		struct user_i387_struct fp;

-		err = copy_from_user(&fp, sc.fpstate,
+		err = copy_from_user(&fp, (void *)sc.fpstate,
 				     sizeof(struct user_i387_struct));
 		if (err)
 			return 1;
 <at>  <at>  -291,7 +291,7  <at>  <at>  static int copy_sc_to_user(struct sigcontext __user *to,
 #endif
 #undef PUTREG
(Continue reading)

Anton Ivanov | 26 Nov 10:49 2015
Picon

Old process in D state bug

Hi List, hi Richard,

While working on the EPOLL I managed to consistently reproduce and get 
down to the bottom of the process in D state bug which you occasionally 
see with UML. I recall asking Richard's help on this for the first time 
nearly 5 years ago ;-).

It is extremely rare with the POLL based controller, timers and the 
stock UBD drivers. As you make things go faster (anywhere in UML) it 
rares its ugly head. So improving the IRQs, improving UBD itself, etc - 
all make it easier to trigger.

It looks like it is possible to end up in a state where the restart list 
is not empty (an earlier transaction to the disk io thread failed with 
EAGAIN), but with no pending IO on the UBD IPC thread fd. So the restart 
list is never re-triggered and the UBD device ends up with a non-empty 
queue. The process that requested the IO ends up in D state. Any other 
processes trying IO to the same disk join it. As the requests to the 
same UBD queue up, ultimately, UML goes belly up.

Pinging the UML process with SIGIO does not help as there is no IO 
pending on the fd. So it is not a lost interrupt. It somehow manages to 
race forming the restart queue.

If, however, you have more than one UBD device IO to the other one 
unstucks it by re-running the restart queue out of the ubd interrupt 
handler.

Once again - this is extremely rare at present, but possible (I have 
seen it a few times over the last 5 years).
(Continue reading)


Gmane