forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] rump hypcall integration for LKL #255
Open
thehajime
wants to merge
11
commits into
lkl:master
Choose a base branch
from
libos-nuse:rump-hypcall-upstream
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,898
−43
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
970ebee
lkl: let atomic ops outsourced
thehajime 12ea48f
lkl: add signal delivery support
thehajime f5ad407
lkl: add irq_{request/release} host_ops entries
thehajime 5a87063
lkl: add getparam host_ops entry
thehajime 82f73f9
lkl: add rump hypercall implementation for frankenlibc build
thehajime 499ba64
lkl: fix arm-none-eabi- build with frankenlibc
thehajime 75bae62
lkl: add experimental rump syscall proxy support
thehajime badf2bd
lkl: add rumpun unikernel support for LKL
thehajime 5f9d302
lkl: work around for arm build failure (Issue #229)
thehajime f82b294
lkl: temporary disabled btrfs
thehajime 95be33a
Revert "device core: Remove deprecated create_singlethread_workqueue"
thehajime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
obj-y = rumpdev_pci.o | ||
|
||
# need to build with | ||
librumpdev_linux_pci.a: ${RUMP_BMK_PCI_HYPERCALLS} | ||
rm -f $@ | ||
$(AR) rc $@ ${RUMP_BMK_PCI_HYPERCALLS} | ||
|
||
install: librumpdev_linux_pci.a | ||
install -D librumpdev_linux_pci.a ${DESTDIR}/lib/ | ||
|
||
|
||
.PHONY: ${RUMP_BMK_PCI_HYPERCALLS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Reused from src-netbsd/sys/rump/dev/lib/libpci/pci_user.h */ | ||
/* | ||
* Possible userfeature macro flags: | ||
* | ||
* RUMPCOMP_USERFEATURE_PCI_DMAFREE: | ||
* Support free'ing DMA memory. If not, panic() when free() is called. | ||
* | ||
* RUMPCOMP_USERFEATURE_PCI_IOSPACE | ||
* Support for PCI I/O space. If yes, rumpcomp_pci_iospace_init() | ||
* must be provided. | ||
*/ | ||
|
||
|
||
void *rumpcomp_pci_map(unsigned long addr, unsigned long len); | ||
int rumpcomp_pci_confread(unsigned int bus, unsigned int dev, | ||
unsigned int fun, int reg, unsigned int *value); | ||
int rumpcomp_pci_confwrite(unsigned int bus, unsigned int dev, | ||
unsigned int fun, int reg, unsigned int value); | ||
int rumpcomp_pci_irq_map(unsigned int bus, unsigned int device, | ||
unsigned int fun, int intrline, unsigned int cookie); | ||
void *rumpcomp_pci_irq_establish(unsigned int cookie, | ||
int (*handler)(void *), void *data); | ||
|
||
/* XXX: needs work: support boundary-restricted allocations */ | ||
int rumpcomp_pci_dmalloc(size_t size, size_t align, | ||
unsigned long *pap, unsigned long *vap); | ||
#ifdef RUMPCOMP_USERFEATURE_PCI_DMAFREE | ||
void rumpcomp_pci_dmafree(unsigned long mem, size_t size); | ||
#endif | ||
|
||
struct rumpcomp_pci_dmaseg { | ||
unsigned long ds_pa; | ||
unsigned long ds_len; | ||
unsigned long ds_vacookie; | ||
}; | ||
int rumpcomp_pci_dmamem_map(struct rumpcomp_pci_dmaseg *dss, size_t nseg, | ||
size_t totlen, void **vap); | ||
|
||
unsigned long rumpcomp_pci_virt_to_mach(void *virt); | ||
|
||
#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE | ||
int rumpcomp_pci_iospace_init(void); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
/* | ||
* rumprun PCI access (reused from src-netbsd/.../rumpdev_pci.c) | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2013 Antti Kantee. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | ||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include <linux/init.h> | ||
#include <linux/kernel.h> | ||
#include <linux/pci.h> | ||
#include <linux/slab.h> | ||
#include <linux/interrupt.h> | ||
#include <linux/types.h> | ||
#include <linux/io.h> | ||
#include <asm/host_ops.h> | ||
|
||
#include "pci_user.h" | ||
|
||
struct rump_pci_sysdata { | ||
int domain; /* PCI domain */ | ||
}; | ||
|
||
/* stubs: should not called */ | ||
int __weak rumpcomp_pci_confread(unsigned int bus, unsigned int dev, | ||
unsigned int fun, | ||
int reg, unsigned int *value) | ||
{ | ||
return 0; | ||
} | ||
|
||
int __weak rumpcomp_pci_confwrite(unsigned int bus, unsigned int dev, | ||
unsigned int fun, | ||
int reg, unsigned int value) | ||
{ | ||
return 0; | ||
} | ||
|
||
void * __weak rumpcomp_pci_map(unsigned long addr, unsigned long len) | ||
{ | ||
return NULL; | ||
} | ||
|
||
int __weak rumpcomp_pci_irq_map(unsigned int bus, unsigned int device, | ||
unsigned int fun, | ||
int intrline, unsigned int cookie) | ||
{ | ||
return 0; | ||
} | ||
|
||
void * __weak rumpcomp_pci_irq_establish(unsigned int cookie, | ||
int (*handler)(void *), void *data) | ||
{ | ||
return NULL; | ||
} | ||
|
||
void __iomem *__pci_ioport_map(struct pci_dev *dev, | ||
unsigned long port, unsigned int nr) | ||
{ | ||
/* XXX: no care at the moment */ | ||
return rumpcomp_pci_map(port, nr); | ||
} | ||
|
||
/* from arch/x86/pci/common.c */ | ||
void pcibios_fixup_bus(struct pci_bus *b) | ||
{ | ||
pci_read_bridge_bases(b); | ||
} | ||
|
||
/* from arch/x86/pci/i386.c */ | ||
resource_size_t | ||
pcibios_align_resource(void *data, const struct resource *res, | ||
resource_size_t size, resource_size_t align) | ||
{ | ||
return 0; | ||
} | ||
|
||
/* from drivers/pci/access.c | ||
* | ||
* @bus: PCI bus to scan | ||
* @devfn: slot number to scan (must have zero function.) | ||
*/ | ||
void *rump_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where) | ||
{ | ||
unsigned long addr; | ||
|
||
addr = (1 << 31) | (bus->number << 16) | (PCI_SLOT(devfn) << 11) | | ||
(PCI_FUNC(devfn) << 8) | (where & 0xfc); | ||
|
||
/* FIXME: length? */ | ||
return rumpcomp_pci_map(addr, 0); | ||
} | ||
|
||
int rump_pci_generic_read(struct pci_bus *bus, unsigned int devfn, | ||
int where, int size, u32 *val) | ||
{ | ||
|
||
rumpcomp_pci_confread(bus->number, PCI_SLOT(devfn), | ||
PCI_FUNC(devfn), where, val); | ||
if (size <= 2) | ||
*val = (*val >> (8 * (where & 3))) & ((1 << (size * 8)) - 1); | ||
|
||
return PCIBIOS_SUCCESSFUL; | ||
} | ||
|
||
int rump_pci_generic_write(struct pci_bus *bus, unsigned int devfn, | ||
int where, int size, u32 val) | ||
{ | ||
u32 mask, tmp; | ||
|
||
if (size == 4) { | ||
rumpcomp_pci_confwrite(bus->number, PCI_SLOT(devfn), | ||
PCI_FUNC(devfn), where, val); | ||
return PCIBIOS_SUCCESSFUL; | ||
} | ||
|
||
mask = ~(((1 << (size * 8)) - 1) << ((where & 0x3) * 8)); | ||
|
||
/* This brings the way much overhead though I picked this | ||
* code from access.c.. maybe should come up with single | ||
* write method to avoid that. | ||
*/ | ||
|
||
rumpcomp_pci_confread(bus->number, PCI_SLOT(devfn), | ||
PCI_FUNC(devfn), where, &tmp); | ||
tmp &= mask; | ||
tmp |= val << ((where & 0x3) * 8); | ||
|
||
rumpcomp_pci_confwrite(bus->number, PCI_SLOT(devfn), | ||
PCI_FUNC(devfn), where, tmp); | ||
|
||
return PCIBIOS_SUCCESSFUL; | ||
} | ||
|
||
|
||
#ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH | ||
#include <dev/pci/pcireg.h> | ||
#include <dev/pci/pcivar.h> | ||
#include <dev/pci/pciidereg.h> | ||
#include <dev/pci/pciidevar.h> | ||
|
||
void * | ||
pciide_machdep_compat_intr_establish(device_t dev, | ||
const struct pci_attach_args *pa, int chan, | ||
int (*func)(void *), void *arg) | ||
{ | ||
pci_intr_handle_t ih; | ||
struct pci_attach_args mypa = *pa; | ||
|
||
mypa.pa_intrline = PCIIDE_COMPAT_IRQ(chan); | ||
if (pci_intr_map(&mypa, &ih) != 0) | ||
return NULL; | ||
return rumpcomp_pci_irq_establish(ih, func, arg); | ||
} | ||
|
||
__strong_alias(pciide_machdep_compat_intr_disestablish, pci_intr_disestablish); | ||
#endif /* __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH */ | ||
|
||
|
||
/* from drivers/pci/xen-pcifront.c */ | ||
static int pci_lib_claim_resource(struct pci_dev *dev, void *data) | ||
{ | ||
int i; | ||
struct resource *r; | ||
|
||
for (i = 0; i < PCI_NUM_RESOURCES; i++) { | ||
r = &dev->resource[i]; | ||
|
||
if (!r->parent && r->start && r->flags) { | ||
dev_info(&dev->dev, "claiming resource %s/%d\n", | ||
pci_name(dev), i); | ||
if (pci_claim_resource(dev, i)) { | ||
dev_err(&dev->dev, | ||
"Could not claim resource %s/%d!", | ||
pci_name(dev), i); | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int rump_trigger_irq(void *arg) | ||
{ | ||
struct irq_data *data = arg; | ||
|
||
lkl_trigger_irq(data->irq); | ||
return 0; | ||
} | ||
|
||
int rump_pci_irq_request(struct irq_data *data) | ||
{ | ||
int ret, int_irq; | ||
struct irq_desc *desc = irq_to_desc(data->irq); | ||
const char *name = desc->name ? desc->name : "null"; /* XXX */ | ||
|
||
static int intr[5] = {9, 10, 11, 14, 15}; | ||
static int intnum; | ||
|
||
/* setup IRQ */ | ||
int_irq = lkl_get_free_irq(name); | ||
|
||
ret = rumpcomp_pci_irq_map(0, 0, 0, intr[intnum++], int_irq); | ||
rumpcomp_pci_irq_establish(int_irq, rump_trigger_irq, data); | ||
|
||
return 0; | ||
} | ||
|
||
void rump_pci_irq_release(struct irq_data *data) | ||
{ | ||
/* XXX: NOP */ | ||
} | ||
|
||
struct pci_ops rump_pci_root_ops = { | ||
.map_bus = rump_pci_map_bus, | ||
.read = rump_pci_generic_read, | ||
.write = rump_pci_generic_write, | ||
}; | ||
|
||
|
||
static int __init rump_pci_init(void) | ||
{ | ||
struct pci_bus *bus; | ||
struct rump_pci_sysdata *sd; | ||
int busnum = 0; | ||
|
||
sd = kzalloc(sizeof(*sd), GFP_KERNEL); | ||
if (!sd) | ||
return -1; | ||
|
||
pr_info("PCI: root bus %02x: using default resources\n", busnum); | ||
bus = pci_scan_bus(busnum, &rump_pci_root_ops, sd); | ||
if (!bus) { | ||
kfree(sd); | ||
return -1; | ||
} | ||
pci_walk_bus(bus, pci_lib_claim_resource, NULL); | ||
pci_bus_add_devices(bus); | ||
|
||
return 0; | ||
} | ||
subsys_initcall(rump_pci_init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _ASM_LKL_DMA_H | ||
#define _ASM_LKL_DMA_H | ||
|
||
#include <asm-generic/dma.h> | ||
|
||
#ifdef CONFIG_PCI | ||
extern int isa_dma_bridge_buggy; | ||
#else | ||
#define isa_dma_bridge_buggy (0) | ||
#endif | ||
|
||
#endif /* _ASM_LKL_DMA_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _ASM_LKL_PCI_H | ||
#define _ASM_LKL_PCI_H | ||
|
||
#include <asm-generic/pci.h> | ||
|
||
# define pcibios_assign_all_busses() 0 | ||
#define PCIBIOS_MIN_IO 0x1000 | ||
#define PCIBIOS_MIN_MEM 0x10000000 | ||
|
||
#endif /* _ASM_LKL_PCI_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void do_signal(struct pt_regs *regs); | ||
|
||
#include <asm-generic/signal.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef _ASM_LKL_UACCESS_H | ||
#define _ASM_LKL_UACCESS_H | ||
|
||
#include <linux/compiler.h> | ||
#include <linux/types.h> | ||
#include <linux/irqflags.h> | ||
#include <linux/string.h> | ||
#include <asm/errno.h> | ||
#include <asm/thread_info.h> | ||
|
||
#ifdef ENABLE_SYSPROXY | ||
#include <rump/rumpuser.h> | ||
#endif | ||
|
||
#define __access_ok(addr, size) (1) | ||
|
||
/* handle rump remote client */ | ||
static inline __must_check long __copy_from_user(void *to, | ||
const void __user *from, unsigned long n) | ||
{ | ||
int error = 0; | ||
struct thread_info *ti; | ||
|
||
ti = current_thread_info(); | ||
|
||
if (unlikely(from == NULL && n)) | ||
return -EFAULT; | ||
|
||
if (!ti->rump_client) { | ||
memcpy(to, from, n); | ||
} else if (n) { | ||
#ifdef ENABLE_SYSPROXY | ||
error = rumpuser_sp_copyin(ti->rump_client, from, to, n); | ||
#else | ||
; | ||
#endif | ||
} | ||
|
||
return error; | ||
} | ||
#define __copy_from_user(to, from, n) __copy_from_user(to, from, n) | ||
|
||
static inline __must_check long __copy_to_user(void __user *to, | ||
const void *from, unsigned long n) | ||
{ | ||
int error = 0; | ||
struct thread_info *ti; | ||
|
||
ti = current_thread_info(); | ||
|
||
if (unlikely(to == NULL && n)) | ||
return -EFAULT; | ||
|
||
if (!ti->rump_client) { | ||
memcpy(to, from, n); | ||
} else if (n) { | ||
#ifdef ENABLE_SYSPROXY | ||
error = rumpuser_sp_copyout(ti->rump_client, from, to, n); | ||
#else | ||
; | ||
#endif | ||
} | ||
|
||
return error; | ||
} | ||
#define __copy_to_user(to, from, n) __copy_to_user(to, from, n) | ||
|
||
#include <asm-generic/uaccess.h> | ||
|
||
#endif /* _ASM_LKL_UACCESS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
extra-y := vmlinux.lds | ||
|
||
obj-y = setup.o threads.o irq.o time.o syscalls.o misc.o console.o \ | ||
syscalls_32.o cpu.o | ||
syscalls_32.o cpu.o atomic.o signal.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#include <linux/kernel.h> | ||
#include <linux/init.h> | ||
#include <asm/host_ops.h> | ||
|
||
#if defined(__ARMEL__) | ||
static void *atomic_lock; | ||
|
||
long lkl__sync_fetch_and_or(long *ptr, long value) | ||
{ | ||
lkl_ops->sem_down(atomic_lock); | ||
*ptr = value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return 0; | ||
} | ||
|
||
long lkl__sync_fetch_and_and(long *ptr, long value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr *= value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
int lkl__sync_fetch_and_add(int *ptr, int value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr += value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
int lkl__sync_fetch_and_sub(int *ptr, int value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr -= value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
void lkl__sync_synchronize(void) | ||
{ | ||
} | ||
|
||
void atomic_ops_init(void) | ||
{ | ||
atomic_lock = lkl_ops->sem_alloc(1); | ||
} | ||
|
||
void atomic_ops_cleanup(void) | ||
{ | ||
lkl_ops->sem_free(atomic_lock); | ||
} | ||
|
||
#else | ||
long lkl__sync_fetch_and_or(long *ptr, long value) | ||
{ | ||
return __sync_fetch_and_or(ptr, value); | ||
} | ||
|
||
long lkl__sync_fetch_and_and(long *ptr, long value) | ||
{ | ||
return __sync_fetch_and_and(ptr, value); | ||
} | ||
|
||
int lkl__sync_fetch_and_add(int *ptr, int value) | ||
{ | ||
return __sync_fetch_and_add(ptr, value); | ||
} | ||
|
||
int lkl__sync_fetch_and_sub(int *ptr, int value) | ||
{ | ||
return __sync_fetch_and_sub(ptr, value); | ||
} | ||
|
||
void lkl__sync_synchronize(void) | ||
{ | ||
return __sync_synchronize(); | ||
} | ||
|
||
void atomic_ops_init(void) | ||
{ | ||
} | ||
|
||
void atomic_ops_cleanup(void) | ||
{ | ||
} | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <linux/sched.h> | ||
|
||
static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) | ||
{ | ||
ksig->ka.sa.sa_handler(ksig->sig); | ||
} | ||
|
||
void do_signal(struct pt_regs *regs) | ||
{ | ||
struct ksignal ksig; | ||
|
||
while (get_signal(&ksig)) { | ||
/* Whee! Actually deliver the signal. */ | ||
handle_signal(&ksig, regs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Rump system call proxy interface for Linux | ||
* Copyright (c) 2015 Hajime Tazaki | ||
* | ||
* Author: Hajime Tazaki <thehajime@gmail.com> | ||
*/ | ||
|
||
#include <linux/stddef.h> | ||
#include <linux/types.h> | ||
#include <generated/utsrelease.h> | ||
|
||
#ifdef ENABLE_SYSPROXY | ||
#include "rump.h" | ||
|
||
int rump_init_server(const char *url) | ||
{ | ||
return rumpuser_sp_init(url, "Linux", UTS_RELEASE, "libos"); | ||
} | ||
|
||
void rump_sysproxy_init(void) | ||
{ | ||
rump_init_server("unix:///tmp/rump-server"); | ||
} | ||
|
||
void rump_sysproxy_fini(void) | ||
{ | ||
rumpuser_sp_fini(NULL); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
/* | ||
* Rump hypercall interface for Linux | ||
* Copyright (c) 2015 Hajime Tazaki | ||
* | ||
* Author: Hajime Tazaki <thehajime@gmail.com> | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <sys/types.h> | ||
|
||
#include "rump.h" | ||
|
||
#include <lkl.h> | ||
#include <lkl_host.h> | ||
|
||
static struct lwp *rump_lkl_lwproc_curlwp(void); | ||
static int rump_lkl_lwproc_newlwp(pid_t pid); | ||
static void rump_lkl_lwproc_switch(struct lwp *newlwp); | ||
static void rump_lkl_lwproc_release(void); | ||
static int rump_lkl_lwproc_rfork(void *priv, int flags, const char *comm); | ||
|
||
void | ||
rump_schedule(void) | ||
{ | ||
} | ||
|
||
void | ||
rump_unschedule(void) | ||
{ | ||
} | ||
|
||
int | ||
rump_daemonize_begin(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
int | ||
rump_daemonize_done(int error) | ||
{ | ||
return 0; | ||
} | ||
|
||
|
||
int | ||
rump_pub_lwproc_rfork(int arg1) | ||
{ | ||
int rv = 0; | ||
|
||
rump_schedule(); | ||
// rv = rump_lkl_lwproc_rfork(arg1); | ||
rump_unschedule(); | ||
|
||
return rv; | ||
} | ||
|
||
int | ||
rump_pub_lwproc_newlwp(pid_t arg1) | ||
{ | ||
int rv; | ||
|
||
rump_schedule(); | ||
rv = rump_lkl_lwproc_newlwp(arg1); | ||
rump_unschedule(); | ||
|
||
return rv; | ||
} | ||
|
||
void | ||
rump_pub_lwproc_switch(struct lwp *arg1) | ||
{ | ||
|
||
rump_schedule(); | ||
rump_lkl_lwproc_switch(arg1); | ||
rump_unschedule(); | ||
} | ||
|
||
void | ||
rump_pub_lwproc_releaselwp(void) | ||
{ | ||
|
||
rump_schedule(); | ||
rump_lkl_lwproc_release(); | ||
rump_unschedule(); | ||
} | ||
|
||
struct lwp * | ||
rump_pub_lwproc_curlwp(void) | ||
{ | ||
struct lwp *rv; | ||
|
||
rump_schedule(); | ||
rv = rump_lkl_lwproc_curlwp(); | ||
rump_unschedule(); | ||
|
||
return rv; | ||
} | ||
|
||
int | ||
rump_syscall(int num, void *data, size_t dlen, long *retval) | ||
{ | ||
int ret = 0; | ||
|
||
ret = lkl_syscall(num, (long *)data); | ||
/* FIXME: need better err translation */ | ||
if (ret < 0) { | ||
retval[0] = -ret; | ||
ret = -1; | ||
} | ||
return ret; | ||
} | ||
|
||
|
||
static int | ||
rump_lkl_hyp_syscall(int num, void *arg, long *retval) | ||
{ | ||
return rump_syscall(num, arg, 0, retval); | ||
} | ||
|
||
static int | ||
rump_lkl_lwproc_rfork(void *priv, int flags, const char *comm) | ||
{ | ||
#ifdef ENABLE_SYSPROXY | ||
/* FIXME: needs new task_struct instead of get_current() */ | ||
struct thread_info *ti = task_thread_info(get_current()); | ||
|
||
/* store struct spc_client */ | ||
ti->rump_client = priv; | ||
|
||
rumpuser_curlwpop(RUMPUSER_LWP_CREATE, (struct lwp *)ti); | ||
rumpuser_curlwpop(RUMPUSER_LWP_SET, (struct lwp *)ti); | ||
#endif | ||
return 0; | ||
} | ||
|
||
static void | ||
rump_lkl_lwproc_release(void) | ||
{ | ||
struct thread_info *ti = (struct thread_info *)rumpuser_curlwp(); | ||
|
||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, (struct lwp *)ti); | ||
} | ||
|
||
static void | ||
rump_lkl_lwproc_switch(struct lwp *newlwp) | ||
{ | ||
struct thread_info *ti = (struct thread_info *)rumpuser_curlwp(); | ||
|
||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, (struct lwp *)ti); | ||
rumpuser_curlwpop(RUMPUSER_LWP_SET, (struct lwp *)ti); | ||
} | ||
|
||
/* find rump_task created by rfork */ | ||
static int | ||
rump_lkl_lwproc_newlwp(pid_t pid) | ||
{ | ||
#ifdef FIXME | ||
/* find rump_task */ | ||
struct thread_info *ti = NULL; | ||
struct task_struct *p; | ||
|
||
for_each_process(p) { | ||
if (p->pid == pid) { | ||
ti = task_thread_info(p); | ||
break; | ||
} | ||
} | ||
|
||
if (!ti) { | ||
pr_warn("newlwp: could not find pid %d\n", pid); | ||
ti = current_thread_info(); | ||
/* FIXME */ | ||
// return ESRCH; | ||
} | ||
|
||
/* set to currnet */ | ||
rumpuser_curlwpop(RUMPUSER_LWP_SET, (struct lwp *)ti); | ||
|
||
#endif /* FIXME */ | ||
return 0; | ||
} | ||
|
||
static struct lwp * | ||
rump_lkl_lwproc_curlwp(void) | ||
{ | ||
return rumpuser_curlwp(); | ||
} | ||
|
||
static void | ||
rump_lkl_hyp_lwpexit(void) | ||
{ | ||
struct thread_info *ti = (struct thread_info *)rumpuser_curlwp(); | ||
|
||
rumpuser_curlwpop(RUMPUSER_LWP_DESTROY, (struct lwp *)ti); | ||
#ifdef FIXME | ||
free_thread_info(ti); | ||
#endif | ||
} | ||
|
||
static pid_t | ||
rump_lkl_hyp_getpid(void) | ||
{ | ||
#ifdef FIXME | ||
struct thread_info *ti = (struct thread_info *)rumpuser_curlwp(); | ||
|
||
return ti->task->pid; | ||
#endif | ||
return -1; | ||
} | ||
|
||
static void rump_lkl_user_unschedule(int nlocks, int *countp, | ||
void *interlock) {} | ||
static void rump_lkl_user_schedule(int nlocks, void *interlock) {} | ||
static void rump_lkl_hyp_execnotify(const char *comm) {} | ||
|
||
const struct rumpuser_hyperup hyp = { | ||
.hyp_schedule = rump_schedule, | ||
.hyp_unschedule = rump_unschedule, | ||
.hyp_backend_unschedule = rump_lkl_user_unschedule, | ||
.hyp_backend_schedule = rump_lkl_user_schedule, | ||
|
||
.hyp_lwproc_switch = rump_lkl_lwproc_switch, | ||
.hyp_lwproc_release = rump_lkl_lwproc_release, | ||
.hyp_lwproc_newlwp = rump_lkl_lwproc_newlwp, | ||
.hyp_lwproc_curlwp = rump_lkl_lwproc_curlwp, | ||
|
||
.hyp_getpid = rump_lkl_hyp_getpid, | ||
.hyp_syscall = rump_lkl_hyp_syscall, | ||
.hyp_lwproc_rfork = rump_lkl_lwproc_rfork, | ||
.hyp_lwpexit = rump_lkl_hyp_lwpexit, | ||
.hyp_execnotify = rump_lkl_hyp_execnotify, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Rump hypercall interface for Linux | ||
* Copyright (c) 2015 Hajime Tazaki | ||
* | ||
* Author: Hajime Tazaki <thehajime@gmail.com> | ||
*/ | ||
|
||
#define __dead | ||
#define __printflike(x, y) | ||
#include <rump/rumpuser.h> | ||
|
||
struct irq_data; | ||
|
||
void rump_sysproxy_init(void); | ||
void rump_sysproxy_fini(void); | ||
|
||
extern const struct rumpuser_hyperup hyp; | ||
#ifdef ENABLE_SYSPROXY | ||
extern struct rump_sysproxy_ops rump_sysproxy_ops; | ||
#endif | ||
|
||
int rump_pci_irq_request(struct irq_data *data); | ||
void rump_pci_irq_release(struct irq_data *data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this means that x86-32 is not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LKL does not support x86-32, yet #341
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a messy part of lots of ifdefs and a result of what i personally tried. this can be expanded a platform which is currently not supported (e.g., x86-32).