Skip to content
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

argo: port to 4.19 kernel #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 47 additions & 23 deletions src/argo-linux/argo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,7 @@ argo_recv_stream(struct argo_private *p, void *_buf, int len, int recv_flags,

ret = copy_to_user(buf, &pending->data[pending->data_ptr], to_copy);
if ( ret )
printk(KERN_ERR "ARGO - copy_to_user failed: buf: %p other: %p to_copy: %u pending %p data_ptr %u data: %p\n",
printk(KERN_ERR "ARGO - copy_to_user failed: buf: %p other: %p to_copy: %lu pending %p data_ptr %lu data: %p\n",
buf, &pending->data[pending->data_ptr], to_copy, pending,
pending->data_ptr, pending->data);
/* FIXME: error exit action here? */
Expand Down Expand Up @@ -3047,14 +3047,34 @@ static const struct dentry_operations argofs_dentry_operations = {
.d_dname = argofs_dname,
};

static struct inode *
argo_make_inode (void)
{
struct inode *inode = new_inode(argo_mnt->mnt_sb);

if (!inode)
return NULL;

inode->i_ino = get_next_ino();
inode->i_fop = argo_mnt->mnt_root->d_inode->i_fop;
inode->i_state = argo_mnt->mnt_root->d_inode->i_state;
inode->i_mode = argo_mnt->mnt_root->d_inode->i_mode;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();

return inode;
}

static int
allocate_fd_with_private (void *private)
{
int fd;
int fd, rc;
struct file *f;
struct inode *ind;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0))
struct qstr name = { .name = "" };
struct path path;
struct inode *ind;
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
fd = get_unused_fd();
Expand All @@ -3064,37 +3084,41 @@ allocate_fd_with_private (void *private)
if ( fd < 0 )
return fd;

#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0))
path.dentry = d_alloc_pseudo(argo_mnt->mnt_sb, &name);
if ( unlikely(!path.dentry) )
{
put_unused_fd(fd);
if (unlikely(!path.dentry))
return -ENOMEM;
}
ind = new_inode(argo_mnt->mnt_sb);
ind->i_ino = get_next_ino();
ind->i_fop = argo_mnt->mnt_root->d_inode->i_fop;
ind->i_state = argo_mnt->mnt_root->d_inode->i_state;
ind->i_mode = argo_mnt->mnt_root->d_inode->i_mode;
ind->i_uid = current_fsuid();
ind->i_gid = current_fsgid();
d_instantiate(path.dentry, ind);
#endif

path.mnt = mntget(argo_mnt);
ind = argo_make_inode();
if (!ind) {
rc = -ENOMEM;
goto out;
}

DEBUG_APPLE;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0))
f = alloc_file(&path, FMODE_READ | FMODE_WRITE, &argo_fops_stream);
if ( !f )
{
//FIXME putback fd?
return -ENFILE;
#else
f = alloc_file_pseudo(ind, argo_mnt, "", O_RDWR, &argo_fops_stream);
#endif
if ( !f ) {
rc = -ENFILE;
goto out;
}

#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0))
d_instantiate(path.dentry, ind);
path.mnt = mntget(argo_mnt);
#endif
f->private_data = private;
f->f_flags = O_RDWR;

fd_install (fd, f);

return fd;

out:
put_unused_fd(fd);
return rc;
}

static int
Expand Down Expand Up @@ -3835,7 +3859,7 @@ argo_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
}
break;
default:
printk(KERN_ERR "unknown ioctl: cmd=%x ARGOIOCACCEPT=%x\n", cmd,
printk(KERN_ERR "unknown ioctl: cmd=%x ARGOIOCACCEPT=%lx\n", cmd,
ARGOIOCACCEPT);
DEBUG_BANANA;
}
Expand Down
15 changes: 15 additions & 0 deletions src/argo-linux/include/argo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
#ifndef HYPERVISOR_argo_op
#define __HYPERVISOR_argo_op 39

/*
* Removed because unused in:
* https://lkml.org/lkml/2018/8/20/267
*/
#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
({ \
__HYPERCALL_DECLS; \
__HYPERCALL_5ARG(a1, a2, a3, a4, a5); \
asm volatile (__HYPERCALL \
: __HYPERCALL_5PARAM \
: __HYPERCALL_ENTRY(name) \
: __HYPERCALL_CLOBBER5); \
(type)__res; \
})

static inline int __must_check
HYPERVISOR_argo_op(int cmd, void *arg1, void *arg2, uint32_t arg3,
uint32_t arg4)
Expand Down
22 changes: 22 additions & 0 deletions src/libargo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Makefile
Makefile.in
aclocal.m4
ar-lib
autom4te.cache/
compile
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
m4/
missing
src/Makefile
src/Makefile.in
src/config.h
src/config.h.in
src/stamp-h1