@@ -777,6 +777,25 @@ exception.
* -KVM_EBUSY - another *KVMI_VCPU_INJECT_EXCEPTION*-*KVMI_VCPU_EVENT_TRAP*
pair is in progress
+17. KVMI_VM_GET_MAX_GFN
+-----------------------
+
+:Architectures: all
+:Versions: >= 1
+:Parameters: none
+:Returns:
+
+::
+
+ struct kvmi_error_code;
+ struct kvmi_vm_get_max_gfn_reply {
+ __u64 gfn;
+ };
+
+Provides the maximum GFN allocated to the VM by walking through all
+memory slots. Stricly speaking, the returned value refers to the first
+inaccessible GFN, next to the maximum accessible GFN.
+
Events
======
@@ -29,6 +29,7 @@ enum {
KVMI_VM_WRITE_PHYSICAL = KVMI_VM_MESSAGE_ID(7),
KVMI_VM_PAUSE_VCPU = KVMI_VM_MESSAGE_ID(8),
KVMI_VM_CONTROL_CLEANUP = KVMI_VM_MESSAGE_ID(9),
+ KVMI_VM_GET_MAX_GFN = KVMI_VM_MESSAGE_ID(10),
KVMI_NEXT_VM_MESSAGE
};
@@ -177,4 +178,8 @@ struct kvmi_vm_control_cleanup {
__u8 padding[7];
};
+struct kvmi_vm_get_max_gfn_reply {
+ __u64 gfn;
+};
+
#endif /* _UAPI__LINUX_KVMI_H */
@@ -1322,6 +1322,17 @@ static void test_cmd_vcpu_inject_exception(struct kvm_vm *vm)
disable_vcpu_event(vm, KVMI_VCPU_EVENT_BREAKPOINT);
}
+static void test_cmd_vm_get_max_gfn(void)
+{
+ struct kvmi_vm_get_max_gfn_reply rpl;
+ struct kvmi_msg_hdr req;
+
+ test_vm_command(KVMI_VM_GET_MAX_GFN, &req, sizeof(req),
+ &rpl, sizeof(rpl), 0);
+
+ pr_debug("max_gfn: 0x%llx\n", rpl.gfn);
+}
+
static void test_introspection(struct kvm_vm *vm)
{
srandom(time(0));
@@ -1347,6 +1358,7 @@ static void test_introspection(struct kvm_vm *vm)
test_cmd_vm_control_cleanup(vm);
test_cmd_vcpu_control_cr(vm);
test_cmd_vcpu_inject_exception(vm);
+ test_cmd_vm_get_max_gfn();
unhook_introspection(vm);
}
@@ -290,6 +290,18 @@ static int handle_vm_control_cleanup(struct kvm_introspection *kvmi,
return kvmi_msg_vm_reply(kvmi, msg, ec, NULL, 0);
}
+static int handle_vm_get_max_gfn(struct kvm_introspection *kvmi,
+ const struct kvmi_msg_hdr *msg,
+ const void *req)
+{
+ struct kvmi_vm_get_max_gfn_reply rpl;
+
+ memset(&rpl, 0, sizeof(rpl));
+ rpl.gfn = kvm_get_max_gfn(kvmi->kvm);
+
+ return kvmi_msg_vm_reply(kvmi, msg, 0, &rpl, sizeof(rpl));
+}
+
/*
* These commands are executed by the receiving thread.
*/
@@ -300,6 +312,7 @@ static kvmi_vm_msg_fct const msg_vm[] = {
[KVMI_VM_CONTROL_CLEANUP] = handle_vm_control_cleanup,
[KVMI_VM_CONTROL_EVENTS] = handle_vm_control_events,
[KVMI_VM_GET_INFO] = handle_vm_get_info,
+ [KVMI_VM_GET_MAX_GFN] = handle_vm_get_max_gfn,
[KVMI_VM_PAUSE_VCPU] = handle_vm_pause_vcpu,
[KVMI_VM_READ_PHYSICAL] = handle_vm_read_physical,
[KVMI_VM_WRITE_PHYSICAL] = handle_vm_write_physical,