Skip to content

Commit

Permalink
libvmmapi: Provide wrappers for fetching register capability tags
Browse files Browse the repository at this point in the history
  • Loading branch information
markjdb committed Jan 5, 2025
1 parent 7c11272 commit 246cc50
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/libvmmapi/aarch64/vmmapi_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const cap_ioctl_t vm_ioctl_cmds[] = {
VM_MD_IOCTLS,
#if __has_feature(capabilities)
VM_GET_CHERI_CAPABILITY_TAG,
VM_GET_REGISTER_CHERI_CAPABILITY_TAG,
VM_GET_REGISTER_CHERI_CAPABILITY_TAG_SET,
#endif
};
size_t vm_ioctl_ncmds = nitems(vm_ioctl_cmds);
Expand Down
36 changes: 36 additions & 0 deletions lib/libvmmapi/vmmapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,23 @@ vm_get_register(struct vcpu *vcpu, int reg, uintcap_t *ret_val)
return (error);
}

#if __has_feature(capabilities)
int
vm_get_register_cheri_capability_tag(struct vcpu *vcpu, int reg, uint8_t *tagp)
{
struct vm_register_cheri_capability_tag vmreg;
int error;

bzero(&vmreg, sizeof(vmreg));
vmreg.regnum = reg;

error = vcpu_ioctl(vcpu, VM_GET_REGISTER_CHERI_CAPABILITY_TAG, &vmreg);
if (error == 0)
*tagp = vmreg.tag;
return (error);
}
#endif

int
vm_set_register_set(struct vcpu *vcpu, unsigned int count,
const int *regnums, uintcap_t *regvals)
Expand Down Expand Up @@ -682,6 +699,25 @@ vm_get_register_set(struct vcpu *vcpu, unsigned int count,
return (error);
}

#if __has_feature(capabilities)
int
vm_get_register_cheri_capability_tag_set(struct vcpu *vcpu, unsigned int count,
const int *regnums, uint8_t *tags)
{
struct vm_register_cheri_capability_tag_set vmtagset;
int error;

bzero(&vmtagset, sizeof(vmtagset));
vmtagset.count = count;
vmtagset.regnums = regnums;
vmtagset.tags = tags;

error = vcpu_ioctl(vcpu, VM_GET_REGISTER_CHERI_CAPABILITY_TAG_SET,
&vmtagset);
return (error);
}
#endif

int
vm_run(struct vcpu *vcpu, struct vm_run *vmrun)
{
Expand Down
8 changes: 8 additions & 0 deletions lib/libvmmapi/vmmapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,18 @@ int vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc);
#endif
int vm_set_register(struct vcpu *vcpu, int reg, uintcap_t val);
int vm_get_register(struct vcpu *vcpu, int reg, uintcap_t *retval);
#if __has_feature(capabilities)
int vm_get_register_cheri_capability_tag(struct vcpu *vcpu, int reg,
uint8_t *tagp);
#endif
int vm_set_register_set(struct vcpu *vcpu, unsigned int count,
const int *regnums, uintcap_t *regvals);
int vm_get_register_set(struct vcpu *vcpu, unsigned int count,
const int *regnums, uintcap_t *regvals);
#if __has_feature(capabilities)
int vm_get_register_cheri_capability_tag_set(struct vcpu *vcpu,
unsigned int count, const int *regnums, uint8_t *tags);
#endif
int vm_run(struct vcpu *vcpu, struct vm_run *vmrun);
int vm_suspend(struct vmctx *ctx, enum vm_suspend_how how);
int vm_reinit(struct vmctx *ctx);
Expand Down

0 comments on commit 246cc50

Please sign in to comment.