Skip to content

Commit 75bae62

Browse files
committed
lkl: add experimental rump syscall proxy support
The code is not built as-is but put an implementation using rump syscall proxy which makes an LKL application communicate with outside of the process. Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
1 parent 499ba64 commit 75bae62

5 files changed

Lines changed: 103 additions & 1 deletion

File tree

arch/lkl/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ generic-y += tlb.h
7070
generic-y += tlbflush.h
7171
generic-y += topology.h
7272
generic-y += trace_clock.h
73-
generic-y += uaccess.h
7473
generic-y += unaligned.h
7574
generic-y += vga.h
7675
generic-y += word-at-a-time.h

arch/lkl/include/asm/thread_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct thread_info {
2222
bool dead;
2323
lkl_thread_t tid;
2424
struct task_struct *prev_sched;
25+
void *rump_client; /* for syscall proxy */
2526
unsigned long stackend;
2627
};
2728

arch/lkl/include/asm/uaccess.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifndef _ASM_LKL_UACCESS_H
2+
#define _ASM_LKL_UACCESS_H
3+
4+
#include <linux/compiler.h>
5+
#include <linux/types.h>
6+
#include <linux/irqflags.h>
7+
#include <linux/string.h>
8+
#include <asm/errno.h>
9+
#include <asm/thread_info.h>
10+
11+
#ifdef ENABLE_SYSPROXY
12+
#include <rump/rumpuser.h>
13+
#endif
14+
15+
#define __access_ok(addr, size) (1)
16+
17+
/* handle rump remote client */
18+
static inline __must_check long __copy_from_user(void *to,
19+
const void __user *from, unsigned long n)
20+
{
21+
int error = 0;
22+
struct thread_info *ti;
23+
24+
ti = current_thread_info();
25+
26+
if (unlikely(from == NULL && n))
27+
return -EFAULT;
28+
29+
if (!ti->rump_client) {
30+
memcpy(to, from, n);
31+
} else if (n) {
32+
#ifdef ENABLE_SYSPROXY
33+
error = rumpuser_sp_copyin(ti->rump_client, from, to, n);
34+
#else
35+
;
36+
#endif
37+
}
38+
39+
return error;
40+
}
41+
#define __copy_from_user(to, from, n) __copy_from_user(to, from, n)
42+
43+
static inline __must_check long __copy_to_user(void __user *to,
44+
const void *from, unsigned long n)
45+
{
46+
int error = 0;
47+
struct thread_info *ti;
48+
49+
ti = current_thread_info();
50+
51+
if (unlikely(to == NULL && n))
52+
return -EFAULT;
53+
54+
if (!ti->rump_client) {
55+
memcpy(to, from, n);
56+
} else if (n) {
57+
#ifdef ENABLE_SYSPROXY
58+
error = rumpuser_sp_copyout(ti->rump_client, from, to, n);
59+
#else
60+
;
61+
#endif
62+
}
63+
64+
return error;
65+
}
66+
#define __copy_to_user(to, from, n) __copy_to_user(to, from, n)
67+
68+
#include <asm-generic/uaccess.h>
69+
70+
#endif /* _ASM_LKL_UACCESS_H */

tools/lkl/lib/rump-sysproxy.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Rump system call proxy interface for Linux
3+
* Copyright (c) 2015 Hajime Tazaki
4+
*
5+
* Author: Hajime Tazaki <thehajime@gmail.com>
6+
*/
7+
8+
#include <linux/stddef.h>
9+
#include <linux/types.h>
10+
#include <generated/utsrelease.h>
11+
12+
#ifdef ENABLE_SYSPROXY
13+
#include "rump.h"
14+
15+
int rump_init_server(const char *url)
16+
{
17+
return rumpuser_sp_init(url, "Linux", UTS_RELEASE, "libos");
18+
}
19+
20+
void rump_sysproxy_init(void)
21+
{
22+
rump_init_server("unix:///tmp/rump-server");
23+
}
24+
25+
void rump_sysproxy_fini(void)
26+
{
27+
rumpuser_sp_fini(NULL);
28+
}
29+
#endif

tools/lkl/lib/rump.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ void rump_sysproxy_init(void);
1515
void rump_sysproxy_fini(void);
1616

1717
extern const struct rumpuser_hyperup hyp;
18+
#ifdef ENABLE_SYSPROXY
19+
extern struct rump_sysproxy_ops rump_sysproxy_ops;
20+
#endif
1821

1922
int rump_pci_irq_request(struct irq_data *data);
2023
void rump_pci_irq_release(struct irq_data *data);

0 commit comments

Comments
 (0)