Merge of Wu's GSOC 09 branch (src.20090525.r4372.wu)
Main changes: - COW optimization for safecopy. - safemap, a grant-based interface for sharing memory regions between processes. - Integration with safemap and complete rework of DS, supporting new data types natively (labels, memory ranges, memory mapped ranges). - For further information: http://wiki.minix3.org/en/SummerOfCode2009/MemoryGrants Additional changes not included in the original Wu's branch: - Fixed unhandled case in VM when using COW optimization for safecopy in case of a block that has already been shared as SMAP. - Better interface and naming scheme for sys_saferevmap and ds_retrieve_map calls. - Better input checking in syslib: check for page alignment when creating memory mapping grants. - DS notifies subscribers when an entry is deleted. - Documented the behavior of indirect grants in case of memory mapping. - Test suite in /usr/src/test/safeperf|safecopy|safemap|ds/* reworked and extended. - Minor fixes and general cleanup. - TO-DO: Grant ids should be generated and managed the way endpoints are to make sure grant slots are never misreused.
This commit is contained in:
@@ -350,8 +350,11 @@
|
||||
|
||||
# define SYS_VTIMER (KERNEL_CALL + 45) /* sys_vtimer() */
|
||||
# define SYS_RUNCTL (KERNEL_CALL + 46) /* sys_runctl() */
|
||||
# define SYS_SAFEMAP (KERNEL_CALL + 47) /* sys_safemap() */
|
||||
# define SYS_SAFEREVMAP (KERNEL_CALL + 48) /* sys_saferevmap() sys_saferevmap2() */
|
||||
# define SYS_SAFEUNMAP (KERNEL_CALL + 49) /* sys_safeunmap() */
|
||||
|
||||
#define NR_SYS_CALLS 47 /* number of system calls */
|
||||
#define NR_SYS_CALLS 50 /* number of system calls */
|
||||
#define SYS_CALL_MASK_SIZE BITMAP_CHUNKS(NR_SYS_CALLS)
|
||||
|
||||
/* Field names for SYS_MEMSET. */
|
||||
@@ -536,6 +539,15 @@
|
||||
#define VSCP_VEC_ADDR m2_p1 /* start of vector */
|
||||
#define VSCP_VEC_SIZE m2_l2 /* elements in vector */
|
||||
|
||||
/* Field names for SYS_SAFEMAPs */
|
||||
#define SMAP_EP m2_i1
|
||||
#define SMAP_GID m2_i2
|
||||
#define SMAP_OFFSET m2_i3
|
||||
#define SMAP_SEG m2_p1
|
||||
#define SMAP_ADDRESS m2_l1
|
||||
#define SMAP_BYTES m2_l2
|
||||
#define SMAP_FLAG m2_s1
|
||||
|
||||
/* Field names for SYS_SPROF, _CPROF, _PROFBUF. */
|
||||
#define PROF_ACTION m7_i1 /* start/stop/reset/get */
|
||||
#define PROF_MEM_SIZE m7_i2 /* available memory for data */
|
||||
@@ -556,11 +568,13 @@
|
||||
#define SVMCTL_PF_WHO m1_i1 /* GET_PAGEFAULT reply: process ep */
|
||||
#define SVMCTL_PF_I386_CR2 m1_i2 /* GET_PAGEFAULT reply: CR2 */
|
||||
#define SVMCTL_PF_I386_ERR m1_i3 /* GET_PAGEFAULT reply: error code */
|
||||
#define SVMCTL_MRG_ADDR m1_p1 /* MEMREQ_GET reply: address */
|
||||
#define SVMCTL_MRG_LEN m1_i1 /* MEMREQ_GET reply: length */
|
||||
#define SVMCTL_MRG_WRITE m1_i2 /* MEMREQ_GET reply: writeflag */
|
||||
#define SVMCTL_MRG_EP m1_i3 /* MEMREQ_GET reply: process */
|
||||
#define SVMCTL_MRG_REQUESTOR m1_p2 /* MEMREQ_GET reply: requestor */
|
||||
#define SVMCTL_MRG_TARGET m2_i1 /* MEMREQ_GET reply: target process */
|
||||
#define SVMCTL_MRG_ADDR m2_i2 /* MEMREQ_GET reply: address */
|
||||
#define SVMCTL_MRG_LENGTH m2_i3 /* MEMREQ_GET reply: length */
|
||||
#define SVMCTL_MRG_FLAG m2_s1 /* MEMREQ_GET reply: flag */
|
||||
#define SVMCTL_MRG_EP2 m2_l1 /* MEMREQ_GET reply: source process */
|
||||
#define SVMCTL_MRG_ADDR2 m2_l2 /* MEMREQ_GET reply: source address */
|
||||
#define SVMCTL_MRG_REQUESTOR m2_p1 /* MEMREQ_GET reply: requestor */
|
||||
#define SVMCTL_MAP_VIR_ADDR m1_p1
|
||||
|
||||
/* Reply message for VMCTL_KERN_PHYSMAP */
|
||||
@@ -654,19 +668,23 @@
|
||||
|
||||
#define DS_RQ_BASE 0x800
|
||||
|
||||
#define DS_PUBLISH (DS_RQ_BASE + 0) /* publish information */
|
||||
#define DS_SUBSCRIBE (DS_RQ_BASE + 1) /* subscribe to information */
|
||||
#define DS_RETRIEVE (DS_RQ_BASE + 2) /* retrieve information by name */
|
||||
#define DS_CHECK (DS_RQ_BASE + 3) /* retrieve updated information */
|
||||
#define DS_PUBLISH (DS_RQ_BASE + 0) /* publish data */
|
||||
#define DS_RETRIEVE (DS_RQ_BASE + 1) /* retrieve data by name */
|
||||
#define DS_SUBSCRIBE (DS_RQ_BASE + 2) /* subscribe to data updates */
|
||||
#define DS_CHECK (DS_RQ_BASE + 3) /* retrieve updated data */
|
||||
#define DS_DELETE (DS_RQ_BASE + 4) /* delete data */
|
||||
#define DS_SNAPSHOT (DS_RQ_BASE + 5) /* take a snapshot */
|
||||
#define DS_RETRIEVE_LABEL (DS_RQ_BASE + 6) /* retrieve label's name */
|
||||
|
||||
/* DS field names: DS_SUBSCRIBE, DS_PUBLISH, DS_RETRIEVE */
|
||||
# define DS_KEY_GRANT m2_p1 /* key for the information */
|
||||
# define DS_KEY_LEN m2_i1 /* length of key incl. '\0' */
|
||||
/* DS field names */
|
||||
# define DS_KEY_GRANT m2_i1 /* key for the data */
|
||||
# define DS_KEY_LEN m2_s1 /* length of key incl. '\0' */
|
||||
# define DS_FLAGS m2_i2 /* flags provided by caller */
|
||||
|
||||
/* DS_PUBLISH, DS_RETRIEVE */
|
||||
# define DS_VAL m2_l1 /* data (u32, char *, etc.) */
|
||||
# define DS_VAL_LEN m2_l2 /* data length */
|
||||
# define DS_NR_SNAPSHOT m2_i3 /* number of snapshot */
|
||||
# define DS_STRING m2_i3 /* inline string */
|
||||
|
||||
/*===========================================================================*
|
||||
* Miscellaneous messages used by TTY *
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
#define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */
|
||||
#endif
|
||||
|
||||
/* Click alignment macros. */
|
||||
#define CLICK_FLOOR(n) (((vir_bytes)(n) / CLICK_SIZE) * CLICK_SIZE)
|
||||
#define CLICK_CEIL(n) CLICK_FLOOR((vir_bytes)(n) + CLICK_SIZE-1)
|
||||
|
||||
/* Sizes of memory tables. The boot monitor distinguishes three memory areas,
|
||||
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
||||
* for DOS MINIX.
|
||||
|
||||
@@ -5,34 +5,68 @@
|
||||
|
||||
#include <minix/types.h>
|
||||
|
||||
/* DS Flag values. */
|
||||
#define DS_IN_USE 0x0001 /* Internal use only. */
|
||||
#define DS_PUBLIC 0x0002 /* Publically retrievable value. */
|
||||
#define DS_INITIAL 0x0004 /* On subscription, send initial contents. */
|
||||
/* Flags. */
|
||||
#define DSF_IN_USE 0x001 /* entry is in use */
|
||||
#define DSF_PRIV_RETRIEVE 0x002 /* only owner can retrieve */
|
||||
#define DSF_PRIV_OVERWRITE 0x004 /* only owner can overwrite */
|
||||
#define DSF_PRIV_SNAPSHOT 0x004 /* only owner can take a snapshot */
|
||||
#define DSF_PRIV_SUBSCRIBE 0x008 /* only owner can subscribe */
|
||||
#define DSF_TYPE_U32 0x010 /* u32 data type */
|
||||
#define DSF_TYPE_STR 0x020 /* string data type */
|
||||
#define DSF_TYPE_MEM 0x040 /* memory range data type */
|
||||
#define DSF_TYPE_MAP 0x080 /* mapped memory range data type */
|
||||
#define DSF_TYPE_LABEL 0x100 /* label data type */
|
||||
|
||||
/* These type flags are mutually exclusive. Give as args to ds_subscribe. */
|
||||
#define DS_TYPE_U32 0x0100
|
||||
#define DS_TYPE_STR 0x0200
|
||||
#define DS_TYPE_MASK 0xff00 /* All type info. */
|
||||
#define DSF_MASK_TYPE 0xFF0 /* mask for type flags. */
|
||||
#define DSF_MASK_INTERNAL 0xFFF /* mask for internal flags. */
|
||||
|
||||
#define DSF_OVERWRITE 0x01000 /* overwrite if entry exists */
|
||||
#define DSF_INITIAL 0x02000 /* check subscriptions immediately */
|
||||
|
||||
#define DSMF_MAP_MAPPED 0x10000 /* map mapped memory range */
|
||||
#define DSMF_COPY_MAPPED 0x20000 /* copy mapped memory range */
|
||||
#define DSMF_COPY_SNAPSHOT 0x40000 /* copy snapshot */
|
||||
|
||||
/* DS constants. */
|
||||
#define DS_MAX_KEYLEN 80 /* Max length for a key, including '\0'. */
|
||||
#define DS_MAX_VALLEN 100 /* Max legnth for a str value, incl '\0'. */
|
||||
#define DS_MAX_KEYLEN 80 /* Max length of a key, including '\0'. */
|
||||
#define DS_MAX_STRLEN 16 /* Max length of string, including '\0'. */
|
||||
|
||||
/* ds.c */
|
||||
_PROTOTYPE( int ds_subscribe, (char *name_regexp, int type, int flags));
|
||||
|
||||
/* publish/update item */
|
||||
_PROTOTYPE( int ds_publish_u32, (char *name, u32_t val));
|
||||
_PROTOTYPE( int ds_publish_str, (char *name, char *val));
|
||||
/* U32 */
|
||||
_PROTOTYPE( int ds_publish_u32, (const char *name, u32_t val, int flags));
|
||||
_PROTOTYPE( int ds_retrieve_u32, (const char *name, u32_t *val));
|
||||
_PROTOTYPE( int ds_delete_u32, (const char *ds_name));
|
||||
|
||||
/* retrieve item by name + type */
|
||||
_PROTOTYPE( int ds_retrieve_u32, (char *name, u32_t *val) );
|
||||
_PROTOTYPE( int ds_retrieve_str, (char *name, char *val, size_t len));
|
||||
/* STRING */
|
||||
_PROTOTYPE( int ds_publish_str, (const char *name, char *val, int flags));
|
||||
_PROTOTYPE( int ds_retrieve_str, (const char *name, char *val, size_t len));
|
||||
_PROTOTYPE( int ds_delete_str, (const char *ds_name));
|
||||
|
||||
/* retrieve updates for item */
|
||||
_PROTOTYPE( int ds_check_u32, (char *n, size_t namelen, u32_t *val));
|
||||
_PROTOTYPE( int ds_check_str, (char *n, size_t namelen, char *v, size_t vlen));
|
||||
/* MEM */
|
||||
_PROTOTYPE( int ds_publish_mem, (const char *ds_name, void *vaddr,
|
||||
size_t length, int flags));
|
||||
_PROTOTYPE( int ds_retrieve_mem, (const char *ds_name, char *vaddr,
|
||||
size_t *length));
|
||||
_PROTOTYPE( int ds_delete_mem, (const char *ds_name));
|
||||
|
||||
/* MAP */
|
||||
_PROTOTYPE( int ds_publish_map, (const char *ds_name, void *vaddr,
|
||||
size_t length, int flags));
|
||||
_PROTOTYPE( int ds_snapshot_map, (const char *ds_name, int *nr_snapshot));
|
||||
_PROTOTYPE( int ds_retrieve_map, (const char *ds_name, char *vaddr,
|
||||
size_t *length, int nr_snapshot, int flags));
|
||||
_PROTOTYPE( int ds_delete_map, (const char *ds_name));
|
||||
|
||||
/* LABEL */
|
||||
_PROTOTYPE( int ds_publish_label, (const char *ds_name, u32_t value,int flags));
|
||||
_PROTOTYPE( int ds_retrieve_label_name, (char *ds_name, u32_t num));
|
||||
_PROTOTYPE( int ds_retrieve_label_num, (const char *ds_name, u32_t *value));
|
||||
_PROTOTYPE( int ds_delete_label, (const char *ds_name));
|
||||
|
||||
/* Subscribe and check. */
|
||||
_PROTOTYPE( int ds_subscribe, (const char *regex, int flags));
|
||||
_PROTOTYPE( int ds_check, (char *ds_name, int *type));
|
||||
|
||||
#endif /* _MINIX_DS_H */
|
||||
|
||||
|
||||
@@ -49,6 +49,13 @@ struct vscp_vec {
|
||||
size_t v_bytes; /* no. of bytes */
|
||||
};
|
||||
|
||||
/* Types on VM invocation. */
|
||||
#define VMPTYPE_NONE 0
|
||||
#define VMPTYPE_CHECK 1
|
||||
#define VMPTYPE_COWMAP 2
|
||||
#define VMPTYPE_SMAP 3
|
||||
#define VMPTYPE_SUNMAP 4
|
||||
|
||||
/* Invalid grant number. */
|
||||
#define GRANT_INVALID -1
|
||||
#define GRANT_VALID(g) ((g) > GRANT_INVALID)
|
||||
@@ -56,6 +63,7 @@ struct vscp_vec {
|
||||
/* Operations: any combination is ok. */
|
||||
#define CPF_READ 0x000001 /* Granted process may read. */
|
||||
#define CPF_WRITE 0x000002 /* Granted process may write. */
|
||||
#define CPF_MAP 0x000004 /* Granted process may map. */
|
||||
|
||||
/* Internal flags. */
|
||||
#define CPF_USED 0x000100 /* Grant slot in use. */
|
||||
|
||||
@@ -62,7 +62,8 @@ _PROTOTYPE( int sys_vmctl, (endpoint_t who, int param, u32_t value));
|
||||
_PROTOTYPE( int sys_vmctl_get_pagefault_i386, (endpoint_t *who, u32_t *cr2, u32_t *err));
|
||||
_PROTOTYPE( int sys_vmctl_get_cr3_i386, (endpoint_t who, u32_t *cr3) );
|
||||
_PROTOTYPE( int sys_vmctl_get_memreq, (endpoint_t *who, vir_bytes *mem,
|
||||
vir_bytes *len, int *wrflag, endpoint_t *) );
|
||||
vir_bytes *len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s,
|
||||
endpoint_t *) );
|
||||
_PROTOTYPE( int sys_vmctl_enable_paging, (struct mem_map *));
|
||||
|
||||
_PROTOTYPE( int sys_readbios, (phys_bytes address, void *buf, size_t size));
|
||||
@@ -149,6 +150,14 @@ _PROTOTYPE(int sys_vsafecopy, (struct vscp_vec *copyvec, int elements));
|
||||
_PROTOTYPE(int sys_memset, (unsigned long pattern,
|
||||
phys_bytes base, phys_bytes bytes));
|
||||
|
||||
/* Grant-based map functions. */
|
||||
_PROTOTYPE(int sys_safemap, (endpoint_t grantor, cp_grant_id_t grant,
|
||||
vir_bytes grant_offset, vir_bytes my_address, size_t bytes, int my_seg,
|
||||
int writable));
|
||||
_PROTOTYPE(int sys_saferevmap_gid, (cp_grant_id_t grant));
|
||||
_PROTOTYPE(int sys_saferevmap_addr, (vir_bytes addr));
|
||||
_PROTOTYPE(int sys_safeunmap, (int my_seg, vir_bytes my_address));
|
||||
|
||||
_PROTOTYPE(int sys_umap, (endpoint_t proc_ep, int seg, vir_bytes vir_addr,
|
||||
vir_bytes bytes, phys_bytes *phys_addr));
|
||||
_PROTOTYPE(int sys_umap_data_fb, (endpoint_t proc_ep, vir_bytes vir_addr,
|
||||
|
||||
@@ -49,13 +49,15 @@ _PROTOTYPE( void panic, (char *who, char *mess, int num));
|
||||
_PROTOTYPE( int getuptime, (clock_t *ticks));
|
||||
_PROTOTYPE( int getuptime2, (clock_t *ticks, time_t *boottime));
|
||||
_PROTOTYPE( int tickdelay, (clock_t ticks));
|
||||
_PROTOTYPE( int micro_delay_calibrate, (void));
|
||||
_PROTOTYPE( int tsc_calibrate, (void));
|
||||
_PROTOTYPE( u32_t sys_hz, (void));
|
||||
_PROTOTYPE( double getidle, (void));
|
||||
_PROTOTYPE( void util_stacktrace, (void));
|
||||
_PROTOTYPE( void util_nstrcat, (char *str, unsigned long n) );
|
||||
_PROTOTYPE( void util_stacktrace_strcat, (char *));
|
||||
_PROTOTYPE( int micro_delay, (u32_t micros));
|
||||
_PROTOTYPE( u32_t tsc_64_to_micros, (u64_t tsc));
|
||||
_PROTOTYPE( u32_t tsc_to_micros, (u32_t low, u32_t high));
|
||||
_PROTOTYPE( u32_t micros_to_ticks, (u32_t micros));
|
||||
_PROTOTYPE( void ser_putc, (char c));
|
||||
_PROTOTYPE( void get_randomness, (struct k_randomness *, int));
|
||||
|
||||
@@ -44,12 +44,13 @@
|
||||
#define SI_PROC_TAB 2 /* copy of entire process table */
|
||||
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
|
||||
#define SI_MEM_ALLOC 4 /* get memory allocation data */
|
||||
#define SI_DATA_STORE 5 /* get copy of data store */
|
||||
#define SI_LOADINFO 6 /* get copy of load average structure */
|
||||
#define SI_KPROC_TAB 7 /* copy of kernel process table */
|
||||
#define SI_CALL_STATS 8 /* system call statistics */
|
||||
#define SI_PCI_INFO 9 /* get kernel info via PM */
|
||||
#define SI_PROCPUB_TAB 10 /* copy of public entries of process table */
|
||||
#define SI_DATA_STORE 5 /* get copy of data store mappings */
|
||||
#define SI_SUBSCRIPTION 6 /* get copy of data store subscriptions */
|
||||
#define SI_LOADINFO 7 /* get copy of load average structure */
|
||||
#define SI_KPROC_TAB 8 /* copy of kernel process table */
|
||||
#define SI_CALL_STATS 9 /* system call statistics */
|
||||
#define SI_PCI_INFO 10 /* get kernel info via PM */
|
||||
#define SI_PROCPUB_TAB 11 /* copy of public entries of process table */
|
||||
|
||||
/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
|
||||
#define NULL ((void *)0)
|
||||
|
||||
Reference in New Issue
Block a user