Thomas Meyer | 14 Sep 12:42 2014

[PATCH] um: Register UML with systemd-machined

Call machined's "CreateMachine" to create a scope unit for the
current uml instance.

Signed-off-by: Thomas Meyer <thomas <at>>
 arch/um/Makefile            |  4 +-
 arch/um/include/shared/os.h |  1 +
 arch/um/os-Linux/Makefile   |  6 ++-
 arch/um/os-Linux/machined.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
 arch/um/os-Linux/umid.c     | 69 +++++++++++++++++++----------------
 5 files changed, 135 insertions(+), 34 deletions(-)
 create mode 100644 arch/um/os-Linux/machined.c

diff --git a/arch/um/Makefile b/arch/um/Makefile
index e4b1a96..e9e3dee 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
 <at>  <at>  -132,8 +132,10  <at>  <at>  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc

 LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))

+LINK_DBUS = $(shell pkg-config --libs dbus-1)
 # Used by which has special support for um link
-export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
+export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(LINK_DBUS)

 # When cleaning we don't include .config, so we don't include
 # TT or skas makefiles and don't clean skas_ptregs.h.
(Continue reading)

Thomas Meyer | 13 Sep 16:03 2014

[PATCH] um: register with systemd-machined


This patch registers an UML instance with systemd-machined.
You may need to modify the dbus policy to allow this request
in /etc/dbus-1/system.d/org.freedesktop.machine1.conf

Attached patch crashes the UML kernel, but I've know idea why!
Help is appreciated and feedback is welcome!

diff --git a/arch/um/Makefile b/arch/um/Makefile
index e4b1a96..e9e3dee 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
 <at>  <at>  -132,8 +132,10  <at>  <at>  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc

 LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))

+LINK_DBUS = $(shell pkg-config --libs dbus-1)
 # Used by which has special support for um link
-export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
+export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(LINK_DBUS)

 # When cleaning we don't include .config, so we don't include
 # TT or skas makefiles and don't clean skas_ptregs.h.
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 08eec0b..13f8f10 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
 <at>  <at>  -217,6 +217,7  <at>  <at>  extern int helper_wait(int pid);
(Continue reading)

Toralf Förster | 5 Sep 17:27 2014

fuzz tested UML hangs while using NFS files as victim files - UML issue or NFS issue ?

Within a 32 bit stable Gentoo user mode linux guest system I do experience sometimes that trinity don't exit
after it completed the maximum number of jobs.
This might be either an UML, a trinity or a NFS issue (I use NFS victims files). Now I'm wondering where do
report it ? (Or is it a trinity issue ?)

UML guest kernel is v3.17-rc3-94-gb7fece1, host is 3.16.1.

The trinity log gives :
child0:4020] <timed out>
[child0:4020] <timed out>
[main] Bailing main loop because Completed maximum number of operations..
[watchdog] [3628] Watchdog exiting because Completed maximum number of operations..

Within the UML guest I do see this :

trinity ~ # ps -ef | grep trinity
tfoerste  3415  3414  0 16:33 ?        00:00:12 bash -c logger "1#-1, M=/mnt/nfsv3"; cd ~; sudo su -c 'if [[ -d ./t3 ]];
then sudo chmod -R a+rwx ./t3; sudo rm -rf ./t3; fi'; mkdir ./t3; cd ./t3; if [[ -n /mnt/nfsv3 ]]; then if [[ -d
/mnt/nfsv3/victims/v1 ]]; then sudo chmod -R a+rwx /mnt/nfsv3/victims/v1; sudo rm -rf
/mnt/nfsv3/victims/v1 || exit; fi; mkdir -p /mnt/nfsv3/victims/v1/v2; for i in $(seq -w 0 99); do touch
/mnt/nfsv3/victims/v1/v2/f$i; mkdir /mnt/nfsv3/victims/v1/v2/d$i; done; fi; MALLOC_CHECK_=2
trinity -C 2 -N 100000 -q -x mremap -V /mnt/nfsv3/victims/v1/v2
tfoerste  3627  3415  0 16:33 ?        00:00:00 trinity -C 2 -N 100000 -q -x mremap -V /mnt/nfsv3/victims/v1/v2
tfoerste  3628  3627  0 16:33 ?        00:00:04 [trinity-watchdo] <defunct>
tfoerste  3629  3627 36 16:33 ?        00:15:12 [trinity-main]
root      4083  4077  0 17:15 pts/0    00:00:00 grep --colour=auto trinity

trinity ~ # cat /proc/3629/stack                                                                                                                       
[<0805f8b4>] __switch_to+0x44/0x70                                                                                                                     
(Continue reading)

anton.ivanov | 4 Sep 21:00 2014

UML Performance improvement patchset

Patch dependencies:

[PATCH v3 01/10] Epoll based interrupt controller

Full redesign of the existing UML poll based controller. The old
poll controller incurs huge penalties for IRQ sharing and many devices
setup due to the device list being walked twice.

Additionally, the current controller has no notion of true Edge, 
Level and Write completion IRQs. 

This patch fixes the list walking bottleneck and adds all of 
the above alowing for UML to be scaled to 100s of devices 
(tested with 512+ network devices).

[PATCH v3 02/10] Remove unnecessary 'reactivate' statements

As a result of adding true Edge/Level semantics in the epoll 
controller there is no need to do the "reactivate fd" any more.

This one is an enhancement of 1 and depends on it.

[PATCH v3 03/10] High performance networking subsystem

This patchset adds vector IO ops for xmit and receive. Xmit
is optional (as it depends on a 3.0+ host), receive is always on.

The result is that UML can now hit 1G+ rates for transports
which have been enabled to use these. Presently this patchset
(Continue reading)

anton.ivanov | 29 Aug 09:58 2014

[PATCHv2 10/10] High Resolution Timer subsystem for UML

From: Anton Ivanov <antivano <at>>

This patch adds an extra timer source which has correct timing
and uses an up-to-date OS API and.

Results - correct kernel behaviour on timer related tasks.

    1. Improvement in network performance (TCP state machines
are now fed correct time).
    2. Correct QoS and traffic shaping.

This improvement does not (and cannot) fix UML userspace. Its
timer/time related behaviour is heavily dependent on getting
VTALRM pacing which is instantiated on a per userspace thread
basis. This patch does not fix this!!! It sorts out only the
kernel side - forwarding, qos, tcp, etc.

Signed-off-by: Anton Ivanov <antivano <at>>

I missed timer_internal.h on the original submission. Apologies.

 arch/um/Makefile                        |    2 +-
 arch/um/include/asm/irq.h               |    3 +-
 arch/um/include/shared/kern_util.h      |    1 +
 arch/um/include/shared/os.h             |    5 +
 arch/um/include/shared/timer-internal.h |   20 ++++
 arch/um/kernel/irq.c                    |   12 +++
 arch/um/kernel/process.c                |    7 +-
 arch/um/kernel/time.c                   |   44 +++++---
(Continue reading)

anton.ivanov | 29 Aug 09:56 2014

[PATCHv2 3/10] High performance networking subsystem

From: Anton Ivanov <antivano <at>>

    Support for multi-packet vector IO - multiple packets
    read in one syscall and written in one syscall. Should work with
    legacy UML, thorough tested only for the epoll based IRQ controller

    Minimal host kernel version for RX - 2.6.32
    Minimal host kernel version for TX - 3.0

    Tested on Debian 7.0/Ubuntu 12.x LTS which have the relevant
    syscalls, but do not have the appropriate glibc routine for TX
    (this is why it is a direct syscall).

Signed-off-by: Anton Ivanov <antivano <at>>

I have missed net_extra_* on the original submission, this is a resubmit.

 arch/um/drivers/Makefile          |    2 +-
 arch/um/drivers/net_extra_kern.c  |  218 +++++++++++++++++++++++++
 arch/um/drivers/net_extra_user.c  |  319 +++++++++++++++++++++++++++++++++++++
 arch/um/drivers/net_kern.c        |   63 +++++---
 arch/um/include/asm/irq.h         |   26 +--
 arch/um/include/shared/net_kern.h |   24 +++
 arch/um/include/shared/net_user.h |   24 +++
 arch/um/kernel/irq.c              |    3 +
 8 files changed, 646 insertions(+), 33 deletions(-)
 create mode 100644 arch/um/drivers/net_extra_kern.c
 create mode 100644 arch/um/drivers/net_extra_user.c
(Continue reading)

anton.ivanov | 29 Aug 09:05 2014

[PATCH 01/10] Epoll based interrupt controller

From: Anton Ivanov <antivano <at>>

1. Minimum kernel 2.5.99
2. No "walk the list" lookups for received IRQs - immediate identification
of the correct handler to invoke
3. Full set of IRQ semantics - edge, level, read, write
    3.1. Write is now a *REAL* write - so if you (ab)use the
    write to signify NONE (as in line.c) you will hang!!!
    3.2. Read is fully backward compatible
4. Otherwise mostly compatible with original poll() based controller
5. Provides significant performance improvement (up to 10x times for
large device numbers) ands lays the groundwork for the network and
timer improvements to follow

Signed-off-by: Anton Ivanov <antivano <at>>
 arch/um/drivers/line.c            |    3 +-
 arch/um/include/shared/irq_user.h |   19 +-
 arch/um/include/shared/os.h       |   13 +-
 arch/um/kernel/irq.c              |  456 +++++++++++++++++++++++++------------
 arch/um/os-Linux/irq.c            |  145 +++++-------
 5 files changed, 392 insertions(+), 244 deletions(-)

diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 8035145..6c4511f 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
 <at>  <at>  -1,4 +1,5  <at>  <at> 
+ * Copyright (C) 2012 - 2014 Cisco Systems
(Continue reading)

Alan | 27 Aug 17:28 2014

[PATCH] um,ethertap: use strncpy

I can't prove the case pointed out in
is correct so let us play safe.

Signed-off-by: Alan Cox <alan <at>>
 arch/um/os-Linux/drivers/ethertap_user.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index b39b669..6d49182 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
 <at>  <at>  -105,7 +105,7  <at>  <at>  static int etap_tramp(char *dev, char *gate, int control_me,
 	sprintf(data_fd_buf, "%d", data_remote);
 	sprintf(version_buf, "%d", UML_NET_VERSION);
 	if (gate != NULL) {
-		strcpy(gate_buf, gate);
+		strncpy(gate_buf, gate, 15);
 		args = setup_args;
 	else args = nosetup_args;

Slashdot TV.  
Video for Nerds.  Stuff that matters.
Toralf Förster | 23 Aug 22:05 2014

Re: [PATCH] UML: UBD: Fix for processes stuck in D state forever in UserModeLinux

I just applied the patch in on top of latest git
tree of Linus and fuzz tested a 32bit UML - works better than before. I'd say it now hangs less often than
before - just a first impression.



Slashdot TV.  
Video for Nerds.  Stuff that matters.
Toralf Förster | 11 Aug 21:22 2014

spinlock recursion w/ 3.16.0-10473-gc8d6637

/me wonders who could/should be informed about this BUG message from a 32 bit UML guest (the "dirty" comes
from reverted commit 8c86e70a)

BUG: spinlock recursion on CPU#0, rngd/1231
 lock: 0x86f1588, .magic: dead4ead, .owner: rngd/1231, .owner_cpu: 0
CPU: 0 PID: 1231 Comm: rngd Not tainted 3.16.0-10473-gc8d6637-dirty #3
 085bfb48 085bfb48 00000003 086f0547 85f6e1c0 086f1588 00000008 85f9f990
 08500fcf 00000000 85f9f964 85f9f9bc 084fd789 085cc734 086f1588 dead4ead
 85f6e408 000004cf 00000000 8437ab40 086f1588 085ca958 85f9f9cc 084fd7ab
Call Trace:
 [<084fd7ab>] ? spin_bug+0x1b/0x1f
 [<08500fcf>] dump_stack+0x26/0x28
 [<084fd789>] spin_dump+0xa1/0xa8
 [<084fd7ab>] spin_bug+0x1b/0x1f
 [<080a0db3>] do_raw_spin_lock+0x43/0x100
 [<0809739c>] ? finish_task_switch.constprop.53+0x3c/0x90
 [<08505421>] _raw_spin_lock+0x11/0x20
 [<08060622>] sigio_lock+0x12/0x20
 [<08071261>] add_sigio_fd+0x11/0x100
 [<0805ec9a>] reactivate_fd+0x6a/0x80
 [<08060597>] sigio_interrupt+0x37/0x40
 [<080a59bf>] handle_irq_event_percpu+0x2f/0x130
 [<080a9c94>] ? rcu_bh_qs+0x44/0x50
 [<080a5af4>] handle_irq_event+0x34/0x50
 [<080a8100>] handle_edge_irq+0xf0/0x120
 [<080a53cb>] generic_handle_irq+0x2b/0x30
 [<0805eda5>] do_IRQ+0x25/0x40
 [<0805ee25>] sigio_handler+0x65/0x90
 [<08071ade>] sig_handler_common+0xae/0xd0
(Continue reading)

Toralf Förster | 10 Aug 18:22 2014

3.16.0-10436-g9138475 - first impression

Well, might be too early to try the new kernel at a 32 bit Linux, but this is what I got today (just once, next
attempt to start the kernel worked fine) :

tfoerste <at> n22 /mnt/ramdisk $ stresc Xterm.log.n22.2014.    
Locating the bottom of the address space ... 0x1000
Locating the top of the address space ... 0xc0000000
Core dump limits :
        soft - 0
        hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking environment variables for a tempdir...none found
Checking if /dev/shm is on tmpfs...OK
Checking PROT_EXEC mmap in /dev/shm...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Adding 3354624 bytes to physical memory to account for exec-shield gap
Kernel virtual memory size shrunk to 976224256 bytes
bootconsole [earlycon0] enabled
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 262144 (order: 8, 1048576 bytes)
Inode-cache hash table entries: 131072 (order: 7, 524288 bytes)
Sorting __ex_table...
Memory: 2007004K/2051276K available (4824K kernel code, 304K rwdata, 1776K rodata, 118K init, 241K bss,
44272K reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
(Continue reading)