size_bits uint8 bits; /* Address bits this frame bears */
};
+cap Frame_Mapping from Frame {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap DevFrame from PhysAddr from_self {
/* Mappable device frame */
size_bits uint8 bits; /* Address bits this frame bears */
};
+cap DevFrame_Mapping from DevFrame {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
cap Kernel is_always_copy {
/* Capability to a kernel */
size_bits { vnode_size };
};
+cap VNode_x86_64_pml4_Mapping from VNode_x86_64_pml4 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
+
cap VNode_x86_64_pdpt from RAM {
/* PDPT */
size_bits { vnode_size };
};
+cap VNode_x86_64_pdpt_Mapping from VNode_x86_64_pdpt {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_x86_64_pdir from RAM {
/* Page directory */
size_bits { vnode_size };
};
+cap VNode_x86_64_pdir_Mapping from VNode_x86_64_pdir {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_x86_64_ptable from RAM {
/* Page table */
size_bits { vnode_size };
};
+cap VNode_x86_64_ptable_Mapping from VNode_x86_64_ptable {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
/* x86_32-specific capabilities: */
size_bits { vnode_size };
};
+cap VNode_x86_32_pdpt_Mapping from VNode_x86_32_pdpt {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_x86_32_pdir from RAM {
/* Page directory */
size_bits { vnode_size };
};
+cap VNode_x86_32_pdir_Mapping from VNode_x86_32_pdir {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_x86_32_ptable from RAM {
/* Page table */
size_bits { vnode_size };
};
+cap VNode_x86_32_ptable_Mapping from VNode_x86_32_ptable {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
/* ARM specific capabilities: */
cap VNode_ARM_l1 from RAM {
size_bits { vnode_size };
};
+cap VNode_ARM_l1_Mapping from VNode_ARM_l1 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_ARM_l2 from RAM {
/* L2 Page Table */
address genpaddr base; /* Base address of VNode */
size_bits { vnode_size };
};
+cap VNode_ARM_l2_Mapping from VNode_ARM_l2 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
/* ARM AArch64-specific capabilities: */
cap VNode_AARCH64_l1 from RAM {
size_bits { vnode_size };
};
+cap VNode_AARCH64_l1_Mapping from VNode_AARCH64_l1 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_AARCH64_l2 from RAM {
/* L2 Page Table */
address genpaddr base; /* Base address of VNode */
size_bits { vnode_size };
};
+cap VNode_AARCH64_l2_Mapping from VNode_AARCH64_l2 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
+
cap VNode_AARCH64_l3 from RAM {
/* L3 Page Table */
address genpaddr base; /* Base address of VNode */
size_bits { vnode_size };
};
+cap VNode_AARCH64_l3_Mapping from VNode_AARCH64_l3 {
+ "struct capability" frame;
+ eq lvaddr pte;
+ uint16 pte_count;
+
+ address { get_address(frame) };
+};
/** IRQTable and IO are slightly different **/
failure ROOT_CAP_LOOKUP "Error looking up root capability",
failure DEST_TYPE_INVALID "Destination capability is of invalid type",
failure INVALID_RETYPE "Invalid source/destination type pair for retyping",
+ failure RETYPE_MAPPING_EXPLICIT "Invalid explicit retype to mapping type",
failure REVOKE_FIRST "Capability already has descendants or siblings",
failure INVALID_SIZE_BITS "Invalid size for new objects",
failure SLOTS_INVALID "Destination capability slots exceed capacity of CNode",
static inline bool type_is_vnode(enum objtype type)
{
- STATIC_ASSERT(30 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(44 == ObjType_Num, "Check VNode definitions");
return (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
static inline size_t vnode_objbits(enum objtype type)
{
// This function should be emitted by hamlet or somesuch.
- STATIC_ASSERT(30 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(44 == ObjType_Num, "Check VNode definitions");
if (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
*/
static inline size_t vnode_entry_bits(enum objtype type) {
// This function should be emitted by hamlet or somesuch.
- STATIC_ASSERT(30 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(44 == ObjType_Num, "Check VNode definitions");
if (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
return 0;
}
+static inline enum objtype get_mapping_type(enum objtype captype)
+{
+ STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all mapping types");
+
+ switch (captype) {
+ case ObjType_Frame:
+ return ObjType_Frame_Mapping;
+ case ObjType_DevFrame:
+ return ObjType_DevFrame_Mapping;
+ case ObjType_VNode_x86_64_pml4:
+ return ObjType_VNode_x86_64_pml4_Mapping;
+ case ObjType_VNode_x86_64_pdpt:
+ return ObjType_VNode_x86_64_pdpt_Mapping;
+ case ObjType_VNode_x86_64_pdir:
+ return ObjType_VNode_x86_64_pdir_Mapping;
+ case ObjType_VNode_x86_64_ptable:
+ return ObjType_VNode_x86_64_ptable_Mapping;
+ case ObjType_VNode_x86_32_pdpt:
+ return ObjType_VNode_x86_32_pdpt_Mapping;
+ case ObjType_VNode_x86_32_pdir:
+ return ObjType_VNode_x86_32_pdir_Mapping;
+ case ObjType_VNode_x86_32_ptable:
+ return ObjType_VNode_x86_32_ptable_Mapping;
+ case ObjType_VNode_ARM_l1:
+ return ObjType_VNode_ARM_l1_Mapping;
+ case ObjType_VNode_ARM_l2:
+ return ObjType_VNode_ARM_l2_Mapping;
+ case ObjType_VNode_AARCH64_l1:
+ return ObjType_VNode_AARCH64_l1_Mapping;
+ case ObjType_VNode_AARCH64_l2:
+ return ObjType_VNode_AARCH64_l2_Mapping;
+ case ObjType_VNode_AARCH64_l3:
+ return ObjType_VNode_AARCH64_l3_Mapping;
+ /* all other types are not mappable */
+ default:
+ return ObjType_Null;
+ }
+}
+
+static inline bool type_is_mapping(enum objtype type)
+{
+ STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all mapping types");
+
+ switch (type) {
+ case ObjType_Frame_Mapping:
+ case ObjType_DevFrame_Mapping:
+ case ObjType_VNode_x86_64_pml4_Mapping:
+ case ObjType_VNode_x86_64_pdpt_Mapping:
+ case ObjType_VNode_x86_64_pdir_Mapping:
+ case ObjType_VNode_x86_64_ptable_Mapping:
+ case ObjType_VNode_x86_32_pdpt_Mapping:
+ case ObjType_VNode_x86_32_pdir_Mapping:
+ case ObjType_VNode_x86_32_ptable_Mapping:
+ case ObjType_VNode_ARM_l1_Mapping:
+ case ObjType_VNode_ARM_l2_Mapping:
+ case ObjType_VNode_AARCH64_l1_Mapping:
+ case ObjType_VNode_AARCH64_l2_Mapping:
+ case ObjType_VNode_AARCH64_l3_Mapping:
+ return true;
+
+ /* all other types are not mapping types */
+ default:
+ return false;
+ }
+}
/**
* CNode capability commands.
* Predicates related to sharing capabilities
*/
-STATIC_ASSERT(ObjType_Num == 30, "Knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
static inline bool
distcap_needs_locality(enum objtype type)
{
case ObjType_VNode_AARCH64_l1:
case ObjType_VNode_AARCH64_l2:
case ObjType_VNode_AARCH64_l3:
+ case ObjType_VNode_ARM_l1_Mapping:
+ case ObjType_VNode_ARM_l2_Mapping:
+ case ObjType_VNode_AARCH64_l1_Mapping:
+ case ObjType_VNode_AARCH64_l2_Mapping:
+ case ObjType_VNode_AARCH64_l3_Mapping:
+ case ObjType_VNode_x86_64_pml4_Mapping:
+ case ObjType_VNode_x86_64_pdpt_Mapping:
+ case ObjType_VNode_x86_64_pdir_Mapping:
+ case ObjType_VNode_x86_64_ptable_Mapping:
+ case ObjType_VNode_x86_32_pdpt_Mapping:
+ case ObjType_VNode_x86_32_pdir_Mapping:
+ case ObjType_VNode_x86_32_ptable_Mapping:
+ case ObjType_DevFrame_Mapping:
+ case ObjType_Frame_Mapping:
// XXX: KCB should need locality?
//case ObjType_KernelControlBlock:
return true;
}
}
-STATIC_ASSERT(ObjType_Num == 30, "Knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
static inline bool
distcap_is_moveable(enum objtype type)
{
struct capability monitor_ep;
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
int sprint_cap(char *buf, size_t len, struct capability *cap)
{
switch (cap->type) {
return snprintf(buf, len, "x86_64 PML4 at 0x%" PRIxGENPADDR,
cap->u.vnode_x86_64_pml4.base);
+ case ObjType_Frame_Mapping:
+ return snprintf(buf, len, "Frame Mapping (Frame cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.frame_mapping.frame,
+ cap->u.frame_mapping.pte,
+ cap->u.frame_mapping.pte_count);
+
+ case ObjType_DevFrame_Mapping:
+ return snprintf(buf, len, "DevFrame Mapping (DevFrame cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.devframe_mapping.frame,
+ cap->u.devframe_mapping.pte,
+ cap->u.devframe_mapping.pte_count);
+
+ case ObjType_VNode_x86_64_pml4_Mapping:
+ return snprintf(buf, len, "x86_64 PML4 Mapping (x86_64 PML4 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_64_pml4_mapping.frame,
+ cap->u.vnode_x86_64_pml4_mapping.pte,
+ cap->u.vnode_x86_64_pml4_mapping.pte_count);
+
+ case ObjType_VNode_x86_64_pdpt_Mapping:
+ return snprintf(buf, len, "x86_64 PDPT Mapping (x86_64 PDPT cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_64_pdpt_mapping.frame,
+ cap->u.vnode_x86_64_pdpt_mapping.pte,
+ cap->u.vnode_x86_64_pdpt_mapping.pte_count);
+
+ case ObjType_VNode_x86_64_pdir_Mapping:
+ return snprintf(buf, len, "x86_64 PDIR Mapping (x86_64 PDIR cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_64_pdir_mapping.frame,
+ cap->u.vnode_x86_64_pdir_mapping.pte,
+ cap->u.vnode_x86_64_pdir_mapping.pte_count);
+
+ case ObjType_VNode_x86_64_ptable_Mapping:
+ return snprintf(buf, len, "x86_64 PTABLE Mapping (x86_64 PTABLE cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_64_ptable_mapping.frame,
+ cap->u.vnode_x86_64_ptable_mapping.pte,
+ cap->u.vnode_x86_64_ptable_mapping.pte_count);
+
+ case ObjType_VNode_x86_32_pdpt_Mapping:
+ return snprintf(buf, len, "x86_32 PDPT Mapping (x86_32 PDPT cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_32_pdpt_mapping.frame,
+ cap->u.vnode_x86_32_pdpt_mapping.pte,
+ cap->u.vnode_x86_32_pdpt_mapping.pte_count);
+
+ case ObjType_VNode_x86_32_pdir_Mapping:
+ return snprintf(buf, len, "x86_32 PDIR Mapping (x86_32 PDIR cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_32_pdir_mapping.frame,
+ cap->u.vnode_x86_32_pdir_mapping.pte,
+ cap->u.vnode_x86_32_pdir_mapping.pte_count);
+
+ case ObjType_VNode_x86_32_ptable_Mapping:
+ return snprintf(buf, len, "x86_32 PTABLE Mapping (x86_32 PTABLE cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_x86_32_ptable_mapping.frame,
+ cap->u.vnode_x86_32_ptable_mapping.pte,
+ cap->u.vnode_x86_32_ptable_mapping.pte_count);
+
+ case ObjType_VNode_ARM_l1_Mapping:
+ return snprintf(buf, len, "ARM l1 Mapping (ARM l1 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_arm_l1_mapping.frame,
+ cap->u.vnode_arm_l1_mapping.pte,
+ cap->u.vnode_arm_l1_mapping.pte_count);
+
+ case ObjType_VNode_ARM_l2_Mapping:
+ return snprintf(buf, len, "ARM l2 Mapping (ARM l2 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_arm_l2_mapping.frame,
+ cap->u.vnode_arm_l2_mapping.pte,
+ cap->u.vnode_arm_l2_mapping.pte_count);
+
+ case ObjType_VNode_AARCH64_l1_Mapping:
+ return snprintf(buf, len, "AARCH64 l1 Mapping (AARCH64 l1 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_aarch64_l1_mapping.frame,
+ cap->u.vnode_aarch64_l1_mapping.pte,
+ cap->u.vnode_aarch64_l1_mapping.pte_count);
+
+ case ObjType_VNode_AARCH64_l2_Mapping:
+ return snprintf(buf, len, "AARCH64 l2 Mapping (AARCH64 l2 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_aarch64_l2_mapping.frame,
+ cap->u.vnode_aarch64_l2_mapping.pte,
+ cap->u.vnode_aarch64_l2_mapping.pte_count);
+
+ case ObjType_VNode_AARCH64_l3_Mapping:
+ return snprintf(buf, len, "AARCH64 l3 Mapping (AARCH64 l3 cap @0x%p, "
+ "pte @0x%"PRIxLVADDR", pte_count=%hu)",
+ cap->u.vnode_aarch64_l3_mapping.frame,
+ cap->u.vnode_aarch64_l3_mapping.pte,
+ cap->u.vnode_aarch64_l3_mapping.pte_count);
+
case ObjType_IRQTable:
return snprintf(buf, len, "IRQTable cap");
// If you create more capability types you need to deal with them
// in the table below.
-STATIC_ASSERT(30 == ObjType_Num, "Knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
static size_t caps_numobjs(enum objtype type, uint8_t bits, uint8_t objbits)
{
case ObjType_Notify_IPI:
case ObjType_PerfMon:
case ObjType_IPI:
+ case ObjType_VNode_ARM_l1_Mapping:
+ case ObjType_VNode_ARM_l2_Mapping:
+ case ObjType_VNode_AARCH64_l1_Mapping:
+ case ObjType_VNode_AARCH64_l2_Mapping:
+ case ObjType_VNode_AARCH64_l3_Mapping:
+ case ObjType_VNode_x86_64_pml4_Mapping:
+ case ObjType_VNode_x86_64_pdpt_Mapping:
+ case ObjType_VNode_x86_64_pdir_Mapping:
+ case ObjType_VNode_x86_64_ptable_Mapping:
+ case ObjType_VNode_x86_32_pdpt_Mapping:
+ case ObjType_VNode_x86_32_pdir_Mapping:
+ case ObjType_VNode_x86_32_ptable_Mapping:
+ case ObjType_DevFrame_Mapping:
+ case ObjType_Frame_Mapping:
return 1;
default:
*
* For the meaning of the parameters, see the 'caps_create' function.
*/
-STATIC_ASSERT(ObjType_Num == 30, "Knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
static errval_t caps_init_objects(enum objtype type, lpaddr_t lpaddr, uint8_t
bits, uint8_t objbits, size_t numobjs)
*/
// If you create more capability types you need to deal with them
// in the table below.
-STATIC_ASSERT(30 == ObjType_Num, "Knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
static errval_t caps_create(enum objtype type, lpaddr_t lpaddr, uint8_t bits,
uint8_t objbits, size_t numobjs, coreid_t owner,
assert(type != ObjType_Null);
assert(type < ObjType_Num);
assert(numobjs > 0);
+ assert(!type_is_mapping(type));
genpaddr_t genpaddr = local_phys_to_gen_phys(lpaddr);
}
+STATIC_ASSERT(44 == ObjType_Num, "Knowledge of all cap types");
/// Retype caps
errval_t caps_retype(enum objtype type, size_t objbits,
struct capability *dest_cnode, cslot_t dest_slot,
TRACE_CAP_MSG("retyping", src_cte);
+ /* No explicit retypes to Mapping allowed */
+ if (type_is_mapping(type)) {
+ return SYS_ERR_RETYPE_MAPPING_EXPLICIT;
+ }
+
/* Check retypability */
err = is_retypeable(src_cte, src_cap->type, type, from_monitor);
if (err_is_fail(err)) {
* Cap tracing
*/
#ifdef TRACE_PMEM_CAPS
-STATIC_ASSERT(ObjType_Num == 30, "knowledge of all cap types");
+STATIC_ASSERT(44 == ObjType_Num, "knowledge of all cap types");
+#define MAPPING_TYPES \
+ ((1ul<<ObjType_VNode_x86_64_pml4_Mapping) | \
+ (1ul<<ObjType_VNode_x86_64_pdpt_Mapping) | \
+ (1ul<<ObjType_VNode_x86_64_pdir_Mapping) | \
+ (1ul<<ObjType_VNode_x86_64_ptable_Mapping) | \
+ (1ul<<ObjType_VNode_x86_32_pdpt_Mapping) | \
+ (1ul<<ObjType_VNode_x86_32_pdir_Mapping) | \
+ (1ul<<ObjType_VNode_x86_32_ptable_Mapping) | \
+ (1ul<<ObjType_VNode_ARM_l1_Mapping) | \
+ (1ul<<ObjType_VNode_ARM_l2_Mapping) | \
+ (1ul<<ObjType_VNode_AARCH64_l1_Mapping) | \
+ (1ul<<ObjType_VNode_AARCH64_l2_Mapping) | \
+ (1ul<<ObjType_VNode_AARCH64_l3_Mapping) | \
+ (1ul<<ObjType_Frame_Mapping) | \
+ (1ul<<ObjType_DevFrame_Mapping))
+
#define ALL_PMEM_TYPES \
((1ul<<ObjType_RAM) | \
(1ul<<ObjType_Frame) | \
(1ul<<ObjType_VNode_AARCH64_l2) | \
(1ul<<ObjType_VNode_AARCH64_l3) | \
(1ul<<ObjType_PhysAddr) | \
- (1ul<<ObjType_KernelControlBlock))
+ (1ul<<ObjType_KernelControlBlock) | \
+ MAPPING_TYPES)
#define TRACE_TYPES_ENABLED_INITIAL 0x0
#define TRACE_PMEM_BEGIN_INITIAL 0x0