Skip to content

Commit

Permalink
libkvmi: add kvmi_create_ept_view and kvmi_destroy_ept_view
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdangl authored and mdontu-bd committed Dec 8, 2023
1 parent bec49c3 commit 2d1cee7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/libkvmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ int kvmi_set_ept_page_conv( void *dom, unsigned short index, unsigned long l
int kvmi_get_ept_page_conv( void *dom, unsigned short index, unsigned long long gpa, bool *sve );
int kvmi_switch_ept_view( void *dom, unsigned short vcpu, unsigned short view );
int kvmi_disable_ve( void *dom, unsigned short vcpu );
int kvmi_create_ept_view( void *dom, unsigned short *view );
int kvmi_destroy_ept_view( void *dom, unsigned short view );
int kvmi_get_ept_view( void *dom, unsigned short vcpu, unsigned short *view );
int kvmi_control_ept_view( void *dom, unsigned short vcpu, unsigned short view, bool visible );
bool kvmi_remote_mapping_v2( void );
Expand Down
12 changes: 12 additions & 0 deletions include/linux/kvmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ enum {
KVMI_QUERY_PHYSICAL = 39,
KVMI_VCPU_ALLOC_GFN = 41,
KVMI_VCPU_FREE_GFN = 42,
KVMI_CREATE_EPT_VIEW = 43,
KVMI_DESTROY_EPT_VIEW = 44,
KVMI_VCPU_CHANGE_GFN = 60,

KVMI_VCPU_CONTROL_SINGLESTEP = 63,
Expand Down Expand Up @@ -353,6 +355,16 @@ struct kvmi_vcpu_free_gfn {
__u64 gfn;
};

struct kvmi_create_ept_view_reply {
__u16 view;
__u16 pad[3];
};

struct kvmi_destroy_ept_view {
__u16 view;
__u16 pad[3];
};

/*
* ioctls for /dev/kvmmem
*/
Expand Down
20 changes: 20 additions & 0 deletions src/kvmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,3 +2734,23 @@ int kvmi_free_gfn( void *dom, __u64 gfn )

return request( dom, KVMI_VCPU_FREE_GFN, &req, sizeof( req ), NULL, NULL );
}

int kvmi_create_ept_view( void *dom, unsigned short *view )
{
struct kvmi_create_ept_view_reply rpl;
int err;
size_t received = sizeof( rpl );

err = request( dom, KVMI_CREATE_EPT_VIEW, NULL, 0, &rpl, &received );
if ( !err && view )
*view = rpl.view;

return err;
}

int kvmi_destroy_ept_view( void *dom, unsigned short view )
{
struct kvmi_destroy_ept_view req = { .view = view };

return request( dom, KVMI_DESTROY_EPT_VIEW, &req, sizeof( req ), NULL, 0 );
}
2 changes: 2 additions & 0 deletions src/version.ld
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ KVMI_1.0 {
kvmi_control_ept_view;
kvmi_alloc_gfn;
kvmi_free_gfn;
kvmi_create_ept_view;
kvmi_destroy_ept_view;
local:
*;
};

0 comments on commit 2d1cee7

Please sign in to comment.