Commit 1d9c6dfb authored by Anton Burtsev's avatar Anton Burtsev Committed by Vikram Narayanan

Cleaned up (sort of) capability code

parent 42684499
......@@ -4,7 +4,7 @@
#include <linux/types.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
//#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/fs.h>
......@@ -208,7 +208,7 @@ bool lcd_cap_delete_internal_lockless(struct cte *cap, bool *last_refere
// pointer to the cspace is also added to the TCB of the caller.
// Output:
// pointer to the newly created cspace.
struct cap_space * lcd_cap_create_cspace(void *objects[], lcd_cap_rights rights[]);
int lcd_cap_init_cspace(struct cap_space *cspace);
// will be used to access the object on which a method is to be invoked.
// the returned value is a pointer to the entry in the table where the capability
......@@ -219,7 +219,7 @@ struct cap_space * lcd_cap_create_cspace(void *objects[], lcd_cap_rights rights[
// keep_locked: whether or not to keep the semaphore protecting cdt locked.
// Output:
// pointer to the capability table entry if the cid is valid else NULL is returned.
struct cte * lcd_cap_lookup_capability(struct task_struct *tcb, capability_t cid, bool keep_locked);
struct cte * lcd_cap_lookup_capability(struct cap_space *cspace, capability_t cid, bool keep_locked);
// creates a new capability, inserts it into cspace of caller and
// returns the capability identifier.
......@@ -231,7 +231,7 @@ struct cte * lcd_cap_lookup_capability(struct task_struct *tcb, capability_t cid
// Output:
// capability identifier within the cspace of the thread which intended to create this capability.
// 0 = Failure
capability_t lcd_cap_create_capability(struct task_struct *tcb, void * hobject, lcd_cap_rights crights);
capability_t lcd_cap_create_capability(struct cap_space *cspace, void * hobject, lcd_cap_rights crights);
// will be used to grant a capability to another thread
// returns the address of the capability within the cspace of the receiver thread.
......@@ -242,7 +242,7 @@ capability_t lcd_cap_create_capability(struct task_struct *tcb, void * hobject,
// src_cid: capability identifier of the capability being granted.
// dst_tcb: pointer to the task_struct of the receiver thread.
// crights: the rights on the capability to be granted to the receiver.
capability_t lcd_cap_grant_capability(struct task_struct *stcb, capability_t src_cid, struct task_struct *dtcb, lcd_cap_rights crights);
capability_t lcd_cap_grant_capability(struct cap_space *src_space, capability_t src_cid, struct cap_space *dst_space, lcd_cap_rights crights);
// will be called to delete a particular capability in the calling threads
// cspace. threads have right to delete capabilities in their own cspace.
......@@ -252,7 +252,7 @@ capability_t lcd_cap_grant_capability(struct task_struct *stcb, capability_t src
// Output:
// 0 = Success
// Any other value indicates failure.
uint32_t lcd_cap_delete_capability(struct task_struct *tcb, capability_t cid);
uint32_t lcd_cap_delete_capability(struct cap_space *cspace, capability_t cid);
// will be called to delete the capability and all its children.
// the children can be present in cspace belonging to different threads.
......@@ -264,14 +264,14 @@ uint32_t lcd_cap_delete_capability(struct task_struct *tcb, capability_t cid);
// Ouptput:
// 0 = Success
// Any other value indicates failure.
uint32_t lcd_cap_revoke_capability(struct task_struct *tcb, capability_t cid);
uint32_t lcd_cap_revoke_capability(struct cap_space *cspace, capability_t cid);
// should be called when the thread exits.
// this is extremely heavy function which updates the CDT for all capabilities present
// in the cspace of the exiting thread.
// Input:
// ptcb: pointer to the task_struct of the thread which is getting terminated.
void lcd_cap_destroy_cspace(struct task_struct *tcb);
void lcd_cap_destroy_cspace(struct cap_space *cspace);
// will be used to get the rights available with a capability.
// Input:
......@@ -281,7 +281,7 @@ void lcd_cap_destroy_cspace(struct task_struct *tcb);
// Output:
// Return Value: 0 = Success, Any other value indicates failure.
// The rights associated with the capability will be saved in the rights ouput paramter.
uint32_t lcd_cap_get_rights(struct task_struct *tcb, capability_t cid, lcd_cap_rights *rights);
uint32_t lcd_cap_get_rights(struct cap_space *cspace, capability_t cid, lcd_cap_rights *rights);
// will be used to craete a copy of the capability identified by cid within the same cspace
// the rights of the copied capability could be modified using the rights parameter.
......@@ -293,6 +293,6 @@ uint32_t lcd_cap_get_rights(struct task_struct *tcb, capability_t cid, lcd_cap_r
// Output:
// the capability identifier for the copied capability is returned.
// 0 indicates failure.
capability_t lcd_cap_mint_capability(struct task_struct *tcb, capability_t cid, lcd_cap_rights rights);
capability_t lcd_cap_mint_capability(struct cap_space *cspace, capability_t cid, lcd_cap_rights rights);
#endif // __LCD_CAP_H__
#ifndef HOST_IPC_H
#define HOST_IPC_H
#include "ipc_common_defs.h"
#include <lcd/cap.h>
#include "ipc_common_defs.h"
enum ipc_state {
IPC_DONT_CARE = 0,
IPC_RCV_WAIT = 1,
......@@ -10,13 +11,13 @@ enum ipc_state {
IPC_RUNNING = 3,
};
typedef struct {
struct ipc_wait_list_elem {
u32 peer;
struct list_head list;
struct task_struct *task;
} ipc_wait_list_elem;
};
typedef struct {
struct sync_ipc {
// either we put an explicit capid here
// so that given the capid we can fetch
// the peers sync_ipc or lcd_struct
......@@ -34,10 +35,17 @@ typedef struct {
struct task_struct *task;
//spinlock_t rcv_lock;
// struct list_head rcv_q;
} sync_ipc_t;
};
struct lcd_message_info {
unsigned char regs;
unsigned char cap_regs;
};
//headers used by host for ipc
int ipc_send(u32 myself, u32 recv_capid);
//int ipc_send(u32 myself, u32 recv_capid);
int ipc_send(capability_t cap, struct lcd_message_info *msg);
int ipc_recv(u32 myself, u32 send_capid);
void display_mr(utcb_t *p_utcb);
......
......@@ -31,7 +31,7 @@ enum vmx_reg {
};
/* XXX: split and move arch dependent parts to ./arch/x86/lcd */
typedef struct lcd {
struct lcd {
int cpu;
int vpid;
int launched;
......@@ -76,7 +76,7 @@ typedef struct lcd {
struct vmx_msr_entry host[NR_AUTOLOAD_MSRS];
} msr_autoload;
sync_ipc_t sync_ipc;
struct sync_ipc sync_ipc;
struct vmcs *vmcs;
void *shared;
......@@ -84,7 +84,7 @@ typedef struct lcd {
struct start_info *si;
struct module *mod;
} lcd_t;
};
int lcd_init_module(void __user * umod, unsigned long len, const char __user * uargs);
......@@ -106,4 +106,5 @@ int lcd_find_hva_by_gpa(struct lcd *lcd, u64 gpa, u64 *hva);
int lcd_run(struct lcd *lcd);
const char* lcd_exit_reason(int exit_code);
#endif /* LCD_LCD_H */
......@@ -60,6 +60,10 @@ struct sched_param {
#include <linux/magic.h>
#include <linux/cgroup-defs.h>
#ifdef CONFIG_LCD
#include <lcd/cap.h>
#endif
#include <asm/processor.h>
#define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
......@@ -1463,7 +1467,9 @@ struct task_struct {
atomic_t usage;
unsigned int flags; /* per process flags, defined below */
unsigned int ptrace;
void *cspace;
#ifdef CONFIG_LCD
struct cap_space cspace;
#endif
#ifdef CONFIG_SMP
struct llist_node wake_entry;
int on_cpu;
......
This diff is collapsed.
......@@ -18,15 +18,17 @@ void display_mr(utcb_t *p_utcb) {
//};
int ipc_send(u32 myself, u32 recv_capid)
int ipc_send(capability_t cap, struct lcd_message_info *msg)
{
struct lcd *recv_lcd, *snd_lcd;
ipc_wait_list_elem stack_elem;
printk(KERN_ERR "ipc_send : myself %d reciever %d\n", myself, recv_capid);
struct ipc_wait_list_elem stack_elem;
#if 0
printk(KERN_ERR "ipc_send : myself %p re %d\n", current->utcb, cap);
//chk if the reciever is ready
// fetch the reciever task struct from if
recv_lcd = (struct lcd *) get_cap_obj(recv_capid);
recv_lcd = (struct lcd *) get_cap_obj(recv);
if (recv_lcd == NULL) {
printk(KERN_ERR "ipc_send : Cant get object for reciever %d\n", recv_capid);
return -1;
......@@ -67,7 +69,7 @@ int ipc_send(u32 myself, u32 recv_capid)
schedule();
}
#endif
printk(KERN_ERR "ipc_send : Finished\n");
return 0;
......@@ -78,7 +80,7 @@ int ipc_recv(u32 myself, u32 send_capid)
{
struct lcd *recv_lcd, *snd_lcd;
struct list_head *ptr;
ipc_wait_list_elem *entry;
struct ipc_wait_list_elem *entry;
printk(KERN_ERR "ipc_recv : myself %d sender %d\n", myself, send_capid);
......@@ -102,7 +104,7 @@ int ipc_recv(u32 myself, u32 send_capid)
recv_lcd->sync_ipc.snd_sleepers);
list_for_each(ptr, &recv_lcd->sync_ipc.snd_q) {
entry = list_entry(ptr, ipc_wait_list_elem, list);
entry = list_entry(ptr, struct ipc_wait_list_elem, list);
if (entry->peer == send_capid) {
printk(KERN_ERR "ipc_recv : Found expected sender %d\n", send_capid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment