Add a flag to grants system indicating a slot is VALID; so a slot
can be reserved (USED), while toggling VALID on and off.
This commit is contained in:
parent
a587273c56
commit
607fb6bf7f
3 changed files with 19 additions and 5 deletions
|
@ -62,6 +62,7 @@ struct vscp_vec {
|
|||
#define CPF_DIRECT 0x000200 /* Grant from this process to another. */
|
||||
#define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
|
||||
#define CPF_MAGIC 0x000800 /* Grant from any to any. */
|
||||
#define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
|
||||
|
||||
/* Prototypes for functions in libsys. */
|
||||
_PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int));
|
||||
|
@ -78,6 +79,7 @@ _PROTOTYPE( int cpf_setgrant_indirect, (cp_grant_id_t g, endpoint_t who_to,
|
|||
endpoint_t who_from, cp_grant_id_t his_g));
|
||||
_PROTOTYPE( int cpf_setgrant_magic, (cp_grant_id_t g, endpoint_t who_to,
|
||||
endpoint_t who_from, vir_bytes addr, size_t bytes, int access));
|
||||
_PROTOTYPE( int cpf_setgrant_disable, (cp_grant_id_t grant_id));
|
||||
|
||||
/* Set a process' grant table location and size (in-kernel only). */
|
||||
#define _K_SET_GRANT_TABLE(rp, ptr, entries) \
|
||||
|
|
|
@ -90,8 +90,8 @@ endpoint_t *e_granter; /* new granter (magic grants) */
|
|||
phys_copy(phys_grant, vir2phys(&g), sizeof(g));
|
||||
|
||||
/* Check validity. */
|
||||
if(!(g.cp_flags & CPF_USED)) {
|
||||
kprintf("grant verify failed: invalid\n");
|
||||
if((g.cp_flags & (CPF_USED | CPF_VALID)) != (CPF_USED | CPF_VALID)) {
|
||||
kprintf("grant verify failed: unused or invalid\n");
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ int access;
|
|||
GID_CHECK(gid);
|
||||
ACCESS_CHECK(access);
|
||||
|
||||
grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED;
|
||||
grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED | CPF_VALID;
|
||||
grants[gid].cp_u.cp_direct.cp_who_to = who;
|
||||
grants[gid].cp_u.cp_direct.cp_start = addr;
|
||||
grants[gid].cp_u.cp_direct.cp_len = bytes;
|
||||
|
@ -322,7 +322,7 @@ cp_grant_id_t his_gid;
|
|||
GID_CHECK(gid);
|
||||
|
||||
/* Fill in new slot data. */
|
||||
grants[gid].cp_flags = CPF_USED | CPF_INDIRECT;
|
||||
grants[gid].cp_flags = CPF_USED | CPF_INDIRECT | CPF_VALID;
|
||||
grants[gid].cp_u.cp_indirect.cp_who_to = who_to;
|
||||
grants[gid].cp_u.cp_indirect.cp_who_from = who_from;
|
||||
grants[gid].cp_u.cp_indirect.cp_grant = his_gid;
|
||||
|
@ -342,7 +342,7 @@ int access;
|
|||
ACCESS_CHECK(access);
|
||||
|
||||
/* Fill in new slot data. */
|
||||
grants[gid].cp_flags = CPF_USED | CPF_MAGIC | access;
|
||||
grants[gid].cp_flags = CPF_USED | CPF_MAGIC | CPF_VALID | access;
|
||||
grants[gid].cp_u.cp_magic.cp_who_to = who_to;
|
||||
grants[gid].cp_u.cp_magic.cp_who_from = who_from;
|
||||
grants[gid].cp_u.cp_magic.cp_start = addr;
|
||||
|
@ -351,3 +351,15 @@ int access;
|
|||
return 0;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
cpf_setgrant_disable(gid)
|
||||
cp_grant_id_t gid;
|
||||
{
|
||||
GID_CHECK(gid);
|
||||
|
||||
/* Grant is now no longer valid, but still in use. */
|
||||
grants[gid].cp_flags = CPF_USED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue