@@ -254,9 +254,20 @@ The vCPU commands start with::
struct kvmi_get_version_reply {
__u32 version;
__u32 padding;
+ struct kvmi_features features;
};
-Returns the introspection API version.
+For x86
+
+::
+
+ struct kvmi_features {
+ __u8 singlestep;
+ __u8 padding[7];
+ };
+
+Returns the introspection API version and some of the features supported
+by the hardware.
This command is always allowed and successful (if the introspection is
built in kernel).
@@ -139,4 +139,9 @@ struct kvmi_event_msr_reply {
__u64 new_val;
};
+struct kvmi_features {
+ __u8 singlestep;
+ __u8 padding[7];
+};
+
#endif /* _UAPI_ASM_X86_KVMI_H */
@@ -1199,6 +1199,11 @@ bool kvmi_arch_pf_event(struct kvm_vcpu *vcpu, gpa_t gpa, gva_t gva,
return ret;
}
+void kvmi_arch_features(struct kvmi_features *feat)
+{
+ feat->singlestep = !!kvm_x86_ops->control_singlestep;
+}
+
bool kvmi_arch_pf_of_interest(struct kvm_vcpu *vcpu)
{
return kvm_x86_ops->spt_fault(vcpu) &&
@@ -97,6 +97,7 @@ struct kvmi_error_code {
struct kvmi_get_version_reply {
__u32 version;
__u32 padding;
+ struct kvmi_features features;
};
struct kvmi_vm_check_command {
@@ -56,6 +56,8 @@ struct vcpu_worker_data {
bool restart_on_shutdown;
};
+static struct kvmi_features features;
+
typedef void (*fct_pf_event)(struct kvm_vm *vm, struct kvmi_msg_hdr *hdr,
struct pf_ev *ev,
struct vcpu_reply *rpl);
@@ -372,7 +374,10 @@ static void test_cmd_get_version(void)
"Unexpected KVMI version %d, expecting %d\n",
rpl.version, KVMI_VERSION);
+ features = rpl.features;
+
DEBUG("KVMI version: %u\n", rpl.version);
+ DEBUG("\tsinglestep: %u\n", features.singlestep);
}
static int cmd_check_command(__u16 id)
@@ -127,5 +127,6 @@ int kvmi_arch_cmd_set_page_access(struct kvm_introspection *kvmi,
bool kvmi_arch_pf_event(struct kvm_vcpu *vcpu, gpa_t gpa, gva_t gva,
u8 access);
bool kvmi_arch_pf_of_interest(struct kvm_vcpu *vcpu);
+void kvmi_arch_features(struct kvmi_features *feat);
#endif
@@ -182,6 +182,8 @@ static int handle_get_version(struct kvm_introspection *kvmi,
memset(&rpl, 0, sizeof(rpl));
rpl.version = KVMI_VERSION;
+ kvmi_arch_features(&rpl.features);
+
return kvmi_msg_vm_reply(kvmi, msg, 0, &rpl, sizeof(rpl));
}
This is used by the introspection tool to check the hardware support for single step. Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com> --- Documentation/virt/kvm/kvmi.rst | 13 ++++++++++++- arch/x86/include/uapi/asm/kvmi.h | 5 +++++ arch/x86/kvm/kvmi.c | 5 +++++ include/uapi/linux/kvmi.h | 1 + tools/testing/selftests/kvm/x86_64/kvmi_test.c | 5 +++++ virt/kvm/introspection/kvmi_int.h | 1 + virt/kvm/introspection/kvmi_msg.c | 2 ++ 7 files changed, 31 insertions(+), 1 deletion(-)