Message type for SYS_UMAP{,_REMOTE}

Change-Id: Id46df10aee6189a0d3673013b498c7cc79edcc7e
This commit is contained in:
Lionel Sambuc 2014-05-21 17:54:35 +02:00
parent 5735105bc8
commit dc823abec2
6 changed files with 52 additions and 42 deletions

View file

@ -310,18 +310,8 @@
# define IRQ_WORD 0x200 /* word values */
# define IRQ_LONG 0x400 /* long values */
/* Field names for _UMAP, _VIRCOPY, _PHYSCOPY. */
#define CP_SRC_ENDPT m5_i1 /* process to copy from */
#define CP_SRC_ADDR m5_l1 /* address where data come from */
#define CP_DST_ENDPT m5_i2 /* process to copy to */
#define CP_DST_ADDR m5_l2 /* address where data go to */
#define CP_NR_BYTES m5_l3 /* number of bytes to copy */
#define CP_FLAGS m5_s2 /* number of bytes to copy */
#define CP_FLAG_TRY 0x01 /* do not transparently map */
#define UMAP_SEG m5_s1
/* Field names for SYS_VUMAP. */
#define VUMAP_ENDPT m10_i1 /* grant owner, or SELF for local addresses */
#define VUMAP_VADDR m10_l1 /* address of virtual (input) vector */

View file

@ -764,6 +764,24 @@ typedef struct {
} mess_lsys_krn_sys_setalarm;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_setalarm);
typedef struct {
endpoint_t src_endpt;
int segment;
vir_bytes src_addr;
endpoint_t dst_endpt;
int nr_bytes;
uint8_t padding[36];
} mess_lsys_krn_sys_umap;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_umap);
typedef struct {
phys_bytes dst_addr;
uint8_t padding[52];
} mess_krn_lsys_sys_umap;
_ASSERT_MSG_SIZE(mess_krn_lsys_sys_umap);
typedef struct {
int request;
int vec_size;
@ -1431,6 +1449,7 @@ typedef struct {
mess_krn_lsys_schedule m_krn_lsys_schedule;
mess_krn_lsys_sys_irqctl m_krn_lsys_sys_irqctl;
mess_krn_lsys_sys_umap m_krn_lsys_sys_umap;
mess_fs_vfs_breadwrite m_fs_vfs_breadwrite;
mess_fs_vfs_chmod m_fs_vfs_chmod;
@ -1514,6 +1533,7 @@ typedef struct {
mess_lsys_krn_sys_memset m_lsys_krn_sys_memset;
mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio;
mess_lsys_krn_sys_setalarm m_lsys_krn_sys_setalarm;
mess_lsys_krn_sys_umap m_lsys_krn_sys_umap;
mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio;
mess_lsys_pci_busc_get_bar m_lsys_pci_busc_get_bar;

View file

@ -2,11 +2,11 @@
* m_type: SYS_UMAP
*
* The parameters for this kernel call are:
* m5_i1: CP_SRC_PROC_NR (process number)
* m5_s1: UMAP_SEG (segment where address is: T, D, or S)
* m5_l1: CP_SRC_ADDR (virtual address)
* m5_l2: CP_DST_ADDR (returns physical address)
* m5_l3: CP_NR_BYTES (size of datastructure)
* m_lsys_krn_sys_umap.src_endpt (process number)
* m_lsys_krn_sys_umap.segment (segment where address is: T, D, or S)
* m_lsys_krn_sys_umap.src_addr (virtual address)
* m_krn_lsys_sys_umap.dst_addr (returns physical address)
* m_lsys_krn_sys_umap.nr_bytes (size of datastructure)
*/
#include "kernel/system.h"
@ -24,15 +24,15 @@
*==========================================================================*/
int do_umap(struct proc * caller, message * m_ptr)
{
int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX;
int endpt = (int) m_ptr->CP_SRC_ENDPT;
int seg_index = m_ptr->m_lsys_krn_sys_umap.segment & SEGMENT_INDEX;
int endpt = m_ptr->m_lsys_krn_sys_umap.src_endpt;
/* This call is a subset of umap_remote, it allows mapping virtual addresses
* in the caller's address space and grants where the caller is specified as
* grantee; after the security check we simply invoke do_umap_remote
*/
if (seg_index != MEM_GRANT && endpt != SELF) return EPERM;
m_ptr->CP_DST_ENDPT = SELF;
m_ptr->m_lsys_krn_sys_umap.dst_endpt = SELF;
return do_umap_remote(caller, m_ptr);
}

View file

@ -2,12 +2,12 @@
* m_type: SYS_UMAP_REMOTE
*
* The parameters for this kernel call are:
* m5_i1: CP_SRC_PROC_NR (process number)
* m5_s1: UMAP_SEG (segment where address is: T, D, or S)
* m5_l1: CP_SRC_ADDR (virtual address)
* m5_i2: CP_DST_ENDPT (process number of grantee to check access for)
* m5_l2: CP_DST_ADDR (returns physical address)
* m5_l3: CP_NR_BYTES (size of datastructure)
* m_lsys_krn_sys_umap.src_endpt (process number)
* m_lsys_krn_sys_umap.segment (segment where address is: T, D, or S)
* m_lsys_krn_sys_umap.src_addr (virtual address)
* m_lsys_krn_sys_umap.dst_endpt (process number of grantee to check access for)
* m_krn_lsys_sys_umap.dst_addr (returns physical address)
* m_lsys_krn_sys_umap.nr_bytes (size of datastructure)
*/
#include "kernel/system.h"
@ -26,12 +26,12 @@
int do_umap_remote(struct proc * caller, message * m_ptr)
{
/* Map virtual address to physical, for non-kernel processes. */
int seg_type = m_ptr->UMAP_SEG & SEGMENT_TYPE;
int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX;
vir_bytes offset = m_ptr->CP_SRC_ADDR;
int count = m_ptr->CP_NR_BYTES;
int endpt = (int) m_ptr->CP_SRC_ENDPT;
endpoint_t grantee = (endpoint_t) m_ptr->CP_DST_ENDPT;
int seg_type = m_ptr->m_lsys_krn_sys_umap.segment & SEGMENT_TYPE;
int seg_index = m_ptr->m_lsys_krn_sys_umap.segment & SEGMENT_INDEX;
vir_bytes offset = m_ptr->m_lsys_krn_sys_umap.src_addr;
int count = m_ptr->m_lsys_krn_sys_umap.nr_bytes;
endpoint_t endpt = m_ptr->m_lsys_krn_sys_umap.src_endpt;
endpoint_t grantee = m_ptr->m_lsys_krn_sys_umap.dst_endpt;
int proc_nr, proc_nr_grantee;
phys_bytes phys_addr = 0, lin_addr = 0;
struct proc *targetpr;
@ -108,7 +108,7 @@ int do_umap_remote(struct proc * caller, message * m_ptr)
return EFAULT;
}
m_ptr->CP_DST_ADDR = phys_addr;
m_ptr->m_krn_lsys_sys_umap.dst_addr = phys_addr;
if(phys_addr == 0) {
printf("kernel: umap 0x%x done by %d / %s, pc 0x%lx, 0x%lx -> 0x%lx\n",
seg_type, caller->p_endpoint, caller->p_name,

View file

@ -22,14 +22,14 @@ phys_bytes *phys_addr; /* placeholder for result */
* - In all other cases, should be a valid endpoint (neither ANY nor NONE).
*/
m.CP_SRC_ENDPT = proc_ep;
m.CP_DST_ENDPT = grantee;
m.UMAP_SEG = seg;
m.CP_SRC_ADDR = vir_addr;
m.CP_NR_BYTES = bytes;
m.m_lsys_krn_sys_umap.src_endpt = proc_ep;
m.m_lsys_krn_sys_umap.dst_endpt = grantee;
m.m_lsys_krn_sys_umap.segment = seg;
m.m_lsys_krn_sys_umap.src_addr = vir_addr;
m.m_lsys_krn_sys_umap.nr_bytes = bytes;
result = _kernel_call(SYS_UMAP_REMOTE, &m);
*phys_addr = m.CP_DST_ADDR;
*phys_addr = m.m_krn_lsys_sys_umap.dst_addr;
return(result);
}

View file

@ -13,13 +13,13 @@ phys_bytes *phys_addr; /* placeholder for result */
message m;
int result;
m.CP_SRC_ENDPT = proc_ep;
m.UMAP_SEG = seg;
m.CP_SRC_ADDR = vir_addr;
m.CP_NR_BYTES = bytes;
m.m_lsys_krn_sys_umap.src_endpt = proc_ep;
m.m_lsys_krn_sys_umap.segment = seg;
m.m_lsys_krn_sys_umap.src_addr = vir_addr;
m.m_lsys_krn_sys_umap.nr_bytes = bytes;
result = _kernel_call(SYS_UMAP, &m);
*phys_addr = m.CP_DST_ADDR;
*phys_addr = m.m_krn_lsys_sys_umap.dst_addr;
return(result);
}